// 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
// ekşi sözlük'ten aşırılmıştır

var yok = "Galatasaray Sözlük - Aslan Yazdığı Yerden Belli Olur";
var id = 0, 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 == 'none') ? 'block' : 'none';
}

function ov(o) {
    o.id = "butOver";
}

function md(o) {
    o.id = "butDown";
}

function bn(o) {
    o.id = "";
}

function b(t, u, c, tt) {
    document.write(pr);
    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.replace("<td>", "<td colspan=" + s + ">") + 'target="' + t + ' href="' + u + '">&nbsp;' + c + '&nbsp;</a></td>');
}

function s(f, c) {
    document.write(pr + 'onclick="G(\'' + f + '\').submit()" style="cursor:hand">&nbsp;&nbsp;' + c + '&nbsp;</a></td>');
}

function a(u,c,t) {
  is="a"+(id++);
  document.write(pr+'"hr('+is+')" title="'+t+'"><a id='+is+' href="'+u+'" class=icon>&nbsp;'+c+'&nbsp;</a></td>');
}

function p(u, c, t, m) {
    document.write(pr + 'title="' + t + '" 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="sozsol" href="sol.php?ix=' + c + '">' + c + '</a> ');
}

function get() {
    var o = G('fg');
    o.submit();
}

function ara() {
    if (top.sozsol) top.sozsol.location.href = 'sol.php?a=ara&q=' + 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('ben.php?kim=' + encodeURIComponent(n),400,420);
}

function tasi(i)
{
  od('hagip.php?islem=entrytasi&id='+i,430,163);
}

function paylas(i)
{
  od('paylas.php?id='+i);
}

function favori(i)
{
  od('favori.php?id='+i);
}

function translate(i)
{
  od('translate.php?&id='+i,800,400);
}

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:od('oy.php?id="+i+"&oy=1')","On","10 numara");
	  		a("javascript:od('oy.php?id="+i+"&oy=-1')","Of","ofsayt");
			document.write('<td>&nbsp;</td>');
			a("javascript:od('msj.php?kime="+an+"&konu="+i+"')","/msg","mesaj at");
			a("javascript:oi('"+an+"')","?","yazar hakkında");
			a("javascript:favori('"+i+"')","+","favorilere ekle");
	  }
	  a("javascript:paylas('"+i+"')","P","paylaş");
	  a("javascript:translate('"+i+"')","T","translate this entry");
	  if(f&2)a("javascript:od('ihbar.php?id="+i+"',430,160)","ihbar","sil ve ihbar et");
      //if(f&128)a("javascript:od('addfave.php?id="+i+"')","-D","favorilere ekle");
	  if(f&1)a("javascript:tasi('"+i+"')",">","taşı");
	  if(f&4)a("eduzenle.php?id="+i+"&ref="+(re?re:""),"...","düzelt");
	  //if(f&32)a("sozluk.php?a=eh&id="+i,"~","duzeltme tarihcesi");
	  //if(f&64)a("javascript:od('showmodhistory.asp?id="+i+"',500,300)","!","moderasyon tarihcesi");
	  if(f&8)a("javascript:od('esil.php?id="+i+"',430,160)","X","sil");
	  if(f&256){document.write('<td>&nbsp;</td>');a("javascript:location.href='iletisim.php?id="+i+"'","!?", "şikayet et");}
	  if(f&512)a("javascript:od('esil.php?id="+i+"&tamsil=1')","XX","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 setmsg(fi, ft, an) {
    fi.value = an;
    ft.focus();
}

function ean(an) {
    return encodeURIComponent(an.replace(/\'/g, "\\\'"));
}

function due(s) {
    return decodeURIComponent(s).replace(/\+/g, " ");
}

function trm(s) { return s.replace(/^\s+|\s+$/g, ''); }
function nada(s) { return trm(s) == ""; }

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:setmsg(G('to'),G('msg'),'" + ean(an) + "')", "cevab ver", "popup beklemeden mesaj yazma aparati");
            a("javascript:od('msg.asp?to=" + ean(an) + "')", "/msg", "mesaj at");
            a("javascript:oi('" + ean(an) + "')", "?", "yazar hakkinda");
        }
        if (f & 2) a("javascript:od('domsg.asp?a=a&amp;id=" + i + "')", "->", "arsivle");
        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 copyid(id, f) {
    var c = G('cidtxt');
    var u = "http://www.rerererarara.net/sozluk.php?id=" + id;
    var s = '#' + id;
    var p = s + ' numarali entry\'nin adresi';
    if (!c) { prompt(p, u); return; }
    if (document.selection) {
        c.innerText = u;
        var ct = c.createTextRange();
        ct.execCommand("Copy");
    } else {
        prompt(p, u)
    }
}

function dd(i) {
    od('kontrol.php?sec=mesaj&islem=mesaj_yeni&gkime=' + i);
    G('d' + i).style.visibility = '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 (sprite == 1) {
            var o_s = G('a' + 's');
            o_s.style.left = sint[n = maxs]; o_s.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 ods(n, s, f) {
    document.write('<select name="' + n + '"><option></option>');
    for (var n = 1; n <= 31; n++) document.write("<option " + (n == f ? "selected='selected'" : "") + ">" + 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, f) {
    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 " + (n == f ? "selected='selected'" : "") + " value='" + n + "'>" + mo[n - 1] + "</option>");
    document.write('</select>');
}

function oys(n, f) {
    document.write('<select name="' + n + '"><option></option>');
    with (new Date()) for (var n = getFullYear(); n >= 2008; n--) document.write("<option " + (n == f ? "selected='selected'" : "") + ">" + n + "</option>");
    document.write('</select>');
}

function ors(t) {
	document.write('<select style="width:120px" class=tedit onchange="if(this.selectedIndex>0){window.open(this.options[this.selectedIndex].value+\''+t+'\');this.selectedIndex=0;}">'+
      '<option>..başka nerede..</option>'+
      '<option value="http://www.google.com.tr/search?q=">google</option>'+
      '<option value="http://www.galatasaray.org/search.php?searchCategory=&searchKeyword=">galatasaray.org</option>'+
      '<option value="http://en.wikipedia.org/wiki/Special:Search?fulltext=Search&search=">wikipedia</option>'+
	  '<option value="http://www.youtube.com/results?search_query=">youtube</option>'+
      '<option value="http://www.tdk.gov.tr/TR/Genel/SozBul.aspx?F6E10F8892433CFFAAF6AA849816B2EF4376734BED947CDE&Kelime=">tdk sözlüğü</option>'+
	  '<option value="http://sourtimes.org/show.asp?t=">ek$i sözlük</option>'+

    '</select>');
}

function orse() {
    document.write('</select>');
}

function orsc(c, t) {
    document.write('<select class="asl" onchange="if(this.selectedIndex>0){window.open(decodeURIComponent(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 decodeURI(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 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 dbsim(e, b) {
    var k, c;
    if (window.event) k = e.keyCode; else k = e.which;
    if (k == 13) G(b).click();
}
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) == 0) {
        alert("kime gidecek?");
        return false;
    } else if ((frm.msg.value.length) == 0) {
        alert("mesaj yaz istersen..!");
        return false;
    } else if (frm.msg.value.length > 8000) {
        alert("mesaj çok uzun..!");
        return false;
    }
    //dab();
    return true;
}
function tdb(i) {
    with (G(i).style) display = (display == "block") ? "none" : "block";
}
function bye() {
    if (confirm('burası galatasaray sözlük ve sen çıkıyor musun?')) location.href = 'logout.php';
}

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 = 'olmadi 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 tarayiciniz bir seyleri 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);
}
function fff(w, f) {
    var m = "Dikkat! Yazdıklarınız boşa gitmesin?\n\n" + f.value.substr(0, 30) + "...\n";
    if (f.value != f.defaultValue) {
        w.onbeforeunload = function() {
            f.focus();
            if (document.all && event) event.returnValue = m
            else return m
        }
    } else nof(w);
}

function nof(w) { w.onbeforeunload = function() { } }

function vt(ta, len) {
    if (ta.value.length <= len) return true;
    alert("yazdiginiz " + len + " karakterden uzun (" + (ta.value.length - len) + " fazlasi var)");
    return false;
}

function hrTimeout(hr, d) {
    return function() {
        hr.timedout = true;
        hr.abort();
        d.innerHTML = "timeout";
    }
}
function dsajx(id, code, title) {
    var d = G((code == 'ed' ? 'vt' : 'sl') + id);
    var b
    if(!d) return;
    var hr = gax();
    if (!hr) { alert('ajax yaptik biz bunu ama web tarayiciniz desteklemiyor, kötü sans.'); return }
    var p = "a=" + code + "&s=" + id
    if (code == 'ed') {
        p = p + "&nr=" + encodeURIComponent(title)
        b = G('gb' + id)
        if (b) b.style.display = 'none';
    }
    d.innerHTML = "isleniyor..."
    hr.open('POST', 'dosucksjx.asp', true);
    hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    hr.setRequestHeader("Content-length", p.length);
    hr.setRequestHeader("Connection", "close");
    hr.onreadystatechange = function() {
        if(hr.readyState != 4) return;
        clearTimeout(hr.abortTimer);
        if(hr.timedout) return;
        if(hr.status == 200) {
            if (code == 'ed') {
                G('rd' + id).innerHTML = hr.responseText;
                if (b) b.style.display = "block";
                d.innerHTML = '';
            } else {
                d.innerHTML = "islendi<br/>(" + title + ")<br/><br/>";
            }
        } else if (hr.status > 0) {
            d.innerHTML = "beceremedik biz bu isi <br/>(" + hr.statusText + ")<br/>" + hr.responseText;
        }
    }
    hr.abortTimer = setTimeout(hrTimeout(hr, d), 30000);
    hr.timedout = false;
    hr.send(p)
}
function nmosf() {
    var a = navigator.userAgent.toLowerCase();
    var m = (a.indexOf('mobile') != -1);
    var s = (a.indexOf('safari') != -1);
    return (!m || !s || typeof (window.Touch) != "object");
}

function bpc() {
  document.write("giden her sevgilinin ardından hep biz olduk el sallayan, haykırsak duyarlar mı sesimizi hangi sevdadan galip çıktık ki? yürüyoruz sessiz ve kederli nevizade geceleri, inletiyoruz her çıkışında istiklal caddesini! boşuna çekilmedi bunca çile içiyoruz gündüz gece, haykırdık ama duymadı hiç kimse peşindeyiz her yerde! şşş! zaten aşklar hep yalan dolan sonu hep acı hüsran, bize her sevdadan geriye kalan SADECE GALATASARAY..!");
}

function tou() {
    top.document.title = yok;
}
function tol(jt) {
    top.document.title = yok + ' - ' + jt;
    if (gqs("txt").length == 0) return;
    G('d').focus();
}