﻿function Scroller(ulId, speed) {

	this.container = document.getElementById(ulId);
	this.container.Scroller = this;
	this.speed = speed;

	this.scroll = function() {
			var c = this.container.firstChild;
			var first = null;
			while (c) {
				if (c.tagName == 'LI') {
					first = c;
					break;
				}
				c = c.nextSibling;
			}
			var nodeSize = 0;	// Default
			var px = 0;
			nodeSize = first.clientWidth;
			if (first.style.marginLeft != '') {
				px = parseInt(first.style.marginLeft);
			}
			first.style.marginLeft = ( px - 1 ) + 'px';
			if ( parseInt(first.style.marginLeft) <= -(nodeSize) ) {
				first.style.marginLeft = '0px';
				this.container.removeChild(first);
				this.container.appendChild(first);
			}
		setTimeout('document.getElementById(\'' + this.container.id + '\').Scroller.scroll()', this.speed);
	}

	setTimeout('document.getElementById(\'' + ulId + '\').Scroller.scroll()', this.speed);

}

function ajax_urunara() {
           if (window.document.getElementById("ctl00_urun_ara_box").value != 'Aranacak ürün adını/markasını girin') {
               if (window.document.getElementById("ctl00_urun_ara_box").value.length > 2) {
                   window.open("arama.aspx?aranan=" + window.document.getElementById("ctl00_urun_ara_box").value, "_self")
               }
               else {
                   alert('Aranacak kelime en az 3 karakter olmalıdır')
               }
           }
       }
       
function disableEnterKey(e) {
    if (window.document.getElementById("ctl00_urun_ara_box").value == "Aranacak ürün adını/markasını girin") {
        window.document.getElementById("ctl00_urun_ara_box").value = "";
    }

    var key;
    if (window.event) {
        key = window.event.keyCode; //IE
    }
    else {
        key = e.which; //firefox     
    }
    return (key != 13);
}

function urunara() {
    if (document.getElementById('ctl00_urun_ara_box').value.length > 2) { window.open("arama.aspx?aranan=" + document.getElementById('ctl00_urun_ara_box').value, "_self") };
}
function aranull() {
    if (window.document.getElementById("ctl00_urun_ara_box").value == "Aranacak ürün adını/markasını girin") {
        window.document.getElementById("ctl00_urun_ara_box").value = "";
    }
}
function handleError() {
    //	return true;
}
window.onerror = handleError;
var e;
var f;
var x;
var y;
var z;
var w;
var m;
var n;
var o;
var mm;
var nn;
var oo;
var aa;
var bb;
var cc;
var div_adi;
var progress_div;
function sonucgizle() {
    document.getElementById(progress_div).innerHTML = ""
    //document.getElementById(div_adi).innerHTML =""
}

function urunara(par) {
    div_adi = "sonuclar";
    progress_div = "progress_div";
    document.getElementById(progress_div).innerHTML ="<table border='1px'  style='background-color:Gray ; color:White; font-family:Arial; font-size:12px; font-weight:bold; border:1px; ' width='100%' height='100%'><tr><td align='center'  bgcolor='Red' > <font size='4'>B e k l e y i n . . . </font></td></tr></table>";
    document.getElementById(div_adi).innerHTML = ""
    if (par.length > 2) {
        if (document.getElementById("aranan_kelime").value != document.getElementById("ctl00_urun_ara_box").value) {

            document.getElementById("aranan_kelime").value = document.getElementById("ctl00_urun_ara_box").value;
            document.getElementById(div_adi).innerHTML = ""
            //mytime=setTimeout('sonucgizle(10)',3000)

            // window.document.getElementById(progress_div).style.top = "120px"
            //    window.document.getElementById(progress_div).style.left= "740px"

            ajax_loader(div_adi, "ajax_arama.aspx?tip=ajax&ara=" + par, "progress_div")
        }
        else {
            document.getElementById(div_adi).innerHTML = "";
        }
    }

}

function tab_goster(tabid) {
    //////////////////////////////
    if (tabid <= 5) {
        window.document.getElementById("td_" + tabid + "_sag").style.background = "url('site_tasarim/urun_detay/urundetay_tabs_sel_sag.jpg') no-repeat";
        window.document.getElementById("td_" + tabid + "_orta").style.background = "url('site_tasarim/urun_detay/urundetay_tabs_sel_orta.jpg') repeat-x";
        window.document.getElementById("td_" + tabid + "_sol").style.background = "url('site_tasarim/urun_detay/urundetay_tabs_sel_sol.jpg') no-repeat";
    }
    var id = tabid;
    var i = 0;
    while (i <= 5) {
        if (i != tabid) {
            window.document.getElementById("td_" + i + "_sag").style.background = "";
            window.document.getElementById("td_" + i + "_orta").style.background = "";
            window.document.getElementById("td_" + i + "_sol").style.background = "";
        }
        i += 1
    }
    div_adi = "tab_ana_div";
    progress_div = "tab_ana_div";
    document.getElementById(div_adi).innerHTML = ""

    var dosyaadi = "";
    if (id == 0) { dosyaadi = "urundetay_kampanyalar.aspx" }
    if (id == 1) { dosyaadi = "urundetay_ozellikler.aspx" }
    if (id == 2) { dosyaadi = "urundetay_resimler.aspx" }
    if (id == 3) { dosyaadi = "urundetay_urunyorumlari.aspx" }
    if (id == 4) { dosyaadi = "urundetay_odemesecenekleri.aspx" }
    if (id == 5) { dosyaadi = "urundetay_iliskiliurunler.aspx" }

    // reklam urunler için alan
    if (id == 11) { dosyaadi = "http://www.ekopasaj.com/v-pills/v-pills-nedir-ne-ise-yarar.aspx" }
    if (id == 12) { dosyaadi = "http://www.ekopasaj.com/v-pills/v-pills-icinde-neler-var.aspx" }
    if (id == 13) { dosyaadi = "http://www.ekopasaj.com/v-pills/v-pills-satis-yetki-belgelerimiz.aspx" }
    if (id == 14) { dosyaadi = "http://www.ekopasaj.com/v-pills/v-pills-biz-sizi-arayalim.aspx" }
    if (id == 15) { dosyaadi = "http://www.ekopasaj.com/v-pills/v-pills-sss.aspx" }
    if (id == 16) { dosyaadi = "http://www.ekopasaj.com/v-pills/v-pills-dikkat-edilecek-hususlar.aspx" }







    if (id == 0) { window.document.getElementById("div_kampanya").style.display = "block"; }

    if (id != 0) {
        window.document.getElementById("div_kampanya").style.display = "none";

        ajax_loader("tab_ana_div", dosyaadi + "?id=" + window.document.getElementById("ctl00_ContentPlaceHolder1_urun_no").value, "tab_ana_div")
    }
    //////////////////////////////
}



function sepete_ekle() {
    var ii = 1;
    var sayac = 0
    var birlikte_al_ad = "";
    while (ii <= document.getElementById("kampanya_adet").value) {
        if (document.getElementById("birlikteal_" + ii).checked) {
            birlikte_al_ad += document.getElementById("birlikteal_urun_no_" + ii).value + "||";
            document.getElementById("birlikteal_" + ii).checked = false;
        }
        ii += 1
    }
    if (birlikte_al_ad != "") {
        birlikte_al_ad = "&birlikte_al=" + birlikte_al_ad;
    }
    document.getElementById("sepet_uye_div").style.height = "490px";
    document.getElementById("frame").height = "460px";

    window.document.getElementById("frame").src = "sepet_frame.aspx?tip=ekle&urun_no=" + window.document.getElementById("ctl00_ContentPlaceHolder1_urun_no").value + birlikte_al_ad + "&k=" + Math.random() + "&k=" + Math.random();

    document.getElementById("sepet_uye_div").style.display = "block";


}


function ajax_loader(prm_div_adi, prm_url, prm_loader_div) {


    div_adi = prm_div_adi;
    progress_div = prm_loader_div;
    // loader gif goruntulenecekse
    if (prm_loader_div.length > 0) {

        // document.getElementById(prm_loader_div).innerHTML = "&nbsp;&nbsp;<img src='site_tasarim/araniyor.gif' height=25/>";
        document.getElementById(prm_loader_div).style.display = "block";
    }
    //\\loader gif goruntulenecekse
    if (window.XMLHttpRequest) {
        m = new XMLHttpRequest();
        m.onreadystatechange = ajax_change;
        //window.open(prm_url, "_blank")

        m.open("GET", prm_url, true);

        m.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=windows-1254");
        m.send(null)
    } else if
			(window.ActiveXObject) {
        m = new ActiveXObject("Microsoft.XMLHTTP");
        if (m) {
            m.onreadystatechange = ajax_change;
            m.open("GET", prm_url, true);
            m.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=windows-1254");
            m.send()
        }
    }

}

function ajax_change() {
    if (m.readyState == 4) {
        if (m.status == 200 && m.responseText != "") {
            // if (prm_loader_div.length > 0) {
            if (progress_div.length > 0) {

                document.getElementById(progress_div).innerHTML = "";
            }
 
            document.getElementById(div_adi).innerHTML = m.responseText;

        }
        else {
            document.getElementById(progress_div).innerHTML = "";
        }

    }
}

function kritik_stok_sorgula() {
/*
    document.getElementById("sepet_uye_div").style.height = "200px";
    document.getElementById("frame").height = "170px";
    window.document.getElementById("frame").src = "kritik_urun_sorgula.aspx?urun_no=" + window.document.getElementById("ctl00_ContentPlaceHolder1_urun_no").value;
    document.getElementById("sepet_uye_div").style.display = "block";
*/
}

function resim_ekle() {

    document.getElementById("sepet_uye_div").style.height = "330px";
    document.getElementById("frame").height = "300px";
    window.document.getElementById("frame").src = "urundetay_resimekle.aspx?urun_no=" + window.document.getElementById("ctl00_ContentPlaceHolder1_urun_no").value;
    document.getElementById("sepet_uye_div").style.display = "block";

}
function yorum_ekle() {
    document.getElementById("sepet_uye_div").style.height = "470px";
    document.getElementById("frame").height = "440px";
    window.document.getElementById("frame").src = "urundetay_yorumekle.aspx?urun_no=" + window.document.getElementById("ctl00_ContentPlaceHolder1_urun_no").value;
    document.getElementById("sepet_uye_div").style.display = "block";

}
function arkadasina_gonder() {
    document.getElementById("sepet_uye_div").style.height = "470px";
    document.getElementById("frame").height = "440px";
    window.document.getElementById("frame").src = "urundetay_arkadasinagonder.aspx?urun_no=" + window.document.getElementById("ctl00_ContentPlaceHolder1_urun_no").value;
    document.getElementById("sepet_uye_div").style.display = "block";
}
function haberver() {
    document.getElementById("sepet_uye_div").style.height = "470px";
    document.getElementById("frame").height = "440px";
    window.document.getElementById("frame").src = "urundetay_haberver.aspx?urun_no=" + window.document.getElementById("ctl00_ContentPlaceHolder1_urun_no").value;
    document.getElementById("sepet_uye_div").style.display = "block";
}
function mhizm(param, aciklama) {

    document.getElementById("bordo_baslik").innerHTML = aciklama;
    ajax_loader_m("mh_div", param + ".aspx", "mh_div")
    window.document.title = "Ekopasaj.com : " + aciklama;
}

function sizeTo(layerName, img, iHeight, iWidth, animate) {
    var ie4 = (document.all)
    if (ie4) {
        var targetLayer = document.all[layerName]
        // Locate the image to resize
        var el = targetLayer.children.tags("IMG")[0]
        // Add a clip sub-object. This is used to hide browser differences.
        el.clip = new Object
    }
    else {
        // You can't just resize the image. In Netscape we manipulate
        // the positioned DIV the image is displayed within.
        var el = document.layers[layerName]
        // Add a style object. This is used to hide browser differences
        el.style = new Object
        // Store current height and width in IE compatible properties
        el.style.pixelHeight = el.offsetHeight = el.clip.height
        el.style.pixelWidth = el.offsetWidth = el.clip.width
    }
    if (!animate) { // No animation, just change image size
        if (ie4) {
            // Change image size directly in IE
            el.style.pixelWidth = iWidth; el.style.pixelHeight = iHeight
        }
        else {
            // Create new image with new size in Netscape
            el.document.write("<img src='" + img + "' width=" + iWidth + " height=" + iHeight + ">");
            el.document.close();
        }
    }
    else
        if ((el.offsetHeight != iHeight) || (el.offsetWidth != iWidth)) {
        // Notice we set both the style and clip sub-objects. The clip
        // object is used in Netscape, the style object is used in IE.
        // By setting both directly we do not need to distinguish between
        // browsers.
        if (el.offsetHeight < iHeight)
            el.style.pixelHeight = el.clip.height = el.offsetHeight + 1;
        if (el.offsetWidth < iWidth)
            el.style.pixelWidth = el.clip.width = el.offsetWidth + 1;
        if (el.offsetHeight > iHeight)
            el.style.pixelHeight = el.clip.height = el.offsetHeight - 1;
        if (el.offsetWidth > iWidth)
            el.style.pixelWidth = el.clip.width = el.offsetWidth - 1;
        // IE already resized the image when we set the style properties
        // In Netscape we need to write out a new image with the new size
        if (!ie4) {
            el.document.write("<img src='" + img + "' width=" + el.style.pixelWidth + " height=" + el.style.pixelHeight + ">");
            el.document.close();
        }
        // Continue animation
        setTimeout('sizeTo("' + layerName + '","' + img + '",' + iHeight + ',' + iWidth + ',' + animate + ')', 10);
    }
}


function ajax_loader_m(prm_div_adi, prm_url, prm_loader_div) {
    div_adi = prm_div_adi;
    progress_div = prm_loader_div;
    // loader gif goruntulenecekse
    if (prm_loader_div.length > 0) {

        // document.getElementById(prm_loader_div).innerHTML = "&nbsp;&nbsp;<img src='site_tasarim/araniyor.gif' height=25/>";
        document.getElementById(prm_loader_div).style.display = "block";
    }
    //\\loader gif goruntulenecekse
    if (window.XMLHttpRequest) {
        m = new XMLHttpRequest();
        m.onreadystatechange = ajax_change_m;
        //window.open(prm_url, "_blank")

        m.open("GET", prm_url, true);

        m.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=windows-1254");
        m.send(null)
    } else if
			(window.ActiveXObject) {
        m = new ActiveXObject("Microsoft.XMLHTTP");
        if (m) {
            m.onreadystatechange = ajax_change_m;
            m.open("GET", prm_url, true);
            m.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=windows-1254");
            m.send()
        }
    }

}
function ajax_change_m() {
    if (m.readyState == 4) {
        if (m.status == 200 && m.responseText != "") {
            // if (prm_loader_div.length > 0) {
            if (progress_div.length > 0) {

                //       document.getElementById(progress_div).style.display = "none";
            }

            document.getElementById(div_adi).innerHTML = m.responseText;

        }
        else {
            //     document.getElementById(progress_div).style.display = "none";
        }

    }
}