﻿// 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 = ""
     }
 }
 
/*
function getEmail() 
{
   if ((document.aspnetForm.ctl00$tbJoinEmail.value == "name@email.com") || (document.aspnetForm.ctl00$tbJoinEmail.value == "")) 
   {
       alert("Please enter a valid email address.");
       document.aspnetForm.ctl00$tbJoinEmail.focus(); 
   } 
   else 
   {
       part2 = document.aspnetForm.ctl00$tbJoinEmail.value;
       myurl = "http://localhost/DotNet2Web/EmailPreference.aspx?eemail=" + part2;
       window.openWindow(myurl,450,510);
   }
}

function unsubscribe() 
{
   if (document.MainForm.tbUnsubscribe.value == "") 
   {
       alert("Please enter a valid email address.");
       document.MainForm.tbUnsubscribe.focus();
   } 
   else 
   {
       part2 = document.MainForm.tbUnsubscribe.value;
       myurl = "http://echo3.bluehornet.com/clients/guess/clupdate.htm?eemail=" + part2;
       openWindow(myurl,450,510);
   }
}

//Multiple mouseover changes
function rollover(img1_name, img1_src, img2_name, img2_src)
   {
   document[img1_name].src = img1_src;
   document[img2_name].src = img2_src;
   }
*/