// 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();
}

// -----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;
				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 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)
{
		CountryID = document.getElementById('s_country').value;
		fetch_remote_page(File_Path+"?StateName="+StateName+"&CountryID="+CountryID+"&Table="+TableName+"&Option="+Option, Option);	
}
function GetTown(File_Path,TableName,Option,PostCode)
{
		//alert(PostCode);
		CountryID = document.getElementById('s_country').value;
		fetch_remote_page(File_Path+"?PostCode="+PostCode+"&CountryID="+CountryID+"&Table="+TableName+"&Option="+Option, Option);	
}
function GetStudent(File_Path,TableName,Option,ClassId)
{
		//alert(PostCode);
		fetch_remote_page(File_Path+"?ClassId="+ClassId+"&Table="+TableName+"&Option="+Option, Option);	
}
function GetClass(File_Path,TableName,Option,SchoolId)
{
		//alert(PostCode);
		fetch_remote_page(File_Path+"?SchoolId="+SchoolId+"&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 getCountrySuggestion(CountryNameText)
{
		fetch_remote_page(File_Path+"?CountryName="+CountryNameText+"&Table=country&Option=CountrySuggestion", 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();
}
function ShowCurrencySymbol(CurrencyCode){
	switch(CurrencyCode)
	{
		case 'USD':
			return "$";
		break;
		case 'AUD':
			return "$";
		break;
		case 'EUR':
			return "&euro;";
		break;
		case 'NZD':
			return "$";
		break;
		case 'GBP':
			return "&pound;";
		break;
		case 'CAD':
			return "$";
		break;
	}
}
function GetKeywordVal(SearchFieldVal)
{
	var SearchValCombo = document.getElementById('Keyword');
	var SearchValComboLength = document.getElementById('Keyword').options.length;
	for(var i=0;i<SearchValComboLength;i++)
	{
		SearchValCombo.remove(SearchValCombo.options[i]);
	}
	if(SearchFieldVal=='c_age')
	{
		var opt = document.createElement('option');
		opt.text = "Select Age";
		opt.value = "0";
		
		try
		{
			SearchValCombo.add(opt,null);
		}
		catch(ex)
		{
			SearchValCombo.add(opt);
		}
		for(var i=4;i<=18;i++)
		{
			var opt = document.createElement('option');
			opt.text = i;
			opt.value = i;
			try
			{
				SearchValCombo.add(opt,null);
			}
			catch(ex)
			{
				SearchValCombo.add(opt);
			}
		}
	}
	else if(SearchFieldVal=='s_gender')
	{
		var opt = document.createElement('option');
		opt.text = "Select Gender";
		opt.value = "0";
		try
		{
			SearchValCombo.add(opt,null);
		}
		catch(ex)
		{
			SearchValCombo.add(opt);
		}
		
		var opt = document.createElement('option');
		opt.text = "Male";
		opt.value = "Male";
		try
		{
			SearchValCombo.add(opt,null);
		}
		catch(ex)
		{
			SearchValCombo.add(opt);
		}
		
		var opt = document.createElement('option');
		opt.text = "Female";
		opt.value = "Female";
		try
		{
			SearchValCombo.add(opt,null);
		}
		catch(ex)
		{
			SearchValCombo.add(opt);
		}
	}
	else if(SearchFieldVal=='s_state')
	{
		var opt = document.createElement('option');
		opt.text = "Select State";
		opt.value = "0";
		 try
		  {
			 SearchValCombo.add(opt,null); // standards compliant
		  }
			catch(ex)
		  {
			 SearchValCombo.add(opt); // IE only
		  }
		for(var i=0;i<StateName.length;i++)
		{
			var opt = document.createElement('option');
			opt.text = StateName[i];
			opt.value = StateID[i]
			
			  try
			  {
				 SearchValCombo.add(opt,null); // standards compliant
			  }
				catch(ex)
			  {
				 SearchValCombo.add(opt); // IE only
			  }
		}
	}
	else if(SearchFieldVal=='s_postcode')
	{
		var opt = document.createElement('option');
		opt.text = "Select Postcode";
		opt.value = "0";
		
		try
		{
			SearchValCombo.add(opt,null);
		}
		catch(ex)
		{
			SearchValCombo.add(opt);
		}
		
		for(var i=0;i<PostCode.length;i++)
		{
			var opt = document.createElement('option');
			opt.text = PostCode[i];
			opt.value = PostCode[i];
		
			try
			{
				SearchValCombo.add(opt,null);
			}
			catch(ex)
			{
				SearchValCombo.add(opt);
			}
		}
	}
	else if(SearchFieldVal=='s_country')
	{
		var opt = document.createElement('option');
		opt.text = "Select Country";
		opt.value = "0";
		 try
		  {
			 SearchValCombo.add(opt,null); // standards compliant
		  }
			catch(ex)
		  {
			 SearchValCombo.add(opt); // IE only
		  }
		for(var i=0;i<CountryName.length;i++)
		{
			var opt = document.createElement('option');
			opt.text = CountryName[i];
			opt.value = CountryID[i]
			
			  try
			  {
				 SearchValCombo.add(opt,null); // standards compliant
			  }
				catch(ex)
			  {
				 SearchValCombo.add(opt); // IE only
			  }
		}
	}
	
}
