
function getXmlHttp() {
    var xmlHttp = false;

   // Internet Explorer (5.0+)
   try {
     xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
   } catch (e) {
      try {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        xmlHttp = false;
      }

   }
   // Mozilla veya Safari
   if ( !xmlHttp && typeof XMLHttpRequest != 'undefined' ) {

     try{
        xmlHttp = new XMLHttpRequest();
     }catch(e) {
        xmlHttp = false;
     }
   }
   // Diger (IceBrowser)
   if ( !xmlHttp && window.createRequest ) {
	 try{
        xmlHttp = window.createRequest();
     }catch(e) {
        xmlHttp = false;
     }
   }
	return xmlHttp;
}

function JXP(yukleniyor, yer, dosya, sc) {
	xmlHttp = new getXmlHttp();

	if (xmlHttp) {
	   	xmlHttp.onreadystatechange = function () {}
	   	xmlHttp.abort();
	}

    xmlHttp.onreadystatechange = function () {	Loading(yukleniyor, yer) }

	xmlHttp.open('POST', dosya, true)
	xmlHttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT")
   	xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8')
    xmlHttp.setRequestHeader("Content-length", sc.length)
    xmlHttp.setRequestHeader("Connection", "close")
    xmlHttp.send(sc)

}

function Loading(yukleniyor, yer) {
	if(yukleniyor == 1 && yer != 'no_id' ) {
		if( xmlHttp.readyState == 1 || xmlHttp.readyState == 2 || xmlHttp.readyState == 3 ) {

		}
	}
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
            document.getElementById(yer).innerHTML = xmlHttp.responseText;
        } else {
            document.getElementById(yer).innerHTML = '<strong>HATA:</strong> ' + xmlHttp.statusText;
        }
		function getXmlHttp() {};
    }
}

function Select_JXP(yer, dosya, sc) {
// bu fonksiyon select'in içeriğini doldurmak için yazıldı
xmlHttp = new getXmlHttp();

	if (xmlHttp) {
	   	xmlHttp.onreadystatechange = function () {}
	   	xmlHttp.abort();
	}

    xmlHttp.onreadystatechange = function () {	Select_Loading(yer) }

	xmlHttp.open('POST', dosya, true)
	xmlHttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT")
   	xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8')
    xmlHttp.setRequestHeader("Content-length", sc.length)
    xmlHttp.setRequestHeader("Connection", "close")
    xmlHttp.send(sc)

}

function Select_Loading(yer) {
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
            var response = xmlHttp.responseText;
            var list=document.getElementById(yer);
            var ayrac=response.split('|');

            while (list.childNodes[0]) {
              list.removeChild(list.childNodes[0])
            }

            for (i=1; i<ayrac.length; i++) {

            // gelen değer |118,deniz YIKILMAZ şeklidendir
            // | işareti id ve isim birleşik önce bunu ayırıyoyoruz
            // , işareti ise önce select option value = degerayrac[0] değer sonraki ise optionda gözüken bölüm
               var degerayrac=ayrac[i].split(',');

               var x=document.createElement('option');
              // var y=document.createTextNode(ayrac[i]);
               var y=document.createTextNode(degerayrac[1]);

               x.appendChild(y);
               list.appendChild(x);
               x.value = degerayrac[0];

               }
        }
    }
}
function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) 	{
		while (obj.offsetParent) 		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return (curleft - 160);
}
function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) 	{
		while (obj.offsetParent) 		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return (curtop-160);
}
function AltKategoriGetir(anacat) {
var sc = "anacat=" + anacat + "&iop=altkategorilerigetir";
Select_JXP("altcat", "includes/islem.php", sc);
}

function HaberveyaKampanyaGoster(haberid) {
 var sc = "mesajid=" + haberid + "&iop=habergoster";
 JXP(1, "haberyeri", "includes/islem.php", sc);
}

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
    obj.value=obj.value.substring(0,mlength)
document.getElementById('yazialani').innerHTML =  obj.value.length + "/" + mlength;
}

function SiparisUrunSil(sid) {
 var sc = "silinenid=" + sid + "" + "&iop=siparisurunusil";
 JXP(1, "siparislisteyeri", "includes/islem.php", sc);
}
