﻿// Tab
//var nTab = 5;
function TabLoad(nTab) {
    var ActivePanel = $get("ctl00_cph_ucProductDetail1_hfActiveTab").value;
    if (ActivePanel == "") { ActivePanel = 'tab1'; }

    for (i = 1; i < nTab; i++) {
        if ('tab' + i == ActivePanel) {
            $get('div_' + ActivePanel).style.display = '';
            $get(ActivePanel).className = 'TabActive';
        }
        else {
            $get('div_' + 'tab' + i).style.display = 'none';
        }
    }
}

function TabChanged(obj, nTab) {
    obj.className = 'TabActive';
    $get('ctl00_cph_ucProductDetail1_hfActiveTab').value = obj.id;

    for (i = 1; i < nTab; i++) {
        if ('tab' + i == obj.id) {
            $get('div_' + obj.id).style.display = '';
        }
        else {
            $get('div_tab' + i).style.display = 'none';
            $get('tab' + i).className = 'Tab';
        }
    }
}




//var menuids = ["VerticalMenu"] //Enter id(s) of SuckerTree UL menus, separated by commas

//function buildsubmenus_vertical() {
//    for (var i = 0; i < menuids.length; i++) {
//        var ultags = document.getElementById(menuids[i]).getElementsByTagName("ul")
//        for (var t = 0; t < ultags.length; t++) {
//            ultags[t].parentNode.getElementsByTagName("a")[0].className = "subfolderstyle"
//            if (ultags[t].parentNode.parentNode.id == menuids[i]) //if this is a first level submenu
//                ultags[t].style.left = ultags[t].parentNode.offsetWidth + "px" //dynamically position first level submenus to be width of main menu item
//            else //else if this is a sub level submenu (ul)
//                ultags[t].style.left = ultags[t - 1].getElementsByTagName("a")[0].offsetWidth + "px" //position menu to the right of menu item that activated it
//            ultags[t].parentNode.onclick = function() {
//            if (this.getElementsByTagName("ul")[0].style.display == "block"){
//                this.getElementsByTagName("ul")[0].style.display = "none"}
//              else{
//                this.getElementsByTagName("ul")[0].style.display = "block"
//              }
//            }
//        }
//        for (var t = ultags.length - 1; t > -1; t--) { //loop through all sub menus again, and use "display:none" to hide menus (to prevent possible page scrollbars
//            ultags[t].style.visibility = "visible"
//            ultags[t].style.display = "none"
//        }
//    }
//}

var menuids = ["VerticalMenu"] //Enter id(s) of SuckerTree UL menus, separated by commas

function buildsubmenus_vertical() {
    for (var i = 0; i < menuids.length; i++) {
        var ultags = document.getElementById(menuids[i]).getElementsByTagName("ul")
        for (var t = 0; t < ultags.length; t++) {
            ultags[t].parentNode.getElementsByTagName("a")[0].className = "subfolderstyle"
            if (ultags[t].parentNode.parentNode.id == menuids[i]) //if this is a first level submenu
                ultags[t].style.left = ultags[t].parentNode.offsetWidth + "px" //dynamically position first level submenus to be width of main menu item
            else //else if this is a sub level submenu (ul)
                ultags[t].style.left = ultags[t - 1].getElementsByTagName("a")[0].offsetWidth + "px" //position menu to the right of menu item that activated it
            ultags[t].parentNode.onmouseover = function() {
                this.getElementsByTagName("ul")[0].style.display = "block"
            }
            ultags[t].parentNode.onmouseout = function() {
                this.getElementsByTagName("ul")[0].style.display = "none"
            }
        }
        for (var t = ultags.length - 1; t > -1; t--) { //loop through all sub menus again, and use "display:none" to hide menus (to prevent possible page scrollbars
            ultags[t].style.visibility = "visible"
            ultags[t].style.display = "none"
        }
    }

}

function doClear(theText) {
    if (theText.value == theText.defaultValue) {
        theText.value = ""
    }
}

function isNumberKey(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode

    if (charCode == 44)
        return true;

    if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 46)
        return false;

    return true;
}
function ChangePicture(PicPath) {
    Progress(); //Update progressi gösteriyor
    document.getElementById('ctl00_cph_ucProductDetail1_imgPicture').src = PicPath;
    setTimeout("document.getElementById('ctl00_cph_ucProductDetail1_imgPicture').style.display='';Progress();", 1500);
    //Update progressi kapatıyor
}



function Progress() {
    if (document.getElementById("Progress").style.display == 'none') {
        document.getElementById("Progress").style.display = '';
    }
    else {
        document.getElementById("Progress").style.display = 'none';
    }
}

function ShowHide(Obj) {
    try {
        if ($get(Obj).style.display == '') {
            $get(Obj).style.display = 'none';
        }
        else {
            $get(Obj).style.display = '';
        }
    }
    catch (e) {
        alert(e.message);
    }
}

function OpenChildWindow(URL, Width, Height) {
    var sFeatures = "dialogHeight: " + Height + "px;";
    sFeatures += "dialogWidth: " + Width + "px;";
    sFeatures += "center: yes;";
    sFeatures += "scroll: no;";
    sFeatures += "status: yes;";
    sFeatures += "resizable: yes;";

    entryWindow = window.showModalDialog(URL, 'ChildForm', sFeatures);
    if (entryWindow == true) {
        window.document.getElementById('ctl00_cph_btnHiddenForUpdate').click();
    }

}

function WindowClose() {
    window.returnValue = true;
    window.close();
}
function WindowCancel() {
    window.returnValue = false;
    window.close();
}


var w = 800, h = 600;

if (document.all || document.layers) {
    w = screen.availWidth;
    h = screen.availHeight;
}

function openPopup(theURL, Width, Height) { //v2.0

    var popW = Width, popH = Height;

    if (typeof (parent.blnMultilanguage) != "undefined" && popupLocation.indexOf("multilanguage") == -1)
        popH += 180;

    var leftPos = (w - popW) / 2, topPos = (h - popH) / 2;
    if (popH > 500)
        topPos = 0;

    entryWindow = window.open(theURL, 'Keops', 'width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos + ',status=0,resizable=1,scrollbars=yes,location=yes');
   

    if (entryWindow == true) {
        window.document.getElementById('ctl00_cph_btnHiddenForUpdate').click();
    }
    else {

    }
}


function getPrint(print_area) {
    var pp = window.open();
    pp.document.writeln('<HTML><HEAD><title>Baskı Önizleme</title></HEAD>')
    pp.document.writeln('<form  method="post">');
    pp.document.writeln('<TABLE width=100%><TR><TD></TD></TR><TR><TD align=right><INPUT ID="PRINT" type="button" value="Yazdır" onclick="javascript:location.reload(true);window.print();"><INPUT ID="CLOSE" type="button" value="Kapat" onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');
    pp.document.writeln(document.getElementById(print_area).innerHTML);
    pp.document.writeln('</form></body></HTML>');

}

function CheckOtherIsCheckedByGVID(spanChk, gv) {
    var IsChecked = spanChk.checked;
    //    if (IsChecked) {
    //        spanChk.parentElement.parentElement.style.backgroundColor = '#228b22';
    //        spanChk.parentElement.parentElement.style.color = 'white';
    //    }

    var CurrentRdbID = spanChk.id;
    var CurrentRdbValue = spanChk.value;
    var Chk = spanChk;

    Parent = document.getElementById(gv);

    var items = Parent.getElementsByTagName('input');


    for (i = 0; i < items.length; i++) {

        if (items[i].id != CurrentRdbID && items[i].type == "radio" && items[i].value == CurrentRdbValue) {
            if (items[i].checked) {
                items[i].checked = false;
                //items[i].parentElement.parentElement.style.backgroundColor = 'white';
                //items[i].parentElement.parentElement.style.color = 'black';
            }

        }

    }

}


function CheckOtherIsCheckedByGVIDMore(spanChk) {
    var IsChecked = spanChk.checked;
    //    if (IsChecked) {
    //        spanChk.parentElement.parentElement.style.backgroundColor = '#228b22';
    //        spanChk.parentElement.parentElement.style.color = 'white';
    //    }

    var CurrentRdbID = spanChk.id;

    var Chk = spanChk;

    Parent = document.getElementById('ctl00_cph_ucShipping1_gvAddress');

    for (i = 0; i < Parent.rows.length; i++) {

        var tr = Parent.rows[i];
        var td = tr.childNodes[0];
        var item = td.firstChild;

        if (item.id != CurrentRdbID && item.type == "radio") {
            if (item.checked) {
                item.checked = false;
                //                item.parentElement.parentElement.style.backgroundColor = 'white';
                //                item.parentElement.parentElement.style.color = 'black';
            }
        }

    }

}

PositionX = 100;
PositionY = 100;
defaultWidth = 500;
defaultHeight = 500;
var AutoClose = false;


if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
    var isNN = (navigator.appName == "Netscape") ? 1 : 0;
    var isIE = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;
}
var optNN = 'scrollbars=no,width=' + defaultWidth + ',height=' + defaultHeight + ',left=' + PositionX + ',top=' + PositionY;
var optIE = 'scrollbars=no,width=150,height=100,left=' + PositionX + ',top=' + PositionY;
function popImage(imageURL, imageTitle) {
    if (isNN) { imgWin = window.open('about:blank', '', optNN); }
    if (isIE) { imgWin = window.open('about:blank', '', optIE); }
    with (imgWin.document) {
        writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>'); writeln('<sc' + 'ript>');
        writeln('var isNN,isIE;'); writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
        writeln('isNN=(navigator.appName=="Netscape")?1:0;'); writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
        writeln('function reSizeToImage(){'); writeln('if (isIE){'); writeln('window.resizeTo(300,300);');
        writeln('width=300-(document.body.clientWidth-document.images[0].width);');
        writeln('height=300-(document.body.clientHeight-document.images[0].height);');
        writeln('window.resizeTo(width,height);}'); writeln('if (isNN){');
        writeln('window.innerWidth=document.images["George"].width;'); writeln('window.innerHeight=document.images["George"].height;}}');
        writeln('function doTitle(){document.title="' + imageTitle + '";}'); writeln('</sc' + 'ript>');
        if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
        else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
        writeln('<img name="George" src=' + imageURL + ' style="display:block"></body></html>');
        close();
    }
}