﻿// Genel fonksiyonlari iceren script dosyasi

var ShowLoading=true;
function DisableLoading() {
ShowLoading=false;
window.setTimeout("EnableLoading()",100);
}
function EnableLoading() {
ShowLoading=true;
}
function ShowWorking(validators)
{

    if(!ShowLoading)
        return;
    if( validators > 0 )
    { 
        if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
    }
    
    var docEl=(document.body && document.body.scrollTop)?document.body:document.documentElement;
    
    var iframe = dc("iframe");
    iframe.id = "workingFrame"
    iframe.frameBorder = "no";
    iframe.style.position = "absolute";
    
    iframe.style.top = docEl.scrollTop + "px";  
    iframe.style.left = "0px";
    
    if(document.body && document.body.clientWidth && document.body.clientWidth>10) {
        iframe.style.width = document.body.clientWidth+"px";
        iframe.style.height = document.body.clientHeight+"px";
    }
    else if(document.body && document.body.getBoundingClientRect) {
	    var width = document.body.getBoundingClientRect().right - document.body.getBoundingClientRect().left;
	    var height = document.body.getBoundingClientRect().bottom - document.body.getBoundingClientRect().top;
        iframe.style.width = width+"px";
        iframe.style.height = height+"px";
    }
    else {
        iframe.style.width = "100%";
        iframe.style.height = "100%";
    }
    
    iframe.style.zIndex = "9998";
    iframe.style.backgroundColor = "#ffffff";
    if( ie() )iframe.style.filter = "alpha(opacity=70)";
    else iframe.style.opacity = 0.7;

    var div = dc("div");
    div.id = "workingDiv";
    div.style.marging = "10px";
    div.style.padding = "10px";
    div.style.zIndex = "9999";
    div.style.position = "absolute";
    div.style.top = docEl.scrollTop + 120 + "px";
    div.style.left = (document.body.offsetWidth / 2) - 135 + "px";
    div.style.width = "250px";
    div.style.height = "150px";
    div.style.border = "ridge 2px";
    div.style.backgroundColor = "#dfd9d9";
    
    
    /*
    if( ie() )
        div.innerHTML = "<object type=\"application/x-shockwave-flash\" width=\"250px\" height=\"150px\" ><param name=\"movie\" value=\"../Images/calisiyor.swf\" /></object>";
    else
        div.innerHTML = "<embed type=\"application/x-shockwave-flash\" src=\"../Images/calisiyor.swf\" width=\"250px\" height=\"150px\" ></embed>";
    */
    
    
    
    //div.style.verticalAlign="center";
    //div.style.textAlign="center";
    div.innerHTML = "<img src=\"../Images/calisiyor.gif\" width=\"250px\" height=\"150px\" />";
    
    body().appendChild(iframe);
    body().appendChild(div);

    window.onscroll = window.onresize = function resizeFrame(){ 
        if(!gid("workingFrame") || !gid("workingDiv")) return;
        gid("workingFrame").style.top = docEl.scrollTop + "px"
        gid("workingDiv").style.left = (document.body.offsetWidth / 2) - 135 + "px"
        gid("workingDiv").style.top = docEl.scrollTop + 120 + "px"
        //if(!ie())gid("workingDiv").innerHTML = "<embed type=\"application/x-shockwave-flash\" src=\"../Images/calisiyor.swf\" width=\"250px\" height=\"150px\" ></embed>"
    }

    return true;
}

var _v1,_v2,_v3;
function ShowMessage(title,message,icon) {
_v1=title;
_v2=message;
_v3=icon;
window.setTimeout('ShowMessage2()',100);
}

function ShowMessage2()
{  
var docEl=(document.body && document.body.scrollTop)?document.body:document.documentElement;
var title=_v1;
var message=_v2;
var icon=_v3;   
    var iframe = dc("iframe");
   
    var div = dc("div");
    var table = dc("table");
    var tbody = dc("tbody");
    
    var bar = dc("hr");
    var img = dc("img");
    
    var trTitle = dc("tr");
    var trMessage = dc("tr");
    var trBottom = dc("tr");
    
    var tdTitle1 = dc("td");
    var tdTitle2 = dc("td");
    var tdMessage = dc("td");
    var tdBottom = dc("td");
    var btnClose = dc("button");
    
    var messageTitle = document.createTextNode(title);
    var messageText = dc("div");
    
    div.id = "msgboxDiv";
    div.style.border = "ridge 4px";
    div.style.position = "absolute";
    div.style.width = "420px";
    div.style.height = "280px";

    iframe.frameBorder = "no";
    iframe.style.position = "absolute";
    iframe.style.top = "0px";
    iframe.style.left = "0px";
    
    if(document.body && document.body.clientWidth && document.body.clientWidth>10) {
        iframe.style.width = document.body.clientWidth+"px";
        iframe.style.height = document.body.clientHeight+"px";
    }
    else if(document.body && document.body.getBoundingClientRect) {
	    var width = document.body.getBoundingClientRect().right - document.body.getBoundingClientRect().left;
	    var height = document.body.getBoundingClientRect().bottom - document.body.getBoundingClientRect().top;
        iframe.style.width = width+"px";
        iframe.style.height = height+"px";
    }
    else {
        iframe.style.width = "100%";
        iframe.style.height = "100%";
    }

    iframe.id = "msgboxiframe";
    
    window.onscroll = window.onresize = 
        function frameOnResize() {
            if(!gid("msgboxiframe") || !gid("msgboxDiv")) return;
            gid("msgboxiframe").style.width = "100%";
            gid("msgboxiframe").style.height = "100%";
            if(document.body.offsetHeight>0)gid("msgboxiframe").style.height = document.body.offsetHeight + "px";
            if( docEl.scrollTop > 0 )gid("msgboxDiv").style.top = docEl.scrollTop + "px";
            else gid("msgboxDiv").style.top = 100 + "px";
            gid("msgboxDiv").style.left = (document.body.offsetWidth / 2) - 210 + "px";
        }
    
    table.border = "0";
    table.cellSpacing = "4";
    table.cellPadding = "4";
    table.style.backgroundColor = "#E1E1E1";
    table.style.width = "100%";
    table.style.height = "100%";
    
    img.src = "../Images/" + icon + ".gif" ;
    
    messageText.innerHTML = message;
    messageText.style.width = "100%";
    messageText.style.height = "150px";
    messageText.style.backgroundColor = "#E1E1E1";
    messageText.style.border = "none";
    //messageText.readOnly = "true";
    messageText.id = "msgboxbody";
    
    trTitle.id = "msgboxtitle"
    trTitle.style.fontFamily = "Verdana";
    trTitle.style.color = "#990101";
    trTitle.style.fontWeight = "bold";
    trTitle.style.fontSize = "14px";
    trTitle.style.paddingLeft = "7px";
    
    tdTitle2.style.width = "100%";
    
    btnClose.id = "msgboxbutton";
    btnClose.innerHTML = "Tamam";
    btnClose.onclick = function onclick(){ body().removeChild(gid("msgboxiframe"));body().removeChild(gid("msgboxDiv")); }
    btnClose.style.fontSize = "10pt";
    btnClose.style.fontFamily = "Verdana";
    btnClose.style.width = "120px";
    btnClose.style.height = "25px";
    
    tdBottom.style.textAlign = "right";
    
    tdTitle1.appendChild(img);
    tdTitle2.appendChild(messageTitle);
    trTitle.appendChild(tdTitle1);
    trTitle.appendChild(tdTitle2);
    tbody.appendChild(trTitle);
    
    tdMessage.colSpan = "2";
    tdMessage.appendChild(bar);
    tdMessage.appendChild(messageText);
    trMessage.appendChild(tdMessage);
    tbody.appendChild(trMessage);
    
    tdBottom.colSpan = "2";
    tdBottom.appendChild(btnClose);
    trBottom.appendChild(tdBottom);
    tbody.appendChild(trBottom);
    
    table.appendChild(tbody);
    div.appendChild(table);
    
    iframe.style.backgroundColor = "#ffffff";
    if( ie() )iframe.style.filter = "alpha(opacity=70)";
    else iframe.style.opacity = 0.7;
    iframe.style.zIndex = "9998";
    
    div.style.zIndex = "9999";
    div.style.top = docEl.scrollTop + 100 + "px";   
    div.style.left = (document.body.offsetWidth / 2) - 210 + "px";
    
    body().appendChild(iframe);
    body().appendChild(div);
}

function dc(tagName)
{
    return document.createElement(tagName);
}

function ie()
{
    if( navigator.appName.indexOf("Microsoft") > -1 )return true;
    return false;
}

function body()
{
    var theBody = document.body;
    if(theBody && document.body.tagName=="BODY")
        return theBody;
    if(ie())theBody = document.body.firstChild;
    return theBody;
}

function gid(id)
{
    return document.getElementById(id);
}

var AcikMenuID;

function CloseAll() {
    MainMenuItems = document.getElementsByTagName('div');
    for (var i = 0; i < MainMenuItems.length; i++) {
        if (MainMenuItems[i].id.indexOf('accmenuno') != -1) {
            document.getElementById("Accordion" + MainMenuItems[i].id.substr(9) + "Content").style.display = 'none';
        }
    }
}

function MenuAyarla(ID) {
    if (AcikMenuID != ID) {
        CloseAll();
        var contentID = "Accordion" + ID + "Content";
        var menuID = "accmenuno" + ID;
        var mainmenuID = "";
        var AcilacakMenuler = new Array();

        AcilacakMenuler[0] = menuID;
        if (document.getElementById(menuID).getAttribute('mainmenu') != null)
            mainmenuID = document.getElementById(menuID).getAttribute('mainmenu');

        var j = 1;
        while (mainmenuID != "") {
            AcilacakMenuler[j] = mainmenuID;
            j++;
            if (document.getElementById(mainmenuID).getAttribute('mainmenu') != null)
                mainmenuID = document.getElementById(mainmenuID).getAttribute('mainmenu');
            else
                mainmenuID = "";
        }

        for (var i = 0; i < AcilacakMenuler.length; i++) {
            if (AcikMenuID != ID)
                document.getElementById("Accordion" + AcilacakMenuler[i].substr(9) + "Content").style.display = 'block';
        }
        AcikMenuID = ID;
    }
    else {
        var menuID = "accmenuno" + ID;
        var contentID = "Accordion" + ID + "Content";
        document.getElementById(contentID).style.display = 'none';
        if (document.getElementById(menuID).getAttribute('mainmenu') != null)
            AcikMenuID = document.getElementById(menuID).getAttribute('mainmenu').substr(9);
        else
            AcikMenuID = "";
    }
}

