// Coded By wIxI


function emailkontrol(reg, deger)
{
	veri = new RegExp(reg, "g"); 
	return veri.test(deger); 
}

function tema(veri)
{
	if(veri=="")
	{
		alert("Error..");
		return;
	}
	
	
}

function mesajkontrol()
{
	var kim = document.getElementById("kim");
	var kime = document.getElementById("kime");
	var mesaj = document.getElementById("mesaj");
	var oID = document.getElementById("oID").value;
	var links = document.getElementById("links").value;
	
	var regkontrol   = "^"+"([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0-9_\.\-]+)"+"@"+"([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0-9_\.\-]+)"+"[\.]"+"([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0-9_\.\-]+)"+"$";


	
	if(oID=="")
	{
		alert("Güvenlik Duvari");	
	}
	
	if(kim.value=="")
	{
		kim.style.backgroundColor="#FFC";
		kim.style.borderColor="#FF0000";
		kim.style.filter="alpha(opacity=50)";
		kim.style.opacity=".5";
	}
	else
	{
		kim.style.background="none";
		kim.style.borderColor="#0C0";
		kim.style.filter="alpha(opacity=100)";
	}
	if(kime.value=="")
	{
		kime.style.backgroundColor="#FFC";
		kime.style.borderColor="#FF0000";
		kime.style.filter="alpha(opacity=50)";
		kime.style.opacity=".5";
	}
	else
	{
		kime.style.background="none";
		kime.style.borderColor="#0C0";
	}
	if(mesaj.innerHTML=="")
	{
		mesaj.style.backgroundColor="#FFC";
		mesaj.style.borderColor="#FF0000";
		mesaj.style.filter="alpha(opacity=50)";
		mesaj.style.opacity=".5";
	}
	else
	{
		mesaj.style.background="none";
		mesaj.style.borderColor="#0C0";
	}
	
		if(! emailkontrol(regkontrol, kim.value) || ! emailkontrol(regkontrol, kime.value))
	{
		alert("E-mail Error!")
		return;
	}
	
	if(kim.value!="" || kime.value!="" || mesaj.value!="")
	{
		return XMLHttp("inc/mail.php","paygonder", yukcis, "ekle=evet&oID="+oID+"&links="+links+"&kim="+kim.value+"&kime="+kime.value+"&mesaj="+mesaj.value);
	}
}

var yukcis = "<div style=\"text-align:center; color:#CCC; font-size:12px; font-weight:700;\"><img src=\"img/ajaxyukle.gif\" /><br />Loading..</div>";

function XMLHttp(sayfa, ID, ibare, val){

	if(! window.XMLHttpRequest===false){	
		var xml = new XMLHttpRequest();	
	}else{
		xml = new ActiveXObject("Microsoft.XMLHttp");
	}
	 
	 xml.open("GET",sayfa+"?"+val+"&rand="+Math.random(),true);
	 
	  xml.onreadystatechange = function(){
		document.getElementById(ID).innerHTML = ibare;
		
		if(xml.readyState == 4){
			document.getElementById(ID).innerHTML = xml.responseText;
		}
	 }

	 xml.send(null);	 
}