/* 
	 FILE: rollovers.js
     DESC: JavaScript functionality for main navigation 
*/

function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() {
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/* Form validation for Media Kit */

function openWindow() {
	newWindow = window.open('iamWindow1.asp','IAM','width=425,height=500');
}


/*  Start Auto Download for GETITNOW */
function DownloadAndInstallInfo() {
	var downloadURL = '/currentIAM/iamsetup.exe';
	var detect = navigator.userAgent.toLowerCase();
	
	if ( detect.indexOf('msie 5.5') != -1) { 
		window.open( downloadURL, '__TEMPWINDOW__','width=1,height=1,screenx=1,screeny=1,scrollbars=no,location=no,toolbar=no,resizable=no');
	}
	else {
		location = downloadURL;
	}
}


/* Form validation */
function verifyIt(f) {

	if (f.name.value=="") {
		alert("Please enter your name.")
		f.name.focus()
		return false
	}
		if (f.company.value=="") {
			alert("Please enter your company name.")
			f.company.focus()
			return false
		}

	if (f.phone.value=="") {
		alert("Please enter your phone number.")
		f.phone.focus()
		return false
	}
	if (f.email.value=="") {
		alert("Please enter your e-mail address.")
		f.email.focus()
		return false
	}
		var symbol = f.email.value
		var atpos = symbol.indexOf("@",1)
		var bad = ",;:/ "

	for (x=0; x<bad.length; x++) {
			if (symbol.indexOf(bad.charAt(x)) != -1) {
				alert ("You have entered an invalid character or a space. Please check your e-mail address.")
				f.email.focus()
				f.email.select()
				return false
			}
		}

		if (symbol.indexOf("@")==-1) {
			alert("Please enter a valid e-mail address. Be sure to include an '@' symbol and a '.'")
			f.email.focus()
			return false
		}

		if (symbol.indexOf(".")==-1) {
			alert("Please enter a valid e-mail address. Be sure to include an '@' symbol and a '.'")
			f.email.focus()
			return false
		}

		if (symbol.indexOf("@",atpos+1) != -1) {
			alert("Please enter only one e-mail address.")
			f.email.focus()
			return false
		}

	else {
		return true
	}

}
/* Tell Your Friends Preview */

function previewIAM() {
	newWindow = window.open('jsIAMPreview.asp', 'iamPreview', 'width=500,height=600,top=0,left=0,scrollbars=yes,location=no,toolbar=no,resizable=no')
}
function previewFax() {
	newWindow = window.open('jsFWPreview.asp', 'faxPreview', 'width=430,height=400,screenx=350,screeny=55,scrollbars=no,location=no,toolbar=no,resizable=no')
}

/* TYF Validation */

function tyf_verifyIt(f){

	var symbol = f.youremail.value
	var atpos = symbol.indexOf("@",1)
	var bad = ",;:/ "

	if (f.yourname.value==""){
	   		alert("Please enter your name.");
	   		f.yourname.focus()
	   		return false
   	}
   	if (f.youremail.value==""){
		   	alert("Please enter your e-mail address.");
	   		f.youremail.focus()
	   		return false
   	}
	for (x=0; x<bad.length; x++) {
		if (symbol.indexOf(bad.charAt(x)) != -1) {
			alert ("You have entered an invalid character or a space. Please check your e-mail address.")
			f.youremail.focus()
			f.youremail.select()
			return false
		}
	}
	if (symbol.indexOf("@")==-1) {
		alert("Please enter a valid email address. Be sure to include an '@' symbol and a '.'")
		f.youremail.focus()
		return false
	}
	if (symbol.indexOf(".")==-1) {
		alert("Please enter a valid email address. Be sure to include an '@' symbol and a '.'")
		f.youremail.focus()
		return false
	}
	if (symbol.indexOf("@",atpos+1) != -1) {
		alert("Please enter only one of your e-mail addresses.")
		f.youremail.focus()
		return false
	}
    if ((f.friendmail1.value=="")&&(f.friendmail2.value=="")&&(f.friendmail3.value=="")&&(f.friendmail4.value=="")&&(f.friendmail5.value=="")&&(f.friendmail6.value=="")&&(f.friendmail7.value=="")&&(f.friendmail8.value=="")&&(f.friendmail9.value=="")&&(f.friendmail10.value=="")){
   		alert("Please enter a friend's e-mail address.");
   		f.friendmail1.focus()
   		return false
   	}
	if (f.iam.checked != true){
		if (f.ffn.checked != true) {
			alert("You must choose to send at least one e-mail to your friends.")
			return false
		}
	}
   	else{
   		return true
   	}
}

/* FaxWave Validation */

function fw_verifyIt(){
	var f = document.forms[0];
	if (f.elements[3].value==""){
		alert("Please enter your email address.");
	}else{
		f.submit();
	}

}


/* Error checking for FaxWave signup form */
function checkFaxwaveForm(valid) {
	var symbol=valid.email.value
	var atpos = symbol.indexOf("@",1)

	if(valid.firstname.value==0) {
		alert("Please enter your first name.")
		valid.firstname.focus()
        return false
	}
	if(valid.lastname.value==0) {
		alert("Please enter your last name.")
		valid.lastname.focus()
		return false
	}

	if (symbol.indexOf("@")==-1) {
		alert("Please input a valid email address. Be sure to include an '@' symbol and a '.'")
		valid.email.focus()
		return false
	}
	if (symbol.indexOf(".")==-1) {
		alert("Please input a valid email address. Be sure to include an '@' symbol and a '.'")
		valid.email.focus()
		return false
	}
	if (symbol.indexOf("@",atpos+1) != -1) {
		alert("Please only enter one e-mail address.")
		valid.email.focus()
		return false
	}
	var valewe = valid.password1.value.length
	var fone = valid.phone.value.length
	if(valid.password1.value.length < 4) {
		alert("Please enter a password of at least 4 digits.")
		valid.password1.focus()
		return false
	}
	if(valid.password1.value.length > 10) {
		alert("Please enter a password with 4 to 10 digits.")
		valid.password1.focus()
		return false
	}
	if(valid.password1.value != valid.password2.value) {
		alert("Your passwords do not match. Please try again.")
		valid.password1.focus()
		valid.password1.select()
		return false
	}
	if(valid.email.value != valid.email2.value) {
		alert("Your e-mail addresses do not match. Please try again.")
		valid.email.focus()
		valid.email.select()
		return false
	}
	if(valewe < 4) {
		alert("Please enter a password of at least 4 digits.")
		valid.password1.focus()
		valid.password1.select()
		return false
	}
	if(valid.phone.value==0) {
		alert("Please enter your phone number.")
		valid.phone.focus()
		return false
	}
	if(fone < 10) {
		alert("Please enter your phone number (10 digit minimum).")
		valid.phone.focus()
		valid.phone.select()
		return false
	}
	if(valid.birthyear.value==0) {
		alert("Please enter the year that you were born.")
		valid.birthyear.focus()
		return false
	}
	if(valid.peopleinhouse.value==0) {
		alert("Please enter the number of people in your household.")
		valid.peopleinhouse.focus()
		return false
	}
    var thisYear = (new Date()).getYear()
    thisYear = (thisYear < 200)? thisYear + 1900: thisYear
    
    if (valid.birthyear.value >= (thisYear - 13)) {
        //alert("thisYear= " + thisYear);
        alert("We're sorry, but we cannot register you at this time.");
        document.formname.birthyear.focus()
        document.formname.birthyear.select()
        return false;
    }
	else {
		return true
	}
}

/* Open Learn More window on Upgrade Page */

function moreInfo() {
	newWindow = window.open('learnMore.asp', '', 'width=500,height=575,screenx=350,screeny=55,scrollbars=yes,location=no,toolbar=no,resizable=no')
}