function pushSave(frm,pageSysExecute){
	document.getElementById(frm).style.backgroundImage    = "url(cms/Images/ajax-2.gif)";
	document.getElementById(frm).style.backgroundPosition = "right top";
	document.getElementById(frm).style.backgroundRepeat   = "no-repeat";
	//if(pageSysExecute!="none"){
	setTimeout("pushSave('" + frm + "','" + pageSysExecute + "')",600);
	//}
}

function pushSave(frm,sysExecute){
	pushDefault(frm);
	if(sysExecute!="none"){
		$("#accordion").accordion("option","active","false");
		$('#core').load(sysExecute);
	}
}

function pushError(frm,id){
	document.getElementById(frm).style.backgroundColor = "red";
	setTimeout("pushDefault('" + frm + "')",1000);
}

function pushDefault(frm){
	document.getElementById(frm).style.backgroundColor = "#ffffff";
	document.getElementById(frm).style.backgroundImage = "none";
	if(document.getElementById("INFO")){
		document.getElementById("INFO").innerHTML = "";
	}
}

function evalScript(scripts)
{	try
	{	if(scripts != '')	
		{	var script = "";
			scripts = scripts.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){
									 if (scripts !== null) script += arguments[1] + '\n';
										return '';});
			if(script) (window.execScript) ? window.execScript(script) : window.setTimeout(script, 0);
		}
		return false;
	}
	catch(e)
	{	alert(e)
	}
}

function closeaccordion(){
	$("#accordion").accordion("option","active","false");
}

function closeacc(accid){
	$("#" + accid).accordion("option","active","false");
}

function accadd(accid,pageSysName){
	$("#" + accid).accordion("option","active",0);
	get_aj(pageSysName,0,0);
}

function get_aj(node,id,accid)
{
	var url = rootpath + "/booking/get_" + node + ".asp?" + node + "id=" + id + "&accid=" + accid;
	try
	{  
		xmlHttp = new XMLHttpRequest();  
	}
	catch (e)
	{   
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{    
			try
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{      
				alert(alert_str);
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			var result = xmlHttp.responseText;
			if(id==0){
				document.getElementById("NEW0").innerHTML = result;
			}else{
				document.getElementById("FRM_" + id).innerHTML = result;
			}
			evalScript(result);
		}
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function accordionadd(pageSysName){
	$("#accordion").accordion("option","active",0);
	if(pageSysName=='roomType'){
		get_roomType(0);	
	}
	if(pageSysName=='price'){
		get_price(0);	
	}
	if(pageSysName=='paymentMethod'){
		get_paymentMethod(0);	
	}
}

function get_roomType(roomTypeID)
{
	var url = rootpath + "booking/get_roomType.asp?roomtypeid=" + roomTypeID;
	try
	{  
		xmlHttp = new XMLHttpRequest();  
	}
	catch (e)
	{   
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{    
			try
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{      
				alert(alert_str);
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			var result = xmlHttp.responseText;
			if(roomTypeID==0){
				document.getElementById("NEW0").innerHTML = result;
			}else{
				document.getElementById("FRM_ROOMTYPE" + roomTypeID).innerHTML = result;
			}
			evalScript(result);
		}
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function get_price(priceid)
{
	var url = rootpath + "booking/get_price.asp?priceid=" + priceid;
	try
	{  
		xmlHttp = new XMLHttpRequest();  
	}
	catch (e)
	{   
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{    
			try
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{      
				alert(alert_str);
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			var result = xmlHttp.responseText;
			if(priceid==0){
				document.getElementById("NEW0").innerHTML = result;
			}else{
				document.getElementById("FRM_PRICE" + priceid).innerHTML = result;
			}
			evalScript(result);
		}
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function get_paymentMethod(methodid)
{
	var url = rootpath + "booking/get_paymentMethod.asp?methodid=" + methodid;
	try
	{  
		xmlHttp = new XMLHttpRequest();  
	}
	catch (e)
	{   
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{    
			try
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{      
				alert(alert_str);
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			var result = xmlHttp.responseText;
			if(methodid==0){
				document.getElementById("NEW0").innerHTML = result;
			}else{
				document.getElementById("FRM_PAYMENTMETHOD" + methodid).innerHTML = result;
			}
			evalScript(result);
		}
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function get_booking(bookingid)
{
	var url = rootpath + "booking/get_booking.asp?bookingid=" + bookingid;
	try
	{  
		xmlHttp = new XMLHttpRequest();  
	}
	catch (e)
	{   
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{    
			try
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{      
				alert(alert_str);
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			var result = xmlHttp.responseText;
			if(bookingid==0){
				document.getElementById("NEW0").innerHTML = result;
			}else{
				document.getElementById("FRM_BOOKING" + bookingid).innerHTML = result;
			}
			evalScript(result);
		}
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function delete_booking(bookingid)
{
	var url = rootpath + "booking/delete_booking.asp?bookingid=" + bookingid;
	try
	{  
		xmlHttp = new XMLHttpRequest();  
	}
	catch (e)
	{   
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{    
			try
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{      
				alert(alert_str);
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			var result = xmlHttp.responseText;
			$('#core').load(result);
		}
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
