// JavaScript Document

//REGISTRATION  -  PAGE 1

function submit_registration_1(action)
{
		var check = check_registration_1();
		if (check != false)
		{
				if(action=="add")
				{
					document.biodata1.action = "save_registartion1_data.php";
					document.biodata1.submit();
				}
				else
				{
					document.biodata1.action = "save_registartion1_data.php";
					document.biodata1.submit();
				}
		}
}

function check_registration_1()
{
		if(document.biodata1.name.value=="")
		{
				alert("Enter username (your email address).");
				document.biodata1.name.focus();
				return false;
		}
		else
		{
				var mail = document.biodata1.name.value;
				if(mail.search("@.")==-1)
				{
					alert("Entered username(email address) is invalid. Try again.");
					document.biodata1.name.focus();
					return false;
				}
		}
		if(document.biodata1.password.value=="")
		{
				alert("Enter password.");
				document.biodata1.password.focus();
				return false;
		}
		else
		{
				var pwd = document.biodata1.password.value;
				if(pwd.length < 4)
				{
						alert("Password should be greater than 4 characters.");
						document.biodata1.password.focus();
						return false;
				}
		}
		if(document.biodata1.confirm_pwd.value=="")
		{
				alert("Confirm your password.");
				document.biodata1.confirm_pwd.focus();
				return false;
		}
		if(document.biodata1.password.value != document.biodata1.confirm_pwd.value)
		{
				alert("Password doesn't match. Enter again.");
				document.biodata1.password.value = "";
				document.biodata1.confirm_pwd.value = "";
				document.biodata1.password.focus();
				return false;
		}
		if(document.biodata1.email.value=="")
		{
				alert("Enter your full name.");
				document.biodata1.email.focus();
				return false;
		}
		if((document.biodata1.dobDay.options[document.biodata1.dobDay.selectedIndex].value=="day") || (document.biodata1.dobMonth.options[document.biodata1.dobMonth.selectedIndex].value=="month") || (document.biodata1.dobYear.options[document.biodata1.dobYear.selectedIndex].value=="year"))
		{
				alert("Enter your date of birth.");
				document.biodata1.dobDay.focus();
				return false;
		}
		
		if(document.biodata1.country.options[document.biodata1.country.selectedIndex].text=="-Select Country-")
		{
				alert("Select your country.");
				document.biodata1.country.focus();
				return false;
		}
		if(document.biodata1.city.value=="")
		{
				alert("Enter your city.");
				document.biodata1.city.focus();
				return false;
		}
		if(document.biodata1.profession.options[document.biodata1.profession.selectedIndex].value=="0")
		{
				alert("Select your profession.");
				document.biodata1.profession.focus();
				return false;
		}
		
}

function submit_registration_2()
{
		if(document.biodata2.experience.options[document.biodata2.experience.selectedIndex].text =="-Select Experience-")
		{
			alert("Select your experience.");
			document.biodata2.experience.focus();
		}
		else
		{
			document.biodata2.action = "save_registartion2_data.php";
			document.biodata2.submit();
		}

}

function check_registration_2()
{
		if(document.biodata2.experience.options[document.biodata2.experience.selectedIndex].text=="-Select Experience-")
		{
				alert("Enter your total experience.");
				document.biodata3.experience.focus();
				return false;
		}
		if(document.biodata2.last_desig.value=="")
		{
				alert("Enter your last designation.");
				document.biodata2.last_desig.focus();
				return false;
		}
}

function submit_registration_3()
{
		var chk = check_reg_3();
		if(chk!=false)
		{
			document.biodata3.action = "save_registartion3_data.php";
			document.biodata3.submit();
		}
		
}
function check_reg_3()
{	
		var sal=document.biodata3.income.value
		/*if(sal=="0")
		{
			alert("Must enter your salery..");
			document.biodata3.income.focus();
			return false;
		}*/
		/*if(sal.length<4)
		{
			alert("Enter your salery Rs. 10000 minimum");
			document.biodata3.income.focus();
			return false;
		}
*/

/*var income = document.biodata3.income.value;
				if((income.length < 4) || (income.charAt(0)==0))
				{
	alert("Please enter your expected income in greater than equal to four figures \n and should not be start with zero.");
						document.biodata3.income.focus();
						return false;
				}
		}*/
}


function submit_login()
{
		var check = check_login();
		if (check!=false)
		{
			document.login.action = "check_user_login.php";
			document.login.submit();
		}
}
function check_login()
{
		if(document.login.username.value == "")
		{
				alert("Enter username.");
				document.login.username.focus();
				return false;
		}
		if(document.login.pwd.value == "")
		{
				alert("Enter password.");
				document.login.pwd.focus();
				return false;
		}
}

function getPage()
{
		var country = document.search_data.country.options[document.search_data.country.selectedIndex].value;
		document.search_data.hdnCountry.value = country;
		var page  = document.search_data.page.options[document.search_data.page.selectedIndex].value;
		document.search_data.page_name.value = page;
		populate_subHeadings(page);
}

function populate_subHeadings(page)
{
	if(page=="Job")
	{
		document.search_data.for_value.options.length=0;
		jobArray = new Array("Part Time Job", "Full time job", "Social work","All")
   		var option0 = new Option("Part Time Job","Part Time Job")
		var option1 = new Option("Full time job", "Full time job")   
		var option2 = new Option("Social work", "Social work")   
		var option3 = new Option("All", "All")   
		for (var i=0; i < 4; i++) 
		{
			eval("document.search_data.for_value.options[i]=option" + i)      
			if (i==0) 
			{         
				document.search_data.for_value.options[i].selected=true      
			}
		}
	}
	else if(page=="Marriage")
	{
		document.search_data.for_value.options.length=0;
		jobArray = new Array("Son", "Daughter", "Self","All")
   		var option0 = new Option("Groom Wanted","Son")
		var option1 = new Option("Bride Wanted", "Daughter")   
		var option2 = new Option("Self", "Self")   
		var option3 = new Option("All", "All")   
		for (var i=0; i < 4; i++) 
		{
			eval("document.search_data.for_value.options[i]=option" + i)      
			if (i==0) 
			{         
				document.search_data.for_value.options[i].selected=true      
			}
		}
	}
	else if(page=="Business Opportunities")
	{
		document.search_data.for_value.options.length=0;
		jobArray = new Array("Looking for venture capital / funds for business", "Business partners", "Distributors / Dealers","Expansion","Others")
   		var option0 = new Option("Looking for venture capital / funds for business","Looking for venture capital / funds for business")
		var option1 = new Option("Business partners", "Business partners")   
		var option2 = new Option("Distributors / Dealers", "Distributors / Dealers")   
		var option3 = new Option("Expansion", "Expansion")  
		var option4 = new Option("Others", "Others")  
		for (var i=0; i < 5; i++) 
		{
			eval("document.search_data.for_value.options[i]=option" + i)      
			if (i==0) 
			{         
				document.search_data.for_value.options[i].selected=true      
			}
		}
	}
	else if(page=="Investment Advisor Required")
	{
			document.search_data.for_value.options.length=0;
		jobArray = new Array("Govt. Schemes", "Private Schemes", "Shares","Bonds")
   		var option0 = new Option("Govt. Schemes","Govt. Schemes")
		var option1 = new Option("Private Schemes", "Private Schemes")   
		var option2 = new Option("Shares", "Shares")   
		var option3 = new Option("Bonds", "Bonds")
		for (var i=0; i < 4; i++) 
		{
			eval("document.search_data.for_value.options[i]=option" + i)      
			if (i==0) 
			{         
				document.search_data.for_value.options[i].selected=true      
			}
		}
	}
	else if(page=="House")
	{
		document.search_data.for_value.options.length=0;
		jobArray = new Array("Require a house on rental", "Purchase a house", "Sell a house")
   		var option0 = new Option("Require a house on rental","Require a house on rental")
		var option1 = new Option("Purchase a house", "Purchase a house")   
		var option2 = new Option("Sell a house", "Sell a house")   
		for (var i=0; i < 3; i++) 
		{
			eval("document.search_data.for_value.options[i]=option" + i)      
			if (i==0) 
			{         
				document.search_data.for_value.options[i].selected=true      
			}
		}
	}
	else if(page=="Medical Aid Required")
	{
		document.search_data.for_value.options.length=0;
		jobArray = new Array("Doctor", "Nurse", "Pharmacy","Ambulance","Others")
   		var option0 = new Option("Doctor","Doctor")
		var option1 = new Option("Nurse", "Nurse")   
		var option2 = new Option("Pharmacy", "Pharmacy")   
		var option3 = new Option("Ambulance", "Ambulance")   
		var option4 = new Option("Others", "Others")   
		for (var i=0; i < 5; i++) 
		{
			eval("document.search_data.for_value.options[i]=option" + i)      
			if (i==0) 
			{         
				document.search_data.for_value.options[i].selected=true      
			}
		}
	}
	else if(page=="Insurance Required")
	{
		document.search_data.for_value.options.length=0;
		jobArray = new Array("Medical Insurance", "Life Insurance", "Vehicle Insurance","Others")
   		var option0 = new Option("Medical Insurance","Medical Insurance")
		var option1 = new Option("Life Insurance", "Life Insurance")   
		var option2 = new Option("Vehicle Insurance", "Vehicle Insurance")   
		var option3 = new Option("Others", "Others")   
		for (var i=0; i < 4; i++) 
		{
			eval("document.search_data.for_value.options[i]=option" + i)      
			if (i==0) 
			{         
				document.search_data.for_value.options[i].selected=true      
			}
		}
	}
	else if(page=="Vehicle Details")
	{
		document.search_data.for_value.options.length=0;
		jobArray = new Array("Require a taxi", "Require a  driver", "Require a driving license")
   		var option0 = new Option("Require a taxi","Require a taxi")
		var option1 = new Option("Require a  driver", "Require a  driver")   
		var option2 = new Option("Require a driving license", "Require a driving license")   
		for (var i=0; i < 3; i++) 
		{
			eval("document.search_data.for_value.options[i]=option" + i)      
			if (i==0) 
			{         
				document.search_data.for_value.options[i].selected=true      
			}
		}
	}
	else if(page=="Ticketing Required For")
	{
		document.search_data.for_value.options.length=0;
		jobArray = new Array("Railway", "Aeroplane", "Bus")
   		var option0 = new Option("Railway","Railway")
		var option1 = new Option("Aeroplane", "Aeroplane")   
		var option2 = new Option("Bus", "Bus")   
		for (var i=0; i < 3; i++) 
		{
			eval("document.search_data.for_value.options[i]=option" + i)      
			if (i==0) 
			{         
				document.search_data.for_value.options[i].selected=true      
			}
		}
	}
	else if(page=="Lawyer Required For")
	{
		document.search_data.for_value.options.length=0;
		jobArray = new Array("Writing will", "Fight a dispute", "Others")
   		var option0 = new Option("Writing will","Writing will")
		var option1 = new Option("Fight a dispute", "Fight a dispute")   
		var option2 = new Option("Others", "Others")   
		for (var i=0; i < 3; i++) 
		{
			eval("document.search_data.for_value.options[i]=option" + i)      
			if (i==0) 
			{         
				document.search_data.for_value.options[i].selected=true      
			}
		}
	}
	else if(page=="Household Help Required")
	{
		document.search_data.for_value.options.length=0;
		jobArray = new Array("Electrician", "Carpentar", "Contractor","Plumber","Others")
   		var option0 = new Option("Electrician","Electrician")
		var option1 = new Option("Carpentar", "Carpentar")   
		var option2 = new Option("Contractor", "Contractor")  
		var option3 = new Option("Plumber", "Plumber") 
		var option4 = new Option("Others", "Others") 
		for (var i=0; i < 5; i++) 
		{
			eval("document.search_data.for_value.options[i]=option" + i)      
			if (i==0) 
			{         
				document.search_data.for_value.options[i].selected=true      
			}
		}
	}
	else if(page=="Entertainment")
	{
		document.search_data.for_value.options.length=0;
   		var option0 = new Option("Looking for a club or voluntary organization","Looking for a club or voluntary organization")
		eval("document.search_data.for_value.options[0]=option0")      
		document.search_data.for_value.options[0].selected=true      
	}
	else if(page=="Latest Technology Teacher Required For")
	{
		document.search_data.for_value.options.length=0;
		jobArray = new Array("Computers", "Internet", "Mobile","Others")
   		var option0 = new Option("Computers","Computers")
		var option1 = new Option("Internet", "Internet")   
		var option2 = new Option("Mobile", "Mobile")  
		var option3 = new Option("Others", "Others") 
		for (var i=0; i < 4; i++) 
		{
			eval("document.search_data.for_value.options[i]=option" + i)      
			if (i==0) 
			{         
				document.search_data.for_value.options[i].selected=true      
			}
		}
	}
	else if(page=="Old Age Home Required")
	{
		document.search_data.for_value.options.length=0;
		jobArray = new Array("Yes", "No")
   		var option0 = new Option("Yes","Yes")
		var option1 = new Option("No", "No")   
		
		for (var i=0; i < 2; i++) 
		{
			eval("document.search_data.for_value.options[i]=option" + i)      
			if (i==0) 
			{         
				document.search_data.for_value.options[i].selected=true      
			}
		}
	}
	else if(page=="New Documents Required")
	{
		document.search_data.for_value.options.length=0;
		jobArray = new Array("Driving license","Ration Card", "Passport")
   		var option0 = new Option("Driving license","Driving license")
		var option1 = new Option("Ration Card", "Ration Card")   
		var option2 = new Option("Passport", "Passport")  
		for (var i=0; i < 3; i++) 
		{
			eval("document.search_data.for_value.options[i]=option" + i)      
			if (i==0) 
			{         
				document.search_data.for_value.options[i].selected=true      
			}
		}
	}
	else if(page=="Banking")
	{
		document.search_data.for_value.options.length=0;
		jobArray = new Array("Open a bank account","Reference", "Cash delivery","Others")
   		var option0 = new Option("Open a bank account","Open a bank account")
		var option1 = new Option("Reference", "Reference")   
		var option2 = new Option("Cash delivery", "Cash delivery")  
		var option3 = new Option("Others", "Others")  
		for (var i=0; i < 4; i++) 
		{
			eval("document.search_data.for_value.options[i]=option" + i)      
			if (i==0) 
			{         
				document.search_data.for_value.options[i].selected=true      
			}
		}
	}
	else if(page=="Bill Collection Agent Required")
	{
		document.search_data.for_value.options.length=0;
		jobArray = new Array("Yes","No")
   		var option0 = new Option("Yes","Yes")
		var option1 = new Option("No", "No")   
		for (var i=0; i < 2; i++) 
		{
			eval("document.search_data.for_value.options[i]=option" + i)      
			if (i==0) 
			{         
				document.search_data.for_value.options[i].selected=true      
			}
		}
	}   
}

function search_result()
{
		var check = check_search_fields();
		if(check!=false)
		{
					var country = document.search_data.country.options[document.search_data.country.selectedIndex].value;
					var city = document.search_data.city.value;
					var name=document.search_data.r_name.value;
					var from_age = document.search_data.from_age.value;
					var to_age = document.search_data.to_age.value;
					var gender = document.search_data.gender.options[document.search_data.gender.selectedIndex].value;
										
					if(gender=="male")
					{
							gender_flag = 0;
					}
					else if(gender=="female")
					{
							gender_flag = 1;
					}
					else
					{
							gender_flag = -1;
					}
					if(document.search_data.profession.options[document.search_data.profession.selectedIndex].value=="0")
				   {
					   	var profession = "";
				   }
				   else
				   {
					var profession = document.search_data.profession.options[document.search_data.profession.selectedIndex].value
				   }
					if (document.search_data.page.options[document.search_data.page.selectedIndex].value != "-Please Select-")
					{
						page = document.search_data.page.options[document.search_data.page.selectedIndex].value;
					}
					else
					{
						page = "";
					}
					if(document.search_data.for_value.options[document.search_data.for_value.selectedIndex].value!="-Please Select-")
					{
						sub_heading = document.search_data.for_value.options[document.search_data.for_value.selectedIndex].value;
					}
					else
					{
						sub_heading = "";
					}
					if(sub_heading=="Others")
					{
							others=document.search_data.others.value;;
					}
					else
					{
							others = "";
					}
				if(document.search_data.for_value.options[document.search_data.for_value.selectedIndex].value!="-Please Select-")
				{
					if(sub_heading=="Others")
					{
						if(document.search_data.others.value=="")
						{
								alert("Enter the value for other.");
								document.search_data.others.focus();
						}
						else
						{
							document.search_data.action = "search_results.php?main_page=1&country="+country+"&city=" +city+"&from_age="+from_age+"&to_age="+to_age+"&gender="+gender_flag+"&profession="+ profession +"&page=" +page+"&for_value="+sub_heading+"&others=" + others +"&name="+name;
							document.search_data.submit();
						}
					}
					else
					{
						document.search_data.action = "search_results.php?main_page=1&country="+country+"&city=" +city+"&from_age="+from_age+"&to_age="+to_age+"&gender="+gender_flag+"&profession="+ profession +"&page=" +page+"&for_value="+sub_heading+"&others=" + others+"&name="+name;
						document.search_data.submit();
					}
				}
				else
				{
						document.search_data.action = "search_results.php?main_page=1&country="+country+"&city=" +city+"&from_age="+from_age+"&to_age="+to_age+"&gender="+gender_flag+"&profession="+ profession +"&page=" +page+"&for_value="+sub_heading+"&others=" + others+"&name="+name;
						document.search_data.submit();
				}
		}
}

function check_search_fields()
{
		if(document.search_data.country.options[document.search_data.country.selectedIndex].value=="-Select Country-")
		{
				alert("Select a country");
				document.search_data.country.focus();
				return false;
		}
		var count = 0;
		var blnFrom = false;
		var blnTo = false;
		if(document.search_data.from_age.value!="")
		{
			blnFrom = true;
			count =1;
		}
		if(document.search_data.to_age.value!="")
		{
			blnTo = true;
			count =2;
		}

		if((count >=1) && (count < 2))
		{
				if(!blnFrom)
				{
						alert("Enter the age from.");
						document.search_data.from_age.focus();
						return false;
				}
				if(document.search_data.from_age.value!="")
				{
					var from_age = document.search_data.from_age.value;
					var blnFlag =false;
					for(i=0;i<=from_age.length;i++)
					{	
						//alert(phone.charAt(i));
						if (isNaN(from_age.charAt(i)))
						{
							blnFlag = true;
							break;
						}
					}
					if(blnFlag==true)
					{
						alert("Enter a number for from age.");
						document.search_data.from_age.value="";
						document.search_data.from_age.focus();
						return false;
					}
				}
				
				if(!blnTo)
				{
						alert("Enter the age to.");
						document.search_data.to_age.focus();
						return false;
				}
				
		}
		if(document.search_data.to_age.value!="")
				{
					var to_age = document.search_data.to_age.value;
					var blnFlag =false;
					for(i=0;i<=to_age.length;i++)
					{	
						//alert(phone.charAt(i));
						if (isNaN(to_age.charAt(i)))
						{
							blnFlag = true;
							break;
						}
					}
					if(blnFlag==true)
					{
						alert("Enter a number for to age.");
						document.search_data.to_age.value="";
						document.search_data.to_age.focus();
						return false;
					}
				}
		
		
}

function get_sub_heading()
{
		var sub_heading = document.search_data.for_value.options[document.search_data.for_value.selectedIndex].value;
		if(sub_heading=="Others")
		{
				document.getElementById("others").style.display = "inline";
		}
		else
		{
				document.getElementById("others").style.display = "none";
		}
}
function submit_contactUs()
{
		var chk  = check_contact_fields();
		if(chk != false)
		{
				document.contact.action="contact_us_confirmation.php";
				document.contact.submit();
		}
}

function check_contact_fields()
{
	if(document.contact.name.value=="")
	{
			alert("Enter your name.");
			document.contact.name.focus();
			return false;
	}
	
	if(document.contact.name.value!="")
   
   {       str=document.contact.name.value;
			flag=validate(str);
			 if(flag==0)
			 {   
				  alert('Special characters not allowed in first name.');
				  document.contact.name.focus();
				  			return false;

			 }
   }
   
   if(document.contact.name.value!="")
   
   {  
			   var str1=document.contact.name.value;
			   var iChars = "0123456789!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
			   var length= str1.length;
			   for (var i = 0; i <length ; i++) {
			  
				if (iChars.indexOf(document.contact.name.value.charAt(i)) != -1) {
					alert('Please enter valid name.');
				document.contact.name.focus();
				return false;

				}
			 }
   
   }
   
   
	if(document.contact.country.options[document.contact.country.selectedIndex].value=="-Select Country-")
	{
			alert("Select a country.");
			document.contact.country.focus();
			return false;
	}
	if(document.contact.city.value=="")
	{
			alert("Enter city.");
			document.contact.city.focus();
			return false;
	}
	
	if(document.contact.city.value!="")
   
   {       str=document.contact.city.value;
			flag=validate(str);
			 if(flag==0)
			 {   
				  alert('Special characters not allowed in city name.');
				  document.contact.city.focus();
				  			return false;

			 }
   }
   
   if(document.contact.city.value!="")
   
   {  
			   var str1=document.contact.city.value;
			   var iChars = "0123456789!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
			   var length= str1.length;
			   for (var i = 0; i <length ; i++) {
			  
				if (iChars.indexOf(document.contact.city.value.charAt(i)) != -1) {
					alert('Please enter valid city name.');
				document.contact.city.focus();
				return false;

				}
			 }
   
   }
   
	
	if(document.contact.email.value=="")
	{
			alert("Enter email.");
			document.contact.email.focus();
			return false;
	}
	else
	{
		  
		  if(!validateEmail(document.contact.email.value)){
				alert('Please enter valid email address');
				document.contact.email.value='';
			    document.contact.email.focus();
			    return false;
		}
		  
				  
			}
	if(document.contact.detail.value=="")
	{
			alert("Enter detailed information.");
			document.contact.detail.focus();
			return false;
	}
	
	
	if(document.contact.detail.value!="")
   
   {       str=document.contact.detail.value;
			flag=validate(str);
			 if(flag==0)
			 {   
				  alert('Special characters not allowed in message.');
				  document.contact.detail.focus();
				  			return false;

			 }
   }
}
function validateEmail(emailStr)
{
	
			/* The following pattern is used to check if the entered e-mail address
			   fits the user@domain format.  It also is used to separate the username
			   from the domain. */
			var emailPat=/^(.+)@(.+)$/
			/* The following string represents the pattern for matching all special
			   characters.  We don't want to allow special characters in the address. 
			   These characters include ( ) < > @ , ; : \ " . [ ]    */
			//var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
//			var specialChars="\\(\\)<>@,`';:~!#$%^&*+=|{}?\\\\\\\"\\.\\[\\]"                 
			var specialChars="\\(\\)<>@,`';:~!#$%^&*=|{}?\\\\\\\"\\.\\[\\]"         //////////// Change By Mario: /////////////
			
			/* The following string represents the range of characters allowed in a 
			   username or domainname.  It really states which chars aren't allowed. */
			var validChars="\[^\\s" + specialChars + "\]"
			/* The following pattern applies if the "user" is a quoted string (in
			   which case, there are no rules about which characters are allowed
			   and which aren't; anything goes).  E.g. "sg cricket"@disney.com
			   is a legal e-mail address. */
			var quotedUser="(\"[^\"]*\")"
			/* The following pattern applies for domains that are IP addresses,
			   rather than symbolic names.  E.g. sg@[123.124.233.4] is a legal
			   e-mail address. NOTE: The square brackets are required. */
			var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
			/* The following string represents an atom (basically a series of
			   non-special characters.) */
			var atom=validChars + '+'
			/* The following string represents one word in the typical username.
			   For example, in sg.sg@somewhere.com, sg and sg are words.
			   Basically, a word is either an atom or quoted string. */
			var word="(" + atom + "|" + quotedUser + ")"
			// The following pattern describes the structure of the user
			var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
			/* The following pattern describes the structure of a normal symbolic
			   domain, as opposed to ipDomainPat, shown above. */
			var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


			/* Finally, let's start trying to figure out if the supplied address is
			   valid. */

			/* Begin with the coarse pattern to simply break up user@domain into
			   different pieces that are easy to analyze. */
			var matchArray=emailStr.match(emailPat)
			if (matchArray==null) {
			  /* Too many/few @'s or something; basically, this address doesn't
			     even fit the general mould of a valid e-mail address. */
				//alert("Email address seems incorrect (check @ and .'s)")
				return false
			}
			var user=matchArray[1]
			var domain=matchArray[2]

			// See if "user" is valid 
			if (user.match(userPat)==null) {
			    // user is not valid
			    //alert("The username doesn't seem to be valid.")
			    return false
			}

			/* if the e-mail address is at an IP address (as opposed to a symbolic
			   host name) make sure the IP address is valid. */
			var IPArray=domain.match(ipDomainPat)
			if (IPArray!=null) {
			    // this is an IP address
				  for (var i=1;i<=4;i++) {
				    if (IPArray[i]>255) {
				        //alert("Destination IP address is invalid!")
					return false
				    }
			    }
			    return true
			}

			// Domain is symbolic name
			var domainArray=domain.match(domainPat)
			if (domainArray==null) {
			//alert("The domain name doesn't seem to be valid.")
			    return false
			}

			/* domain name seems valid, but now make sure that it ends in a
			   three-letter word (like com, edu, gov) or a two-letter word,
			   representing country (uk, nl, no), and that there's a hostname preceding 
			   the domain or country. */

			/* Now we need to break up the domain to get a count of how many atoms
			   it consists of. */
			var atomPat=new RegExp(atom,"g")
			var domArr=domain.match(atomPat)
			var len=domArr.length
			if (domArr[domArr.length-1].length<2 || 
			    domArr[domArr.length-1].length>4) {                  //	domArr[domArr.length-1].length>3) {   ====> Change By Mario;
			
			   // the address must end in a two letter or three letter word.
			   //alert("The address must end in a three-letter domain, or two letter country.")
			   return false
			}

			// Make sure there's a host name preceding the domain.
			if (len<2) {
			   var errStr="This address is missing a hostname!"
			   //alert(errStr)
			   return false
			}

			// If we've gotten this far, everything's valid!
			return true;
}

function validate(str)
{
	
	var myRegExp = /<script/;
	var myRegExp1 = /<input/;
	var myRegExp2 = /<img/;
	var matchPos = str.search(myRegExp);
	var matchPos1 = str.search(myRegExp1);
	var matchPos2 = str.search(myRegExp2);
	if(matchPos != -1 || matchPos1 != -1 || matchPos2 != -1)
   {
	   return 0;
   }
   else
   { return 1;
   }
   

}


function submit_ad()
{
		var check = check_ad_fields();
		if(check!=false)
		{
				document.ad.action="save_ad_data.php";
				document.ad.submit();
		}
}
function check_ad_fields()
{
		if(document.ad.title.value=="")
		{
				alert("Enter Advertisement title.");
				document.ad.title.focus();
				return false;
		}
		if(document.ad.message.value=="")
		{
				alert("Enter message.");
				document.ad.message.focus();
				return false;
		}
		if(document.ad.country.options[document.ad.country.selectedIndex].value=="-Select Country-")
		{
				alert("Select country.");
				document.ad.country.focus();
				return false;
		}
		if(document.ad.city.value=="")
		{
				alert("Enter city.");
				document.ad.city.focus();
				return false;
		}
}
function submit_search_ad()
{
		var check = check_searchAd_fields();
		if(check!=false)
		{
				country =document.search_ad.country.options[document.search_ad.country.selectedIndex].value;
				city= document.search_ad.city.value;
				document.search_ad.action = "searchAd_results.php?page=1&country="+country+"&city="+city;
				document.search_ad.submit();
		}
}
function check_searchAd_fields()
{
		if(document.search_ad.country.options[document.search_ad.country.selectedIndex].value=="-Select Country-")
		{
				alert("Select country.");
				document.search_ad.country.focus();
				return false;
		}
}
//ADMIN_LOGIN

function check_admin_login()
{
	var check = checkLoginFields();
	if(check!=false)
	{
		document.admin_login.action="check_admin_login.php";
		document.admin_login.submit();
	}
}
function checkLoginFields()
{
		if(document.admin_login.username.value=="")
		{
				alert("Enter username.");
				document.admin_login.username.focus();
				return false;
		}
		if(document.admin_login.pwd.value=="")
		{
				alert("Enter password.");
				document.admin_login.pwd.focus();
				return false;
		}
}
function selectAll(action)
{
		if(action=='user')
		{
			var arrAll = document.getElementsByName('chkUser');
		}
		if(action=='member')
		{
			var arrAll = document.getElementsByName('chkUser');
		}
		if(action=='search')
		{
				var arrAll = document.getElementsByName('chkUser');
		}
		if(action=="feedback")
		{
				var arrAll = document.getElementsByName('chkUser');
		}
		for(var j=0;j<arrAll.length;j++)
		{
			if(document.getElementById('checkAll').checked)
			{
				arrAll[j].checked= true;
			}
			else
			{
				arrAll[j].checked= false;
			}
		}
}
function all_users(action)
{
		var checkedStr="";
		var checkArr= document.getElementsByName("chkUser");
		
		for (var i = 0;i < checkArr.length; i++)
		{
			
			if(checkArr[i].checked)
			{
					if (checkedStr == "")
					{ 
					 	checkedStr = checkArr[i].value;
					}
					else 
					{	
						checkedStr = checkedStr + "," + checkArr[i].value;
					 }
						
			}
				
		}
	  var offersObj = document.getElementById("userId");
      offersObj.value = checkedStr;
	if(offersObj.value!="")
	{
	  if (action=="Approve")
	  {
		  document.users.action = "doApproveUsers.php";
	  }
	  else
	  {
		 document.users.action = "deleteSelectedUsers.php"; 
	  }
	  document.users.submit();
	}
	else
	{
			alert("Select atleast one checkbox.");
	}
}

function approve_feedback(action)
{
		var checkedStr="";
		var checkArr= document.getElementsByName("chkUser");
		
		for (var i = 0;i < checkArr.length; i++)
		{
			
			if(checkArr[i].checked)
			{
					if (checkedStr == "")
					{ 
					 	checkedStr = checkArr[i].value;
					}
					else 
					{	
						checkedStr = checkedStr + "," + checkArr[i].value;
					 }
						
			}
				
		}
	  var fdbObj = document.getElementById("fdbId");
      fdbObj.value = checkedStr;
	if(fdbObj.value!="")
	{
	  if (action=="approve")
	  {
		  document.feedback.action = "doApproveFeedbacks.php";
	  }
	  else
	  {
		 document.feedback.action = "deleteSelectedFeeds.php"; 
	  }
	  document.feedback.submit();
	}
	else
	{
			alert("Select atleast one checkbox.");
	}
}


function all_advert(action)
{
		var checkedStr="";
		var checkArr= document.getElementsByName("chkUser");
		
		for (var i = 0;i < checkArr.length; i++)
		{
			
			if(checkArr[i].checked)
			{
					if (checkedStr == "")
					{ 
					 	checkedStr = checkArr[i].value;
					}
					else 
					{	
						checkedStr = checkedStr + "," + checkArr[i].value;
					 }
						
			}
				
		}
	  var offersObj = document.getElementById("userId");
      offersObj.value = checkedStr;
	if(offersObj.value!="")
	{
	  if (action=="Approve")
	  {
		  document.ad.action = "doApproveAds.php";
	  }
	  else
	  {
		 document.ad.action = "deleteSelectedAds.php"; 
	  }
	  document.ad.submit();
	}
	else
	{
			alert("Select atleast one checkbox.");
	}
}
function show_page(action)
{
	if(action=="account")
	{
			if(document.links.profile.options[document.links.profile.selectedIndex].value=="My Biodata")
			{
				location.href = "edit_biodata.php";
			}
			else if(document.links.profile.options[document.links.profile.selectedIndex].value=="Search Profile")
			{
					location.href = "search_data.php";
			}
	}	
	else if(action=="register")
	{
			if(document.links.profile.options[document.links.profile.selectedIndex].value=="Register Profile")
			{
				location.href = "my_biodata.php";
			}
			else if(document.links.profile.options[document.links.profile.selectedIndex].value=="Search Profile")
			{
					location.href = "search_data.php";
			}
	}
	else if(action=="ad")
	{
			if(document.links.advertisement.options[document.links.advertisement.selectedIndex].value=="Place your Ad")
			{
				location.href = "free_ad.php";
			}
			else if(document.links.advertisement.options[document.links.advertisement.selectedIndex].value=="Search an Ad")
			{
					location.href = "search_ad.php";
			}
	}
}
function change_admin_password()
{
	var check = checkPasswordFields();
	if(check!=false)
	{
		document.change_admin_pwd.action="save_admin_password.php";
		document.change_admin_pwd.submit();
	}
}
function checkPasswordFields()
{
		if(document.change_admin_pwd.oldPwd.value=="")
		{
				alert("Enter your old password.");
				document.change_admin_pwd.oldPwd.focus();
				return false;
		}
		if(document.change_admin_pwd.newPwd.value=="")
		{
				alert("Enter your new password.");
				document.change_admin_pwd.newPwd.focus();
				return false;
		}
		if(document.change_admin_pwd.confirmPwd.value=="")
		{
				alert("Re-enter the password to confirm.");
				document.change_admin_pwd.confirmPwd.focus();
				return false;
		}
}

function view_member()
{
		var checkedStr="";
		var checkArr= document.getElementsByName("chkUser");
		
		for (var i = 0;i < checkArr.length; i++)
		{
			
			if(checkArr[i].checked)
			{
					if (checkedStr == "")
					{ 
					 	checkedStr = checkArr[i].value;
					}
					else 
					{	
						checkedStr = checkedStr + "," + checkArr[i].value;
					 }
						
			}
				
		}
	  var offersObj = document.getElementById("userId");
      offersObj.value = checkedStr;
	if(offersObj.value!="")
	{
		document.user.action = "deleteSelectedMembers.php"; 
	    document.user.submit();
	}
	else
	{
			alert("Select atleast one checkbox.");
	}
}

function send_email_sikh()
{
		var check = check_sikh_fields();
		if(check!=false)
		{
			
			document.email.action= "send_email_code.php";
			document.email.submit();
		}
}

function check_sikh_fields()
{
		if(document.email.from.value=="")
		{
				alert("Enter your email address.");
				document.email.from.focus();
				return false;
		}
		if(document.email.to.value=="")
		{
				alert("Enter to email address.");
				document.email.to.focus();
				return false;
		}
}
//FORGOT PASSWORD
function submit_forgotPwd()
{
	if(document.forgot_pwd.email.value=="")
	{
			alert("Enter your email address.");
			document.forgot_pwd.email.focus();
	}
	else
	{
			document.forgot_pwd.action="check_forgotpwd_details.php";
			document.forgot_pwd.submit();
	}
}

function profile_page(action)
{
		if(action=='account')
		{
				document.getElementById("profile_links").style.display = "inline";
				document.getElementById("ad_links").style.display = "none";
		}
		else if(action=='register')
		{
				document.getElementById("profile_links").style.display = "inline";
				document.getElementById("ad_links").style.display = "none";
		}
		else if(action=='ad')
		{
				document.getElementById("ad_links").style.display = "inline";
				document.getElementById("profile_links").style.display = "none";
				
//				document.getElementById("profile_links").style.display = "none";
		}
}

function set_display()
{
	//	document.getElementById("profile_links").style.display = "none";
//		document.getElementById("ad_links").style.display = "none";
}

function send_email()
{
		var check = check_mail_fields();
		if(check!=false)
		{
				document.email.submit();
		}
}

function check_mail_fields()
{
		if(document.email.to.value =="")
		{
				alert("Enter from value.");
				document.email.from.focus();
				return false;
		}
		if(document.email.to.value =="")
		{
				alert("Enter to value.");
				document.email.to.focus();
				return false;
		}
		if(document.email.message.value =="")
		{
				alert ("Enter message.");
				document.email.message.focus();
				return false;
		}
}

function send_mail(email)
{
		var check = check_mail();
		if(check!=false)
		{
				document.email.action="user_search_mail.php?to="+email;
				document.email.submit();
		}
}

function check_mail()
{
		if(document.email.title.value =="")
		{
				alert("Enter subject.");
				document.email.title.focus();
				return false;
		}
		if(document.email.message.value =="")
		{
				alert ("Enter message.");
				document.email.message.focus();
				return false;
		}
}


function admin_search_result()
{
		
		/*if(document.search_data.all_mems.checked==true)
		{
				document.search_data.action = "admin_search_results.php?type=all";
				document.search_data.submit();
		}
		else
		{*/
			var check = check_search_fields();
		
		if(check!=false)
		{
			 var country = document.search_data.country.options[document.search_data.country.selectedIndex].value;
					var city = document.search_data.city.value;
					var name = document.search_data.r_name.value;
					var from_age = document.search_data.from_age.value;
					var to_age = document.search_data.to_age.value;
					var gender = document.search_data.gender.options[document.search_data.gender.selectedIndex].value;
					
					if(gender=="male")
					{
							gender_flag = 0;
					}
					else if(gender=="female")
					{
							gender_flag = 1;
					}
					else
					{
							gender_flag=-1;
					}
					if(document.search_data.profession.options[document.search_data.profession.selectedIndex].value=="0")
				   {
					   	var profession = "";
				   }
				   else
				   {
					var profession = document.search_data.profession.options[document.search_data.profession.selectedIndex].value
				   }
					if (document.search_data.page.options[document.search_data.page.selectedIndex].value != "-Please Select-")
					{
						page = document.search_data.page.options[document.search_data.page.selectedIndex].value;
					}
					else
					{
						page = "";
					}
					if(document.search_data.page.options[document.search_data.page.selectedIndex].value!="-Please Select-")
					{
						sub_heading = document.search_data.page.options[document.search_data.page.selectedIndex].value;
					}
					else
					{
						sub_heading = "";
					}
					if(sub_heading=="Others")
					{
							others=document.search_data.others.value;;
					}
					else
					{
							others = "";
					}
					
					
				if(document.search_data.for_value.options[document.search_data.for_value.selectedIndex].value!="-Please Select-")
				{
					
					if(sub_heading=="Others")
					{
						if(document.search_data.others.value=="")
						{
								alert("Enter the value for other.");
								document.search_data.others.focus();
						}
						else
						{
							document.search_data.action = "admin_search_results.php?main_page=1&country="+country+"&city=" +city+"&from_age="+from_age+"&to_age="+to_age+"&gender="+gender_flag+"&profession="+ profession +"&page=" +page+"&for_value="+sub_heading+"&others=" + others+"&name=" + name;
							document.search_data.submit();
						}
					}
					else
					{
							sub_heading=document.search_data.for_value.options[document.search_data.for_value.selectedIndex].value;
						document.search_data.action = "admin_search_results.php?main_page=1&country="+country+"&city=" +city+"&from_age="+from_age+"&to_age="+to_age+"&gender="+gender_flag+"&profession="+ profession +"&page=" +page+"&for_value="+sub_heading+"&others=" + others+"&name=" + name;
						document.search_data.submit();
					}
				}
				else
				{
						
						document.search_data.action = "admin_search_results.php?main_page=1&country="+country+"&city=" +city+"&from_age="+from_age+"&to_age="+to_age+"&gender="+gender_flag+"&profession="+ profession +"&page=" +page+"&for_value="+sub_heading+"&others=" + others+"&name=" + name;
						document.search_data.submit();
				}
		}
		//}
}

function check_search_fields()
{
		/*if(document.search_data.country.options[document.search_data.country.selectedIndex].value=="-Select Country-")
		{
				alert("Select a country");
				document.search_data.country.focus();
				return false;
		}*/
		var count = 0;
		var blnFrom = false;
		var blnTo = false;
		if(document.search_data.from_age.value!="")
		{
			blnFrom = true;
			count =1;
		}
		if(document.search_data.to_age.value!="")
		{
			blnTo = true;
			count =2;
		}

		if((count >=1) && (count < 2))
		{
				if(!blnFrom)
				{
						alert("Enter the age from.");
						document.search_data.from_age.focus();
						return false;
				}
				if(document.search_data.from_age.value!="")
				{
					var from_age = document.search_data.from_age.value;
					var blnFlag =false;
					for(i=0;i<=from_age.length;i++)
					{	
						//alert(phone.charAt(i));
						if (isNaN(from_age.charAt(i)))
						{
							blnFlag = true;
							break;
						}
					}
					if(blnFlag==true)
					{
						alert("Enter a number for from age.");
						document.search_data.from_age.value="";
						document.search_data.from_age.focus();
						return false;
					}
				}
				
				if(!blnTo)
				{
						alert("Enter the age to.");
						document.search_data.to_age.focus();
						return false;
				}
				
		}
		if(document.search_data.to_age.value!="")
				{
					var to_age = document.search_data.to_age.value;
					var blnFlag =false;
					for(i=0;i<=to_age.length;i++)
					{	
						//alert(phone.charAt(i));
						if (isNaN(to_age.charAt(i)))
						{
							blnFlag = true;
							break;
						}
					}
					if(blnFlag==true)
					{
						alert("Enter a number for to age.");
						document.search_data.to_age.value="";
						document.search_data.to_age.focus();
						return false;
					}
				}
		
		
}


function search_send_mail()
{
		var checkedStr="";
		var checkArr= document.getElementsByName("chkUser");
		
		for (var i = 0;i < checkArr.length; i++)
		{
			
			if(checkArr[i].checked)
			{
					if (checkedStr == "")
					{ 
					 	checkedStr = checkArr[i].value;
					}
					else 
					{	
						checkedStr = checkedStr + "," + checkArr[i].value;
					 }
						
			}
				
		}
	  var searchObj = document.getElementById("userId");
      searchObj.value = checkedStr;
	if(searchObj.value!="")
	{
		document.user.action = "search_send_mail.php"; 
	    document.user.submit();
	}
	else
	{
			alert("Select atleast one checkbox.");
	}
}
function send_mail_search(action)
{
		var check = check_search_mail();
		if(check!=false)
		{
				if(action=="search")
				{
					document.user.action='send_search_mail.php';
				}
				else
				{
						document.user.action='feedback_mail.php';
				}
				document.user.submit();
		}
}
function check_search_mail()
{
		if(document.user.from.value=="")
		{
				alert("Enter from mail.");
				document.user.from.focus();
				return false;
		}
		if(document.user.subject.value=="")
		{
				alert("Enter subject.");
				document.user.subject.focus();
				return false;
		}
		if(document.user.message.value=="")
		{
				alert("Enter your message.");
				document.user.message.focus();
				return false;
		}
		
}
function submit_subject_form()
{
		if(document.subject.subName.value=="")
		{
				alert("Enter name of subject.");
				document.subject.subName.focus();
				
		}
		else
		{
				document.subject.action="save_subject_data.php";
				document.subject.submit();
		}
}
function getAllMessages()
{
		if(document.discussion.subject.options[document.discussion.subject.selectedIndex].value!="-Select-")
		{
			var subjectId = document.discussion.subject.options[document.discussion.subject.selectedIndex].value;
			document.discussion.subjectId.value = subjectId;
			document.discussion.action = "discussion.php";
			document.discussion.submit();
		}
}
function get_subject_name()
{
		if(document.discussion.subject.options[document.discussion.subject.selectedIndex].value!="-Select-")
		{
			var subjectId = document.discussion.subject.options[document.discussion.subject.selectedIndex].value;
			document.discussion.subId.value = subjectId;
			document.discussion.sub_name.value = document.discussion.subject.options[document.discussion.subject.selectedIndex].text;
			document.discussion.action = "subject_report.php";
			document.discussion.submit();
			
		}
}
function submit_message()
{
	
	if(document.msg.message.value=="")
	{
		alert("Enter message.");
		document.msg.message.focus();
	}
	else
	{
		document.msg.submit();
	}

}
function check_subject_value()
{
		if(document.discussion.subject.options[document.discussion.subject.selectedIndex].value=="-Select-")
		{
				alert("Enter name of subject.");
				document.discussion.subject.focus();
				
		}
		else
		{
				$subId = document.discussion.subject.options[document.discussion.subject.selectedIndex].value;
				document.discussion.action="add_message.php?subjectId=" + $subId;
				document.discussion.submit();
		}
}
function modify_subject()
{
		if(document.discussion.subjectName.value=="")
		{
				alert("Enter subject name.");
				document.discussion.subjectName.focus();
		}
		else
		{
				document.discussion.action="modify_subject.php";
				document.discussion.submit();
		}
}
function delete_subject()
{
		if(document.discussion.subject.options[document.discussion.subject.selectedIndex].value=="-Select Subject-")
		{
				alert("Select subject.");
				document.discussion.subject.focus();
		}
		else
		{
				document.discussion.action="delete_subject.php";
				document.discussion.submit();
		}
}
function submit_message_form()
{
		var check = checkMessageFields();
		if(check!=false)
		{
				document.message.action="messages_report.php";
				document.message.submit();
		}
}
function checkMessageFields()
{
		if(document.message.subject.options[document.message.subject.selectedIndex].value=="-Select Subject-")
		{
				alert("Select Subject.");
				document.message.subject.focus();
				return false;
		}
		if(document.message.users.options[document.message.users.selectedIndex].value=="-Select User-")
		{
				alert("Select user.");
				document.message.users.focus();
				return false;
		}
}

function get_subject_users()
{
		if(document.message.subject.options[document.message.subject.selectedIndex].value!="-Select Subject-")
		{
			var subjectId = document.message.subject.options[document.message.subject.selectedIndex].value;
			document.message.subId.value = subjectId;
			document.message.action = "manage_messages.php";
			document.message.submit();
		}
}
function getUserName()
{
		if(document.message.users.options[document.message.users.selectedIndex].value!="-Select Users-")
		{
			var subjectId = document.message.subject.options[document.message.subject.selectedIndex].value;
			document.message.subId.value = subjectId;
			
			var userId = document.message.users.options[document.message.users.selectedIndex].value;
			document.message.usrId.value=userId;
			
			document.message.action = "manage_messages.php";
			document.message.submit();
		}
}
function getSubjectMessage()
{
		if(document.message.msg.options[document.message.msg.selectedIndex].value!="-Select Message-")
		{
			var subjectId = document.message.subject.options[document.message.subject.selectedIndex].value;
			document.message.subId.value = subjectId;
			
			var userId = document.message.users.options[document.message.users.selectedIndex].value;
			document.message.usrId.value=userId;
			
			var msgId = document.message.msg.options[document.message.msg.selectedIndex].value;
			document.message.msgId.value=msgId;
			
			var msgText = document.message.msg.options[document.message.msg.selectedIndex].title;
			document.message.msgText.value=msgText;
			
			document.message.action = "manage_messages.php";
			document.message.submit();
		}
}
function delete_message()
{
		if(document.message.content.value=="")
		{
				alert("Select message");
				document.message.msgs.focus();
		}
		else
		{
				document.message.action="delete_messages.php";
				document.message.submit();
		}
}
function modify_message()
{
		if(document.message.content.value=="")
		{
				alert("Select message");
				document.message.msgs.focus();
		}
		else
		{
				document.message.action="modify_messages.php";
				document.message.submit();
		}
}
function getSelectedAd()
{
		var adId = document.ad.ads.options[document.ad.ads.selectedIndex].value;
		document.ad.adId.value = adId;
		document.ad.action="edit_free_ad.php";
		document.ad.submit();
}
function submit_del_ad()
{
		if(document.ad.ads.options[document.ad.ads.selectedIndex].value=="0")
		{
				alert("Select advertisement.");
				document.ad.ads.focus();
		}
		else
		{
				document.ad.action= "save_ad_data.php";
				document.ad.submit();
		}

}
function submit_feedback_form()
{
		var check = check_feedback_fields();
		if(check!=false)
		{
				document.feedback.action= "save_feedback_data.php";
				document.feedback.submit();
		}
}
function check_feedback_fields()
{
		if(document.feedback.name.value=="")
		{
				alert("Enter name.");
				document.feedback.name.focus();
				return false;
		}
		/*if(document.feedback.country.options[document.feedback.country.selectedIndex].value=="0")
		{
				alert("Select Country.");
				document.feedback.country.focus();
				return false;
		}
		if(document.feedback.city.value=="")
		{
				alert("Enter city.");
				document.feedback.city.focus();
				return false;
		}
		if(document.feedback.email.value=="")
		{
				alert("Enter your email.");
				document.feedback.email.focus();
				return false;
		}
		else
		{
				var mail = document.feedback.email.value;
				if(mail.search("@.")==-1)
				{
						alert("Entered email is invalid.");
						document.feedback.email.focus();
						return false;
				}
		}
		if(document.feedback.message.value=="")
		{
				alert("Enter feedback.");
				document.feedback.message.focus();
				return false;
		}*/
}
function submit_link_form()
{
		if(document.links.linktext.value=="")
		{
				alert("Enter link.");
				document.links.linktext.focus();
				return false;
		}
		else
		{
				document.links.action="save_link_data.php";
				document.links.submit();
		}
}
function modify_feedback(action)
{
	var checkedStr="";
		var checkArr= document.getElementsByName("optUser");
		var blnFlag = false;
		for (var i = 0;i < checkArr.length; i++)
		{
				if(checkArr[i].checked)
				{
					if (checkedStr == "")
					{ 
					 	checkedStr = checkArr[i].value;
					}
					else 
					{	
						checkedStr = checkedStr + "," + checkArr[i].value;
						if(action=="modify")
						{
								blnFlag = true;
								break;
								
						}
					 }
				}

		}
	  var fdbObj = document.getElementById("userId");
      fdbObj.value = checkedStr;
	  if(fdbObj.value!="")
	  {
		if(action=="modify")
		{
				
			if(!blnFlag)
			{
				document.feedback.action = "modify_feedback.php"; 
				document.feedback.submit();
			}
			else
			{
					alert("Select only one record to edit.");
			}
		}
		else if(action=="delete")
		{
				document.feedback.action = "deleteSelectedFeeds.php"; 
				document.feedback.submit();
		}
		else
		{
				document.feedback.action = "send_feedback_email.php"; 
				document.feedback.submit();
		}
	  }
	  else
	  {
			alert("Select a record first.");
	  }
	}
	
	function submit_modify_feedback()
	{
			if(document.feedback.name.value=="")
			{
					alert("Enter name.");
					document.feedback.name.focus();
					
			}
			else
			{
					document.feedback.action="update_feedback_data.php";
					document.feedback.submit();
			}
			
	}
	
	function submit_banner_form()
	{
			var check = check_banner_fields();
			if(check!=false)
			{
					document.banners.action="upload_banner_file.php";
					document.banners.submit();
			}
				
	}
	function check_banner_fields()
	{
			if(document.banners.bans.options[document.banners.bans.selectedIndex].value=="0")
			{
					alert("Select Banner number.");
					document.banners.bans.focus();
					return false;
			}
			if(document.banners.banner.value=="")
			{
					alert("Select banner file.");
					document.banners.bans.focus();
					return false;
			}
			if(document.banners.b_link.value=="")
			{
					alert("Enter banner link.");
					document.banners.b_link.focus();
					return false;
			}
	}
	function modify_data()
{
		var checkedStr="";
		var checkArr= document.getElementsByName("optLink");
		
		var blnFlag = false;
		for (var i = 0;i < checkArr.length; i++)
		{
			if(checkArr[i].checked)
			{
					
					 	checkedStr = checkArr[i].id;
						blnFlag = true;
						break;
			}
		}
		
	  if(blnFlag)
	  {
	  var offersObj = document.getElementById("linkId");
      offersObj.value = checkedStr;
	  if(offersObj.value!="")
		{
			document.links.action = "modify_links.php"; 
			document.links.submit();
		}
		
		
	  }
	  else
	  {
		  	alert("Select the record to modify.");
	  }
}

function submit_edit_link()
{
		if(document.links.linktext.value=="")
		{
				alert("Enter link.");
				document.links.linktext.focus();
				
		}
		else
		{
				document.links.action="modify_link_data.php";
				document.links.submit();
		}
}

function delete_search_member()
{
		var checkedStr="";
		var checkArr= document.getElementsByName("chkUser");
		
		for (var i = 0;i < checkArr.length; i++)
		{
			
			if(checkArr[i].checked)
			{
					if (checkedStr == "")
					{ 
					 	checkedStr = checkArr[i].value;
					}
					else 
					{	
						checkedStr = checkedStr + "," + checkArr[i].value;
					 }
						
			}
				
		}
	  var offersObj = document.getElementById("userId");
      offersObj.value = checkedStr;
	if(offersObj.value!="")
	{
		document.user.action = "deleteSearchedMembers.php"; 
	    document.user.submit();
	}
	else
	{
			alert("Select atleast one checkbox.");
	}
}

function approve_messages(action)
{
		var checkedStr="";
		var checkArr= document.getElementsByName("chkUser");
		
		for (var i = 0;i < checkArr.length; i++)
		{
			
			if(checkArr[i].checked)
			{
					if (checkedStr == "")
					{ 
					 	checkedStr = checkArr[i].value;
					}
					else 
					{	
						checkedStr = checkedStr + "," + checkArr[i].value;
					 }
						
			}
				
		}
	  var offersObj = document.getElementById("msgId");
      offersObj.value = checkedStr;
	if(offersObj.value!="")
	{
			if(action=="delete")
			{
				document.messages.action = "deleteSelectedMessages.php"; 
			}
			else
			{
					document.messages.action = "approveSelectedMessages.php"; 
			}
			    document.messages.submit();
	}
	else
	{
			alert("Select atleast one checkbox.");
	}
}

function get_country_code()
{

	var cnt=document.getElementById("country").value;
	if(cnt=="USA")
	{
		document.getElementById("country_code").value='+1';
	}
	if(cnt=="UK")
	{
		document.getElementById("country_code").value='+44';
	}
	if(cnt=="India")
	{
		document.getElementById("country_code").value='+91';
	}
	if(cnt=="Canada")
	{
		document.getElementById("country_code").value='+1';
	}
	if(cnt=="Australia")
	{
     document.getElementById("country_code").value='+61';
	 		
	}
	if(cnt=="Malaysia")
	{
	 document.getElementById("country_code").value='+60';	
		
	}
	
	if(cnt=="Germany")
	{
	 document.getElementById("country_code").value='+49';	
		
	}
	if(cnt=="NewZealand")
	{
	 document.getElementById("country_code").value='+64';	
		
	}
	if(cnt=="Italy")
	{
	 document.getElementById("country_code").value='+39';	
		
	}
	if(cnt=="Singapore")
	{
	 document.getElementById("country_code").value='+65';	
		
	}
	if(cnt=="HongKong")
	{
	 document.getElementById("country_code").value='+852';	
		
	}
	if(cnt=="UAE")
	{
	 document.getElementById("country_code").value='+971';	
		
	}
	if(cnt=="Thailand")
	{
	 document.getElementById("country_code").value='+66';	
		
	}
	if(cnt=="Sweden")
	{
	 document.getElementById("country_code").value='+46';	
		
	}
	if(cnt=="Norway")
	{
	 document.getElementById("country_code").value='+47';	
		
	}
	if(cnt=="France")
	{
	 document.getElementById("country_code").value='+33';	
		
	}
}