﻿/*
*
* Coded by Tolga Arican
* C-Section 2007
*
*/

<!--

function aramaSwitch() {

	var disp = document.getElementById("headerSearch").style.display;
	
	if ((disp == null) || (disp =="block"))
	{
		document.getElementById("headerSearch").style.display = "none";
		document.getElementById("searchOn").style.display = "none";
	}
	else
	{
		document.getElementById("headerSearch").style.display = "block";
		document.getElementById("searchOn").style.display = "block";
	}
}

function dillerSwitch() {

	var disp = document.getElementById("headerLang").style.display;

	if ((disp == null) || (disp =="block"))
		document.getElementById("headerLang").style.display = "none";
	else
		document.getElementById("headerLang").style.display = "block";
}

function searchIt(id) {

	searchStr = document.getElementById("searchBox"+id).value;
	if (searchStr == "")
		document.getElementById("searchBox"+id).style.borderColor="maroon";
	else
		window.location = "arama.asp?arama="+searchStr;
}

function changeLang(lang) {
	
	var bas = location.href.lastIndexOf("/")+1;		
	var simdiki = location.href.substring(bas,location.href.length);

	if (lang == "tr")
		window.location = "../" + simdiki;
	else if (lang == "en")
		window.location = "english/" + simdiki;
}

function changePage(pNumber) {
	
	var bas = location.href.lastIndexOf("/") + 1;
	var son = location.href.lastIndexOf("sayfa");
	var diyez = location.href.lastIndexOf("#");
	
	var soruIsareti = location.href.lastIndexOf("?");
	var sorunsal;
	
	if (soruIsareti > -1)
		sorunsal = "&";
	else
		sorunsal = "?";
	
	var myURL = location.href.substring(bas,son);
	
	if (son > -1)
		window.location = myURL + "sayfa=" + pNumber;
	else {
		if (diyez > -1)
			window.location = location.href.substring(bas,diyez) + sorunsal + "sayfa=" + pNumber;
		else
			window.location = location.href.substring(bas,location.href.length) + sorunsal + "sayfa=" + pNumber;			
	}
}

function urunGoster(picNo,filterTotal,picKey) {
	
	document.getElementById("urunPhoto").innerHTML = "<a href=\"javascript:urunGizle()\"><img src=\"images/resimler/urunler/"+picKey+".jpg\" /></a>";
	
	if( typeof( window.innerWidth ) == 'number' ) {
		// Non-IE
		x = window.innerWidth;
		y = window.innerHeight;
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		// IE 6+
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4
		x = document.body.clientWidth;
		y = document.body.clientHeight;
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	
	x = (x / 2) - 320;
	y = (y / 2) - 240 + scrOfY;
	
	// Photo positioning
	document.getElementById("urunPhoto").style.top = y + "px";	
	document.getElementById("urunPhoto").style.left = x + "px";
	document.getElementById("urunPhoto").style.display = "block";
}

function urunGizle() {
	
	document.getElementById("urunPhoto").style.display = "none";
}

function filtreChange() {
	
	var bool = document.getElementById("filtre1").checked;
	var i = 2;

	while (document.getElementById("filtre"+i) != null)
	{
		document.getElementById("filtre"+i).checked = bool;
		i++;
	}
	
	filtreCheckNonEmpty();
}

function filtreCheckNonEmpty() {
	
	// Hepsini Gösterin akıbeti:
	
	result = true;
	i = 2;
	
	if (document.getElementById("filtre3") != null) {
	
		while (document.getElementById("filtre"+i) != null)
		{
			if (!document.getElementById("filtre"+i).checked)
				result = false;
			i++;
		}
		
		document.getElementById("filtre1").checked = result;	
		
		// Hepsini göster seçili değilse
		if (!document.getElementById("filtre1").checked)
		{
			i = 2;
			result = false;
			
			while (document.getElementById("filtre"+i) != null)
			{
				if (document.getElementById("filtre"+i).checked)
					result = true;
				i++;
			}
			
			if (!result)
			document.getElementById("filtre2").checked = true;
			
		}
	} else {
		
		document.getElementById("filtre1").checked = true;
		document.getElementById("filtre2").checked = true;
	}
}

function filtreDegisti(bolum) {
	
	filtered = "";
	i=2;
	
	while (document.getElementById("filtre"+i) != null)
	{
		if (filtered != "")
			filtered += ",";
			
		filtered += document.getElementById("filtre"+i).checked;
		
		i++;
	}
	
	window.location = "urunler.asp?bolum="+bolum+"&altbolumler="+filtered+"&sayfa=1";
}

// ALFABE islemleri

var seciliAlfabe = "A";

function alfabeyiOlustur() {
	
	var i=0;
	
	var alfabe = new Array("A","B","C","Ç","D","E","F","G","H","I","İ","J","K","L","M","N","O","Ö","P","Q","R","S","Ş","T","U","Ü","V","W","X","Y","Z");
	
	for ( i; i < alfabe.length ; i++ ) {
		document.write('<div><a href="javascript:alfabeSec(\''+alfabe[i]+'\');">'+alfabe[i]+'</a></div>');
	}
}

function alfabeSirala() {
	
	window.location = "alfurunler.asp?harf="+seciliAlfabe;
}

function alfabeAc() {
	
	if (document.getElementById("alfabeKutusu").style.display == "block")	
		document.getElementById("alfabeKutusu").style.display = "none";
	else
		document.getElementById("alfabeKutusu").style.display = "block";	
}

function alfabeSec(harf) {
		
	seciliAlfabe = harf;
	document.getElementById("alfabetikFiltre").innerHTML = harf;

	document.getElementById("alfabeKutusu").style.display = "none";
}

function detayliAra() {
	
	var aramaStr = "";
	var flag = false;
	

	for ( var i = 1 ; i <  5; i++)
	{
		if (aramaStr != "")
			aramaStr += ",";
			
		aramaStr += document.getElementById("detayli"+i).checked;

		if (!flag)
			flag = document.getElementById("detayli"+i).checked
	}
	
	aramaStr += "," + document.getElementById("detayli5").value;
	
	aranacak = document.getElementById("detayli6").value;
	
	if (!flag)
		aramaStr = "true,false,false,false,";
	
	if (aranacak == "")
		document.getElementById("detayli6").style.borderColor = "#d63";
	else
		window.location = "alfurunler.asp?harf="+aranacak+"&m="+aramaStr;
}

// HABERLER islemleri
function haberGoster(id) {
	
	if (document.getElementById("haberDetay"+id) != null) {
		
		document.getElementById("haberDetay"+id).style.display = "block";
		document.getElementById("haberKapat"+id).style.display = "block";
	
		if (document.getElementById("haberSonraki"+id) != null)
			document.getElementById("haberSonraki"+id).style.display = "block";
		document.getElementById("haberDevamEt"+id).style.display = "none";
	}
}

function haberGizle(id) {
	
	document.getElementById("haberDetay"+id).style.display = "none";
	document.getElementById("haberKapat"+id).style.display = "none";
	if (document.getElementById("haberSonraki"+id) != null)
		document.getElementById("haberSonraki"+id).style.display = "none";
	document.getElementById("haberDevamEt"+id).style.display = "block";
}

// SAYFALANDIRMA islemleri

simdikiSayfa = 0;
toplamSayfa = 0;

function sayfalandirmaOlustur(seciliSayfa,toplamSayfa) {
	
	if ((seciliSayfa > 0) && (toplamSayfa > 0)) {
	
		document.write('<div id="alfabeKutusu" class="sayfalandirma-box"');
		
		var i=2;	
		var count = 0;
		
		if (seciliSayfa != toplamSayfa)
			document.write('<div><a href="javascript:changePage(\''+toplamSayfa+'\');"><img src="images/but_sag_ok.gif"></a></div>');
		else
			document.write('<div><span><img src="images/but_sag_ok.gif"></span></div>');
			
		
		for ( i; (count <= 4) && (i>-3) ; i-- )
		{
			
			if ((seciliSayfa+i>0) && (seciliSayfa+i<=toplamSayfa))
			{
				count++;
				if (i == 0)
					document.write('<div><span>'+(seciliSayfa+i)+'</span></div>');
				else
					document.write('<div><a href="javascript:changePage(\''+(seciliSayfa+i)+'\');">'+(seciliSayfa+i)+'</a></div>');
					
				
			}
		}
		
		if (seciliSayfa != 1)
			document.write('<div><a href="javascript:changePage(\'1\');"><img src="images/but_sol_ok.gif"></a></div>');
		else
			document.write('<div><span><img src="images/but_sol_ok.gif"></span></div>');
		
		document.write('</div>');
	}
}

// TOOLS
// baslangic , son , secili olan , bos olacak mi basta, sifir
function dropdownGen(from,to,selected,empty,zero)
{
	if (empty)
		document.write('<option value=\"\"></option>');
	
	var selectedText = "";
	var zero_i = "";
	
	for(i=from;i<=to;i++) {
		
		if (i==selected)
			selectedText = " selected=\"yes\" ";
			
			
		if ((i<10) && zero)
			zero_i = "0" + i;
		else
			zero_i = i;
			
		document.write('<option value=\"' + i + '\" '+selectedText+'>' + zero_i + '</option>'); 
			
		selectedText = "";
	} 
}

function checkemail(str){
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(str))
		return true;
	else
	{
		return false;
	}
	return false;
}

var colorTo="#ffffff";

function colorChange(lid) {

	if (colorTo == "#ffffff")
		colorTo = "#f8f8f8";
	else
		colorTo = "#ffffff";
	
	for (i = 1; document.getElementById("ik"+lid+"-"+i) != null; i++)
		document.getElementById("ik"+lid+"-"+i).style.backgroundColor = colorTo;
}

function formCheck() {
	
	var hata = false;
	
	for (i=1; document.getElementById("f"+i) != null; i++) {
		
		
		if (document.getElementById("f"+i).value == "")
		{
			document.getElementById("f"+i).style.borderColor = "red";	
			document.getElementById("g"+i).style.color = "red";
			hata = true;
		}
		else
		{
			document.getElementById("f"+i).style.borderColor = "#cfcfcf";	
			document.getElementById("g"+i).style.color = "#bbb";
		}
	}
	
	if (!hata) document.getElementById("cform").submit();
}

function requiredInputCheck(i) {
	
	divVal = document.getElementById("f"+i).value;
	
	if (divVal != "") {
		
		document.getElementById("f"+i).style.borderColor = "#cfcfcf";
		document.getElementById("g"+i).style.color = "#bbb";
		
	} else {
		
		document.getElementById("f"+i).style.borderColor = "red";
		document.getElementById("g"+i).style.color = "red";
	}
}

function checkCity() {
	
	var country = document.getElementById("f3").value;
	
	if (country != "Türkiye")
		document.getElementById("sehir").innerHTML = '<input type="text" name="fsehir" />';
	else
		document.getElementById("sehir").innerHTML = '<select name="fsehir"><option value="">Seçiniz</option><option value="Adana" >Adana</option><option value="Adıyaman" >Adıyaman</option><option value="Afyon" >Afyon</option><option value="Ağrı" >Ağrı</option><option value="Aksaray" >Aksaray</option><option value="Amasya" >Amasya</option><option value="Ankara" >Ankara</option><option value="Antalya" >Antalya</option><option value="Ardahan" >Ardahan</option><option value="Artvin" >Artvin</option><option value="Aydın" >Aydın</option><option value="Balıkesir" >Balıkesir</option><option value="Bartın" >Bartın</option><option value="Batman" >Batman</option><option value="Bayburt" >Bayburt</option><option value="Bilecik" >Bilecik</option><option value="Bingöl" >Bingöl</option><option value="Bitlis" >Bitlis</option><option value="Bolu" >Bolu</option><option value="Burdur" >Burdur</option><option value="Bursa" >Bursa</option><option value="Çanakkale" >Çanakkale</option><option value="Çankırı" >Çankırı</option><option value="Çorum" >Çorum</option><option value="Denizli" >Denizli</option><option value="Diyarbakır" >Diyarbakır</option><option value="Düzce" >Düzce</option><option value="Edirne" >Edirne</option><option value="Elazığ" >Elazığ</option><option value="Erzincan" >Erzincan</option><option value="Erzurum" >Erzurum</option><option value="Eskişehir" >Eskişehir</option><option value="G.Antep" >G.Antep</option><option value="Giresun" >Giresun</option><option value="Gümüşhane" >Gümüşhane</option><option value="Hakkari" >Hakkari</option><option value="Hatay" >Hatay</option><option value="Iğdır" >Iğdır</option><option value="Isparta" >Isparta</option><option value="İçel" >İçel</option><option value="İstanbul" >İstanbul</option><option value="İzmir" >İzmir</option><option value="K.Maraş" >K.Maraş</option><option value="Karabük" >Karabük</option><option value="Karaman" >Karaman</option><option value="Kars" >Kars</option><option value="Kastamonu" >Kastamonu</option><option value="Kayseri" >Kayseri</option><option value="Kırıkkale" >Kırıkkale</option><option value="Kırklareli" >Kırklareli</option><option value="Kırşehir" >Kırşehir</option><option value="Kilis" >Kilis</option><option value="Kocaeli" >Kocaeli</option><option value="Konya" >Konya</option><option value="Kütahya" >Kütahya</option><option value="Malatya" >Malatya</option><option value="Manisa" >Manisa</option><option value="Mardin" >Mardin</option><option value="Muğla" >Muğla</option><option value="Muş" >Muş</option><option value="Nevşehir" >Nevşehir</option><option value="62" >Niğde</option><option value="Ordu" >Ordu</option><option value="Osmaniye" >Osmaniye</option><option value="Rize" >Rize</option><option value="Sakarya" >Sakarya</option><option value="Samsun" >Samsun</option><option value="Siirt" >Siirt</option><option value="Sinop" >Sinop</option><option value="Sivas" >Sivas</option><option value="Urfa" >Ş.Urfa</option><option value="Şırnak" >Şırnak</option><option value="Tekirdağ" >Tekirdağ</option><option value="Tokat" >Tokat</option><option value="Trabzon" >Trabzon</option><option value="Tunceli" >Tunceli</option><option value="Uşak" >Uşak</option><option value="Van" >Van</option><option value="Yalova" >Yalova</option><option value="Yozgat" >Yozgat</option><option value="Zonguldak" >Zonguldak</option></select>';
}

function openPopup(url,p_width,p_height){
		popup = window.open("","","toolbar=0,width=" + p_width + ",height=" + p_height + ",location=0,directories=0,status=1,scrollbars=1,menubar=0,resizable=0,copyhistory=0"); 
		popup.location.href = url;
		popup.focus();
}

// AJAX SEARCH RESULTS

var xmlhttp;

function loadXMLDoc(url)
{
	
	if (xmlhttp != null) {
		xmlhttp.close;
		xmlhttp = null;
	}
	
	// mozilla
	if (window.XMLHttpRequest) {
		xmlhttp=new XMLHttpRequest();
	}
	// ie
	else if (window.ActiveXObject) {
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	if (xmlhttp!=null) {
		xmlhttp.onreadystatechange=state_Change;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	}
}

function state_Change()
{

	if (!((window.xmlhttp === undefined) || (xmlhttp === undefined)))  {
		
		if (xmlhttp.readyState==4) {
		
			if (xmlhttp.status==200) {
				document.getElementById('searchAjax').innerHTML = "<b>" + xmlhttp.responseText + "</b> sonuç bulundu.";
				xmlhttp.close;
				xmlhttp = null;
			}
		}
	}

}

function ajaxResultCheck() {

	searchStr = document.getElementById('searchBox1').value;
	
	if (searchStr.length > 2)
		loadXMLDoc('aramajax.asp?arama='+searchStr);
	else
		document.getElementById('searchAjax').innerHTML = "";
}

-->