// JavaScript Document
function checkdays()
{
	if(window.XMLHttpRequest)
	{
	   oRequestday = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{
	   oRequestday = new ActiveXObject("Microsoft.XMLHTTP");
	}
	resmonth=document.getElementById("getmonth").value;
	oRequestday.open("POST","days.php", true);
	oRequestday.onreadystatechange = showdays;
	oRequestday.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	oRequestday.send('resmonth='+resmonth);
}
  function showdays()
{
	if(oRequestday.readyState == 4)
	{	
		if(oRequestday.status == 200)
		{
			document.getElementById("RESULTDAY").innerHTML = oRequestday.responseText;
 		}
		else
		{
			document.getElementById("RESULTDAY").innerHTML = oRequestday.responseText;
 		}
	}
}
// GET TABLE DETAILS
function tabledetails(id)
{
	if(window.XMLHttpRequest)
	{
	   oRequesttabledetails = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{
	   oRequesttabledetails = new ActiveXObject("Microsoft.XMLHTTP");
	}
   // document.getElementById("TABLEDETAILS").innerHTML='<img src="images/load2.gif" />';
 	oRequesttabledetails.open("POST","table-details.php", true);
	oRequesttabledetails.onreadystatechange = showtabledetails;
	oRequesttabledetails.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	oRequesttabledetails.send('ID='+id);
}
  function showtabledetails()
{
	if(oRequesttabledetails.readyState == 4)
	{	
		if(oRequesttabledetails.status == 200)
		{
			document.getElementById("TABLEDETAILS").innerHTML = oRequesttabledetails.responseText;
 		}
		else
		{
			document.getElementById("TABLEDETAILS").innerHTML = oRequesttabledetails.responseText;
 		}
	}
} 
// GET TABLE MODELS 
function gettablehallmodels()
{  
  if(document.getElementById("gettablehalltype").value!='0')
  {  
    setupZoom();
	
 	if(window.XMLHttpRequest)
	{
	   oRequestmodels = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{
	   oRequestmodels = new ActiveXObject("Microsoft.XMLHTTP");
	}
    document.getElementById("ajaxload").innerHTML='<img src="images/ajax_load.gif" />';
	Halltype=document.getElementById("gettablehalltype").value;
	FID=7;
	oRequestmodels.open("POST","ajax-functions.php", true);
	oRequestmodels.onreadystatechange = showmodels;
	oRequestmodels.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	oRequestmodels.send('Halltype='+Halltype+'&FID='+FID);
}
}
  function showmodels()
{
	if(oRequestmodels.readyState == 4)
	{	
		if(oRequestmodels.status == 200)
		{
			document.getElementById("TABLEMODELS").innerHTML = oRequestmodels.responseText;
			document.getElementById("ajaxload").innerHTML='';
 		}
		else
		{
			document.getElementById("TABLEMODELS").innerHTML = oRequestmodels.responseText;
 		}
	}
}
// GET TABLE FROM HOURS 
function getfrom_hour()
{
	if(window.XMLHttpRequest)
	{
	   oRequestfromhour = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{
	   oRequestfromhour = new ActiveXObject("Microsoft.XMLHTTP");
	}
	Hotel_id=document.getElementById("Hotel_ID").value;
	Halltype=document.getElementById("gettablehalltype").value;
	FID=10;
	oRequestfromhour.open("POST","ajax-functions.php", true);
	oRequestfromhour.onreadystatechange = showfromhour;
	oRequestfromhour.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	oRequestfromhour.send('Hotel_id='+Hotel_id+'&Halltype='+Halltype+'&FID='+FID);
}
  function showfromhour()
{
	if(oRequestfromhour.readyState == 4)
	{	
		if(oRequestfromhour.status == 200)
		{
			document.getElementById("TABLEHOUR").innerHTML = oRequestfromhour.responseText;
 		}
		else
		{
			document.getElementById("TABLEHOUR").innerHTML = oRequestfromhour.responseText;
 		}
	}
}
// GET TABLE FROM MINUTES 
function getfrom_mint()
{
	if(window.XMLHttpRequest)
	{
	   oRequestminutes = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{
	   oRequestminutes = new ActiveXObject("Microsoft.XMLHTTP");
	}
	Hotel_id=document.getElementById("Hotel_ID").value;
	Diningid=document.getElementById("gettablehalltype").value;
	Fhour=document.getElementById("getfromhour").value;
	FID=9;
	oRequestminutes.open("POST","ajax-functions.php", true);
	oRequestminutes.onreadystatechange = showminutes;
	oRequestminutes.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	oRequestminutes.send('Hotel_id='+Hotel_id+'&Fhour='+Fhour+'&Diningid='+Diningid+'&FID='+FID);
}
  function showminutes()
{
	if(oRequestminutes.readyState == 4)
	{	
		if(oRequestminutes.status == 200)
		{
			document.getElementById("TABLEMINT").innerHTML = oRequestminutes.responseText;
 		}
		else
		{
			document.getElementById("TABLEMINT").innerHTML = oRequestminutes.responseText;
 		}
	}
}
//validation
function validation()
{
	if(document.getElementById("gettablehalltype").value==0)
{
document.getElementById("ERROR_MAG").innerHTML='<div style="padding-left:150px; width:375px" ><div align="left" style="width:24px; position:absolute; float:left; "><img src="images/inform.png" width="20" height="20" alt="icon" /></div><div align="left" style="padding-left:24px; padding-top:5px" >Please Select a Table Dining Area..!</div></div>';
document.getElementById("ERROR_MAG1").innerHTML='<div style="padding-left:150px; width:375px" ><div align="left" style="width:24px; position:absolute; float:left; "><img src="images/inform.png" width="20" height="20" alt="icon" /></div><div align="left" style="padding-left:24px; padding-top:5px" >Please Select a Table Dining Area..!</div></div>';

document.getElementById("gettablehalltype").focus();
return false;
}
	if(document.getElementById("getmonth").value==0)
{
document.getElementById("ERROR_MAG").innerHTML='<div style="padding-left:150px; width:375px" ><div align="left" style="width:24px; position:absolute; float:left; "><img src="images/inform.png" width="20" height="20" alt="icon" /></div><div align="left" style="padding-left:24px; padding-top:5px" >Please select the month ..!</div></div>';
document.getElementById("ERROR_MAG1").innerHTML='<div style="padding-left:150px; width:375px" ><div align="left" style="width:24px; position:absolute; float:left; "><img src="images/inform.png" width="20" height="20" alt="icon" /></div><div align="left" style="padding-left:24px; padding-top:5px" >Please select the month ..!</div></div>';

document.getElementById("getmonth").focus();
return false;
}
	if(document.getElementById("getday").value==0)
{
document.getElementById("ERROR_MAG").innerHTML='<div style="padding-left:150px; width:375px" ><div align="left" style="width:24px; position:absolute; float:left; "><img src="images/inform.png" width="20" height="20" alt="icon" /></div><div align="left" style="padding-left:24px; padding-top:5px" >Please Select a day..!</div></div>';
document.getElementById("ERROR_MAG1").innerHTML='<div style="padding-left:150px; width:375px" ><div align="left" style="width:24px; position:absolute; float:left; "><img src="images/inform.png" width="20" height="20" alt="icon" /></div><div align="left" style="padding-left:24px; padding-top:5px" >Please Select a day..!</div></div>';

document.getElementById("getday").focus();
return false;
}
if(document.getElementById("getfromhour").value=='HH')
{
document.getElementById("ERROR_MAG").innerHTML='<div style="padding-left:150px; width:375px" ><div align="left" style="width:24px; position:absolute; float:left; "><img src="images/inform.png" width="20" height="20" alt="icon" /></div><div align="left" style="padding-left:24px; padding-top:5px" >Please Select Check In Time Hour ..!</div></div>';
document.getElementById("ERROR_MAG1").innerHTML='<div style="padding-left:150px; width:375px" ><div align="left" style="width:24px; position:absolute; float:left; "><img src="images/inform.png" width="20" height="20" alt="icon" /></div><div align="left" style="padding-left:24px; padding-top:5px" >Please Select Check In Time Hour ..!</div></div>';

document.getElementById("getfromhour").focus();
return false;
}
if(document.getElementById("getfromminutes").value=='MM')
{
document.getElementById("ERROR_MAG").innerHTML='<div style="padding-left:150px; width:375px" ><div align="left" style="width:24px; position:absolute; float:left; "><img src="images/inform.png" width="20" height="20" alt="icon" /></div><div align="left" style="padding-left:24px; padding-top:5px" >Please Select Check In Time Minute ..!</div></div>';
document.getElementById("ERROR_MAG1").innerHTML='<div style="padding-left:150px; width:375px" ><div align="left" style="width:24px; position:absolute; float:left; "><img src="images/inform.png" width="20" height="20" alt="icon" /></div><div align="left" style="padding-left:24px; padding-top:5px" >Please Select Check In Time Minute ..!</div></div>';

document.getElementById("getfromminutes").focus();
return false;
}
if(document.getElementById("gettohour").value=='HH')
{
document.getElementById("ERROR_MAG").innerHTML='<div style="padding-left:150px; width:375px" ><div align="left" style="width:24px; position:absolute; float:left; "><img src="images/inform.png" width="20" height="20" alt="icon" /></div><div align="left" style="padding-left:24px; padding-top:5px" >Please Select Check Out Time Hour ..!</div></div>';
document.getElementById("ERROR_MAG1").innerHTML='<div style="padding-left:150px; width:375px" ><div align="left" style="width:24px; position:absolute; float:left; "><img src="images/inform.png" width="20" height="20" alt="icon" /></div><div align="left" style="padding-left:24px; padding-top:5px" >Please Select Check Out Time Hour ..!</div></div>';

document.getElementById("gettohour").focus();
return false;
}
if(document.getElementById("gettominutes").value=='MM')
{
document.getElementById("ERROR_MAG").innerHTML='<div style="padding-left:150px; width:375px" ><div align="left" style="width:24px; position:absolute; float:left; "><img src="images/inform.png" width="20" height="20" alt="icon" /></div><div align="left" style="padding-left:24px; padding-top:5px" >Please Select Check Out Time Minute ..!</div></div>';
document.getElementById("ERROR_MAG1").innerHTML='<div style="padding-left:150px; width:375px" ><div align="left" style="width:24px; position:absolute; float:left; "><img src="images/inform.png" width="20" height="20" alt="icon" /></div><div align="left" style="padding-left:24px; padding-top:5px" >Please Select Check Out Time Minute ..!</div></div>';

document.getElementById("gettominutes").focus();
return false;
}
if((document.getElementById("gettoampm").value==document.getElementById("getfromampm").value) && (document.getElementById("gettohour").value<=document.getElementById("getfromhour").value))
{
 document.getElementById("ERROR_MAG").innerHTML='<div style="padding-left:150px; width:375px" ><div align="left" style="width:24px; position:absolute; float:left; "><img src="images/inform.png" width="20" height="20" alt="icon" /></div><div align="left" style="padding-left:24px; padding-top:5px" >Invalid Check Out Time  ..!</div></div>';
  document.getElementById("ERROR_MAG1").innerHTML='<div style="padding-left:150px; width:375px" ><div align="left" style="width:24px; position:absolute; float:left; "><img src="images/inform.png" width="20" height="20" alt="icon" /></div><div align="left" style="padding-left:24px; padding-top:5px" >Invalid Check Out Time  ..!</div></div>';

document.getElementById("gettohour").focus();
return false;
}
return true;
}
