function ValidateNo( NumStr, String ) 
{
 		for( var Idx = 0; Idx < NumStr.length; Idx ++ )
 		{
			 var Char = NumStr.charAt( Idx );
			 var Match = false;

				for( var Idx1 = 0; Idx1 < String.length; Idx1 ++) 
				{
					 if( Char == String.charAt( Idx1 ) ) 
					 Match = true;
				}

				if ( !Match ) 
					return false;
 		}

		return true;
}

function Validate1( )
{
	var QuickSearch = document.forms[ 0 ];
	//var FINALAGE = quicksearch.ageto.value - quicksearch.agefrm.value;
	var stAge = 0, endAge = 0;

 	if( QuickSearch.AGEFRM.value == "" )
	{
		alert("Enter age range");
		QuickSearch.AGEFRM.focus();
		return false;
	}
	else if(!ValidateNo(QuickSearch.AGEFRM.value,"1234567890"))
	{
		alert("Invalid age range");
		QuickSearch.AGEFRM.focus();
		return false;
	}
	else if( QuickSearch.AGETO.value == "" )
	{
		alert("Enter age range");
		QuickSearch.AGETO.focus();
		return false;
	}
	else if(!ValidateNo(QuickSearch.AGETO.value,"1234567890"))
	{
		alert("Invalid age range");
		QuickSearch.AGETO.focus();
		return false;
	}
	
	stAge = parseInt( QuickSearch.AGEFRM.value );
		if ( stAge < 18 || stAge > 70 )
		{
			alert( "Invalid Age " +  QuickSearch.AGEFRM.value + ".  Minimum age allowed is 18 and maximum age is 70" );
			QuickSearch.AGEFRM.focus( );
			return false;
		}
		
	endAge = parseInt( QuickSearch.AGETO.value );
	if ( endAge < 18 || endAge > 70 )
		{
			alert( "Invalid Age " +  QuickSearch.AGETO.value + ".  Minimum age allowed is 18 and maximum age is 70" );
			QuickSearch.AGETO.focus( );
			return false;
		}

	if ( stAge != 0 && endAge < stAge )
		{
			alert( "Invalid age range. " + stAge + " to " + endAge );
			QuickSearch.AGEFRM.focus( );
			return false;
		}
	
/*	if ( !QuickSearch.GENDER[0].checked && !QuickSearch.GENDER[1].checked)
	{
		alert( "Please select Gender" );
		QuickSearch.GENDER[0].focus( );
		return false;
	}*/

		// Check Age
	if ( QuickSearch.AGEFRM.value != "" && !ValidateNo( QuickSearch.AGEFRM.value, "0123456789" ) )
	{
		alert("Invalid Age " + QuickSearch.AGEFRM.value);
		QuickSearch.AGEFRM.focus( );
		return false;
	}
	else if ( QuickSearch.AGEFRM.value != "" )
	{
		stAge = parseInt( QuickSearch.AGEFRM.value );
		if ( stAge < 18 || stAge > 70 )
		{
			alert( "Invalid Age " +  QuickSearch.AGEFRM.value + ".  Minimum age allowed is 18 and maximum age is 70" );
			QuickSearch.AGEFRM.focus( );
			return false;
		}
	}

	if( QuickSearch.AGETO.value != "" && !ValidateNo( QuickSearch.AGETO.value, "0123456789" ) )
	{
		alert("Invalid Age " + QuickSearch.AGETO.value);
		QuickSearch.AGETO.focus( );
		return false;
	}
	else if ( QuickSearch.AGETO.value != "" )
	{
		endAge = parseInt( QuickSearch.AGETO.value );
		if ( endAge < 18 || endAge > 70 )
		{
			alert( "Invalid Age " +  QuickSearch.AGETO.value + ".  Minimum age allowed is 18 and maximum age is 70" );
			QuickSearch.AGETO.focus( );
			return false;
		}

		if ( stAge != 0 && endAge < stAge )
		{
			alert( "Invalid age range. " + stAge + " to " + endAge );
			QuickSearch.AGEFRM.focus( );
			return false;
		}
	}
	return true;
}

function Validate2()
{	
	if ( document.MemLogin.username.value == "" )
	{
		alert( "Please Enter Your USERNAME." );
		document.MemLogin.username.focus();
		return false;
	}
	if ( document.MemLogin.password.value == "" )
	{
		alert( "Please Enter Your PASSWORD." );
		document.MemLogin.password.focus();
		return false;
	}
	
	return true;
}

function ValidateEmail( Email )
{
	var atCharPresent = false;
	var dotPresent = false;

	for ( var Idx = 0; Idx < Email.length; Idx++ )
	{
		if ( Email.charAt ( Idx ) == '@' )
		atCharPresent = true;
		if ( Email.charAt ( Idx ) == '.' )
		dotPresent = true;
	}

	if ( !atCharPresent || !dotPresent )
	return false;

	return true;
}


function Validate3()
{	
	if ( document.MemLogin.EMAIL.value == "" )
	{
		alert( "Please Enter Your EMAIL." );
		document.MemLogin.EMAIL.focus();
		return false;
	}
	if ( !ValidateEmail( document.MemLogin.EMAIL.value ) )
	{
		alert( "Enter a valid e-mail ID." + document.MemLogin.EMAIL.value );
		document.MemLogin.EMAIL.focus( );
				bb='N';
		return false;
	}
	for ( var Idx = 0; Idx < document.MemLogin.EMAIL.value.length; Idx++ )
	{
		if ( document.MemLogin.EMAIL.value.charAt(Idx) == '	'
		|| document.MemLogin.EMAIL.value.charAt(Idx) == ' '
		|| document.MemLogin.EMAIL.value.charAt(Idx) == ','
		|| document.MemLogin.EMAIL.value.charAt(Idx) == '/'
		|| document.MemLogin.EMAIL.value.charAt(Idx) == '\\'
		|| document.MemLogin.EMAIL.value.charAt(Idx) == ';' )
		{
			alert( "Blank spaces or other invalid characters are not allowed in the e-mail ID.\nPlease enter only one e-mail ID." );
			document.MemLogin.EMAIL.focus( );
					bb='N';
			return false;
		}
	}	
	return true;
}


function del()
{
			for( i=1; i <= document.form1.loop.value; i++ )
			{
				if(document.getElementById(i).checked == true) 
				{
					var delflag = 1;
				}
			
				
			}
			if(delflag == 1)
			{
				input_box=confirm("Are you sure you want to delete the selected messages?");
				if (input_box==true)
				{
					document.forms[0].method="POST";
					document.forms[0].action="dm_inbox.php";
					document.forms[0].submit();
					return true;
				}
			}
			else
			{
				alert("Select any mail to delete");// Output when Cancel is clicked
				//return false;
			}
		
}

function delmess()
{
				input_box=confirm("Are you sure you want to delete the selected messages?");
				if (input_box==true)
				{
					document.form2.submit();
					return true;
				}
					
}

function IsEmpty(obj, obj_type)
{
	if (obj_type == "text" || obj_type == "password" || obj_type == "textarea" || obj_type == "file")	{
		var objValue;
		
		objValue = obj.value.replace(/\s+$/,"");
		
		if (objValue.length == 0) {
			obj.focus();
			return true;
		} else {
			return false;
		}
	} else if (obj_type == "select") {
		for (i=0; i < obj.length; i++) {
			if (obj.options[i].selected) {
				if(obj.options[i].value == "") {
					obj.focus();
					return true;
				} else {
					return false;
				}
			}
			
		}
		return true;	
	} else if (obj_type == "radio" || obj_type == "checkbox") {
		if (!obj[0] && obj) {
			if (obj.checked) {
				return false;
			} else {
				obj.focus();
				return true;	
			}
		} else {
			for (i=0; i < obj.length; i++) {
				if (obj[i].checked) {
					return false;
				}
			}
			obj[0].focus();
			return true;
		}
	} else {
		return false;
	}
}


function restore()
{
		
		for( i=1; i <= document.form1.loop.value; i++ )
		{
			if(document.getElementById(i).checked == true) 
			{
				var delflag = 1;
			}
		
			
		}
		if(delflag == 1)
		{
			input_box=confirm("Are you sure you want to Restore the selected messages?");
			if (input_box==true)
			{
				document.forms[0].method="POST";
				document.forms[0].action="dm_trash.php";
				document.forms[0].submit();
				return true;
			}
		}
		else
		{
			alert("Select any mail to restore");	
			// Output when Cancel is clicked
			//return false;
		}
}

function resdel()
{
		for( i=1; i <= document.form1.loop.value; i++ )
		{
			if(document.getElementById(i).checked == true) 
			{
				var delflag = 1;
			}
		
			
		}
		if(delflag == 1)
		{
			input_box=confirm("Are you sure you want to delete the selected messages?");
			if (input_box==true)
			{
				document.forms[0].method="POST";
				document.forms[0].action="dm_trash.php?flg=d";
				document.forms[0].submit();
				return true;
			}
		}
		else
		{
			alert("Select any mail to delete");
			// Output when Cancel is clicked
			//return false;
		}
}

function sentdel()
{
		for( i=1; i <= document.form1.loop.value; i++ )
		{
			if(document.getElementById(i).checked == true) 
			{
				var delflag = 1;
			}
		
			
		}
		if(delflag == 1)
		{
			input_box=confirm("Are you sure you want to delete the selected messages?");
			if (input_box==true)
			{
				document.forms[0].method="POST";
				document.forms[0].action="dm_sent.php";
				document.forms[0].submit();
				return true;
			}
		}
		else
		{
			alert("Select any mail to delete");
			// Output when Cancel is clicked
			//return false;
		}
}


function deladdbk()
{
		input_box=confirm("Are you sure you want to delete the selected member ?");
		if (input_box==true)
		{
			document.forms[0].method="POST";
			document.forms[0].action="dm_address.php";
			document.forms[0].submit();
			return true;
		}
		else
		{
			// Output when Cancel is clicked
			//return false;
		}
}


function fun_unhide()
	{
		if(form1.PHTPROTECT[2].checked)
		{
			document.form2.USERNAME.enabled=true;			
		}
		return true;
	}

function HaveChildie()
	{
		if(MatriForm.MARITAL_STATUS[0].checked)
		{
			document.MatriForm.CHILDREN.disabled=true;
			document.MatriForm.CHILDREN.selected=false;
			document.MatriForm.CHILDREN.value=100;
			document.MatriForm.CHILD_LIVING[0].disabled=true;
			document.MatriForm.CHILD_LIVING[1].disabled=true;
			document.MatriForm.CHILD_LIVING[0].checked=false;
			document.MatriForm.CHILD_LIVING[1].checked=false;

		}
		else
		{
			document.MatriForm.CHILDREN.disabled=false;
			document.MatriForm.CHILDREN.selected=true;
			document.MatriForm.CHILD_LIVING[0].disabled=false;
			document.MatriForm.CHILD_LIVING[1].disabled=false;
		}
		return true;
	}

function HaveChildnp()
{
	if (MatriForm.CHILDREN.selectedIndex=="1")
		{
			document.MatriForm.CHILD_LIVING[0].disabled=true;
			document.MatriForm.CHILD_LIVING[1].disabled=true;
		}
	else
		{
			document.MatriForm.CHILD_LIVING[0].disabled=false;
			document.MatriForm.CHILD_LIVING[1].disabled=false;
		}
	return true;
}

/*function HaveChildnp(hc1)
{
		//alert("hi");
		var hc2=hc1;
		if(document.MatriForm.MARITAL_STATUS.options[document.MatriForm.MARITAL_STATUS.selectedIndex].value == 1)
		{
				hc2.selected=false;
		}
		var mtt=hc1;
		if(mtt.options[mtt.selectedIndex].value == 0)
		{
				document.MatriForm.CHILDREN.selected=false;
				document.MatriForm.CHILD_LIVING[0].disabled=true;
				document.MatriForm.CHILD_LIVING[1].disabled=true;
				document.MatriForm.CHILD_LIVING[0].checked=false;
				document.MatriForm.CHILD_LIVING[1].checked=false;

		}
		else
		{
				document.MatriForm.CHILDREN.selected=true;
				document.MatriForm.CHILD_LIVING[0].disabled=false;
				document.MatriForm.CHILD_LIVING[1].disabled=false;
		}
		return false;

}

*/
function reply()
{
	document.forms[0].method="POST";
	document.forms[0].submit();
	return true;
}

function forward()
{
	document.forms[0].action="dm_forward.php";
	document.forms[0].method="POST";
	document.forms[0].submit();
	return true;
}

function fun_submit()
{
	document.forms[0].action="dm_myprofile.php?act=edit&sub=y";
	document.forms[0].method="POST";
	document.forms[0].submit();
	return true;
}

function fun_appsubmit()
{
	document.forms[0].action="dm_myappear.php?act=edit&sub=y";
	document.forms[0].method="POST";
	document.forms[0].submit();
	return true;
}

function fun_lifesubmit()
{
	document.forms[0].action="dm_mylife.php?act=edit&sub=y";
	document.forms[0].method="POST";
	document.forms[0].submit();
	return true;
}

function fun_submit1()
{
	document.forms[0].action="dm_mydesc.php?act=edit&sub=y";
	document.forms[0].method="POST";
	document.forms[0].submit();
	return true;
}

function fun_submit2()
{
	document.forms[0].action="dm_mypersonal.php?act=edit&sub=y";
	document.forms[0].method="POST";
	document.forms[0].submit();
	return true;
}

function fun_fillsubmit()
{
		if(isNaN(document.ff.AGEFROM.value))
		{
			alert("Only numbers are allowed");
			document.ff.AGEFROM.focus();
			return false;
		}
		else if(isNaN(document.ff.AGETO.value))
		{
			alert("Only numbers are allowed");
			document.ff.AGETO.focus();
			return false;
		}
		else
		{
	/*		if(ff.AGEFROM.value<18)
			{
				alert("Below Age Group should not be less then 18");
				ff.AGEFROM.focus();
				return false;
			}*/
			if((document.ff.AGEFROM.value) > (document.ff.AGETO.value))
			{
				alert("Below Age Group should be less than Above Age Group");
				document.ff.AGEFROM.focus();
				return false;
			}
			else
			{
				for(var i = 0;i < document.ff.C1.length;i++)
				{
				document.ff.C1.options[i].selected = true;
				}
			document.forms[0].action="dm_filter.php?STAG=Y";
			document.forms[0].method="POST";
			document.forms[0].submit();
				return true;
			}
		}
return true;
}

function SelectAllList(CONTROL)
{
	for(var i = 0;i < CONTROL.length;i++)
	{
	CONTROL.options[i].selected = true;
	}
}

function fun_filladdsubmit()
{
	if(fm.NAME.value=="")
	{
		alert ("Enter Username/Id");
		fm.NAME.focus();
		return false
	}
	else
	{
	document.forms[0].action="dm_block.php?STAT=Y";
	document.forms[0].method="POST";
	document.forms[0].submit();
	}
	return true;
}

function fun_partsubmit()
{
	document.forms[0].action="dm_mypartner.php?act=edit&STAT=Y";
	document.forms[0].method="POST";
	document.forms[0].submit();
	return true;
}

function fun_factsubmit()
{
	document.forms[0].action="dm_myfunfacts.php?act=edit&STAT=Y";
	document.forms[0].method="POST";
	document.forms[0].submit();
	return true;
}

function fun_extrasubmit()
{
	document.forms[0].action="dm_extras.php?STAT=Y";
	document.forms[0].method="POST";
	document.forms[0].submit();
	return true;
}

function del1()
{
		
		agree=confirm("Are you sure you want to delete the Blocked profile?");
		if (agree==true)
		{
			document.forms[0].method="POST";
			document.forms[0].action="dm_filter.php";
			document.forms[0].submit();
			return true;
		}
		else
		{
			// Output when Cancel is clicked
			//return false;
		}
}

function fun_check(form1)
{			
	var i;
	if(document.form1.check1.checked== true)
	{		
		for( i=1; i <= document.form1.loop.value; i++ )
		{
			document.getElementById(i).checked = true;
			
		}
	}
	else
	{
		for( i=1; i <= document.form1.loop.value; i++ )
		{
			document.getElementById(i).checked = false;
		}
	}
}

function fun_disable(form1)
{			
	if(document.getElementById(1).checked == true)
	{		
		document.getElementById(6).disabled = true;
		document.MatriForm.CHILD_LIVING[0].disabled=true;
		document.MatriForm.CHILD_LIVING[1].disabled=true;
		document.MatriForm.CHILD_LIVING[0].checked=false;
		document.MatriForm.CHILD_LIVING[1].checked=false;
	}
	
}

function fun_enable(form1)
{			
	if(document.getElementById(2).checked == true)
	{		
		document.getElementById(6).disabled = false;
	}
	if(document.getElementById(3).checked == true)
	{		
		document.getElementById(6).disabled = false;
	}
	if(document.getElementById(4).checked == true)
	{		
		document.getElementById(6).disabled = false;
	}
	if(document.getElementById(5).checked == true)
	{		
		document.getElementById(6).disabled = false;
	}
		
}

function unblockpop(theURL) 
{
window.open(theURL, 'Unblock', 'fullscreen=no, scrollbars=no, width=450,height=110');
}

function sendsmilpop(theURL) 
{
window.open(theURL, 'sendsmile', 'fullscreen=no, scrollbars=no, width=400,height=360');
}

function add_fav_check()
{
	if(document.fm1.FAV_UID.value == "")
	{
		alert ("Enter Username/Id");
		document.fm1.FAV_UID.focus();
		return false;
	}
	return true;
}