var http_request = false;
function makeRequest(url, parameters) {
	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Cannot create XMLHTTP instance');
	return false;
	}
	http_request.onreadystatechange = alertContents;
	http_request.open('GET', url + parameters, true);
	http_request.send(null);
}

function alertContents() {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			//alert(http_request.responseText);
			result = http_request.responseText;
			document.getElementById('myspan').innerHTML = result; 
		} else {
			alert('There was a problem with the request.');
		}
	}
}

function get(obj) {
	var getstr = "?";
	for (i=0; i<obj.childNodes.length; i++) {
		if (obj.childNodes[i].tagName == "INPUT") {
			if (obj.childNodes[i].type == "text") {
				getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
			}
			if (obj.childNodes[i].type == "checkbox") {
				if (obj.childNodes[i].checked) {
					getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
				} else {
					getstr += obj.childNodes[i].name + "=&";
				}
			}
			if (obj.childNodes[i].type == "radio") {
				if (obj.childNodes[i].checked) {
					getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
				}
			}
		} 
		if (obj.childNodes[i].tagName == "SELECT") {
			var sel = obj.childNodes[i];
			getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
		}
	}
	makeRequest('arama2.php', getstr);
}


var xmlHttp
// str -> cagrilan combobox
// str2 -> gonderilen value degeri
function boxgetir(str,str2,str3,str4){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	}
	//alert (str); 
	//alert (str2);
	//alert (str3);	
	//alert(str4);
	var url="arama2.php"
	url=url+"?box="+str
	url=url+"&deger="+str2
	url=url+"&prog="+str3
	url=url+"&nkurs="+str4	
	url=url+"&sid="+Math.random()

	if (str==10){
		xmlHttp.onreadystatechange=stateChangep
	}
	if (str==20){
		xmlHttp.onreadystatechange=stateChangek
	}	
	if (str==30){
		xmlHttp.onreadystatechange=stateChangeu
	}
	if (str==40){
		xmlHttp.onreadystatechange=stateChanges
	}
	if (str==50){
		xmlHttp.onreadystatechange=stateChangeo
	}
	if (str==60){
		xmlHttp.onreadystatechange=stateChangec
	}

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChangep(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("ptxtHint").innerHTML=xmlHttp.responseText 
	} 
}
function stateChangek(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("ktxtHint").innerHTML=xmlHttp.responseText 
	} 
}
function stateChangeu(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("utxtHint").innerHTML=xmlHttp.responseText 
	} 
}

function stateChanges(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("stxtHint").innerHTML=xmlHttp.responseText 
	} 
}

function stateChangeo(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("otxtHint").innerHTML=xmlHttp.responseText 
	} 
}
function stateChangedc(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("ctxtHint").innerHTML=xmlHttp.responseText 
	} 
}
function GetXmlHttpObject(){
	var xmlHttp=null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e){
		//Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e){

			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function showMail(str,strm){ 
	//alert(strm);
	//alert(str);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	}
	var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(strm)) {
		alert('Lütfen Geçerli Bir Email Adresi Giriniz');
		return false;
	} else {
		var url="maillist2.php"
		url=url+"?mail="+strm
		url=url+"&durum="+str
		url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=stateChangedm 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
}
function stateChangedm(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("mailbox").innerHTML=xmlHttp.responseText 
	} 
}
function showhide(idx){
	//alert(idx);
	if (document.getElementById){
		obj = document.getElementById(idx);
		if (obj.style.display == "none"){
			obj.style.display = "";
		}
		else if (obj.style.display == ""){
			obj.style.display = "none";
		}
	}
}

function checkEmail() {
	var email = document.getElementById('emailcheck');
	var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email.value)) {
		alert('Lütfen Geçerli Bir Email Adresi Giriniz');
		email.focus
		return false;
	}
}
