function AramaYap(siteurl) {
	var aranacak_k = document.getElementById('aranacak_k').value;
	if (aranacak_k) {
		var grup_k = document.getElementById('grup_k').value;
		window_url = siteurl+'/kategori.php?g='+grup_k+'&a='+aranacak_k;
		window.location=window_url;
	}
}

function ID_AL(ID) {
	return document.getElementById(ID);
}

function XHConn()
{
  var xmlhttp, bComplete = false;
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, fnDone)
  {
    if (!xmlhttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();
    try {
      if (sMethod == "GET"){xmlhttp.open(sMethod, sURL+"?"+sVars, true); sVars = "";}
      else {
        xmlhttp.open(sMethod, sURL, true);
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type",
          "application/x-www-form-urlencoded");
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && !bComplete){ bComplete = true;fnDone(xmlhttp);}};
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
}

function CreaAjax(){var myConn = new XHConn(); if (!myConn) alert("XMLHTTP desteklenmiyor. Daha yeni/güncel bir tarayıcı ile deneyiniz.");return myConn;}


function EpostaListesineEkle() {
	var target_mail = ID_AL('mailistekle');
	var mail_eposta = ID_AL('list_mail').value;
	var verhata_m;
	if (!EpostaKontrol(mail_eposta)) {
		verhata_m = 'Yeniliklerden haberdar olabilmeniz için geçerli bir e-posta adresi yazmalısınız.';
	}
	if (verhata_m) {
		alert(verhata_m);
	} else {	
		target_mail.innerHTML = '<img src="includes/images/yukleniyor2.gif" align="absmiddle"> Lütfen bekleyiniz...';

	var myConn = CreaAjax();
		var sonucu = function (oXML) {
			target_mail.innerHTML = 'Listeye eklendiniz. TEŞEKKÜRLER';
			setTimeout("EpostaListeEkle()",3000);
		};
		myConn.connect(site_url+'/data.php?git=maillistekle', "POST", "list_eposta="+mail_eposta, sonucu);
	}	
}

function EpostaListeEkle() {
	var target_mail = ID_AL('mailistekle');
	target_mail.innerHTML = '<a href="javascript:EpostaListesineEkle();" class="maillist">EKLE</a>';
}

function EpostaKontrol(src) {
     var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
     var regex = new RegExp(emailReg);
     return regex.test(src);
}

function SepetAjax() {
	var sepet_kisayol = ID_AL('sepet_kisayol');
	var sepet_urunler = ID_AL('urunler');
	var sepet_toplamfiyat = ID_AL('toplamfiyat');
	var sepet_satin_al = ID_AL('sepet_satin_al');
	var sepet_toplam_alan = ID_AL('sepet_toplam_alan');
	
	var html_tablo = '<table width="100%" border="0" cellspacing="0" cellpadding="2">';
	var dolumu=0;
	var toplam_fiyat =0;
	if (sepet_kisayol.style.display=='none') {
		sepet_urunler.innerHTML = '<img src="'+site_url+'/includes/images/yukleniyor.gif" align="absmiddle"> Lütfen bekleyiniz...';
		var myConn = CreaAjax();
			var sepeturunler = function (oXML) {
				var xmlobject = oXML.responseXML;
				
				var kok_urun = xmlobject.getElementsByTagName('urunler')[0];
				var urunler_liste = xmlobject.getElementsByTagName("urun");
				
				if (urunler_liste.length>0) {
				
					for (var iu = 0 ; iu < urunler_liste.length ; iu++) { 
						var urunSira = urunler_liste[iu];
						var urunSira_ad = urunSira.getElementsByTagName("ad")[0].firstChild.nodeValue; 
						var urunSira_marka = urunSira.getElementsByTagName("marka")[0].firstChild.nodeValue;
						var urunSira_fiyat = urunSira.getElementsByTagName("fiyat")[0].firstChild.nodeValue;
						
						html_tablo += '<tr><td width="65%" align="left" valign="top"><strong><u>'+urunSira_ad+'</u></strong><br />'+urunSira_marka+'</td>';
						html_tablo += '<td width="35%" align="left" valign="top">'+urunSira_fiyat+' TL</td></tr>';					
						toplam_fiyat +=parseFloat(urunSira_fiyat);
					}
					html_tablo += '</table>';
					toplam_fiyat=toplam_fiyat.toFixed(2);
					sepet_urunler.innerHTML =html_tablo;
					sepet_toplamfiyat.innerHTML = toplam_fiyat+' TL';
					sepet_toplam_alan.style.display='';
					sepet_satin_al.style.display='';
					sepet_toplamfiyat.style.display='';
				} else {
					sepet_urunler.innerHTML ='<tr><td>Sepetiniz Boş.</td></tr>';
					sepet_kisayol.style.display='';
				}
				sepet_kisayol.style.display='';
			};
			myConn.connect(site_url+'/data.php?git=sepeturun', "POST", "",sepeturunler);
	}
}

function SepetAjaxKapatOK() {
	if (!onmouseout_k) {
		ID_AL('sepet_kisayol').style.display='none';
	} else {
		var onmouseout_k = false;
	}
}

var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
var px = document.layers ? "" : "px";
function KayanBanner(id, sx, sy)
{
	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	window[id + "_obj"] = el;
	if(d.layers)el.style=el;
	el.cx = el.sx = sx;el.cy = el.sy = sy;
	el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};
	el.flt=function()
	{
		var pX, pY;
		pX = (this.sx >= 0) ? 0 : ns ? innerWidth : 
		document.documentElement && document.documentElement.clientWidth ? 
		document.documentElement.clientWidth : document.body.clientWidth;
		pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
		document.documentElement.scrollTop : document.body.scrollTop;
		if(this.sy<0) 
		pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 
		document.documentElement.clientHeight : document.body.clientHeight;
		this.cx += (pX + this.sx - this.cx)/8;this.cy += (pY + this.sy - this.cy)/8;
		this.sP(this.cx, this.cy);
		setTimeout(this.id + "_obj.flt()", 40);
	}
	return el;
}