function openWindow(id){
	window.open("download.php?id="+id);	
}

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}
function echeck(str) {
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID");
		   return false;
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID");
		   return false;
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID");
		    return false;
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
}
function validate_nsform(){
	var f = document.nsform.email;
	if ( ( f.value == null ) || ( f.value == "" ) )
		{
			alert("Please Enter Email address!");
			f.focus();
			return false;
		}
		if ( echeck(f.value) == false )
		{
			f.value = "";
			f.focus();
			return false;
		}
}
function validate_registerfrm(){
	if ( document.registerfrm.name.value == '' ){
		alert("Please Enter Name");
		document.registerfrm.name.focus();
		return false;		
	}
	if ( document.registerfrm.password.value == '' ){
		alert("Please Enter password");
		document.registerfrm.password.focus();
		return false;		
	}
	var f = document.registerfrm.email;
	if ( ( f.value == null ) || ( f.value == "" ) )	{
	    alert("Please Enter Email address!");
		f.focus();
		return false;
	}
	if ( echeck(f.value) == false )
	{
	    f.value = "";
		f.focus();
		return false;
	}
	if(document.registerfrm.country.value == ""){
		alert("Please Select Country");
		document.registerfrm.country.focus();
		return false;
	}
	if ( document.registerfrm.city.value == "" ){
		alert("Please Enter City");
		document.registerfrm.city.focus();
		return false;		
	}
	
	var a="";
  	for (var i=0; i < document.registerfrm.gender.length; i++)
  	{	
		if (document.registerfrm.gender[i].checked)
    	{
		  a = 1;
    	} 
  	}
 	if ( a == "" ) 
  	{
   		alert("Please Select Gender.");
		return false;
 	}
	/*if ( document.registerfrm.age.value == "" ){
		alert("Please Enter Age");
		document.registerfrm.age.focus();
		return false;		
	}*/
	if(document.registerfrm.about_you.value == ""){
		alert("Please Enter About You");
		document.registerfrm.about_you.focus();
		return false;
	}
	
	var binal = document.registerfrm.elements['where_u[]'];
	var dinky = 0;
	for (var i=0;i<binal.length;i++)
	{
		 if (binal[i].selected)
		 {
			dinky += 1;	
		 }
	}
	if(dinky==0 )
	{
		alert("Please select Why Are You Here");
		binal[0].focus();
		return false;
	} 
	
	var chks = document.registerfrm.elements['interested[]'];
	var chkservice = 0;
	for (var i=0;i<chks.length;i++)
	{
		 if (chks[i].checked)
		 {
			chkservice += 1;	
		 }
	}
	if(chkservice==0 )
	{
		alert("Please select Interested in");
		chks[0].focus();
		return false;
	} 
}

function validate_loginfrm() {
	if ( document.loginfrm.uname.value == '' ){
		alert("Please Enter User Name");
		document.loginfrm.uname.focus();
		return false;		
	}
	if ( document.loginfrm.password.value == '' ){
		alert("Please Enter password");
		document.loginfrm.password.focus();
		return false;		
	}
}

function validate_forgot_passwordfrm() {
		var f = document.forgot_passwordfrm.email;
		if ( ( f.value == null ) || ( f.value == "" ) )	{
			alert("Please Enter Email address!");
			f.focus();
			return false;
		}
		if ( echeck(f.value) == false )
		{
			f.value = "";
			f.focus();
			return false;
		}
}
function validate_editprofilefrm(){
	if ( document.editprofilefrm.password.value == '' ){
		alert("Please Enter password");
		document.editprofilefrm.password.focus();
		return false;		
	}
	var f = document.editprofilefrm.email;
	if ( ( f.value == null ) || ( f.value == "" ) )	{
	    alert("Please Enter Email address!");
		f.focus();
		return false;
	}
	if ( echeck(f.value) == false )
	{
	    f.value = "";
		f.focus();
		return false;
	}
	if(document.editprofilefrm.country.value == ""){
		alert("Please Select Country");
		document.editprofilefrm.country.focus();
		return false;
	}
	if ( document.editprofilefrm.city.value == "" ){
		alert("Please Enter City");
		document.editprofilefrm.city.focus();
		return false;		
	}
	
	var a="";
  	for (var i=0; i < document.editprofilefrm.gender.length; i++)
  	{	
		if (document.editprofilefrm.gender[i].checked)
    	{
		  a = 1;
    	} 
  	}
 	if ( a == "" ) 
  	{
   		alert("Please Select Gender.");
		return false;
 	}
	/*if ( document.editprofilefrm.age.value == "" ){
		alert("Please Enter Age");
		document.editprofilefrm.age.focus();
		return false;		
	}*/
	if(document.editprofilefrm.about_you.value == ""){
		alert("Please Enter About You");
		document.editprofilefrm.about_you.focus();
		return false;
	}
	
	var binal = document.editprofilefrm.elements['where_u[]'];
	var dinky = 0;
	for (var i=0;i<binal.length;i++)
	{
		 if (binal[i].selected)
		 {
			dinky += 1;	
		 }
	}
	if(dinky==0 )
	{
		alert("Please select Why Are You Here");
		binal[0].focus();
		return false;
	} 
	
	var chks = document.editprofilefrm.elements['interested[]'];
	var chkservice = 0;
	for (var i=0;i<chks.length;i++)
	{
		 if (chks[i].checked)
		 {
			chkservice += 1;	
		 }
	}
	if(chkservice==0 )
	{
		alert("Please select Interested in");
		chks[0].focus();
		return false;
	} 

}
     // contact me form validation
	 
	 
function validate_contactmefrm() {
	if ( document.contactmefrm.name.value == '' ){
		alert("Please Enter  Name");
		document.contactmefrm.name.focus();
		return false;		
	}
	if ( document.contactmefrm.phone.value == '' ){
		alert("Please Enter Phone Number");
		document.contactmefrm.phone.focus();
		return false;		
	}
	var f = document.contactmefrm.email;
	if ( ( f.value == null ) || ( f.value == "" ) )
		{
			alert("Please Enter Email address!");
			f.focus();
			return false;
		}
		if ( echeck(f.value) == false )
		{
			f.value = "";
			f.focus();
			return false;
		}
	 }
