﻿// JScript File
function openWindowDetails(location, width, height)
{
	myLoc = encodeURI(location)
  	window.open(myLoc, 'win1', 'width=' + width + ',height=' + height);
}

function openWindow(location, width, height)
{
  	window.open(location, 'win1', 'width=' + width + ',height=' + height);
}

function openWindowResize(location, width, height)
{
  	window.open(location, 'win1', 'width=' + width + ',height=' + height + ', resizable, scrollbars=yes');
}

/**
 * DHTML email validation script.
 */
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("Please enter a valid email address.")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please enter a valid email address.")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please enter a valid email address.")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please enter a valid email address.")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please enter a valid email address.")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please enter a valid email address.")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Please enter a valid email address.")
		    return false
		 }

 		 return true					
	}

function ValidateForm(url){
	var emailID=document.aspnetForm.ctl00$tbJoinEmail
	
	if ((emailID.value==null)||(emailID.value=="")||(emailID.value=="name@email.com")){
		alert("Please enter a valid email address.")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	else
	{
	    emailID.value=document.aspnetForm.ctl00$tbJoinEmail.value;
        location.href = url + "/EmailPreference.aspx?eemail=" + emailID.value;
    }
 }

 function doClear(theText) 
{
     if (theText.value == theText.defaultValue)
 {
         theText.value = ""
     }
 }

