
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 isNumber(field) {
var re = /^[0-9]*$/;
  if (!re.test(field.value)) {
    alert('Bu bölgeye sadece sayı yazabilisiniz.');
    field.value = field.value.replace(/[^0-9]/g,"");
  }
}

function SektorAltKategoriGetir(anacat) {
var sc = "anacat=" + anacat + "&iop=altkategorilerigetir";
Select_JXP("altcat", "includes/islem.php", sc);
}


