// JavaScript Document
function gonder(param, alan){
	if(alan==null){ alan='alan'; }
	http.open('get', param);
	http.onreadystatechange = function(){ cevapgeldi(alan); }
	http.send(null);
}

function nesneyarat() {
	  var nesne;
	  var tarayici = navigator.appName;
	  if(tarayici == "Microsoft Internet Explorer"){
			nesne = new ActiveXObject("Microsoft.XMLHTTP");
	  }else{
			nesne = new XMLHttpRequest();
	  }
	  return nesne;
}
       
function cevapgeldi(alan) {
	if(http.readyState == 4){
		document.getElementById(alan).innerHTML = '<form>'+http.responseText+'</form>';
	}
}

function mailgonder(adsoyad, eposta, mesaj, tarih){
	  http.open('get', 'mailyolla.php?adsoyad=' + adsoyad + '&eposta=' + eposta + '&mesaj=' + mesaj+ '&tarih=' + tarih);
	  http.onreadystatechange = function(){ cevapgeldi('iletisimform'); }
	  http.send(null);
}

function mesajgonder(){
	  http.open('get', 'mesajyolla.php?adsoyad=' + document.getElementById('adsoyad').value + '&sinif=' + document.getElementById('sinif').value + '&mesaj=' + document.getElementById('mesaj').value+ '&tarih=' + document.getElementById('tarih').value);
	  http.onreadystatechange = function(){ cevapgeldi('defterform'); }
	  http.send(null);
}

function formkontrol(){
  if (document.getElementById('adsoyad').value!=''){
    var str=document.getElementById('eposta').value;
    if ((str.indexOf('.') > 2) && (str.indexOf('@') > 0)){
	  if (document.getElementById('mesaj').value!=''){
	    mailgonder(document.getElementById('adsoyad').value, document.getElementById('eposta').value, document.getElementById('mesaj').value, document.getElementById('tarih').value);
	  } else {
	    alert('Mesajınızı yazın');
	  }
	} else {
	  alert('E-Posta adresini kontrol edin.');
	}
  } else {
    alert('Ad ve soyadınızı yazmalısınız.');
  }
}