
// display messages in multiple languages
function scripts_msgcat(msgnbr) {
	if (!window.uselang) window.uselang="en";
	switch(msgnbr) {
		case 1:
			if (window.uselang == "es") alert("Por favor introduzca su nombre.")
			else alert("Please enter your first name.");
			break;
		case 2:
			if (window.uselang == "es") alert("Por favor introduzca su apellido.")
			else alert('Please enter your last name.');
			break;
		case 3:
			if (window.uselang == "es") alert('Por favor introduzca su direcci\u00f3n.')
			else alert ('Please enter your address.');
			break;
		case 4:
			if (window.uselang == "es") alert('Por favor introduzca su ciudad.')
			else alert ('Please enter your city.');
			break;
		case 5:
			if (window.uselang == "es") alert('Por favor introduzca su c\u00f3digo postal.')
			else alert ('Please enter your zip/postal code.');
			break;
		case 6:
			if (window.uselang == "es") alert('Por favor introduzca su estado y verifique su pa\u00eds.')
			else alert('Please enter your state and make sure your Country is set to US');
			break;
		case 7:
			if (window.uselang == "es") alert('Debe anotar correctamente su pa\u00eds o escribir una regi\u00f3n o provincia en su direcci\u00f3n.')
			else alert('You must select either a US state or a enter a province or region in your address');
			break;
		case 8:
			if (window.uselang == "es") alert('Si su pais es EU, Debe especificar un estado.')
			else alert('You must specify a State when your Country is US');
			break;
		case 9:
			if (window.uselang == "es") alert('Por favor introduzca su pa\u00eds.')
			else alert ('Please enter your country.');
			break;
		case 10:
			if (window.uselang == "es") alert('Por favor introduzca su n\u00famero telef\u00f3nico.')
			else alert ('Please enter your home phone number.');
			break;
		case 11:
			if (window.uselang == "es") alert('Por favor verifique su direcci\u00f3n de correo electr\u00f3nico.')
			else alert ("Please check your email address.");
			break;
		case 12:
			if (window.uselang == "es") alert('Por favor introduzca el su mes de nacimiento.')
			else alert ('Please enter the month of your birth.');
			break;
		case 13:
			if (window.uselang == "es") alert('Por favor introduzca su d\u00eda de nacimiento.')
			else alert ('Please enter the day of your birth.');
			break;
		case 14:
			if (window.uselang == "es") alert('Por favor introduzca su a\u00f1o de nacimiento.')
			else alert ('Please enter the year of your birth.');
			break;
		case 15:
			if (window.uselang == "es") alert('Por favor introduzca un a\u00f1o válido de nacimiento de 4 d\u00edgitos')
			else alert ('Please enter a valid four digit year of birth.');
			break;
		case 16:
			if (window.uselang == "es") alert('Debe tener al menos 18 a\u00f1os para suscribirse')
			else alert ('You must be at least 18 years old to enroll.');
			break;
		case 17:
			if (window.uselang == "es") alert('Por favor verifique su fecha de nacimiento. La fecha ingresada indica que tiene m\u00e1s de 100 a\u00f1os de edad.')
			else alert ('Please check your birthdate. The date makes you more than 100 years old.');
			break;
		case 18:
			if (window.uselang == "es") alert('Por favor introduzca una fecha de nacimiento v\u00e1lida.')
			else alert ('Please enter a valid date of birth.');
			break;
		case 19:
			if (window.uselang == "es") alert('Por favor indique su sexo.')
			else alert ('Please indicate your gender.');
			break;
		case 20:
			if (window.uselang == "es") alert('Por favor lea el Contrato de Acuerdo Independiente.')
			else alert ('Please read and initial the Independent Contractor Agreement.');
			break;
		case 21:
			if (window.uselang == "es") alert('Por favor introduzca el n\u00famero de su tarjeta de cr\u00e9dito.')
			else alert ('Please enter your credit card number.');
			break;
		case 22:
			if (window.uselang == "es") alert('Por favor introduzca el nombre tal como aparece en su tarjeta de cr\u00e9dito')
			else alert ('Please enter the name as it appears on your credit card.');
			break;
		case 23:
			if (window.uselang == "es") alert('Por favor introduzca la direcci\u00f3n donde recibe el estado de cuenta de la tarjeta de cr\u00e9dito')
			else alert ('Please enter the credit card billing address.');
			break;
		case 24:
			if (window.uselang == "es") alert('Por favor introduzca la ciudad donde recibe el estado de cuenta de la tarjeta de cr\u00e9dito')
			else alert ('Please enter the credit card billing city.');
			break;
		case 25:
			if (window.uselang == "es") alert('Por favor introduzca el estado y pa\u00eds donde recibe el estado de cuenta de la tarjeta de cr\u00e9dito')
			else alert('Please enter your billing state and make sure your Billing Country is set to US');
			break;
		case 26:
			if (window.uselang == "es") alert('Debe escoger o introducir un estado o provincia donde recibe su estado de cuenta de la tarjeta de cr\u00e9dito.')
			else alert('You must select either a US state or a enter a province or region in your billing address');
			break;
		case 27:
			if (window.uselang == "es") alert('Especifique un estado donde recibe su estado de cuenta')
			else alert('You must specify a Billing State when your Billing Country is US');
			break;
		case 28:
			if (window.uselang == "es") alert('Por favor introduzca el c\u00f3digo postal donde recibe el estado de cuenta de su tarjeta de cr\u00e9dito.')
			else alert ('Please enter the credit card billing zip/postal code.');
			break;
		case 29:
			if (window.uselang == "es") alert('Por favor introduzca el pa\u00eds donde recibe el estado de cuenta de su tarjeta de cr\u00e9dito')
			else alert ('Please enter the credit card billing country.');
			break;
		
	}
}
// rotating image displayer - unfinished as of 6/10

function display_image() {
	var myimage = new Array();
		myimage[0]=meImage('images/yellow.jpg');
		myimage[1]=meImage('images/yellow2.jpg');
		myimage[2]=meImage('images/orange.jpg');

	function meImage(url) {
		if (document.images) {
			var img= new Image();
			img.url=url;
			return img;
			}
		return null;
	}

	i= new Number;
	looper=new String;

	i.numb=0;	
	while (i.numb<2) {
		looper = myimage[i.numb].url;
		calltime=setTimeout("document.images['change'].src=looper",8000);
		i.numb++;
	}

return true;
}


// validate login

function validate_login(user, pass) {

	if (!user) {alert ('Please enter your user name.'); return false;}
	if (!pass) {alert ('Please enter your account pin.'); return false;}

return true;
}

// open window - popup

function openwin(URL,name,features) { 
 pop=window.open(URL,name,features);
}



// validate email

function validate_email(form) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.vcEmail.value)){
return (true)
}
if (window.uselang) {
	switch(window.uselang) {
		case 'es':
			alert("Invalid E-mail Address! Please re-enter.");
			break;
		default:
			alert("Correo electr\u00f3nico inv\u00e1lido. Por favor vuelva a introducirlo");
			break;
	}
} else {
	alert("Invalid E-mail Address! Please re-enter.");
}
return (false)
}



function checkvalues(user, email, message) {

	if (!user) {alert ('Please enter your name.'); return false;}


	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(email)){
} else {
alert("Invalid E-mail Address! Please re-enter.")
return false;
}

	if (!message) {alert ('Please enter your message.'); return false;}


return true;
}


function newcheck(form) {

	if (!form.name.value) {alert ('Please enter your name.'); return false;}


	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email.value)){
} else {
alert("Invalid E-mail Address! Please re-enter.")
return false;
}

	if (!form.message.value) {alert ('Please enter your message.'); return false;}

return true;
}

function scrb() {
	checkrefby=1;
}

function radioHasValue(obj) {
	var result = false;
	for(var i=0; i<obj.length; i++){
		if(obj[i].checked==true) result = true;
 		}
 		return result;
}

function checkenroll(form) {
	if (typeof(checkrefby) !='undefined') {
		if (form.vcReferredBy.value == '10647534' || form.vcReferredBy.value.indexOf('-') >=0 ){alert('Sorry, the referral PIN you entered is not a valid Agent PIN, please try again.'); return false;}
	}
	if (!form.vcFName.value) {scripts_msgcat(1); return false;}
	if (!form.vcLName.value) {scripts_msgcat(2); return false;}
	if (!form.vcAddress.value) {scripts_msgcat(3); return false;}
	if (!form.vcCity.value) {scripts_msgcat(4); return false;}
	if (!form.vcZip.value) {scripts_msgcat(5); return false;}
	//if State is filled in, country must be US. Otherwise province must be filled in. Otherwise error.
	
	if (form.vcUseState.selectedIndex > 0) {
		if (form.vcCountry.value !='US') { scripts_msgcat(6); return false; }
	} else { 
		if (!trim(form.vcProvince.value)) { scripts_msgcat(7); return false; }
		else {
			if (form.vcCountry.value == 'US') { scripts_msgcat(8); return false;}
		}
	}
	//if (!form.vcState.value) {alert ('Please enter your state.'); return false;}
	if (!form.vcCountry.value) {scripts_msgcat(9); return false;}
	if (!form.vcHPhone.value) {scripts_msgcat(10); return false;}

if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.vcEmail.value)){
if (form.vcEmail.value!=form.vcEmail2.value) {scripts_msgcat(11); return false;}
} else {
	scripts_msgcat(11);
return false;
}

	// Validate Birth Date 
	if (form.BirthMonth.selectedIndex == 0) {scripts_msgcat(12); return false;}
	if (form.BirthDayOfMonth.selectedIndex == 0) {scripts_msgcat(13); return false;}
	strBirthYear = trim(form.BirthYear.value);
	if (strBirthYear.length == 0) {scripts_msgcat(14); return false;}
	var regExp = eval("/^[12][90][0-9]{2}$/");
	if (!strBirthYear.match(regExp)) {scripts_msgcat(15); return false;}
	//var currentYear = <cfoutput>#Year(now())#</cfoutput>-17;
	var now = new Date(); 
	var currentYear = now.getFullYear()-17; 
	//alert("currentYear " + currentYear);
	//alert("Birthday Year is " + strBirthYear);
	if (strBirthYear >= currentYear) {scripts_msgcat(16); return false;}
	if (strBirthYear < (currentYear-84)) {scripts_msgcat(17); return false;}
	form.dBirthDate.value = form.BirthMonth.selectedIndex + '/' + form.BirthDayOfMonth.selectedIndex + '/' + strBirthYear;
	if (!chkdate(form.dBirthDate)) {scripts_msgcat(18); return false;}
	// Validate Gender     
	if (!radioHasValue(form.nGenderID)) {scripts_msgcat(19); return false;}

	if (!form.vcInitials1.value) {scripts_msgcat(20); return false;}
	if (!form.vcCCN.value) {scripts_msgcat(21); return false;}
	if (!form.vcCCName.value) {scripts_msgcat(22); return false;}
	if (!form.vcBillAddress.value) {scripts_msgcat(23); return false;}
	if (!form.vcBillCity.value) {scripts_msgcat(24); return false;}
	//if State is filled in, country must be US. Otherwise province must be filled in. Otherwise error.
	
	if (form.vcUseBillState.selectedIndex > 0) {
		if (form.vcBillCountry.value !='US') { scripts_msgcat(25); return false; }
	} else { 
		if (!trim(form.vcBillProvince.value)) { scripts_msgcat(26); return false; }
		else {
			if (form.vcBillCountry.value == 'US') { scripts_msgcat(27); return false;}
		}
	}
	//if (!form.vcBillState.value) {alert ('Please enter the credit card billing state.'); return false;}
	if (!form.vcBillZip.value) {scripts_msgcat(28); return false;}
	if (!form.vcBillCountry.value) {scripts_msgcat(29); return false;}

	if (form.vcCountry.value != 'US') { form.vcState.value=form.vcProvince.value; } else { form.vcState.value=form.vcUseState[form.vcUseState.selectedIndex].value; }
	if (form.vcBillCountry.value != 'US') { form.vcBillState.value=form.vcBillProvince.value; } else { form.vcBillState.value=form.vcUseBillState[form.vcUseBillState.selectedIndex].value; }
	form.ContractorAgreement.value='';

return true;
}




// moock fpi [f.lash p.layer i.nspector]
// version: 1.3.5
// written by colin moock
// code maintained at: http://www.moock.org/webdesign/flash/detection/moockfpi/
// terms of use posted at: http://www.moock.org/terms/



// #############################################
// These are the user defined globals.
// Modify the following variables to customize the inspection behaviour.

var requiredVersion = 4;   // Version the user needs to view site (max 6, min 2)
var useRedirect = false;    // Flag indicating whether or not to load a separate
                           // page based on detection results. Set to true to
                           // load a separate page. Set to false to embed the
                           // movie or alternate html directly into this page.
                           
// Only set next three vars if useRedirect is true...
// var flashPage = "movie.html"      // The location of the flash movie page
// var noFlashPage = "noflash.html"  // Page displayed if the user doesn't have the
                                  // plugin or we can't detect it.
// var upgradePage = "upgrade.html"  // Page displayed if we detect an old plugin
// #############################################



// *************
// Everything below this point is internal until after the BODY tag.
// Do not modify! Proceed to the BODY tag for further instructions.
// *************

// System globals
var flash2Installed = false;    // boolean. true if flash 2 is installed
var flash3Installed = false;    // boolean. true if flash 3 is installed
var flash4Installed = false;    // boolean. true if flash 4 is installed
var flash5Installed = false;    // boolean. true if flash 5 is installed
var flash6Installed = false;    // boolean. true if flash 6 is installed
var maxVersion = 6;             // highest version we can actually detect
var actualVersion = 0;          // version the user really has
var hasRightVersion = false;    // boolean. true if it's safe to embed the flash movie in the page
var jsVersion = 1.0;            // the version of javascript supported


// Check the browser...we're looking for ie/win
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    // true if we're on ie
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false; // true if we're on windows

// This is a js1.1 code block, so make note that js1.1 is supported.
jsVersion = 1.1;

// Write vbscript detection on ie win. IE on Windows doesn't support regular
// JavaScript plugins array detection.
if(isIE && isWin){
  document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
  document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
  document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
  document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
  document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');  
  document.write('</SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
}


// Next comes the standard javascript detection that uses the 
// navigator.plugins array. We pack the detector into a function so it loads
// before we run it.

function detectFlash() {  
  // If navigator.plugins exists...
  if (navigator.plugins) {
    // ...then check for flash 2 or flash 3+.
    if (navigator.plugins["Shockwave Flash 2.0"]
        || navigator.plugins["Shockwave Flash"]) {

      // Some version of Flash was found. Time to figure out which.
      
      // Set convenient references to flash 2 and the plugin description.
      var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;

      // DEBUGGING: uncomment next line to see the actual description.
      // alert("Flash plugin description: " + flashDescription);
      
      // A flash plugin-description looks like this: Shockwave Flash 4.0 r5
      // We can get the major version by grabbing the character before the period
      // note that we don't bother with minor version detection. 
      // Do that in your movie with $version or getVersion().
      var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
     
      // We found the version, now set appropriate version flags. Make sure
      // to use >= on the highest version so we don't prevent future version
      // users from entering the site.
      flash2Installed = flashVersion == 2;    
      flash3Installed = flashVersion == 3;
      flash4Installed = flashVersion == 4;
      flash5Installed = flashVersion == 5;
      flash6Installed = flashVersion >= 6;
    }
  }
  
  // Loop through all versions we're checking, and
  // set actualVersion to highest detected version.
  for (var i = 2; i <= maxVersion; i++) {  
    if (eval("flash" + i + "Installed") == true) actualVersion = i;
  }
  
  // If we're on webtv, the version supported is 2 (pre-summer2000, 
  // or 3, post-summer2000). Note that we don't bother sniffing varieties
  // of webtv. You could if you were sadistic...
  if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 3;  
  
  // DEBUGGING: uncomment next line to display flash version
  // alert("version detected: " + actualVersion);


  // We're finished getting the version on all browsers that support detection.
  // Time to take the appropriate action.

  // If the user has a new enough version...
  if (actualVersion >= requiredVersion) {
    // ...then we'll redirect them to the flash page, unless we've
    // been told not to redirect.
    if (useRedirect) {
      // Need javascript1.1 to do location.replace
      if(jsVersion > 1.0) {
        // It's safe to use replace(). Good...we won't break the back button.
        window.location.replace(flashPage);  
      } else {
        // JavaScript version is too old, so use .location to load
        // the flash page.
        window.location = flashPage;
      }
    }
    
    // If we got here, we didn't redirect. So we make a note that we should
    // write out the object/embed tags later.
    hasRightVersion = true;                
  } else {  
    // The user doesn't have a new enough version.
    // If the redirection option is on, load the appropriate alternate page.
    if (useRedirect) {
      // Do the same .replace() call only if js1.1+ is available.
      if(jsVersion > 1.0) {
        window.location.replace((actualVersion >= 2) ? upgradePage : noFlashPage);
      } else {
        window.location = (actualVersion >= 2) ? upgradePage : noFlashPage;
      }
    }
  }
}


detectFlash();  // call our detector now that it's safely loaded.  
  





