// JavaScript Document
// JavaScript Documentvar xmlHttp
// 
/*
		01. Menu_Link(xurl,str,xpage)
		02. showMailList(xurl,maillisttype)
		03. change_user_status1(xurl,cat,str,usertype)
		04. Update_Values(xurl,cat,str,usertype)		
		05. CheckUser(xurl,str)
		06. album_page(xurl,str,xpage)
		07.	photo_page(xurl,str,xalbum,pageno)	
		08. Big_Image_Window(aid,pid)
		09. select_rows(xurl,str,stype)
		10.	showNormal_1();
		11. show_newval(str);
*/

// 01
	function Menu_Link(xurl,str,xpage)
	{ 
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		} 
	
		var url=xurl;
		url=url+"?menu="+str;
		url=url+"&page="+xpage;
		url=url+"&sid="+Math.random()
		//alert(url);
		xmlHttp.onreadystatechange=PageDisplay
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
	
	function PageDisplay() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
		document.getElementById("div_display_page").innerHTML=xmlHttp.responseText 
		} 
	} 


// 02

	function showMailList(xurl,maillisttype)
	{ 
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		} 
	
		var url=xurl;
		url=url+"?mail_list_type="+maillisttype
		url=url+"&sid="+Math.random()
		//alert(url);
		xmlHttp.onreadystatechange=mailListChanged 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
	
	function mailListChanged () 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
		document.getElementById("div_maillistby").innerHTML=xmlHttp.responseText 
		} 
	}
	
// 03
function change_user_status1(xurl,cat,str,usertype)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url=xurl;
	url=url+"?userid="+cat +"&status="+str+"&user_type="+usertype
	url=url+"&sid="+Math.random()
	//alert(url);
	xmlHttp.onreadystatechange=change_user_statusChanged1

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function change_user_statusChanged1() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("changeduserStatus1").innerHTML=xmlHttp.responseText 
	} 
} 



// 04
function Update_Values(xurl,cat,str,usertype)
{ 
	var str1="";
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	if(str=="APPROVED")
	{
	str1="approve";
	}
	if(str=="ACTIVE")
	{
		str1="active";
	}
	if(str=="INACTIVE")
	{
		str1="inactive";
	}
	
	if(str=="DENIED")
	{
	str1="deny";
	}
	if(str=="BOOKED")
	{
	str1="Booked";
	}
	if(str=="PENDING" || str=="COMPLETED")
	{
	str1="change status";
	}
	if(usertype=="SITE_ID_STATUS")
	{
	str1="update site allotment status";
	}

	//alert(str);
	if(confirm("Do you really want to "+str1.toLowerCase()+"?"))
	{
	var url=xurl;
	url=url+"?id="+cat +"&value="+str+"&page_type="+usertype
	url=url+"&sid="+Math.random()
	//alert(url);
	xmlHttp.onreadystatechange=UpdateValuesFunction

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	alert("Information updated");
	}
}

function UpdateValuesFunction() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("UpdateValuesDiv").innerHTML=xmlHttp.responseText 
	} 
} 

// 05
 function CheckUser(xurl,str)
	{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url=xurl;
	url=url+"?value="+str
	url=url+"&sid="+Math.random()
	if(str=="")
	{
		alert("Invalid user name.");
		return false;
	}
	else
	{
	//alert(url);
	xmlHttp.onreadystatechange=CheckUserFunction

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
}

function CheckUserFunction() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("CheckUserDiv").innerHTML=xmlHttp.responseText 
	} 
} 



// 06
	function album_page(xurl,str,xpage)
	{ 
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		} 
	
		var url=xurl;
		url=url+"?menu="+str;
		url=url+"&PAGE_NO="+xpage;
		url=url+"&sid="+Math.random()
		//alert(url);
		xmlHttp.onreadystatechange=AlbumPageDisplay
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
	
	function AlbumPageDisplay() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
		document.getElementById("div_display_page").innerHTML=xmlHttp.responseText 
		} 
	} 

// 07
	function photo_page(xurl,str,xalbum,pageno)
	{ 
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		} 
		var url=xurl;
		url=url+"?menu="+str;
		url=url+"&album_id="+xalbum;
		url=url+"&PAGE_NO="+pageno;
		url=url+"&sid="+Math.random()
		//alert(url);
		xmlHttp.onreadystatechange=AlbumPageDisplay
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
	
	function AlbumPageDisplay() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
		document.getElementById("div_display_page").innerHTML=xmlHttp.responseText 
		} 
	} 
// 08
	function Big_Image_Window(aid,pid)
	{
		var new_win; 
		winname="big_impage.php?album_id="+aid+"&id="+pid;
 		new_win=window.open(winname,'BIGIMAGE',"width=900,height=900,toolbar=0,resizable=1,scrollbars=1");
	}


// 09
function select_rows(xurl,stype,str)
{ 
	//alert("sype"+stype);
	//alert("value"+str);
	//alert("selrowssssssss"+stype);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url=xurl;
	url=url+"?value="+str;
	url=url+"&stype="+stype;
	url=url+"&sid="+Math.random()
	if(str=="")
	{
		alert("Invalid value.");
		return false;
	}
	else
	{
	//alert(url);
	xmlHttp.onreadystatechange=showRows 

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
}

function showRows() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("rowsDiv").innerHTML=xmlHttp.responseText 
	
	} 
} 

 
 


// 10
function Show_Products(xurl)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url=xurl;
	url=url+"?sid="+Math.random()
	//alert(url);
	xmlHttp.onreadystatechange=showProducts

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function showProducts() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("showProductsDiv").innerHTML=xmlHttp.responseText 
	} 
} 


// 11
function showNormal_1(xurl,stype,str)
{ 
	//alert("normal"+stype);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url=xurl;
	url=url+"?value="+str;
	url=url+"&stype="+stype;
	url=url+"&sid="+Math.random()
	if(str=="")
	{
		alert("Invalid value.");
		return false;
	}
	else
	{
	//alert(url);
	xmlHttp.onreadystatechange=Funcdiet_normal_1 

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
}

function Funcdiet_normal_1() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("diet_normal_1").innerHTML=xmlHttp.responseText 
	
	} 
} 

// 12
function showNormal_2(xurl,stype,str)
{ 
	//alert(stype);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url=xurl;
	url=url+"?value="+str;
	url=url+"&stype="+stype;
	url=url+"&sid="+Math.random()
	if(str=="")
	{
		alert("Invalid value.");
		return false;
	}
	else
	{
	//alert(url);
	xmlHttp.onreadystatechange=Funcdiet_normal_2 

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
}

function Funcdiet_normal_2() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("diet_normal_2").innerHTML=xmlHttp.responseText 
	
	} 
} 
//---//
function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}
 

function UpdatePaymentStauts(xurl,cat,str,usertype)
{ 
	var str1;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url=xurl;
	url=url+"?id="+cat +"&value="+str+"&page_type="+usertype
	url=url+"&sid="+Math.random()
	//alert(url);
	xmlHttp.onreadystatechange=UpdatePayStatusFunction

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	alert("Update Information");

}

function UpdatePayStatusFunction() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("UpdatePaymentStautsDiv").innerHTML=xmlHttp.responseText 
	} 
} 


// 04
function Show_Values(xurl,cat,str,usertype)
{ 
	var str1;
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	

	var url=xurl;
	url=url+"?id="+cat +"&value="+str+"&page_type="+usertype
	url=url+"&sid="+Math.random()
	//alert(url);
	xmlHttp.onreadystatechange=ShowValuesFunction

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function ShowValuesFunction() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("ShowValuesDiv").innerHTML=xmlHttp.responseText 
	} 
} 

// 11
 function show_newval(spage,xval,str)
	{ 
	
	//alert("spage"+spage);
	//alert("xval"+xval);
	//alert("str"+str);
	document.getElementById("showNewVAl").innerHTML="<img src='images/loader.gif' border='0'>";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url;
	url="show_newval.php?value="+str
	url=url+"&xval="+xval
	url=url+"&stype="+spage
	url=url+"&sid="+Math.random()
	 
	//alert(url);
	xmlHttp.onreadystatechange=showNewValFunction

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	 
}

function showNewValFunction() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("showNewVAl").innerHTML=xmlHttp.responseText 
	} 
} 

// 
 function show_newval_2(spage,xval,str)
	{ 
	document.getElementById("showNewVAl_2").innerHTML="<img src='images/loader.gif' border='0'>";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url;
	url="show_newval.php?value="+str
	url=url+"&xval="+xval
	url=url+"&stype="+spage
	url=url+"&sid="+Math.random()
	 
	//alert(url);
	xmlHttp.onreadystatechange=showNewValFunction_2

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	 
}

function showNewValFunction_2() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("showNewVAl_2").innerHTML=xmlHttp.responseText 
	} 
} 

//Modem replace values
// 
 function show_modem_value(spage,xval,type)
	{ 
	 //alert(spage);
	 //alert(xval);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url;
	url=spage
	url=url+"?xval="+xval
	url=url+"&stype="+type
	url=url+"&sid="+Math.random()
	 
	//alert(url);
	xmlHttp.onreadystatechange=showModemFunction

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	 
}

function showModemFunction() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("modemdiv").innerHTML=xmlHttp.responseText 
	} 
} 


//SHOw normal for admin
// 11
function showNormal_1_admin(xurl,stype,str,qty,d_normal)
{ 
	
	//alert("d_normal"+d_normal);
	//alert("str"+str);
	//alert("dietry"+d_normal);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url=xurl;
	url=url+"?value="+str;
	url=url+"&stype="+stype+"&qty="+qty+"&d_normal="+d_normal;
	url=url+"&sid="+Math.random()
	//alert("admin1"+url);
	if(str=="")
	{
		alert("Invalid value.");
		return false;
	}
	else
	{
	//alert(url);
	xmlHttp.onreadystatechange=Funcdiet_normal_1_admin

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
}

function Funcdiet_normal_1_admin() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("diet_normal_1").innerHTML=xmlHttp.responseText 
	
	} 
} 

//Show normal2 for admin
function showNormal_2_admin(xurl,stype,str,qty,d_normal)
{ 
	 //alert("inseide2");
	 //alert("stype"+stype);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url=xurl;
	url=url+"?value="+str;
	url=url+"&stype="+stype+"&qty="+qty+"&d_normal="+d_normal;
	url=url+"&sid="+Math.random()
	
	//alert("admin22222" + url);
	if(str=="")
	{
		alert("Invalid value.");
		return false;
	}
	else
	{
	//alert(url);
	xmlHttp.onreadystatechange=Funcdiet_normal_2_admin

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
}

function Funcdiet_normal_2_admin() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("diet_normal_2").innerHTML=xmlHttp.responseText 
	
	} 
} 


// 12
function select_rows1(xurl,stype,str)
{ 
	//alert("selrows"+stype);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url=xurl;
	url=url+"?value="+str;
	url=url+"&stype="+stype;
	url=url+"&sid="+Math.random()
	if(str=="")
	{
		alert("Invalid value.");
		return false;
	}
	else
	{
	//alert(url);
	xmlHttp.onreadystatechange=showRows1 

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
}

function showRows1() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("rowsDiv1").innerHTML=xmlHttp.responseText 
	
	} 
} 




// 13
function booking_display(booking_id)
{ 
	//alert("booking_id"+booking_id);
	document.getElementById("loader").style.visibility="visible";
	document.getElementById("booking_html").innerHTML="";
	//alert("hi");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url="booking_update_new.php";
	url=url+"?id="+booking_id;
	url=url+"&sid="+Math.random()
	//alert("url"+url);
	if(booking_id=="")
	{
		alert("Invalid value.");
		return false;
	}
	else
	{
	//alert(url);
	xmlHttp.onreadystatechange=booking_display_function 

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
}

function booking_display_function () 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("booking_html").innerHTML=xmlHttp.responseText 
	document.getElementById("loader").style.visibility="hidden";
	} 
} 



//EDIT	VALUES	FUNCTIONS
// 
// 11
 function show_newval_edit(spage,xval,str)
	{ 
	//alert("s1111111");
	//alert("spage"+spage);
	//alert("xval"+xval);
  document.getElementById("showNewVAl").innerHTML="<img src='images/loader.gif' border='0'>";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url;
	url="show_newval_edit.php?value="+str
	url=url+"&xval="+xval
	url=url+"&stype="+spage
	url=url+"&sid="+Math.random()
	 
		//alert("show_newval_edit"+url);
	xmlHttp.onreadystatechange=showNewValFunction_edit

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	 
}

function showNewValFunction_edit() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("showNewVAl").innerHTML=xmlHttp.responseText 
	} 
} 


 function show_newval_2_edit(spage,xval,str)
	{ 
	//alert("s222222");
	document.getElementById("showNewVAl_2").innerHTML="<img src='images/loader.gif' border='0'>";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url;
	url="show_newval_edit.php?value="+str
	url=url+"&xval="+xval
	url=url+"&stype="+spage
	url=url+"&sid="+Math.random()
	 
	//alert("show_newval_edit_2"+url);
	xmlHttp.onreadystatechange=showNewValFunction_2_edit

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	 
}

function showNewValFunction_2_edit() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("showNewVAl_2").innerHTML=xmlHttp.responseText 
	} 
} 
