﻿// JScript File
function MakeComment(){

//    var objDemo = document.getElementById("ctl00_cphBody_aMakeComment"); 
//    if (objDemo) { 
//    
//    objDemo.focus(); 
//    alert("de")
//    objDemo.click(); 
//    }
$find('ctl00_cphBody_ModalPopupExtender1').show();

}
function eMakeAddBasket() {

    var objDemo = document.getElementById("ctl00_amybasket");
    if (objDemo) { objDemo.click(); }
//    var modal = document.getElementById('ModalPopupExtender2');
//    modal.show(); 

}
function MakeAddBasket() {

//    var objDemo = document.getElementById("ctl00_amybasket");
//    if (objDemo) { objDemo.click(); }
//    var modal = document.getElementById('ModalPopupExtender2');
//    modal.show(); 
$find('ModalPopupExtender2').show();

}

//-------------------------------------------------------------------
function closeBox(divID) {
    /*Hide the box on close event*/
    obj = document.getElementById(divID);
    obj.style.visibility = 'hidden';
}
function GetComments(evt, objID, prodID, divID) {

    Aobj = document.getElementById(objID);
    var IE = false;
    if (navigator.appName == "Microsoft Internet Explorer")
        IE = true;
 
    if (IE) {
        x = Aobj.offsetLeft;
        y =  Aobj.offsetTop;
        
    }
    else {
        x = evt.pageX;
        y = evt.pageY;
       
    }

    /*display the box at 15px from the mouse pointer*/
    obj = document.getElementById(divID);
    obj.style.left = (x + 15) + 'px';
    obj.style.top = (y) + 'px';
    obj.style.visibility = 'visible';

    try {

        ajaxislem(divID, "ajaxpage.aspx?comproductid=" + prodID, "wait2.gif");
    }

    catch (err) {
        //location.replace("resultSiirArama.aspx?query="+query+"&type_id="+type_id);
    }

}
function ProductCompare(divID, pID,IDStr) {

    try {

        ajaxislem(divID, "ajaxpage.aspx?prodid=" + pID + "&idstr=" + IDStr.toString(), "wait.gif");
    }

    catch (err) {
        //location.replace("resultSiirArama.aspx?query="+query+"&type_id="+type_id);
    }
}
function ProductRemove(divID, pID) {

    try {

        ajaxislem(divID, "ajaxpage.aspx?removeprodid=" + pID.toString(), "wait.gif");
    }

    catch (err) {
        //location.replace("resultSiirArama.aspx?query="+query+"&type_id="+type_id);
    }
}
function AddCompareList(divID, pID,catID) {

    try {

        ajaxislem(divID, "ajaxpage.aspx?addcomplistprodid=" + pID.toString()+"&catid="+catID.toString(), "wait.gif");
    }

    catch (err) {
        //location.replace("resultSiirArama.aspx?query="+query+"&type_id="+type_id);
    }
}
function RemoveCompareList(divID, pID, catID) {

    try {
        ajaxislem(divID, "ajaxpage.aspx?removecomplistprodid=" + pID.toString() + "&catid=" + catID.toString(), "wait.gif");
    }

    catch (err) {
        //location.replace("resultSiirArama.aspx?query="+query+"&type_id="+type_id);
    }
}
function AddBasket(divID,IDs,subIDs,bascount) {

    try {

        ajaxislem(divID, "ajaxpage.aspx?addbasketids=" + IDs.toString() + "&subids=" + subIDs.toString() + "&basketcount=" + bascount.toString(), "wait1.gif");

MakeAddBasket();//zaten onclick te fillbasket metodu cağırılıyor,yukarda çağrılmasına gerek yok
FillBasket('divBasketContent');
    }

    catch (err) {
        //location.replace("resultSiirArama.aspx?query="+query+"&type_id="+type_id);
    }
}
function RemoveBasket(divID, subStockID) {

    try {

        ajaxislem(divID, "ajaxpage.aspx?removebasketsubstockid=" + subStockID.toString(), "wait.gif");
        //$find('ModalPopupExtender2').hide();
        
        MakeAddBasket();
        FillBasket('divBasketContent');
    }

    catch (err) {
        //location.replace("resultSiirArama.aspx?query="+query+"&type_id="+type_id);
    }
}
function RemoveBasketGeneral(divID, subStockID) {

    try {

        ajaxislem(divID, "ajaxpage.aspx?removebasketsubstockid=" + subStockID.toString(), "wait.gif");
//   window.location.reload();
   return false;
    }

    catch (err) {

        //location.replace("resultSiirArama.aspx?query="+query+"&type_id="+type_id);
    }
}
function FillBasket(divID) {

    try {

        ajaxislem(divID, "ajaxpage.aspx?fillbasket=1", "wait1.gif");

    }

    catch (err) {
        //location.replace("resultSiirArama.aspx?query="+query+"&type_id="+type_id);
    }
}
function FillBankFires(divID, genPrice) {

    try {

        ajaxislem(divID, "ajaxpage.aspx?getbankfiresprice=" + genPrice.toString(), "wait1.gif");
    }

    catch (err) {
        //location.replace("resultSiirArama.aspx?query="+query+"&type_id="+type_id);
    }
}
function clickButton(e, buttonid) {


    var evt = (e) ? e : window.event;
    
    var bt = document.getElementById(buttonid);
    if (bt) {

        if (evt.keyCode == 13) {
//            bt.click();

window.location.href = bt.href;
            return false;
        }

    } 
}



function ajaxislem(lbl, url, imgName) {
var objdiv;
try {
    
    objdiv = document.getElementById(lbl);

    }

    catch (err) {
        objdiv = document.getElementById("generalajaxdiv");
    }

    objdiv.innerHTML = "<img src='../images/" + imgName + "' alt='icon' border='0' />";
    
    var xmlHttpNesnesi = XMLHTTP_Olustur();

    if (xmlHttpNesnesi) {
        
        var ItemType = "application/x-www-form-urlencoded; charset=UTF-8";


        xmlHttpNesnesi.open("GET", url, true);

        xmlHttpNesnesi.setRequestHeader("Content-Type", ItemType);

        xmlHttpNesnesi.onreadystatechange = function() {

            if (xmlHttpNesnesi.readyState == 4) {
                
                objdiv.innerHTML = xmlHttpNesnesi.responseText;


            }
        }

        xmlHttpNesnesi.send(null);
    }
}

function XMLHTTP_Olustur() {
   
    var retval = null;
    try {

        retval = new ActiveXObject("Msxml2.XMLHTTP")

    }
    catch (e) {
        try {
            retval = new ActiveXObject("Microsoft.XMLHTTP")

        }
        catch (oc) {
            
            retval = null

        }
    }
    if (!retval && (window.XMLHttpRequest || typeof XMLHttpRequest != 'undefined')) {

        retval = new XMLHttpRequest()

    }
    
    return retval
}

function YaziEncode(yazi) {
    yazi = yazi.replace(/ş/g, "_s_");
    yazi = yazi.replace(/ç/g, "_c_");
    yazi = yazi.replace(/ı/g, "_i_");
    yazi = yazi.replace(/ğ/g, "_g_");
    yazi = yazi.replace(/ü/g, "_u_");
    yazi = yazi.replace(/ö/g, "_ö_");
    yazi = yazi.replace(/Ş/g, "_S_");
    yazi = yazi.replace(/Ç/g, "_C_");
    yazi = yazi.replace(/İ/g, "_I_");
    yazi = yazi.replace(/Ğ/g, "_G_");
    yazi = yazi.replace(/Ü/g, "_U_");
    yazi = yazi.replace(/Ö/g, "_O_");

    return yazi;
}

function YaziDecode(yazi) {
    yazi = yazi.replace(/_s_/g, "ş");
    yazi = yazi.replace(/_c_/g, "ç");
    yazi = yazi.replace(/_i_/g, "ı");
    yazi = yazi.replace(/_g_/g, "ğ");
    yazi = yazi.replace(/_u_/g, "ü");
    yazi = yazi.replace(/_ü_/g, "ö");
    yazi = yazi.replace(/_S_/g, "Ş");
    yazi = yazi.replace(/_C_/g, "Ç");
    yazi = yazi.replace(/_I_/g, "İ");
    yazi = yazi.replace(/_G_/g, "Ğ");
    yazi = yazi.replace(/_U_/g, "Ü");
    yazi = yazi.replace(/_O_/g, "Ö");

    return yazi;
}

