﻿// JavaScript Document
	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 stateChanged() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		if (xmlHttp.responseText=='1')	
		{	
		
			document.getElementById("user").style.border="2px solid red";
		}
		else{
			document.getElementById("user").style.border="2px solid blue";
		}

	  } 
	}
	function Changed() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
	div_id="show_posts"+s_year;
	reset_posts_show();
	 document.getElementById(div_id).style.visibility='visible';
		 document.getElementById(div_id).innerHTML=xmlHttp.responseText;
	  } else{
		   document.getElementById(div_id).innerHTML="<div align='center'><img src='../template/classic/images/header_image/loading.gif'   width='64' height='70' />";
		  }
	}
	function ChangedStateExam() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		 $('error').innerHTML=xmlHttp.responseText;
	  } else{
		   $('error').innerHTML="<div align='center'><img src='../template/classic/images/header_image/loading.gif'   width='64' height='70' />";
		  }
	}
	function clicked(id){ 
	  xmlHttp=GetXmlHttpObject();
	  if (xmlHttp==null)
	  {
		alert ("Browser does not support HTTP Request");
		return;
	  }
	
	  url='click.php?clicked='+id;
	  //alert(url);
	  xmlHttp.onreadystatechange=stateChanged;
	  xmlHttp.open("GET",url,true);
	  xmlHttp.send(null);

	}
	function ajax(year,month){ 
	 s_year = year;
	  xmlHttp=GetXmlHttpObject();
	
	  if (xmlHttp==null)
	  {
		alert ("Browser does not support HTTP Request");
		return;
	  }
	  url='arch_show_post.php?year='+year+'&month='+month;
	  xmlHttp.onreadystatechange=Changed;
	  xmlHttp.open("GET",url,true);
	  xmlHttp.send(null);

	}
	function aj_send_fail(a_crs,a_lesson,a_name,a_mail){
	if(a_mail=="" || a_crs=="" || a_lesson==""){
		$('error').innerHTML="لطفا فیلدهای ستارا دار را پر کنید";
	}else{
	  xmlHttp=GetXmlHttpObject();
	  if (xmlHttp==null)
	  {
		alert ("Browser does not support HTTP Request");
		return;
	  }
	   url='exam.php';
	 params='fail=1&crs='+a_crs+'&lesson='+a_lesson+'&name='+a_name+'&mail='+a_mail;
	   xmlHttp.onreadystatechange=ChangedStateExam;

	  xmlHttp.open("POST", url, true);
	  //Send the proper header information along with the request
	  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	  xmlHttp.setRequestHeader("Content-length", params.length);
      xmlHttp.setRequestHeader("Connection", "close");
	  
	 xmlHttp.send(params);
	}

}
	function reset_posts_show(){
	for(i=1387;i<1390;i++){
	id="show_posts"+i;
	$(id).innerHTML="";
	$(id).style.visibility='hidden';
	}}
	/****************************************************************/
	function send_fail(a_crs,a_lesson,a_name,a_mail){
	if(a_mail=="" || a_crs=="" || a_lesson==""){
		$('error').innerHTML="لطفا فیلدهای ستارا دار را پر کنید";
	}else{
	  xmlHttp=GetXmlHttpObject();
	
	  if (xmlHttp==null)
	  {
		alert ("Browser does not support HTTP Request");
		return;
	  }
	  url='exam.php?fail&crs='+a_crs+'&lesson='+a_lesson+'&name='+a_name+'&mail='+a_mail;
	  xmlHttp.onreadystatechange=ChangedStateExam;
	  xmlHttp.open("GET",url,true);
	  xmlHttp.send(null);
		}

	}
	/*	function validation(f_value){ 
	  xmlHttp=GetXmlHttpObject();
	
	  if (xmlHttp==null)
	  {
		alert ("Browser does not support HTTP Request");
		return;
	  }
	  url='aa.php?vld=empty&f_value='+f_value;
	  xmlHttp.onreadystatechange=ChangedStateExam;
	  xmlHttp.open("GET",url,true);
	  xmlHttp.send(null);

	}*/
