// 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. Attendace_rows(xurl,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")
	{
	str1="pending";
	
	}
	if(str=="COMPLETED")
	{
	str1="Completed";
	
	}
    if(str=="INPROCESS")
	{
	str1="Inprocess";
	
	}
   
	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 Attendace_rows(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 value.");
		return false;
	}
	else
	{
	//alert(url);
	xmlHttp.onreadystatechange=showAttendance

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
}

function showAttendance() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("attendaceDiv").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 Product_Details(pid)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	xurl="product_details.php";
	var url=xurl;
	url=url+"?pid="+pid;
	url=url+"&sid="+Math.random()
	//alert(url);
	xmlHttp.onreadystatechange=showProductsDetails

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function showProductsDetails() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("showProductsDetailsDiv").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;
	//alert(xurl);
	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 
	} 
} 
