﻿// top.js (c) 1453 Fatih Sultan Mehmet
// mozilla text selection code by lhurgoyf & serendipity 
// opera text selection workaround by baka
// safari text selection workaround by passion

var bid = 0, lo = null, hreq = false, is = "", se = "", pr = '<td onmousedown="md(this)" onmouseup="bn(this)" onmouseover="ov(this)" onmouseout="bn(this)" class="but" onclick=', sprite = 0, dcss = "sozluk.css";
var tms = new Array();

function G(i) {
    return document.getElementById(i);
}

function togdisp(o) {
    o.style.display = (o.style.display == 'block') ? 'none' : 'block';
}

function ov(o) {
    o.id = "butOver";
}

function md(o) {
    o.id = "butDown";
}

function bn(o) {
    o.id = "";
}

function hr(o) {
    if (o) if (o.click) o.click();
}

function b(t, u, c, tt) {
    document.write(pr + '"hr(this.childNodes[0])"><a ');
    if (tt) document.write(" title='" + tt + "'");
    document.write(' target=' + t + ' href="' + u + '">&nbsp;' + c + '&nbsp;</a></td>');
}

function b2(t, u, c, s) {
    document.write(pr + '"hr(this.childNodes[0])" colspan=' + s + '><a target=' + t + ' href="' + u + '">&nbsp;' + c + '&nbsp;</a></td>');
}

function s(f, c) {
    document.write(pr + '"G(\'' + f + '\').submit()" style="cursor:hand">&nbsp;&nbsp;' + c + '&nbsp;</td>');
}

function a(u, c, t) {
    document.write(pr + '"hr(this.childNodes[0])" title="' + t + '"><a href="' + u + '" class=icon>&nbsp;' + c + '&nbsp;</a></td>');
}

function p(u, c, t, m) {
    document.write(pr + '"hr(this.childNodes[0])" title="' + t + '"><a onclick="return confirm(\'' + m + '\')" href="' + u + '" class=icon>&nbsp;' + c + '&nbsp;</a></td>');
}

function al() {
    for (var c = 'a'; c <= 'z'; c++) document.write('<a target="index" href="index.asp?ix=' + c + '">' + c + '</a> ');
}

function get() {
    var o = G('fg');
    o.submit();
}

function getir() {
    if (top.sozmain) top.sozmain.location.href = 'sozluk.asp?x=' + encodeURI(G('t').value);
}

function ara() {
    if (top.sozindex) top.sozindex.location.href = 'last.asp?b=a&x=' + encodeURI(G('t').value);
}

function mch() {
    var u = "t=";
    var c = document.getElementsByTagName("input")
    for (i = 0; i < c.length; i++)
        if (c[i].type == "checkbox" && c[i].name == "mxx" && c[i].checked)
        u += "&m=" + c[i].value;
    od('movemulti.asp?' + u);
}
function ct() {
    tc = G('ctf');
    if (tc) {
        var i = document.getElementsByTagName("input")
        var c = 0;
        for (j = 0; j < i.length; j++) { if (i[j].type == "checkbox") { if (i[j].checked) c++; } }
        tc.style.display = c > 0 ? 'inline' : 'none';
    }
}

function ci(i) {
    ic = G('c' + i);
    with (ic) {
        style.display = style.display == 'none' ? 'inline' : 'none';
        checked = checked ? false : true;
        ct();
    }
}
function oi(n) {
    od('info.asp?n=' + n, 400, 420);
}
function ois(n) {
    if (top.sozmain) top.sozmain.location.href = 'user.asp?n=' + n;
}
function e(f, i, an, re) {
    with (document) {
        write('<br /><table id="m' + i + '" style="visibility:hidden;float:right"><tr>');
        write('<td class="ei" id="vst' + i + '" style="white-space:nowrap">&nbsp;</td>');
        write('<td class="ei"><a href="javascript:void(0)" onclick="copyid(' + i + ',' + f + ');">#' + i + '</a></td>');
        if (f & 16) {
            a("javascript:mpr(" + i + ",1)", ":)", "şükela!");
            a("javascript:mpr(" + i + ",0)", ":O", "öeehh");
            a("javascript:mpr(" + i + ",-1)", ":(", "çok kötü");
            document.write('<td>&nbsp;</td>');
            a("javascript:od('msg.asp?to=" + an + "&re=" + i + "')", "/msg", "mesaj at");
            a("javascript:oi('" + an + "')", "?", "yazar hakkında");
        }
        if (f & 2) a("javascript:od('gammaz.asp?id=" + i + "',430,160)", ":P", "ispiyonla");
        if (f & 128) a("javascript:od('addfave.asp?id=" + i + "')", "-D", "favorilere ekle");
        if (f & 1) document.write(pr + '"ci(' + i + ')" title="taşı"><a id="m' + i + '" href="javascript:ci(' + i + ')" onclick="javascript:ci(' + i + ')" class=icon>&nbsp;>&nbsp;</a></td>');
        if (f & 4) a("edit.asp?id=" + i + "&ref=" + (re ? re : ""), "...", "düzelt");
        if (f & 32) a("show.asp?a=eh&id=" + i, "~", "düzeltme tarihçesi");
        if (f & 64) a("showmodhistory.asp?id=" + i, "!", "moderasyon tarihçesi");
        if (f & 8) a("javascript:od('del.asp?id=" + i + "',430,160)", "X", "sil");
        if (f & 256) { document.write('<td>&nbsp;</td>'); a("javascript:location.href='iletisim.asp?s=1&id=" + i + "'", "!?", "şikayet et"); }
        if (f & 512) a("javascript:od('del.asp?p=y&id=" + i + "')", "X", "tamamen sil");
        write('</tr></table><br /><br />');
        var d = getElementById('d' + i);
        var m = "G('m" + i + "').style.visibility=";
        d.onmouseover = new Function(m + "'visible'");
        d.onmouseout = new Function(m + "'hidden'");
    }
}

function copyid(id, f) {
    var c = G('cidtxt');
    var u = "http://sozluk.sourtimes.org/show.asp?id=" + id;
    if (!c) { prompt('#' + id + ' numaralı entry\'nin adresi', u); return; }
    if (document.selection) {
        if (f & 256) { c.innerText = u; } else { c.innerText = "#" + id; }
        var ct = c.createTextRange();
        ct.execCommand("Copy");
    } else {
        prompt('#' + id + ' numaralı entry\'nin adresi', u);
    }
}


function dd(i) {
    od('domsg.asp?a=d&id=' + i);
    G('d' + i).style.visibility = 'hidden';
}

function me(f, i, an) {
    with (document) {
        write('<span style="text-align:right"><table id="m' + i + '" style="visibility:hidden"><tr><td style="width:100%">&nbsp;</td>');
        if (f & 4) {
            a("javascript:with(G('ssg')){to.value='" + an + "';msg.focus()}", "cevab ver", "popup beklemeden mesaj yazma aparatı");
            a("javascript:od('msg.asp?to=" + an + "')", "/msg", "mesaj at");
            a("javascript:oi('" + an + "')", "?", "yazar hakkında");
        }
        if (f & 2) a("javascript:od('domsg.asp?a=a&amp;id=" + i + "')", "->", "arşivle");
        if (f & 1) a("javascript:dd(" + i + ")", "X", "sil");

        write('</tr></table></span>');
        var d = getElementById('d' + i);
        var m = "G('m" + i + "').style.visibility=";
        d.onmouseover = new Function(m + "'visible'");
        d.onmouseout = new Function(m + "'hidden'");
    }
}

function tr(i) {
    document.write('<tr style="cursor:default" onmouseover="G("m' + i + '").style.visibility=\'visible\'" onmouseout="style.borderWidth=\'0\';G("m' + i + '").style.visibility=\'hidden\'">');
}

function od(u, w, h, x, y) {
    if (!w) w = 320; if (!h) h = 200; if (!x) x = (screen.width - w) / 2; if (!y) y = (screen.height - h) / 2;
    var w = window.open(u, "_blank", "resizable=yes,scrollbars=yes,top=" + x.toString() + ",left=" + y.toString() + ",width=" + w.toString() + ",height=" + h.toString());
    w.focus();
}

function odf(u, w, h, x, y) {
    od(u, w, h, x, y); return false;
}

function au(d) {
    document.write('<tr><td nowrap align="right" class="aul">(<a class="aul" href="?t=' + an + '">' + an + '</a>, ' + d + ')</td></tr>');
}

function sets(doc, fn) {
    if (doc) {
        var len = doc.styleSheets.length;
        if (doc.createStyleSheet) {
            if (fn == "") {
                if (len > 1) doc.styleSheets[1].href = "";
            } else {
                if (len < 2) doc.createStyleSheet(fn); else doc.styleSheets[1].href = fn;
            }
        } else {
            doc.location.reload();
        }
    }
}

function b2r() {
    if (!document.createStyleSheet) {
        return false;
    }
    if (top.sozbar) sets(top.sozbar.document, dcss);
    if (top.sozindex) sets(top.sozindex.document, dcss);
    if (top.sozmain) sets(top.sozmain.document, dcss);
    return true;
}

function bp(o, m, c) {
    var oo;
    for (var n = 1; n <= m; n++) {
        oo = document.createElement("OPTION");
        o.options.add(oo);
        oo.innerText = n;
        oo.Value = n;
        oo.selected = n == c;
    }
}

var inpp = false, n, o = null, maxs = 5, mx = 20, lx = 30, w, bi = 1, sint = null;

function osr() {
    o = null;
    os();
}

function os() {
    if (o == null) {
        o = G('a');
        window.onscroll = os;
        window.onresize = osr;
        w = document.documentElement.clientWidth;
        sint = new Array();
        for (n = 0; n <= maxs; n++) sint[n] = (parseInt(Math.sin((Math.PI * n / 2) / maxs) * (w - mx - lx)) + lx) + "px";
        o.style.left = sint[n = maxs]; o.style.width = (w - parseInt(sint[n]) - 2) + "px";
    }
    if (o.clientHeight + 44 < document.documentElement.clientHeight)
        o.style.top = (document.documentElement.scrollTop + 44) + "px";
    if (sprite == 1) {
        var o_s = G('a' + 's');
        if (o_s.clientHeight + 208 < document.documentElement.clientHeight)
            o_s.style.top = (document.documentElement.scrollTop + 208) + "px";
    }
}

function ca() {
    var amain = G('amain');
    n += bi; o.style.left = sint[n]; o.style.width = (w - parseInt(sint[n]) - 2) + "px";
    if (bi == 1) if (n < maxs) setTimeout("ca()", 20); else { document.body.focus(); amain.disabled = true; o.style.zIndex = 0; inpp = false; }
    else if (n > 0) setTimeout("ca()", 20); else { amain.disabled = false; var kw = G('kw'); if (kw) kw.focus(); inpp = false; }
}

function pp() {
    if (!o) return;
    if (!inpp) {
        inpp = true;
        if (sprite == 1) if (bi > 0 && bi_s < 0) { pp_s('s'); inpp = false; return; }
        if (bi > 0) o.style.zIndex = 1;
        bi = -bi; ca();
    }
}

function ob(n, t) {
    t = (15 - t) / 15.0;
    document.write('<a href="msg.asp?to=' + encodeURI(n) + '" onclick="od(\'msg.asp?to=' + encodeURI(n) + '\');return false">' + n + '</a><br />');
}

function ods(n, s) {
    document.write(' <select name="' + n + '"><option></option>');
    for (var n = 1; n <= 31; n++) document.write("<option>" + n + "</option>");
    if (s) for (n = 2; n <= 12; n++) document.write("<option value=" + (n * 30) + ">" + n + " ay</option>");
    document.write('</select>');
}

function oms(n) {
    var mo = new Array("ocak", "şubat", "mart", "nisan", "mayıs", "haziran", "temmuz", "ağustos", "eylül", "ekim", "kasım", "aralık");
    document.write(' <select name="' + n + '"><option></option>');
    for (var n = 1; n <= 12; n++) document.write("<option value='" + n + "'>" + mo[n - 1] + "</option>");
    document.write('</select>');
}

function oys(n) {
    document.write(' <select name="' + n + '"><option></option>');
    with (new Date()) for (var n = getFullYear(); n >= 1999; n--) document.write("<option>" + n + "</option>");
    document.write('</select>');
}

function ors(t) {
    document.write(
    '<option>..araştır..</option>' +
    '<option value="http://www.google.com.tr/search?q=">google</option>' +
    '<option value="http://www.tdk.gov.tr/TR/SozBul.aspx?F6E10F8892433CFFAAF6AA849816B2EF4376734BED947CDE&Kelime=">tdk sözlüğü</option>' +
    '<option value="http://www.seslisozluk.com/?word=">seslisözlük</option>' +
    '<option value="http://en.wikipedia.org/wiki/Special:Search?fulltext=Search&search=">wikipedia</option>' +
    '<option value="http://us.imdb.com/find?q=">imdb</option>' +
    '<option value="http://www.mobygames.com/search/quick?q=">mobygames</option>' +
    '<option value="http://www.nisanyansozluk.com/search.asp?w=">etimolojik sözlük</option>' +
    '<option value="http://www.youtube.com/results?search_query=">youtube</option>');
}

function orse() {
    document.write('</select>');
}

function orsc(c, t) {
    document.write('<select class="asl" onchange="if(this.selectedIndex>0){window.open(this.options[this.selectedIndex].value+\'' + t + '\');this.selectedIndex=0;}">');
    ors(t);
    if (c == "") { orse(); return }
    var j = gcol(c); if (!j) { orse(t); return }
    for (var i = 0; i < j; i++) {
        var li = gco(c + "li" + i);
        var ln = gco(c + "ln" + i);
        if (li) document.write('<option value="' + li + '">' + ln + '</option>');
    }
    orse(t);
}

function gcol(ci) {
    var n = 0;
    var c = document.cookie.split(";")
    for (var i = 0; i < c.length; i++) {
        var e = c[i].split("=");
        if (e[0].indexOf(ci + "li") != -1) n++;
    }
    return n;
}

function gcok(o) {
    var e = document.cookie.indexOf(";", o);
    if (e == -1) { e = document.cookie.length }
    return unescape(document.cookie.substring(o, e));
}

function gco(n) {
    var a = n + "=";
    var al = a.length;
    var cl = document.cookie.length;
    var i = 0;
    while (i < cl) {
        var j = i + al;
        if (document.cookie.substring(i, j) == a) {
            return gcok(j);
        }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}

function hen(d, a, b) {
    var o = G(d);
    var tmp = o.scrollTop;
    o.focus();
    if (document.selection && !window.opera) {
        var rg = document.selection.createRange();
        if (rg.parentElement() == o) {
            rg.text = a + rg.text + b;
            rg.select();
        } else alert("lütfen önce şeetmek istediğiniz metni seçin");
    }
    else if (o.selectionStart || o.selectionStart == '0') {
        var s = o.value;
        var end = o.selectionEnd;
        var start = o.selectionStart;
        o.value = s.substring(0, start) + a + s.substring(start, end) + b + s.substring(end);
        end += a.length + b.length;
        o.setSelectionRange(end, end);
    } else o.value += a + b;
    o.scrollTop = tmp;
    return true;
}

function tac() {
    var c = document.getElementsByTagName("input");
    for (var i = 0; i < c.length; i++) if (c[i].type == "checkbox") c[i].checked = !c[i].checked;
}

function selcnt() {
    var c = document.getElementsByTagName("input");
    var cnt = 0;
    for (var i = 0; i < c.length; i++) if (c[i].type == "checkbox") cnt += c[i].checked ? 1 : 0;
    return cnt;
}

function dbln4(e, i) {
    var k, c;
    if (window.event) { k = e.keyCode; c = e.ctrlKey; } else { k = e.which; c = e.ctrlKey; }
    if (c && (k == 10 || k == 13)) G(i).submit();
}
function dab() {
    var c = document.getElementsByTagName("input");
    for (var i = 0; i < c.length; i++) if (c[i].type == "submit" || c[i].type == "button") c[i].disabled = true;
}

function vmsg(frm) {
    if ((frm.to.value.length | frm.msg.value.length) == 0) {
        alert("boş işler bunlar");
        return false;
    } else if (frm.msg.value.length > 8000) {
        alert("mesajı çok uzun yazmışsınız bizimle merkeze kadar geleceksiniz");
        return false;
    }
    dab();
    return true;
}
function tdb(i) {
    with (G(i).style) display = (display == "block") ? "none" : "block";
}
function bye() {
    if (confirm('ek$i sözlük\'ten çıkıyorsunuz?')) location.href = 'logoff.asp';
}

function gax() {
    var r = false;
    if (window.XMLHttpRequest) { // mozilla, safari, etc.
        r = new XMLHttpRequest();
        if (r.overrideMimeType) {
            r.overrideMimeType('text/html');
        }
    } else if (window.ActiveXObject) { // ie
        try {
            r = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                r = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) { }
        }
    }
    return r;
}

function ctims(id) {
    if (typeof (tms[id]) == 'object') {
        if (tms[id].length) {
            clearTimeout(tms[id][0]);
            clearTimeout(tms[id][1]);
        }
    }
    return new Array();
}

function mwa(v, id, c) {
    // wait for the response a total of 45 seconds or cancel
    if (c == 4) {
        hreq = false;
        clearTimeout(tms[id][0]);
        tms[id][1] = setTimeout(
      function(v) {
          return function() {
              v.innerHTML = '';
          };
      } (v), 8000);
        v.innerHTML = 'olmadı galiba. tekrar deneyin.';
        return;
    }
    tms[id][1] = setTimeout(
    function(v) {
        return function() {
            v.innerHTML = 'biraz daha sürecek #' + (++c);
            mwa(v, id, c);
        };
    } (v), 15000);
}

function mpr(id, w, c) {
    var p = 'id=' + id + '&v=' + w;
    if (hreq) return;
    var h = gax();
    if (!h) { alert('oyunuzu gönderemiyoruz çünkü web tarayıcınız bir şeyleri desteklemiyor.'); return }
    hreq = h;
    var v = G('vst' + id); if (!v) return;
    tms[id] = ctims(id);
    hreq.open('POST', 'votejx.asp', true);
    hreq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    hreq.setRequestHeader("Content-length", p.length);
    hreq.setRequestHeader("Connection", "close");
    hreq.onreadystatechange = function() {
        if (hreq.readyState == 4) {
            if (hreq.status == 200) {
                v.innerHTML = c ? 'tamam geçti korkma.' : 'oyunuz kaydedildi. (<a href="javascript:mpr(' + id + ',-2,1)">geri al</a>)';
            } else {
                v.innerHTML = 'bir sebepten oyunuz gidemedi';
            }
            hreq = false;
            clearTimeout(tms[id][1]);
            tms[id][0] = setTimeout(
        function(v) {
            return function() {
                v.innerHTML = '';
            };
        } (v), 8000);
        }
    }
    mwa(v, id, 1);
    v.innerHTML = 'oluyor';
    hreq.send(p);
}
