// 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 
	} 
} 

// 01 
function SHOW_CLIENTS_ORDER_DASHBOARD(orderStatus,PAGE_NO,var1,var2,var3)
{
	var str1;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	//index.php?menu=menu_admin&action=action_admin_dashboard&PAGE_NO=1&var1=website_members&var2=ACT&var3=
	var url="client_orders_dashboard.php";
	url=url+"?order_status="+orderStatus+"&PAGE_NO="+PAGE_NO+"&var1="+var1+"&var2="+var2+"&var3="+var3
	url=url+"&sid="+Math.random()
	//alert(url);
	xmlHttp.onreadystatechange=ShowDashboardFunctionOrders
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	//alert("Status updated successfully..");

	function ShowDashboardFunctionOrders() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			document.getElementById("DivclientOrdersDashboard").innerHTML=xmlHttp.responseText 
		} 
	} 

}

// 01 
function SHOW_PAYMENT_METHOD(paymentMethod,PAGE_NO,var1,var2,var3)
{
	var str1;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	//index.php?menu=menu_admin&action=action_admin_dashboard&PAGE_NO=1&var1=website_members&var2=ACT&var3=
	var url="user_payment_method_type.php";
	url=url+"?method="+paymentMethod+"&PAGE_NO="+PAGE_NO+"&var1="+var1+"&var2="+var2+"&var3="+var3
	url=url+"&sid="+Math.random()
	//alert(url);
	xmlHttp.onreadystatechange=FunctionShowPaymentMethod
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	//alert("Status updated successfully..");

	function FunctionShowPaymentMethod() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			document.getElementById("DivShowPaymentMethod").innerHTML=xmlHttp.responseText 
		} 
	} 

}




//Payment status response

function payment_status(url,type,order_id,user_id)
  {
	
	  //alert("url"+url);
		//alert("type"+type);
		//alert("order_id"+order_id);
		//alert("user"+user_id);
		var str1;
		var credit_block ;
		
		if(type==2)
		  {
			 //alert("inside");
			   credit_block = document.getElementById('tbl2');
				  credit_block.style.display="none";
					//document.getElementById('terms').style.display="none";
					document.getElementById('paymethod').style.display="none";
					document.getElementById('whole').style.display="none";
					document.getElementById('order_details').style.display="none";
					
					
			}
		if(type==3)
		  {
			   credit_block = document.getElementById('tbl3');
				 credit_block.style.display="none";
				 //document.getElementById('terms').style.display="none";
					document.getElementById('paymethod').style.display="none";
					document.getElementById('whole').style.display="none";
					document.getElementById('order_details').style.display="none";
			}	
						document.getElementById('grayFinish').style.display="none";
						document.getElementById('showFinish').style.display="inline";

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	url=url+"?type="+type+"&order_id="+order_id+"&user_id="+user_id;
	url=url+"&sid="+Math.random();
	
	//alert(url);
	//alert(url);
	xmlHttp.onreadystatechange=paystatusfunction
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
	}
	
	function paystatusfunction()
	  {
		
		    	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	           { 
						   //alert("completed");
	               document.getElementById("payment_ajax").innerHTML=xmlHttp.responseText 
	           } 
		
		}

// 01 
function SHOW_ORDERS(orderStatus,PAGE_NO,var1,var2,var3)
{
	var str1;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	//index.php?menu=menu_admin&action=action_admin_dashboard&PAGE_NO=1&var1=website_members&var2=ACT&var3=
	var url="orders_list.php";
	url=url+"?order_status="+orderStatus+"&PAGE_NO="+PAGE_NO+"&var1="+var1+"&var2="+var2+"&var3="+var3
	url=url+"&sid="+Math.random()
	//alert(url);
	xmlHttp.onreadystatechange=ShowAdminOrdersFunction 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	//alert("Status updated successfully..");

	function ShowAdminOrdersFunction() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			document.getElementById("DivAdminOrdersList").innerHTML=xmlHttp.responseText 
		} 
	} 

}


// 01 
function SHOW_ORDER_DETAILS(orderStatus,PAGE_NO,var1,var2,var3)
{
	var str1;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	//index.php?menu=menu_admin&action=action_admin_dashboard&PAGE_NO=1&var1=website_members&var2=ACT&var3=
	var url="order_view_details.php";
	url=url+"?id="+orderStatus+"&PAGE_NO="+PAGE_NO+"&var1="+var1+"&var2="+var2+"&var3="+var3
	url=url+"&sid="+Math.random()
	//alert(url);
	xmlHttp.onreadystatechange=ShowOrderDetailsFunction
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	//alert("Status updated successfully..");

	function ShowOrderDetailsFunction() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			document.getElementById("divShowOrderDetails").innerHTML=xmlHttp.responseText 
		} 
	} 

}
