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(yukleniyor == 1 && yer != 'no_id' ) {
		if( xmlHttp.readyState == 1 || xmlHttp.readyState == 2 || xmlHttp.readyState == 3 ) {
			var loading = '<img src="../images/loading.gif" width="16" height="16" alt="Yukleniyor ..." />'
			document.getElementById(yer).innerHTML = loading;
		}
	}
	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 Urun_satin_al(urunadi,urunturu,gfiyati,uadedi,udosyaturu) {
    var sc = "urunadi=" + urunadi;
    sc += "&urunturu=" + urunturu;
    sc += "&fiyati=" + gfiyati;
    sc += "&adet=" + uadedi;
    sc += "&dosyaturu=" + udosyaturu;
    sc += "&iop=urunal";
    JXP(1, "satisyeri", "../bolum/satis/islem.php", sc);
}
function Urun_Adet_Yenile(uid,adet) {
    var sc = "uid=" + uid;
    sc += "&yeniadet=" + adet;
    sc += "&iop=adetyenile";
    JXP(1, "satistoplam", "../bolum/satis/islem.php", sc);
}
function Urun_Satis_Sil(uid) {
    var sc = "uid=" + uid;
    sc += "&iop=urunsil";
    JXP(1, "satisyeri", "../bolum/satis/islem.php", sc);
}
