﻿document.onclick = disableEvents;
document.oncontextmenu = disableEvents;
var hiddenListAlert = new Array();
var TTCIDList = new Array();

var currentTT;

var ef = 0;
var mpbgStatus = 0;
var hideTTValid = 0;
var showTTValid = 0;

function showTT(ttCID) {
    currentTT = ttCID;
    hideTTValid = 0;
    showTTValid = 1;
    setTimeout('makeTTVisible()', 1000);
}

function makeTTVisible() {
    if (currentTT != null && currentTT != "" && showTTValid == 1) {
        for (i = 0; i < TTCIDList.length; i++) {
            if (document.getElementById(TTCIDList[i]) != null) {
                document.getElementById(TTCIDList[i]).style.display = 'none';
            }
        }
        if (document.getElementById(currentTT)) {
            document.getElementById(currentTT).style.display = 'block';
            TTCIDList.push(currentTT);
        }
    }
}

function hideTT() {
    showTTValid = 0;
    hideTTValid = 1;
    setTimeout('makeTTInVisible()', 2000);
}

function makeTTInVisible() {
    if (hideTTValid == 1) {
        for (i = 0; i < TTCIDList.length; i++) {
            if (document.getElementById(TTCIDList[i]) != null) {
                document.getElementById(TTCIDList[i]).style.display = 'none';
            }
        }
    }
}

function scrollBar() {
    var result = false;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        result = document.height > window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        result = document.documentElement.scrollHeight > document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        result = document.body.scrollHeight > document.body.clientHeight;
    }
    //alert(result);
    return result;
}

function showMPBG() {
    var scrOfY = 0, scrW = 0, scrH = 0;
    if (typeof (window.pageYOffset) == 'number') {
        //Netscape compliant
        scrOfY = window.pageYOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        //DOM compliant
        scrOfY = document.body.scrollTop;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        //IE6 standards compliant mode
        scrOfY = document.documentElement.scrollTop;
    }

    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        scrW = window.innerWidth;
        scrH = document.height > window.innerHeight ? document.height : window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        scrW = document.documentElement.clientWidth;
        scrH = document.documentElement.scrollHeight > document.documentElement.clientHeight ? document.documentElement.scrollHeight : document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        scrW = document.body.clientWidth;
        scrH = document.body.scrollHeight > document.body.clientHeight ? document.body.scrollHeight : document.body.clientHeight;
    }
    var idsbg = document.getElementById('alertbg');
    idsbg.style.width = '100%';
    idsbg.style.height = scrH + 'px';
    idsbg.style.display = 'block';
    return scrOfY;
}

function showMP(mpDiv, width, height) {
    var scrOfY = showMPBG();
    var ids = document.getElementById(mpDiv);
    var left = ((screen.width / 2) - (width / 2));
    if (scrollBar())
        left = left - 12;
    ids.style.left = left + 'px';
    ids.style.top = ((scrOfY + (screen.height / 2)) - (height / 2)) - 100 + 'px';
    ids.style.visibility = 'visible';
    handleFlashControls();
    mpbgStatus = 1;
}

function getAlertHeader(yukseklik, message) {
    return "<div><table cellpadding='0' cellspacing='0' height='" + yukseklik + "px' width='516px'>" +
                        "<tr><td style='background-image: url(/images/site/mparka/mesaj_arka_sol_" + yukseklik + ".png); width: 8px;'>" +
        "</td>" +
        "<td style='background-image: url(/images/site/mparka/mesaj_arka_orta_" + yukseklik + ".png); width: 500px;" +
            "background-repeat: repeat-x' valign='middle'>" +
                        "<table width='500px' align='left' height='" + yukseklik + "px' cellpading='3'><tr><td width='75px' align='center' rowspan='2'><img src='/images/site/dikkat.png'/></td><td align='center' valign='middle' height='" + (yukseklik - 34) + "px'><span class='turuncu_bold'>" + message + "</span></td></tr><tr><td colspan='2' align='center' height='22px'>";
}

function getAlertFooter(yukseklik) {
    return "</td></tr></table>" +
                            "</td>" +
        "<td style='background-image: url(/images/site/mparka/mesaj_arka_sag_" + yukseklik + ".png); width: 8px;'></td></tr>" +
        "</table></div>";
}

function hideMP(mpDiv) {
    hideMPBG()
    document.getElementById(mpDiv).style.visibility = 'hidden';
    mpbgStatus = 0;
}

function contains(array, item) {
    for (i = 0; i < array.length; i++) {
        if (array[i] == item)
            return 1;
    }
    return 0;
}

function hideMPBG() {
    document.getElementById('alertbg').style.display = 'none';
    var i = 0;
    for (i = 0; i < hiddenListAlert.length; i++) {
        document.getElementById(hiddenListAlert[i]).style.visibility = 'visible';
    }
}

function hidealert() {
    if (mpbgStatus == 0)
        hideMPBG();
    ef = 0;
    document.getElementById('alert').style.visibility = 'hidden';
    document.onkeydown = null;
}

function hidecalert() {
    if (mpbgStatus == 0)
        hideMPBG();
    ef = 0;
    document.getElementById('alert').style.visibility = 'hidden';
}

function showalert(message, yukseklik) {
    document.onkeydown = function() {
        if (event.keyCode == 32 || event.keyCode == 13 || event.keyCode == 27) {
            event.returnValue = false;
            event.cancel = true;
            document.getElementById('btnTamam').click();
        }
    }
    ef = 1;
    var scrOfY = showMPBG();
    var ids = document.getElementById('alert');
    var left = ((screen.width / 2) - 258);
    if (scrollBar())
        left = left - 12;
    ids.style.left = left + 'px';
    ids.style.top = ((scrOfY + (screen.height / 2)) - 120) + 'px';
    ids.style.visibility = 'visible';
    ids.innerHTML = getAlertHeader(yukseklik, message) +
                    "<img name='btnTamam' id='btnTamam' style='cursor:pointer' src='/images/site/button/tamam.png' onclick='hidealert();'>" +
                    getAlertFooter(yukseklik);
    handleFlashControls();
}
var cButtonCID;
function showcalert(buttonCID) {
    showcalert3('Silme işlemi geri alınamaz. Silmek istediğinize emin misiniz?', 90, buttonCID);
}

function showcalert2(message, buttonCID) {
    showcalert3(message, 90, buttonCID);
}

function doPostBack(targetId) {
    var targetName = targetId.replace(/_/gi, '$');
    __doPostBack(targetName, '');
}

function showcalert3(message, yukseklik, buttonCID) {
    cButtonCID = buttonCID;
    ef = 1;
    var scrOfY = showMPBG();
    var ids = document.getElementById('alert');
    var left = ((screen.width / 2) - 258);
    if (scrollBar())
        left = left - 12;
    ids.style.left = left + 'px';
    ids.style.top = ((scrOfY + (screen.height / 2)) - 120) + 'px';
    ids.style.visibility = 'visible';
    ids.innerHTML = getAlertHeader(yukseklik, message) +
                    "<img name='btnEvet' id='btnEvet' style='cursor:pointer' src='/images/site/button/evet.png' onclick='hidecalert();doPostBack(document.getElementById(cButtonCID).id);'>&nbsp;&nbsp;<img name='btnIptal' id='btnIptal' style='cursor:pointer' src='/images/site/button/iptal.png' onclick='hidecalert();'>" +
                    getAlertFooter(yukseklik);
    handleFlashControls();
}

function disableEvents() {
    if (ef)
        return false;
}


function ChangeLang(dvCID, imgCID, dvTRCID, imgTRCID, dvENCID, imgENCID, dvRUCID, imgRUCID) {
    document.getElementById(dvTRCID).style.display = 'none';
    document.getElementById(dvENCID).style.display = 'none';
    document.getElementById(dvRUCID).style.display = 'none';
    document.getElementById(imgTRCID).style.border = 'solid 1px #FFFFFF';
    document.getElementById(imgENCID).style.border = 'solid 1px #FFFFFF';
    document.getElementById(imgRUCID).style.border = 'solid 1px #FFFFFF';
    document.getElementById(dvCID).style.display = 'block';
    document.getElementById(imgCID).style.border = 'solid 1px #6666FF';
}

function ParseDateTR(CID) {
    if (CID != "") {
        var str = document.getElementById(CID).value;
        if (str != null && str != "") {
            var tarih = str.split(".");
            return new Date(tarih[2], tarih[1] - 1, tarih[0]);
        }
        return null;
    }
    return null;
}

