function LenControl(Object, maxLength, txtsayac) {
    /*Gelen multiline kontrolün istenen uzunluğa kadar yazılabilmesini sağlar*/
    objectValue = Object.value;
    objectValueLength = objectValue.length;
    if (objectValueLength > maxLength) Object.value = objectValue.substring(0, maxLength);
    document.all(txtsayac).value = (maxLength - Object.value.length);
    Object.focus();
}
function CheckPage(maxCount, txtTool) {
    var PageNumber;
    var Check;
    if (document.all(txtTool).disabled == true)
        return false;

    PageNumber = document.all(txtTool).value;
    Check = false;
    if (PageNumber == '') {
        alert('1 ile ' + maxCount + ' arasında bir sayı girmelisiniz!');
        document.all(txtTool).focus();
        Check = true;
    }
    if (PageNumber < 1 && Check == false) {
        alert('1 ile ' + maxCount + ' arasında bir sayı girmelisiniz!');
        document.all(txtTool).focus();
        Check = true;
    }
    if (PageNumber > maxCount && Check == false) {
        alert('1 ile ' + maxCount + ' arasında bir sayı girmelisiniz!');
        document.all(txtTool).focus();
        Check = true;
    }
    if (Check == true) return false;
    else return true;

}

function checkKey(key) {//Sayfada entera basılınca hangi butonun aktiflenceğini belirler.
    var Btn = null;
    Btn = document.all('LBtnGoToPage');
    if (key == 13) {
        if (Btn != null)
            document.all('LBtnGoToPage').focus();
    }
}

function gundoldur() {
    var g_yil = document.forms[0].txtyil.value;
    var g_ay = document.forms[0].dday.options[document.forms[0].dday.selectedIndex].value;

    var gun = document.forms[0].ddgun.options[document.forms[0].ddgun.selectedIndex].value;
    if (g_ay == "01" || g_ay == "03" || g_ay == "05" || g_ay == "07" || g_ay == "08" || g_ay == "10" || g_ay == "12")
        g_ay = 31;
    else if (g_ay == "04" || g_ay == "06" || g_ay == "09" || g_ay == "11")
        g_ay = 30;
    else if (g_yil % 4 == 0)
        g_ay = 29;
    else
        g_ay = 28;

    document.forms[0].ddgun.options.length = 0;

    for (i = 1; i <= g_ay; i++) {

        var neway = document.createElement("OPTION")
        if (i < 10) {
            neway.text = '0' + i;
            neway.value = '0' + i;
        }
        else {
            neway.text = i;
            neway.value = i;
        }

        if (navigator.appName != "Netscape") {
            document.forms[0].ddgun.options.add(neway)
        }
        if (navigator.appName == "Netscape") {
            a = document.forms[0].ddgun.options.length
            document.forms[0].ddgun.options.length = a + 1
            document.forms[0].ddgun.options[a] = neway
        }
    }

    document.forms[0].elements['ddgun'].selectedIndex = document.forms[0].ddgun.options.length - 1;
    //document.forms[0].ddgun.selectedIndex = document.forms[0].ddgun.options.length-1;
    document.forms[0].ddgun.options[document.forms[0].ddgun.options.length - 1].selected = true;
    if (document.forms[0].ddgun.options.length > gun) {
        document.forms[0].ddgun.value = gun;
    }

}
function onlyCurrency(key) {
    if (key == 44)//, ise yes
        event.returnValue = true;
    else if (key == 46)//. ise no
        event.returnValue = false;
    else if (key < 45 || key > 57) //sayı dışı ise no
        event.returnValue = false;
}


function karakterkontrol(code) {

    //sadece karakter
    if (code == 199 || code == 214 || code == 220 || code == 231 || code == 246 || code == 252 || code == 286 || code == 287 || code == 304 || code == 305 || code == 350 || code == 351)
        return true;
    if (code < 65)
        if (code != 32)
        return false;
    if (code > 90) {
        if (code < 97)
            return false;
        else if (code > 122)
            return false;
    }
    return true;

}
//*****************************************    
function Checkvirgul(objvl, type) {
    if (type == 1) objvl = objvl.replace(',', '.');
    if (type == 2) objvl = objvl.replace('.', ',');
    return objvl;
}
//****************************************
//*****************************************
function rnd(sayi, yuvarla) {
    var carp = 10;
    for (i = 0; i < yuvarla - 1; i++)
        carp = carp * 10;

    var s = sayi;
    if (yuvarla > 0) s = sayi * carp;

    s = Math.round(s)
    if (yuvarla > 0) s = s / carp;

    return s;
}
function PencereAc(Pagestr, w, h, r, s) {
    window.open(Pagestr, 'Sayfa', 'toolbar=no, resizable=' + r + ', scrollbars=' + s + ',width=' + w + ', height=' + h);
}
function NewWindow(Pagestr, w, h, r, s) {
    window.open(Pagestr, 'Sayfa', 'toolbar=no, resizable=' + r + ', scrollbars=' + s + ',width=' + w + ', height=' + h);
}

function openModulDialog(WhichPage, Title, dialogWidth, dialogHeight) {
    url = WhichPage + '&Title=' + Title;
    returnValue = showModalDialog(url, "window", "dialogHeight: " + dialogHeight + "px; dialogWidth: " + dialogWidth + "px;status:no;help:no;close:no")
}

function NewWindow(mypage, myname, w, h, scroll, r) {
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    winprops = 'height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl + ',scrollbars=' + scroll + ',resizable=' + r
    win = window.open(mypage, myname, winprops)
    if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

/* Functions for AJAX */

function LoadPopUpImage(imageurl, pwidth, pheight) {
    document.getElementById('PopUpDiv').innerHTML = "<img src=\"" + imageurl + "\" alt=''>";
    document.getElementById('ctl00_MainContent_PanelPopUp').style.width = pwidth + 20;
    document.getElementById('ctl00_MainContent_PanelPopUp').style.height = pheight + 60;

    //var el = $get('<%=Panel1.ClientID%>'); // Get its position.
    //var newLocation = $common.getLocation(el);

    //var newLocation = new Sys.UI.Point(screen.width / 2) - ((pwidth+20)/2), ((screen.height / 2) - ((pheight+20)/2));
    //var newLocation = new Sys.UI.Point(100,100);
    // Move the Panel to the destination.
    //$common.setLocation(document.getElementById('ctl00_MainContent_PanelPopUp'), newLocation); 


    //document.getElementById('ctl00_MainContent_PanelPopUp').style.position = "absolute";
    //document.getElementById('ctl00_MainContent_PanelPopUp').style.top = "100px";
    //document.getElementById('ctl00_MainContent_PanelPopUp').style.left = (screen.width / 2) - ((pwidth+20)/2);             
    GosterAbi();
}

function LoadPopUpSwf(imageurl, pwidth, pheight) {
    document.getElementById('PopUpDiv').innerHTML = "<embed src=\"" + imageurl + "\" width=\"" + pwidth + "\" height=\"" + pheight + "\" scale=\"ShowAll\" play=\"true\" loop=\"true\" menu=\"true\" wmode=\"Window\" quality=\"1\" type=\"application/x-shockwave-flash\"></embed>";       
    document.getElementById('ctl00_MainContent_PanelPopUp').style.width = pwidth + 20;
    document.getElementById('ctl00_MainContent_PanelPopUp').style.height = pheight + 60;

    //var el = $get('<%=Panel1.ClientID%>'); // Get its position.
    //var newLocation = $common.getLocation(el);

    //var newLocation = new Sys.UI.Point(screen.width / 2) - ((pwidth+20)/2), ((screen.height / 2) - ((pheight+20)/2));
    //var newLocation = new Sys.UI.Point(100,100);
    // Move the Panel to the destination.
    //$common.setLocation(document.getElementById('ctl00_MainContent_PanelPopUp'), newLocation); 


    //document.getElementById('ctl00_MainContent_PanelPopUp').style.position = "absolute";
    //document.getElementById('ctl00_MainContent_PanelPopUp').style.top = "100px";
    //document.getElementById('ctl00_MainContent_PanelPopUp').style.left = (screen.width / 2) - ((pwidth+20)/2);             
    GosterAbi();
}

function LoadPopUpHTML(html) {
    //
    document.getElementById('PopUpDiv').innerHTML = html;   
    GosterAbi();
}

function LoadPopUpFrame(url, width, height, pwidth, pheight) {
    document.getElementById('<%=PanelPopUp.ClientID%>').style.width = pwidth;
    document.getElementById('<%=PanelPopUp.ClientID%>').style.height = pheight + 20;

    document.getElementById('PopUpDiv').innerHTML = "<iframe height=\"" + height + "px\" width=\"" + width + "px\" src=\"" + url + "\"></iframe>";
    GosterAbi();
}

function GosterAbi() {
    var modalPopupBehaviorCtrl = $find('ModalPopupBehaviorID');
    modalPopupBehaviorCtrl.show();
}

function tabhover() {
    

    // get the behavior associated with the tab control
    var tabContainer = $find('<%=TabContainer2.ClientID %>');

    // get all of the tabs from the container
    var tabs = tabContainer.get_tabs();

    // loop through each of the tabs abd attach a handler to
    // the tab header's mousover event
    for (var i = 0; i < tabs.length; i++) {
        var tab = tabs[i];
        $addHandler(tab.get_headerTab, 'mouseover', Function.createDelegate(tab, function() { tabContainer.set_activeTab(this); }));
    }
}


// finds a control that had the given server id, of a the given type
// in the given parent.
//
function findControl(parent, tagName, serverId) {
    var items = parent.getElementsByTagName(tagName);

    // walk the items looking for the right guy
    for (var i = 0; i < items.length; i++) {
        var ctl = items[i];
        if (ctl && ctl.id) {
            // check the end of the name.
            //
            var subId = ctl.id.substring(ctl.id.length - serverId.length);
            if (subId == serverId) {
                return ctl;
            }
        }
    }
    return null;
}

function loadTabPanel(sender, e) {

    var tabContainer = sender;

    if (tabContainer) {
        var updateControlId = "TabButton" + tabContainer.get_activeTabIndex();
        // get the active tab and find our button
        //
        var activeTab = tabContainer.get_activeTab();


        // check to see if we've already loaded
        //
        if (findControl(activeTab.get_element(), "div", "TabContent" + tabContainer.get_activeTabIndex())) return;


        var updateControl = findControl(activeTab.get_element(), "input", updateControlId);

        if (updateControl) {

            // fire the update
            //
            updateControl.click();
        }

    }
}
