function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

//return NewWindow('slideshow.php','name','800','480','yes');

function ValidateForm()
{
	var spy_log = document.userform.log.value;
	var spy_user_pass = document.userform.pwd.value;
	var spy_email = document.userform.spy_email.value;
	var spy_first_name = document.userform.spy_first_name.value;
	var spy_last_name = document.userform.spy_last_name.value;
	var spy_city = document.userform.spy_city.value;
	var spy_state = document.userform.spy_state.value;
	var spy_country = document.userform.spy_birthday_month.value;

	
	if ((spy_email==null)||(spy_email=="") || echeck(spy_email)==false)
	{
		alert("Please Enter your Email")
		return false;
	}
	
	if (spy_log == null || spy_log == "")
	{
		alert("Please enter User Name");
		return false;
	}
	if ( spy_user_pass == null || spy_user_pass == "" )
	{
		alert("Please enter your Password");
		return false;
	}

	if (document.userform.terms_conditions.checked == false)
	{
    	alert("Please Agree with Terms and Conditions");
		return false;
	}
	if (document.userform.guardian_permission.checked == false)
	{
    	alert("Please Agree with age limit");
		return false;
	}

	return true;
}

function ValidateForm2()
{
	var spy_user_pass1 = document.userform.pwd1.value;
	var spy_user_pass2 = document.userform.pwd2.value;
	var spy_email = document.userform.spy_email.value;
	var spy_first_name = document.userform.spy_first_name.value;
	var spy_last_name = document.userform.spy_last_name.value;
	var spy_city = document.userform.spy_city.value;
	var spy_state = document.userform.spy_state.value;
	var spy_country = document.userform.spy_birthday_month.value;

	
	if ((spy_email==null)||(spy_email=="") || echeck(spy_email)==false)
	{
		alert("Please Enter your Email")
		return false;
	}
	
	if ( spy_user_pass1 != null && spy_user_pass1 != "" && spy_user_pass2 != null && spy_user_pass2 != "")
	{
		if (spy_user_pass1 != spy_user_pass2)
		{
			alert("You New Password not the same as Your Confirm Password");
			return false;
		}
	}

	return true;
}

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 Email")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid Email")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid Email")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid Email")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid Email")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid Email")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid Email")
		    return false
		 }

 		 return true					
}