function mail_kontrol(datastr)
{
	if (datastr!='')
	{    var validchars = "0123456789abcdefghijklmnopqrstuvwxyz_-@.";
		var Sonuc = true;
	var Bolum = 1;
	for (var i=0; i < datastr.length; i++) {
			var letter = datastr.charAt(i).toLowerCase();
		if (letter == "@" && Bolum == 2){ Sonuc = false };
		if (letter == "." && Bolum == 2){ Bolum = 3};
		if (letter == "@" && Bolum == 1){ Bolum = 2};
			if (validchars.indexOf(letter) == -1) { Sonuc = false };
		}
	if (Bolum < 3) { Sonuc = false };
		return Sonuc;
	}
}
function trim(stringToTrim)
{
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function formKontrolgb(){
	if(trim(document.x.ads.value)==""){
        document.x.ads.focus();
        return false;
    }
	if(trim(document.x.msg.value)==""){
        document.x.msg.focus();
        return false;
    }		
	if(mail_kontrol(document.x.mail.value)==false) { 
		alert('e-mail adresi geçersiz!');
		document.x.mail.focus(); 
		return false;
	}
	if(trim(document.x.code.value)==""){
    document.x.code.focus();
    return false;
   }	
	document.x.Submit.disabled=true;
	return true;
}

function formKontrol(){
	if(trim(document.x.ads.value)==""){
        document.x.ads.focus();
        return false;
    }
	if(trim(document.x.konu.value)==""){
        document.x.konu.focus();
        return false;
    }
	if (document.x.cep.value.length<10 || isNumeric(document.x.cep.value)==false){
        document.x.cep.focus();
        return false;
    }	

	if(trim(document.x.mesaj.value)==""){
        document.x.mesaj.focus();
        return false;
    }	
	if(mail_kontrol(document.x.mail.value)==false) { 
		alert('e-mail adresi geçersiz..');
		document.x.mail.focus(); 
		return false;
	}
	if(trim(document.x.code.value)==""){
        document.x.code.focus();
        return false;
    }	
	document.x.Submit.disabled=true;
	return true;
}

function formKontrolgb(){
	if(trim(document.x.ads.value)==""){
        document.x.ads.focus();
        return false;
    }
	if(trim(document.x.mesaj.value)==""){
        document.x.mesaj.focus();
        return false;
    }	
	if(mail_kontrol(document.x.mail.value)==false) { 
		alert('e-mail adresi geçersiz..');
		document.x.mail.focus(); 
		return false;
	}
	if(trim(document.x.code.value)==""){
        document.x.code.focus();
        return false;
    }	
	document.x.Submit.disabled=true;
	return true;
}

function formKontrolynt(){
	if(trim(document.x.user_name.value)==""){
        document.x.user_name.focus();
        return false;
    }
	if(trim(document.x.pass_pass.value)==""){
        document.x.pass_pass.focus();
        return false;
    }		
	return true;
}

function formKontrolAnket(){

	sayi=0;
	for (i=0; i<document.x.elements.length; i++) if (document.x.elements[i].type == 'radio'){ if (document.x.elements[i].checked==true) sayi++; }
	if (sayi<14) {
		alert("Lütfen soruların tümüne cevap veriniz..");
		return false;
	}
	if(trim(document.x.okul.value)==""){
        document.x.okul.focus();
        return false;
    }	
	if(trim(document.x.sinif.value)==""){
        document.x.sinif.focus();
        return false;
    }	
	if(trim(document.x.cinsiyet.value)==""){
        document.x.cinsiyet.focus();
        return false;
    }	

if(trim(document.x.code.value)==""){
        document.x.code.focus();
        return false;
    }	
	document.x.Submit.disabled=true;
	return true;
}

function sonucAjax()
	{
		$('#imageCevap').html('<div class="yuk2"></div>');
		$.ajax({
			type: 'POST',
			url: 'inc/form_isle.php',
			data: $('form#x').serialize(),
			success: function(imageCevap) {
				$('#imageCevap').html(imageCevap);
			}
		});
		document.x.Submit.disabled=false;
		return false;
}

function sonucAjaxContent(deger)
	{
		 //$('#content').html('<div class="yuk">Loading...</div>');
		 $.ajax({
		   type: 'GET',
		   url: deger,
		   data: ' ',	   
		   success: function(content) {
			 	$('#content').html(content);
		   }
		 });
		return false;
	}

function isNumeric(str)
{
  for (var i=0; i < str.length; i++)
		{
    var ch = str.substring(i, i+1)
    if( ch < "0" || ch>"9" || str.length == null)
				{
      return false
    }
  }
  return true
}	

function rakam() {
   var key = window.event.keyCode;
   if ( key > 47 && key < 58 )
      return;
   else  window.event.returnValue = null;
}
