// JavaScript Document
// For Approve/Disapprove Property added from Frontend
function Approve(formname,file,chkname)
{
	document.getElementById('ID').value = chkname.value;
	document.getElementById('Process').value = 'Approve';
	document.getElementById('ApproveFlag').value = chkname.checked;
	document.getElementById(formname).action=file;
	document.getElementById(formname).submit();
}
/// For Add/Remove to Featured Property added from Frontend
function Featured(formname,file,chkname)
{
	document.getElementById('ID').value = chkname.value;
	document.getElementById('Process').value = 'Featured';
	document.getElementById('FeaturedFlag').value = chkname.checked;
	document.getElementById(formname).action=file;
	document.getElementById(formname).submit();
}
//For the Miles and zipcode validation.
function check_zipcode(formname)
{
	if(document.getElementById(formname.name).Miles.value!=0)
	{
		if(document.getElementById(formname.name).ZipCode.value=="")
		{		
			alert("Please Enter Value of Zipcode");
			return false;
		}
		else
			return true;
	}
	else
		return true;
}
// -----Chage The Status-------
function chagestatus(formname,file,id,val)
{
	document.getElementById(formname.name).Process.value="STATUS";
	document.getElementById(formname.name).ID.value=id;
	document.getElementById(formname.name).action  = file+".php?val="+val;
	document.getElementById(formname.name).submit();
}

//School
function chagestatusSchool(formname,file,id,val)
{
	document.getElementById(formname.name).Process.value="STATUSSCHOOL";
	document.getElementById(formname.name).ID.value=id;
	document.getElementById(formname.name).action  = file+".php?val="+val;
	document.getElementById(formname.name).submit();
}

//Teacher
function chagestatusTeacher(formname,file,id,val)
{
	document.getElementById(formname.name).Process.value="STATUSTEACHER";
	document.getElementById(formname.name).ID.value=id;
	document.getElementById(formname.name).action  = file+".php?val="+val;
	document.getElementById(formname.name).submit();
}
//finance
function chagestatusfinance(formname,file,id,val)
{
	document.getElementById(formname.name).Process.value="STATUSFINANCE";
	document.getElementById(formname.name).ID.value=id;
	document.getElementById(formname.name).action  = file+".php?val="+val;
	document.getElementById(formname.name).submit();
}
//CMSpage
function chagestatusCMSpage(formname,file,id,val)
{
	document.getElementById(formname.name).Process.value="STATUSCMSPAGE";
	document.getElementById(formname.name).ID.value=id;
	document.getElementById(formname.name).action  = file+".php?val="+val;
	document.getElementById(formname.name).submit();
}
//Password
function chagestatusPassword(formname,file,id,val)
{
	document.getElementById(formname.name).Process.value="STATUSPASSWORD";
	document.getElementById(formname.name).ID.value=id;
	document.getElementById(formname.name).action  = file+".php?val="+val;
	document.getElementById(formname.name).submit();
}
//adminuser
function chagestatusadminuser(formname,file,id,val)
{
	document.getElementById(formname.name).Process.value="STATUSADMINUSER";
	document.getElementById(formname.name).ID.value=id;
	document.getElementById(formname.name).action  = file+".php?val="+val;
	document.getElementById(formname.name).submit();
}

function chagestatusdb(formname,file,id,val)
{
	document.getElementById(formname.name).Process.value="STATUSPOPULER";
	document.getElementById(formname.name).ID.value=id;
	document.getElementById(formname.name).action  = file+".php?val="+val;
	document.getElementById(formname.name).submit();
}
function chagestatusall(formname,file,id,val)
{
	document.getElementById(formname.name).Process.value="CHANGE";
	document.getElementById(formname.name).ID.value=id;
	document.getElementById(formname.name).action  = file+".php?val="+val;
	document.getElementById(formname.name).submit();
}

// -----Chage Admin Type For Admin-------
function chagestatus_type(formname,file,id,statusvalue,val)
{
	document.getElementById(formname.name).Process.value=statusvalue;
	document.getElementById(formname.name).type_status.value=val;
	document.getElementById(formname.name).ID.value=id;
	document.getElementById(formname.name).action  = file+".php";
	document.getElementById(formname.name).submit();
}
//--- Go Back To File -----
function goback()
{
	history.go(-1);
}


//--- Sorting The Record in Webadmin-----
function sortdata(file,OrderBy,OrderType,Keyword,Type,FieldName,Page,PerPageLimit)
{
	window.location="index.php?p="+file+"&OrderBy="+OrderBy+"&OrderType="+OrderType+"&Keyword="+Keyword+"&FieldName="+FieldName+"&Type="+Type+"&Page="+Page+"&PerPageLimit="+PerPageLimit;
}
//--- Sorting The Record in Frontend-----
function sortdatafront(file,OrderBy,OrderType,Condition)
{
	window.location="index.php?p="+file+"&OrderBy="+OrderBy+"&OrderType="+OrderType+"&Condition="+Condition;
}
//--- Add Page For The Record -----
function add(file,PerPageLimit,Page)
{
		window.location="index.php?p="+file+"&var="+PerPageLimit+"&Page="+Page+"&MODE=ADD";
}
//--- Edit Page for The  Record -----
function edit(file,id)
{
	window.location="index.php?p="+file+"&ID="+id+"&MODE=UPDATE";
}
//-----Detail of the page-------
function detail(file,id)
{
	window.location="index.php?p="+file+"&ID="+id;
}
//-----Thumb of the page-------
function thumb(file,parentid)
{
	window.location="index.php?p="+file+"&ParentID="+parentid;
}
//-----Thumb for owner_listing  page-------
function thumbForFront(file,parentid)
{
	window.location=file+".php?ParentID="+parentid;
}

//--- Search For The Show All Record -----
function searchshowall(file,PerPageLimit,RefferenceID)
{
	window.location="index.php?p="+file+"&PerPageLimit="+PerPageLimit+"&ProductID="+RefferenceID;
}
//--- Search For The Record For Go Button-----
function searchgo(formname,file)
{
	document.getElementById(formname.name).action  = "index.php?p="+file;
	document.getElementById(formname.name).submit();
}
//---------------  Change Per Page limit ----------------
function changeperPage(PerPageLimit,formname,file)
{
		document.getElementById(formname.name).action  = "index.php?p="+file+"&PerPageLimit="+PerPageLimit;
		document.getElementById(formname.name).submit();
}
//------------------  Change Display Page -----------------------
function changeDisplayPage(PageNo,formname,file)
{	
	document.getElementById(formname.name).Page.value=PageNo;
	document.getElementById(formname.name).action  = "index.php?p="+file;
	document.getElementById(formname.name).submit();
}
// --------------- Confirm Delete alert Message ------------------
function confirmDel(formname,ID,Process,managefile)
{
	if(Process=="DELETE" || Process=="DELETE CHILD")
		{
			if(confirm("Do you really want to delete?"))
			{
				
				document.getElementById(formname.name).Process.value=Process;
				document.getElementById(formname.name).ID.value=ID;
				//alert(document.getElementById(formname.name).Process.value);
				document.getElementById(formname.name).action  = managefile+".php";
				document.getElementById(formname.name).submit();
				return true;
			}
			else
			{
				return false;
			}
		}
		else
		{
			var ellen=document.getElementById(formname.name).elements.length;
			var count=0;
			for(var i=1;i<ellen;i++)
			{
				if(document.getElementById(formname.name).elements[i].name=="del[]")
				{
					 if(document.getElementById(formname.name).elements[i].checked==true)
						count=count+1;
				}
			}
				if(count==0)
				{
					alert("Please Select Record To Delete");
					return false;
				}
				else
				{
					if(confirm("Do you really want to delete?"))
					{
						
					document.getElementById(formname.name).Process.value=Process;
					document.getElementById(formname.name).ID.value=ID;
					document.getElementById(formname.name).action  = managefile+".php";
					document.getElementById(formname.name).submit();
						return true;
					}
					else
						return false;
				}
	}
}
function confirmDelCancle(formname,ID,Process,managefile)
{
	if(Process=="Cancle")
		{
			if(confirm("Are you sure?"))
			{
				
				document.getElementById(formname).Process.value=Process;
				document.getElementById(formname).ID.value=ID;
				//alert(document.getElementById(formname).Process.value);
				document.getElementById(formname).action  = managefile+".php";
				document.getElementById(formname).submit();
				return true;
			}
			else
			{
				return false;
			}
		}
		else
		{
			var ellen=document.getElementById(formname).elements.length;
			var count=0;
			for(var i=1;i<ellen;i++)
			{
				if(document.getElementById(formname).elements[i].name=="del[]")
				{
					 if(document.getElementById(formname).elements[i].checked==true)
						count=count+1;
				}
			}
				if(count==0)
				{
					alert("Please Select Record To Delete");
					return false;
				}
				else
				{
					if(confirm("Do you really want to delete?"))
					{
						
					document.getElementById(formname).Process.value=Process;
					document.getElementById(formname).ID.value=ID;
					document.getElementById(formname).action  = managefile+".php";
					document.getElementById(formname).submit();
						return true;
					}
					else
						return false;
				}
	}
}
function confirmDelSimple(formname,Process,managefile)
{
	var ellen=document.getElementById(formname).elements.length;
	var count=0;
	for(var i=0;i<ellen;i++)
	{
		if(document.getElementById(formname).elements[i].name=="del[]")
		{	
			 if(document.getElementById(formname).elements[i].checked==true)
			 {
				count=count+1;
			 }
		}
	}
		if(count==0)
		{
			alert("Please Select Record To Delete");
			return false;
		}
		else
		{
			if(confirm("Do you really want to delete?"))
			{
				
			document.getElementById(formname).Process.value=Process;
			document.getElementById(formname).action  = managefile+".php";
			document.getElementById(formname).submit();
				return true;
			}
			else
				return false;
		}
}

// to send message to multiple person 
function confirmSendMessage(formname,Process,managefile)
{

	var ellen=document.getElementById(formname).elements.length;
	var count=0;
	for(var i=0;i<ellen;i++)
	{
		if(document.getElementById(formname).elements[i].name=="send[]")
		{	
			 if(document.getElementById(formname).elements[i].checked==true)
			 {
				count=count+1;
			 }
		}
	}
		if(count==0)
		{
			alert("Please Select Record To Send Message");
			return false;
		}
		else
		{
			document.getElementById(formname).Process.value=Process;
			document.getElementById(formname).action  ="index.php?p="+managefile;
			document.getElementById(formname).submit();
			return true;
		}
}


// ------------------- Check All and Uncheck All -----------------------
function check_all(Form_Obj,eventgiver){
		var ellen=Form_Obj.elements.length;
		if(eventgiver.checked==true){
			for(var i=1;i<ellen;i++){
				if(Form_Obj.elements[i].name=="del[]")
				Form_Obj.elements[i].checked=true;
			}
		}else if(eventgiver.checked==false){
			for(var i=1;i<ellen;i++){
				if(Form_Obj.elements[i].name=="del[]")
				Form_Obj.elements[i].checked=false;
			}
		}
}
//-----window open
function winpopup(url,width,height)
{

window.open(url,'','location=0,menubar=0,titlebar=0,toolbar=0,resizable=0,status=0,height='+height+',width='+width+',top=155,left=155');
}

//-------- Previous Caste on Basis of Religion

function GetCaste(File_Path,TableName,Option,ReligionID)
{
		
		fetch_remote_page(File_Path+"?ReligionID="+ReligionID+"&Table="+TableName+"&Option="+Option, Option);	
}
function GetState(File_Path,TableName,Option,CountryID)
{
		fetch_remote_page(File_Path+"?CountryID="+CountryID+"&Table="+TableName+"&Option="+Option, Option);	
}
function GetPostCode(File_Path,TableName,Option,StateName)
{
	
		fetch_remote_page(File_Path+"?StateName="+StateName+"&Table="+TableName+"&Option="+Option, Option);	
}
function GetTown(File_Path,TableName,Option,PostCode)
{
		//alert(PostCode);
		fetch_remote_page(File_Path+"?PostCode="+PostCode+"&Table="+TableName+"&Option="+Option, Option);	
}
function Getcurrency(File_Path,TableName,Option,countries_id)
{
		fetch_remote_page(File_Path+"?countries_id="+countries_id+"&Table="+TableName+"&Option="+Option, Option);	
}
function Gettitle(File_Path,TableName,Option,countries_id)
{
		fetch_remote_page(File_Path+"?lt_id="+lt_id+"&Table="+TableName+"&Option="+Option, Option);	
}
function GetCity(File_Path,TableName,Option,StateID)
{
		
		fetch_remote_page(File_Path+"?StateID="+StateID+"&Table="+TableName+"&Option="+Option, Option);	
}
function show_hide_row(ID,TrID)
{
	if(ID=='other')
		document.getElementById(TrID).style.display="";
	else
		document.getElementById(TrID).style.display="none";
	
}
function submit_form(formname,file)
{
	document.getElementById(formname.name).action=file;
}
function showTbl(Style,ID){

	if(Style == 'show')
			document.getElementById(ID).style.display = '';
	else if(Style == 'hide')
			document.getElementById(ID).style.display = 'none';
}
//--- checking Authority to done any task and select data
function checking_authority(formname,val,message)
{
	if(val==0)
	{
		alert(message);
		return false;
	}
	else
	{
		return false;
	}
}
function network_checking_authority(formname,val,message,Process,managefile)
{
	if(val==0)
	{
		alert(message);
		return false;
	}
	else
	{
		var ellen=document.getElementById(formname).elements.length;
		var count=0;
		for(var i=0;i<ellen;i++)
		{
			if(document.getElementById(formname).elements[i].name=="send[]")
			{	
				 if(document.getElementById(formname).elements[i].checked==true)
				 {
					count=count+1;
				 }
			}
		}
			if(count==0)
			{
				alert("Please Select Record To Send Message");
				return false;
			}
			else
			{
				document.getElementById(formname).Process.value=Process;
				document.getElementById(formname).action  ="index.php?p="+managefile;
				document.getElementById(formname).submit();
				return true;
			}
	}
}
//--- cehckinh Authority only
function checking_authority_only(formname,val,message)
{
	if(val==0)
	{
		alert(message);
		return false;
	}
	else
		return true;
}
//-- Selecting Accept Or Reject
function AcceptReject(formname,IDvalue,managefile)
{
	document.getElementById(formname).ID.value=IDvalue;
	document.getElementById(formname).action  = managefile+".php";
	document.getElementById(formname).submit();
}

