//----function for using ajax-----------
var xmlHttp

function showCalendarbymonyear(acis04_StaffID, mon, year)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 } 


var url="ajax/getCalendar.php"
url=url+"?acis04_StaffID="+acis04_StaffID
url=url+"&mon="+mon
url=url+"&year="+year


xmlHttp.onreadystatechange=stateChanged7
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function showMonth(acis04_StaffID, startDate, endDate)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 } 

var url="ajax/getDetail.php"
url=url+"?acis04_StaffID="+acis04_StaffID
url=url+"&startDate="+startDate
url=url+"&endDate="+endDate
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged5
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function showCalendar(acis04_StaffID)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 } 


var url="ajax/getCalendar.php?acis04_StaffID="+acis04_StaffID


xmlHttp.onreadystatechange=stateChanged7
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}


function showTask(acis04_StaffID)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 } 


var url="ajax/la.php?acis04_StaffID="+acis04_StaffID


xmlHttp.onreadystatechange=stateChanged6
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function showDetail(acis04_StaffID)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 } 


var url="ajax/getDetail.php?acis04_StaffID="+acis04_StaffID


xmlHttp.onreadystatechange=stateChanged5
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}


function showStaff(assignee)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return;
 } 
var url="ajax/acis04_StaffName.php?assignee="+assignee


xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function showStaffName(machine,empID)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 } 
var url="ajax/syllabus.php"
url=url+"?machine="+machine
url=url+"&empID="+empID
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged2 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function showSection(depart)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 } 
var url="ajax/section.php"
url=url+"?depart="+depart
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}


function showMachine(section)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 } 
var url="ajax/machine.php"
url=url+"?section="+section
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged1 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function showSyllabus(machine,empID)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 } 
var url="ajax/syllabus.php"
url=url+"?machine="+machine
url=url+"&empID="+empID
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged2 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function showMaterial(sylla)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 } 
	var url="ajax/material.php"
	url=url+"?sylla="+sylla
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged3 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function showMaterialDetail(TMaterialID, syllabusID, empNo)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 } 
	var url="ajax/materialDetail.php"
	url=url+"?TMaterialID="+TMaterialID
	url=url+"&syllabusID="+syllabusID
	url=url+"&empNo="+empNo
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged4 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChanged() 
{ 

 if (xmlHttp.readyState==1 || xmlHttp.readyState==2)
 {
//	$("loadname1").style.display="block";
 }

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	 document.getElementById("showsec").innerHTML=xmlHttp.responseText 
	// $("loadname1").style.display="none";
 } 

}



function stateChanged1() 
{ 

 if (xmlHttp.readyState==1 || xmlHttp.readyState==2)
 {
	$("loadname2").style.display="block";
 }

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	 $("showmac").innerHTML=xmlHttp.responseText 
	// $("showMat").innerHTML="double click on selected syllabus to view training materials.";
	 $("loadname2").style.display="none";
	 
 } 

}



function stateChanged2() 
{ 
	
 if (xmlHttp.readyState==1 || xmlHttp.readyState==2)
 {
	$("loadname3").style.display="block";
 }

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	 $("showSylla").innerHTML=xmlHttp.responseText
	 $("loadname3").style.display="none";
	 


	 
 } 

}

function stateChanged3() 
{ 
	
 if (xmlHttp.readyState==1 || xmlHttp.readyState==2)
 {
	$("loadname4").style.display="block";
 }

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	 $("showMat").innerHTML=xmlHttp.responseText
	 $("loadname4").style.display="none";
	
	 if($("checkSylla").value!=1)
	 {
	 $("addBtn").style.display="none";
	 $("upBtn").style.display="inline";
	 }
	 else
	 {
		 $("addBtn").style.display="inline";
		$("upBtn").style.display="none";
	 }
	 
	 document.form1.rExpertise[0].checked=false;
		document.form1.rExpertise[1].checked=false;
		document.form1.rExpertise[2].checked=false;
		document.form1.rExpertise[3].checked=false;
		
		$("sttdate").value="";
		$("enddate").value="";
		$("model").value="";
 } 

}

function stateChanged4() 
{ 
	
 if (xmlHttp.readyState==1 || xmlHttp.readyState==2)
 {
	//$("loadname4").style.display="block";
 }

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	splitval1=xmlHttp.responseText;
	splitval=splitval1.split("%");
	
	if(splitval[0]!=0)
	{
		//
		$("sttdate").value=splitval[0];
		$("enddate").value=splitval[1];
		$("model").value=splitval[2];
		
		if(splitval[3]==4){
			document.form1.rExpertise[0].checked=true;
		}
		else if(splitval[3]==3){
			document.form1.rExpertise[1].checked=true;
		}
		else if(splitval[3]==2){
			document.form1.rExpertise[2].checked=true;
		}
		else if(splitval[3]==1){
			document.form1.rExpertise[3].checked=true;
		}
		else
		{
			document.form1.rExpertise[0].checked=false;
			document.form1.rExpertise[1].checked=false;
			document.form1.rExpertise[2].checked=false;
			document.form1.rExpertise[3].checked=false;
		}
		 $("addBtn").style.display="none";
		 $("upBtn").style.display="inline";
		
	}
	else
	{
		document.form1.rExpertise[0].checked=false;
		document.form1.rExpertise[1].checked=false;
		document.form1.rExpertise[2].checked=false;
		document.form1.rExpertise[3].checked=false;
		
		$("sttdate").value="";
		$("enddate").value="";
		$("model").value="";
		
		 $("addBtn").style.display="inline";
		$("upBtn").style.display="none";
			
	}
	
	 //$("loadname4").style.display="none";
 } 

}

function stateChanged5()
{
	if (xmlHttp.readyState==4||xmlHttp.readyState=="complete")
	{
	  document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
	}
}

function stateChanged6()
{
	if (xmlHttp.readyState==4||xmlHttp.readyState=="complete")
	{
	  document.getElementById("Hint").innerHTML=xmlHttp.responseText;
	}
}

function stateChanged7()
{
	if (xmlHttp.readyState==4||xmlHttp.readyState=="complete")
	{
	  document.getElementById("calendar").innerHTML=xmlHttp.responseText;
	}
}


//this function for validate the browser for AJAX support
function GetXmlHttpObject()
{
var xmlHttp;
try
 {
	 
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");

 }
 catch(e)
 {
  try
  {
	  //alert("b");
   xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } 
  catch(oc)
  {
	  
   xmlHttp = null;
  }
 }
 //Creating object of XMLHTTP in Mozilla and Safari 
 if(!xmlHttp) 
 {
  xmlHttp = new XMLHttpRequest();
 }

return xmlHttp;
}
