
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 updateCounter(element, maxLength) {
	if(element.value.length > maxLength) {
		alert('Mesajınız en fazla ' + maxLength + ' karakter olabilir');
		element.value = element.value.substring(0, maxLength);
	}
}

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 (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
            document.getElementById(yer).innerHTML = xmlHttp.responseText;
        } else {
            document.getElementById(yer).innerHTML = '<strong>HATA VAR:</strong> ' + xmlHttp.statusText;
        }
		function getXmlHttp() {};
    }
}
function Sehir_Sec(ulke) {
    var sc = "ulkeadi=" + ulke;
    sc += "&iop=ulkesec";
    JXP(1, "sehiryeri", "../includes/islem.php", sc);
}

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;
}
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;
}

function closeMessageDialog() {
	var dialog = document.getElementById('messageDialog');
	dialog.style.visibility = 'hidden'
	messageDialogVisible = false;
}

function messageDialog(n) {
	var dialog = document.getElementById('messageDialog');

	var x = findPosX(document.getElementById('messageIcon'+n)) ;
	var y = findPosY(document.getElementById('messageIcon'+n)) + 24;

    dialog.style.top = y + 'px';
    dialog.style.left = x + 'px';
	dialog.style.visibility = 'visible';
    var sc = "mesajid=" + n + "&iop=mesajgoster";
    JXP(1, "messageDialog", "includes/islem.php", sc);

}
function TedarikciGoster(n) {
	var dialog = document.getElementById('messageDialog');

	var x = findPosX(document.getElementById('messageIcon'+n)) ;
	var y = findPosY(document.getElementById('messageIcon'+n)) + 24;

    dialog.style.top = y + 'px';
    dialog.style.left = x + 'px';
	dialog.style.visibility = 'visible';
    var sc = "mesajid=" + n + "&iop=tedarikshow";
    JXP(1, "messageDialog", "includes/islem.php", sc);

}
function Nick_kontrolu(kullanici) {
 var sc = "mesajid=" + kullanici + "&iop=nickkontrol";
    JXP(1, "nickikontrol", "../includes/islem.php", sc);

}


function Kontor_Sayisi_Hesapla_Yonetim(tarih) {
 var sc = "mesajid=" + tarih + "&iop=kontorkontrol";
    JXP(1, "kackontorkaldi_yonetim", "includes/islem.php", sc);

}

function Kontor_Sayisi_Hesapla(tarih) {
 var sc = "mesajid=" + tarih + "&iop=kontorkontrol";
    JXP(1, "kackontorkaldi", "../includes/islem.php", sc);

}


function Ucret_Preorder_bilgisi(adet,urunid,rewritevarmi) {
 var sc = "mesajid=" + urunid + "&urunadet=" + adet + "&link=" + rewritevarmi + "&iop=urunpreorder";
    if (rewritevarmi==0)
        JXP(1, "urunpreorder", "includes/islem.php", sc);
    else
        JXP(1, "urunpreorder", "../includes/islem.php", sc);
}

function Ucret_Preorder_bilgisi_sil(urunid, rewritevarmi) {
 var sc = "mesajid=" + urunid + "&link=" + rewritevarmi + "&iop=urunpreorder_sil";
    if (rewritevarmi==0)
        JXP(1, "urunpreorder", "includes/islem.php", sc);
    else
        JXP(1, "urunpreorder", "../includes/islem.php", sc);

}
function Ucret_Preorder_bilgisi_Yenile(rewritevarmi) {
 var sc = "link=" + rewritevarmi + "&iop=urunpencere_yenile";
    if (rewritevarmi==0)
        JXP(1, "urunpreorder", "includes/islem.php", sc);
    else
        JXP(1, "urunpreorder", "../includes/islem.php", sc);

}


function Uye_Kayit_Basla_Alt_Kategori_Sec(ustkategori,rewritevarmi) {
 var sc = "mesajid=" + ustkategori + "&iop=ukbacatsec";
 if (rewritevarmi==0)
        JXP(1, "uye_altcategory", "includes/islem.php", sc);
    else
        JXP(1, "uye_altcategory", "../includes/islem.php", sc);
}



function Pazaryeri_Urun_kategori_Secimi(urunkisaadi) {
 var sc = "mesajid=" + urunkisaadi + "&iop=pazaruruncatsec";
    JXP(1, "pazaryeri_altcat_secimi", "../includes/islem.php", sc);

}

