// JavaScript Document
// JavaScript Documentvar xmlHttp
// 01.SubLocations

//---------------------------------------------------------------------------------------------------------

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 
	} 
} 
//-----------------------------------------------------------------------------------------
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 
	} 
} 
//-----------------------------------------------------------------------------------------

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)
	if(usertype!="SHOW_MONTH")
	{
		alert("Update Information");
	}
	

}

function UpdatePayStatusFunction() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("UpdatePaymentStautsDiv").innerHTML=xmlHttp.responseText 
	} 
} 

//--------------------------------------------------------------------------------------------//


function Update_Values(xurl,cat,str,usertype,catg)
{ 
	var str1;
	
	//alert(catg);
	
	//alert("hello");
	xmlHttp=GetXmlHttpObject()
	<!-- str1="1" -->
	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=="DENIED")
	{
	str1="deny";
	}
  
    if(str=="DENIED")
	{
	str1="deny";
	}  
    if(str=="SUSPENDED")
	{
	str1="suspended";
	}  
	
	 
	
	
  if(catg!="" || catg=="sus" || (ctag=="sus" && usertype=="USER_CATEGORY"))
   {
   
    if(usertype=="USER_CATEGORY")
	  {
	  
	  alert("ok");
	  str1="to change";
	  
	  }
	  
	  
   
   
    if(confirm("Do you really want to "+str1.toLowerCase()+"?") )
	{
	//alert("original");
	var url=xurl;
	url=url+"?id="+cat +"&value="+str+"&page_type="+usertype+"&catg="+catg;
	url=url+"&sid="+Math.random()
	//alert(url);
	xmlHttp.onreadystatechange=UpdateValuesFunction

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	alert("Update Information");
	}
	
	
	}
	else
	 {
	   
	  alert("please select category");
	  
	  
	  }
	
}

function UpdateValuesFunction() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("UpdateValuesDiv").innerHTML=xmlHttp.responseText 
	} 
} 

//--------------------------------------------------------------------------------------------//


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 
	} 
} 



//--------------------------------------------------------------------------------------------//
function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}

function update_approval_month(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=UpdateMonthFunction

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	alert("Update Information");
 
 
 }
 
 function UpdateMonthFunction() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("UpdateMonthDiv").innerHTML=xmlHttp.responseText 
	} 
} 


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 
	} 
} 



function EventPaymentStauts(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=EventPayStatusFunction

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	alert("Update Information");

}

function EventPayStatusFunction() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("UpdatePaymentStautsDiv").innerHTML=xmlHttp.responseText 
	} 
} 


//Excel functions

function Excel_showMailList(xurl,maillisttype)
{ 

  //alert("category");
	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=excel_mailListChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function excel_mailListChanged() 
{ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	
	document.getElementById("div_category").innerHTML=xmlHttp.responseText 
	} 
} 


function Excel_showMailList_2(xurl,maillisttype)
{ 

  //alert("state");
	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=excel_mailListChanged_2
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function excel_mailListChanged_2() 
{ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	
	document.getElementById("div_state").innerHTML=xmlHttp.responseText 
	} 
} 

//CPAG FUNCTION
function Excel_showMailList_3(xurl,maillisttype)
{ 

  //alert("cpag");
	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=excel_mailListChanged_3
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function excel_mailListChanged_3() 
{ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	
	document.getElementById("div_cpag").innerHTML=xmlHttp.responseText 
	} 
} 






//Consultants calling function


function UpdateConsultantStatus(xurl,cat,str,usertype)
{ 


  //alert("consultant");
	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=UpdateConsultantFunction

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(usertype!="SHOW_MONTH")
	{
		//alert("Update Information");
	}
	

}

function UpdateConsultantFunction() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("consultantdiv").innerHTML=xmlHttp.responseText 
	} 
} 
 
 
 //FILL SUB CATEGORY
 function UpdateSubCategory(xurl,cat,str,usertype)
{ 


   //alert("sub category");
	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=UpdateSubCategoryFunction

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(usertype!="SHOW_MONTH")
	{
		//alert("Update Information");
	}
	

}

function UpdateSubCategoryFunction() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("sub_category").innerHTML=xmlHttp.responseText 
	} 
} 
 
 
