function poporder(URL)
{

day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=yes,width=490,height=450,left = 0,top = 0');");
}


var lists=new Array();
var lists1=new Array();
var centers=new Array();
var emptycenters=new Array();
emptycenters[0]	= new Array('Choose','Choose');

function emptyList(box) 
{
	while (box.options.length) box.options[0] = null;
}

function fillList( box, arr ) 
{
	
	for ( i = 0; i < arr[0].length; i++ ) 
	{
		var getvalursplitcountry="";
		var getvalursplitcountry1="";
		var getvalursplit="";
		var getvalur="";
		var getvalur=arr[0][i];
		var getvalursplit=getvalur.split("_");
		var getvalursplitcountry=getvalursplit[0];
		var getvalursplitcountry1=getvalursplit[1];
		opton = new Option( getvalursplitcountry, arr[0][i+1] );
		
		if(getvalursplitcountry1=="yes"){
			objSelect=box; 
             //Create the optgroup and add to the array
            optgroup = document.createElement('optgroup');
            optgroup.label = getvalursplit[0];
			objSelect.appendChild(optgroup);
          //  optgroup.appendChild(option);
		}else{
		box.options[box.length] = opton;
		}
		i=i+1;
	}
	box.selectedIndex=0;
}

function changeList(box) 
{
	//alert(box.options[box.selectedIndex].value);
	//alert(lists[box.options[box.selectedIndex].value]);
	list = lists[box.options[box.selectedIndex].value];
	//alert(list);
	if(box.options[box.selectedIndex].value != "select" && box.options[box.selectedIndex].value != "Choose" && box.options[box.selectedIndex].value != "")
	{
		
		emptyList(box.form.varState);
		fillList(box.form.varState, list );
	}
}

// JavaScript Document
// ------------- This is Script For Admin Pages----------------------//



function joinstep3frmvalid() {
		 if (document.joinstep3frm.FileSelectPhoto.value=="")
		 { 
			 alert ("Please Upload your Profile photo ");
			 return false;
		 }
}

function forgotfrm_validation() {
		 if (document.forgotfrm.Username.value== "" )
		 { 
			 alert ("Please Enter your Username ");
			 document.forgotfrm.Username.focus();
			 return false;
		 }
	 if (document.forgotfrm.emalid.value== "" )
		 { 
			 alert ("Please Enter your Eamil address");
			 document.forgotfrm.emalid.focus();
			 return false;
		 }
	if (!validateEmail(document.forgotfrm.emalid.value,1,1)) 
	 {
	 document.forgotfrm.emalid.focus();
	 return false;
	 }
}


//script for login validation 
	function loginfrmvalid()
{
		 if (document.loginfrm.varUsername.value== "" )
		 { 
			 alert ("Please enter the User name");
			 document.loginfrm.varUsername.focus();
			 return false;
		 }
		  if (document.loginfrm.varEMail.value == "")
		 { 
			 alert ("Please enter the EMail Address ");
			 document.loginfrm.varEMail.focus();
			 return false;
		 }
		/* if (!validateEmail(document.loginfrm.varEMail.value,1,1)) 
		 {
		  document.loginfrm.varEMail.value="";
		 document.loginfrm.varEMail.focus();
		 return false;
		 }*/
}
//script for login validation 
function loginfrmvalid2()
{
		 if (document.loginfrmmain.varUsername.value== "" )
		 { 
			 alert ("Please enter the User name");
			 document.loginfrmmain.varUsername.focus();
			 return false;
		 }
		 if (document.loginfrmmain.varPassword.value== "" )
		 { 
			 alert ("Please enter the Password");
			document.loginfrmmain.varPassword.focus();
			 return false;
		 }
}

//script for about herfrm
function aboutfrmvalidation()
{
		 if (document.aboutfrm.varCountry.value== "" )
		 { 
			 alert ("Please select the Country of birth");
			 document.aboutfrm.varCountry.focus();
			 return false;
		 }
		 if (document.aboutfrm.varCountryRes.value== "" )
		 { 
			 alert ("Please select the Country of residence");
			document.aboutfrm.varCountryRes.focus();
			 return false;
		 }
		/* if (document.aboutfrm.varState.value=="Choose" )
		 { 
			 alert ("Please select the State");
			document.aboutfrm.varState.focus();
			 return false;
		 }*/
		  		/* if (document.aboutfrm.vartown.value== "" )
		 { 
			 alert ("Please enter the City/Town");
			document.aboutfrm.vartown.focus();
			 return false;
		 }*/
		 if (document.aboutfrm.varPostcode.value== "" )
		 { 
			 alert ("Please enter the postcode");
			document.aboutfrm.varPostcode.focus();
			 return false;
		 }
		
		/*   if (document.aboutfrm.vargender.value== "" )
		 { 
			 alert ("Please select the Gender");
			document.aboutfrm.vargender.focus();
			 return false;
		 }*/
		 	   if (document.aboutfrm.intbirthdate.value== "" )
		 { 
			 alert ("Please select the birth day date");
			document.aboutfrm.intbirthdate.focus();
			 return false;
		 }
		 	   if (document.aboutfrm.intbirthmonth.value== "" )
		 { 
			 alert ("Please select the birth day month");
			document.aboutfrm.intbirthmonth.focus();
			 return false;
		 }
		 	 	   if (document.aboutfrm.intbirthyear.value== "" )
		 { 
			 alert ("Please select the birth day year");
			document.aboutfrm.intbirthyear.focus();
			 return false;
		 }
		/*   if (document.aboutfrm.varCountryNation.value== "" )
		 { 
			 alert ("Please select the your ideal match's country of birth, or nationality");
			document.aboutfrm.varCountryNation.focus();
			 return false;
		 }
		    if (document.aboutfrm.varIdealCountryRes.value== "" )
		 { 
			 alert ("Please select the your ideal match's current country of residence");
			document.aboutfrm.varIdealCountryRes.focus();
			 return false;
		 }*/
}

//script for settnigs validation
function joinstepformvalidation()
{
         /*var  varYourwords= document.johnfrm2.varYourwords.value;
		 if ( varYourwords== "" )
		 { 
			 alert ("Please enter the your Profile Nickname/headline");
			 document.johnfrm2.varYourwords.focus();
			 return false;
		 }*/
         var  varPeoplegetknow= document.johnfrm2.varPeoplegetknow.value;
	
		 if ( varPeoplegetknow== "" )
		 { 
			 alert ("Please enter  the A few words about you!:");
			 document.johnfrm2.varPeoplegetknow.focus();
			 return false;
		 }
		 var knowwords = varPeoplegetknow.split(" ");
		 if((knowwords.length) < 20)
		 {
			alert("Your description about you must be in at least 20 words");
			document.johnfrm2.varPeoplegetknow.focus();
			return false;
		 }
		 
		 var  vardescriptideal= document.johnfrm2.vardescriptideal.value;
		 if ( vardescriptideal== "" )
		 { 
			 alert ("Please enter the Who are you looking for?");
			 document.johnfrm2.vardescriptideal.focus();
			 return false;
		 }
		 var whowords = vardescriptideal.split(" ");
		 if((whowords.length) < 20)
		 {
			alert("Please explain 'Who are you looking for' in at least 20 words");
			document.johnfrm2.vardescriptideal.focus();
			return false;
		 }
		  var  varPhotopicst= document.johnfrm2.varPhotopicst.value;
		 if (varPhotopicst== "" )
		 { 
			 alert ("Please select the Your Photos options");
			 document.johnfrm2.varPhotopicst.focus();
			 return false;
		 }
}

//script for settnigs validation
function joinformvalidation()
{
         var  varUsername= document.preferfrm.varUsername.value;
		 if ( varUsername== "" )
		 { 
			 alert ("Please enter the User name");
			 document.preferfrm.varUsername.focus();
			 return false;
		 }
   /*      var  varPassword= document.johnfrm.varPassword.value;
		 if ( varPassword== "" )
		 { 
			 alert ("Please enter  the Password");
			 document.johnfrm.varPassword.focus();
			 return false;
		 }
		 var varRePassword = document.johnfrm.varRePassword.value;
		 if (varRePassword == "" )
		 { 
			 alert ("Please enter Your Confirm Password");
			 document.johnfrm.varRePassword.focus();
			 return false;
		 }
		 if (varPassword != varRePassword)
		 { 
			 alert ("Password and Confirm Password must be same");
			 document.johnfrm.varRePassword.focus();
			 return false;
		 }*/
		 if (document.preferfrm.varEMail.value == "")
		 { 
			 alert ("Please enter the EMail Address ");
			 document.preferfrm.varEMail.focus();
			 return false;
		 }
		 if (!validateEmail(document.preferfrm.varEMail.value,1,1)) 
		 {
		  document.preferfrm.varEMail.value="";
		 document.preferfrm.varEMail.focus();
		 return false;
		 }
		 	/* if (document.johnfrm.varConfirmEMail.value == "")
		 { 
			 alert ("Please enter the Confirm EMail Address ");
			 document.johnfrm.varConfirmEMail.focus();
			 return false;
		 }
		 if (!validateEmail(document.johnfrm.varConfirmEMail.value,1,1)) 
		 {
		  document.johnfrm.varConfirmEMail.value="";
		 document.johnfrm.varConfirmEMail.focus();
		 return false;
		 }
		  if (document.johnfrm.varEMail.value != document.johnfrm.varConfirmEMail.value)
		 { 
			 alert ("Email and Confirm Email must be same");
			 document.johnfrm.varConfirmEMail.focus();
			 return false;
		 }*/
		 if (document.preferfrm.varFirstname.value == "")
		 { 
			 alert ("Please enter the First name ");
			 document.preferfrm.varFirstname.focus();
			 return false;
		 }
		 if (document.preferfrm.varLastname.value == "")
		 { 
			 alert ("Please enter the Last name ");
			 document.preferfrm.varLastname.focus();
			 return false;
		 }
		/* var varCountry= document.johnfrm.varCountry.value;
		 if (varCountry == "" )
		 { 
			 alert ("Please enter  the Country");
			 document.johnfrm.varCountry.focus();
			 return false;
		 }
		 var varCountryRes= document.johnfrm.varCountryRes.value;
		 if (varCountryRes== "" )
		 { 
			 alert ("Please enter  the country of residence");
			 document.johnfrm.varCountryRes.focus();
			 return false;
		 }	
		 var varState= document.johnfrm.varState.value;
		 if (varState== "" )
		 { 
			 alert ("Please enter  the State of residence");
			 document.johnfrm.varState.focus();
			 return false;
		 }	
		 		 var varCity= document.johnfrm.varCity.value;
		 if (varCity== "" )
		 { 
			 alert ("Please enter  the City ");
			 document.johnfrm.varCity.focus();
			 return false;
		 }	
		 var vartown= document.johnfrm.vartown.value;
		 if (vartown== "" )
		 { 
			 alert ("Please enter  the town ");
			 document.johnfrm.vartown.focus();
			 return false;
		 }	
		 		 var varPostcode= document.johnfrm.varPostcode.value;
		 if (varPostcode== "" )
		 { 
			 alert ("Please enter  the Postcode");
			 document.johnfrm.varPostcode.focus();
			 return false;
		 }	
		  var varIama= document.johnfrm.varIama.value;
		 if (varIama== "" )
		 { 
			 alert ("Please enter the I am a");
			 document.johnfrm.varIama.focus();
			 return false;
		 }
		var varSeeking= document.johnfrm.varSeeking.value;
		 if (varSeeking== "" )
		 { 
			 alert ("Please enter the Seeking");
			 document.johnfrm.varSeeking.focus();
			 return false;
		 }
		 if ( document.johnfrm.VarTermsCon.checked==false)
		 { 
			 alert ("Please check the Terms and conditions");
			 document.johnfrm.VarTermsCon.focus();
			 return false;
		 }*/
		/* if(type=="add"){
			 if ((document.johnfrm.varmypic.checked==false) && (document.johnfrm.varmyproduct.checked==false) )
			 { 
				 alert ("Please select atleast one option");
				 document.johnfrm.varmypic.focus();
				 return false;
			 }
		 }*/
}


// Valid Email  Script
function validateEmail(addr,man,db) {
	if (addr == '' && man) {
	   if (db) alert('Email address is mandatory');
	   return false;
	}
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
	   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
		  if (db) alert('Email address contains invalid characters');
		  return false;
	   }
	}
	for (i=0; i<addr.length; i++) {
	   if (addr.charCodeAt(i)>127) {
		  if (db) alert("Email address contains non ascii characters.");
		  return false;
	   }
	}

	var atPos = addr.indexOf('@',0);
	if (atPos == -1) {
	   if (db) alert('Email address must contain an @');
	   return false;
	}
	if (atPos == 0) {
	   if (db) alert('Email address must not start with @');
	   return false;
	}
	if (addr.indexOf('@', atPos + 1) > - 1) {
	   if (db) alert('Email address must contain only one @');
	   return false;
	}
	if (addr.indexOf('.', atPos) == -1) {
	   if (db) alert('Email address must contain a period in the domain name');
	   return false;
	}
	if (addr.indexOf('@.',0) != -1) {
	   if (db) alert('period must not immediately follow @ in email address');
	   return false;
	}
	if (addr.indexOf('.@',0) != -1){
	   if (db) alert('period must not immediately precede @ in email address');
	   return false;
	}
	if (addr.indexOf('..',0) != -1) {
	   if (db) alert('two periods must not be adjacent in email address');
	   return false;
	}
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
	   if (db) alert('invalid primary domain in email address');
	   return false;
	}
return true;
}


function validateno()

{
	
	if((event.keyCode<48) || (event.keyCode>58))
	{
		if(event.keyCode!=13 && event.keyCode!=46)
		{
			event.keyCode=0;
			alert("Enter Numeric Value");		
	}
	}
}


//script for ideal frm
function idealfrmvalidation()
{
			
		// 1 require at least one radio button be selected
		var radioSelected = false;
		for (i = 0;  i < document.idealfrm.varGenderfemale.length;  i++)
		{
			if (document.idealfrm.varGenderfemale[i].checked)
			radioSelected = true;
		}
		if (!radioSelected)
		{
			alert("Please any gender options.");
			return (false);
		}

		 if (document.idealfrm.vardescriptideal.value== "" )
		 { 
			 alert ("Please enter the ideal desciription");
			 document.idealfrm.vardescriptideal.focus();
			 return false;
		 }
}


function empvalidation(nameval1)
{
		// 1 require at least one radio button be selected
		var radioSelected = false;
		document.idealfrm.varstarsign[0].checked=false;

}

function empvalidation1(val,checkname)
{ 
  var len = document.forms[0].elements[checkname].length;
 
 if(val == 0)
  {
	   for(i=1; i<len; i++){
		  document.forms[0].elements[checkname][i].checked = false;   
	   }
  }else{
	   if(document.forms[0].elements[checkname][0].checked){
		  document.forms[0].elements[checkname][0].checked = false;   
	   }
  }
}

function myvoice_valid()
{
		if(document.myvoicefrm.varpin.value=="")
		{
			alert("Please Enter PIN");
			document.myvoicefrm.varpin.focus();
			return false;
		}
		if(document.myvoicefrm.varpubpermission.value==0)
		{
			if(document.myvoicefrm.txtadtext.value=="")
			{
				alert("Please Enter Ad text");
				document.myvoicefrm.txtadtext.focus();
				return false;
			}
		}
}

function selectradio(){
if(document.idealfrm.ChkPrimaryPhoto.checked==true){
document.idealfrm.RadioPhotoVisi[0].checked=true;
}
}
function selectradio2(val){
if(document.idealfrm.RadioPhotoVisi[0].checked==true){
document.idealfrm.ChkPrimaryPhoto.checked=true;
}else{
document.idealfrm.ChkPrimaryPhoto.checked=false;
}
}

function select_all_inbox(field,value,total){
	
//	alert(document.frm_mymailoutbox.USER.length);
	
//	len = document.frm_mymailoutbox.USER.length;
	if(total>1)
	{
	for (i = 0; i < total; i++) 
			{
				if(document.frm_mymailoutbox.selectall.checked==true)
				document.frm_mymailoutbox.USER[i].checked=true;
				else
				document.frm_mymailoutbox.USER[i].checked=false;
			}
	}
	else
	{
	if(document.frm_mymailoutbox.selectall.checked==true)
	document.frm_mymailoutbox.USER.checked=true;
	else
	document.frm_mymailoutbox.USER.checked=false;
	}
		
}

function select_all(field,value,total){
	
	//alert(document.frm_mail.chk_list.length);
	
	len = document.frm_mymailoutbox.chk_list.length;
	if(total>1)
	{
	for (i = 0; i < len; i++) 
			{
				if(document.frm_mymailoutbox.selectall.checked==true)
				document.frm_mymailoutbox.chk_list[i].checked=true;
				else
				document.frm_mymailoutbox.chk_list[i].checked=false;
			}
	}
	else
	{
	if(document.frm_mymailoutbox.selectall.checked==true)
	document.frm_mymailoutbox.chk_list.checked=true;
	else
	document.frm_mymailoutbox.chk_list.checked=false;
	}
		
}

function openwindow(field,value){
	
	//alert(document.frm_mymailoutbox.chk_list.length);
	//var len;
	len = document.frm_mymailoutbox.chk_list.length;
	//len=len+1;
	len2=0;
	//alert(len);
	for (i = 0; i < len; i++) 
			{
				var chkname	=	document.frm_mymailoutbox.chk_list[i].checked;
				//alert(chkname);
					
					if (chkname == false) 
						{
							len2 = len2 + 1;
							//alert(len2);
						}
						
			}
			//alert(len2);
			if(len == len2)
			{
				//alert(len2);
				alert("Please Select Atleast one Select box");
				return false;
			}
			
document.frm_mymailoutbox.action="mymailbox.php?task=inbox&fun=delete";
document.frm_mymailoutbox.submit();
}

function select_allblock(field,value,total){
	
//	alert(document.frm_mymailoutbox.USER.length);
	
	len = document.frm_mymailoutbox.USER.length;
	if(total>1)
	{
	for (i = 0; i < len; i++) 
			{
				if(document.frm_mymailoutbox.selectall.checked==true)
				document.frm_mymailoutbox.USER[i].checked=true;
				else
				document.frm_mymailoutbox.USER[i].checked=false;
			}
	}
	else
	{
	if(document.frm_mymailoutbox.selectall.checked==true)
	document.frm_mymailoutbox.USER.checked=true;
	else
	document.frm_mymailoutbox.USER.checked=false;
	}
		
}

function openwindowblock()
{
		len = document.frm_mymailoutbox.USER.length;
		for (i = 0; i < document.frm_mymailoutbox.USER.length; i++) 
		{
			//var chkname	=	document.frm_prospect.USER_[i].name;
			
			if(document.frm_mymailoutbox.USER[i].checked == true)
			{
				var Flag	=	false;
			}
		}
		
		if(Flag==true)
		{
			alert("Select atleast any one Member");
			document.frm_mymailoutbox.USER.value;
			return false;
		}

}
function openwindow_out(field,value){
	
	//alert(document.frm_mymailoutbox.chk_list.length);
	//var len;
	len = document.frm_mymailoutbox.chk_list.length;
	//len=len+1;
	len2=0;
	//alert(len);
	for (i = 0; i < len; i++) 
			{
				var chkname	=	document.frm_mymailoutbox.chk_list[i].checked;
				//alert(chkname);
					
					if (chkname == false) 
						{
							len2 = len2 + 1;
							//alert(len2);
						}
						
			}
			//alert(len2);
			if(len == len2)
			{
				//alert(len2);
				alert("Please Select Atleast one Select box");
				return false;
			}
			
document.frm_mymailoutbox.action="mymailbox.php?task=outbox&funout=deleteout";
document.frm_mymailoutbox.submit();
}


function openwindow_trash(field,value){
	
	//alert(document.frm_mymailoutbox.chk_list.length);
	//var len;
	len = document.frm_mymailoutbox.chk_list.length;
	//len=len+1;
	len2=0;
	//alert(len);
	for (i = 0; i < len; i++) 
			{
				var chkname	=	document.frm_mymailoutbox.chk_list[i].checked;
				//alert(chkname);
					
					if (chkname == false) 
						{
							len2 = len2 + 1;
							//alert(len2);
						}
						
			}
			//alert(len2);
			if(len == len2)
			{
				//alert(len2);
				alert("Please Select Atleast one Select box");
				return false;
			}
			
document.frm_mymailoutbox.action="mymailbox.php?task=trashbox&funtrash=deletetrash";
document.frm_mymailoutbox.submit();
}



function selectvideo(){
if(document.idealfrm.ChkPrimaryVideo.checked==true){
document.idealfrm.RadioPhotoVideo[0].checked=true;
}
}
function selectradio2(val){
if(document.idealfrm.RadioPhotoVideo[0].checked==true){
document.idealfrm.ChkPrimaryVideo.checked=true;
}else{
document.idealfrm.ChkPrimaryVideo.checked=false;
}
}

function topic_validation(){
	 if(document.frm_topic.title.value == "")
	{
		alert("Please enter the title of the forum topic.");
		document.frm_topic.title.focus();
		return false;
	}
	 if(document.frm_topic.topic.value == "")
	{
		alert("Please enter the topic description.");
		document.frm_topic.topic.focus();
		return false;
	}
	return true;
}
function searchres(){
	 if(document.searchfrm.vargender.value == "")
	{
		alert("Please select the I am a.");
		document.searchfrm.vargender.focus();
		return false;
	}
}




//script for settnigs validation
function joinformvalidationbasic() {
	var v=document.getElementById('email_address');
	if (v.value== ""){ 
		alert ("Please enter the EMail Address ");
		v.focus();
		return false;
	}
	v=document.getElementById('password');
	if (v.value == ""){ 
		alert ("Please enter the Password");
		v.focus();
		return false;
	} 
	v=document.getElementById('cpass');
	if (v.value == ""){ 
		alert ("The password is not confirm");
		v.focus();
		return false;
	} else {
		if (document.getElementById('password').value!=v.value) {
			alert ("The password is not confirm");
			v.focus();
			return false;
		}
	}
	v=document.getElementById('varSeeking');
	if (v.selectedIndex==0){ 
		alert ("Please select the orientation");
		v.focus();
		return false;
	} 
	v=document.getElementById('varCountryRes');
	if (v.selectedIndex==0){ 
		alert ("Please select the country");
		v.focus();
		return false;
	} 
	v=document.getElementById('varState');
	if (v.selectedIndex==0){ 
		alert ("Please select the state/county");
		v.focus();
		return false;
	} 
	v=document.getElementById('varPostcode');
	if (v.value==''){ 
		alert ("Please enter the Postcode");
		v.focus();
		return false;
	} 
	if (document.getElementById('terms_and_conditions').checked==false){ 
		alert ("Please check the Terms and conditions");
		return false;
	}	
}

function nextstep(value)
{
	if(value == 1)
   document.getElementById("photoupload").style.display = "block";
   else 
   document.getElementById("photoupload").style.display = "none";
}