// <SCRIPT LANGUAGE="JavaScript">


//=============================

function changeCase( field, from ) {

	// Converts a text string to initial caps

	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;

	tmpStr = field.value.toLowerCase();
	strLen = tmpStr.length;


	if ( strLen > 0 ) {

		for ( index = 0; index < strLen; index ++ ) {

			if ( index == 0) {

				tmpChar    = tmpStr.substring( 0, 1 ).toUpperCase();
				postString = tmpStr.substring( 1, strLen );
				tmpStr     = tmpChar + postString;

				}

			else {

				tmpChar = tmpStr.substring( index, index + 1 );

				if ( tmpChar == " " && index < ( strLen - 1 ) ) {

					tmpChar    = tmpStr.substring( index + 1, index + 2 ).toUpperCase();
					preString  = tmpStr.substring( 0, index + 1 );
					postString = tmpStr.substring( index + 2, strLen );
					tmpStr     = preString + tmpChar + postString;
	  	  }
	  	}
		}
	}

	field.value = tmpStr;

	}

// eof changeCase()




//=============================

function changeState( field ) {

	// Converts the State field to uppercase or initial caps

	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;

	tmpStr = field.value.toLowerCase();
	strLen = tmpStr.length;


	if ( strLen <= 2 ) {

		tmpStr = field.value.toUpperCase();

		}

	else {

	if ( strLen > 0 ) {

		for ( index = 0; index < strLen; index ++ ) {

			if ( index == 0) {

				tmpChar    = tmpStr.substring( 0, 1 ).toUpperCase();
				postString = tmpStr.substring( 1, strLen );
				tmpStr     = tmpChar + postString;

				}

			else {

				tmpChar = tmpStr.substring( index, index + 1 );

				if ( tmpChar == " " && index < ( strLen - 1 ) ) {

					tmpChar    = tmpStr.substring( index + 1, index + 2 ).toUpperCase();
					preString  = tmpStr.substring( 0, index + 1 );
					postString = tmpStr.substring( index + 2, strLen );
					tmpStr     = preString + tmpChar + postString;
	  	  }
	  	}
		}
	}
}

field.value = tmpStr;

}

// eof changeState()




//=============================

function validateNum( field ) {

	var valid   = "0123456789."
	var ok      = "yes";
	var temp    = "";

	for ( var i = 0; i < field.value.length; i++ ) {

		temp = "" + field.value.substring( i, i + 1 );

		if ( valid.indexOf( temp ) == "-1" ) ok = "no";

	}

	if ( ok == "no" ) {

		alert( "This field only accepts NUMBERS." );
		field.value = "";
		field.focus();
		field.select();

		return ( false );

	}

//	return ( true );

}

// eof validateNum()




//========================

function validateForm( from ) {

//  Validate Required Fields
//  From = Forms: Contact, Contest, Newsletter


if ( document.entryForm.Fname.value == "" )
	{
		alert( "Please enter a FIRST NAME." );
		document.entryForm.Fname.focus();
		return ( false );
	}

if ( document.entryForm.Lname.value == "" )
	{
		alert( "Please enter a LAST NAME." );
		document.entryForm.Lname.focus();
		return ( false );
	}

if ( document.entryForm.Email.value == "" )
	{
		alert( "Please enter an E-MAIL ADDRESS." );
		document.entryForm.Email.focus();
		return ( false );
	}


//  Return false if E-mail field does not contain an '@' and a '.'


if ( document.entryForm.Email.value != "" )

	{

	if ( document.entryForm.Email.value.indexOf ( '@', 0 ) == -1 ||
		 document.entryForm.Email.value.indexOf ( '.', 0 ) == -1 )
		{
			alert( "\nThe E-MAIL ADDRESS requires an \"@\" and a \".\"\n\nPlease re-enter your E-mail Address.")
			document.entryForm.Email.select();
			document.entryForm.Email.focus();
			return ( false );
		}
	}


if ( from == "Contest" )

	{

	if ( document.entryForm.Country.selectedIndex == 1 ||
		 document.entryForm.Country.selectedIndex == 2 )
	{
    	alert( "We're sorry, but we do not ship Renewal™ products to AUSTRALIA or CANADA." );
	    document.entryForm.Country.focus();
    	return ( false );
	}
}


if ( from == "Contact" )

	{

	if ( document.entryForm.Topic.selectedIndex == 0 )
	{
		alert( "Please select a TOPIC." );
		document.entryForm.Topic.focus();
		return ( false );
	}

	if ( document.entryForm.Message.value == "" )
	{
		alert( "Please enter a MESSAGE." );
		document.entryForm.Message.focus();
		return ( false );
	}

}

}

// eof validateForm()




//========================

function validateDistForm( from ) {

//  Validate Required Fields on the Distribution Forms
//  From = 'Renewal' or 'Private_Label'


if ( document.entryForm.Fname.value == "" )
	{
		alert( "Please enter a FIRST NAME." );
		document.entryForm.Fname.focus();
		return ( false );
	}

if ( document.entryForm.Lname.value == "" )
	{
		alert( "Please enter a LAST NAME." );
		document.entryForm.Lname.focus();
		return ( false );
	}

if ( document.entryForm.Email.value == "" )
	{
		alert( "Please enter an E-MAIL ADDRESS." );
		document.entryForm.Email.focus();
		return ( false );
	}

//  Return false if E-mail field does not contain an '@' and a '.'


if ( document.entryForm.Email.value != "" )

 	{

	if ( document.entryForm.Email.value.indexOf ( '@', 0 ) == -1 ||
		 document.entryForm.Email.value.indexOf ( '.', 0 ) == -1 )
		{
			alert( "\nThe E-MAIL ADDRESS requires an \"@\" and a \".\"\n\nPlease re-enter your E-mail Address.")
			document.entryForm.Email.select();
			document.entryForm.Email.focus();
			return ( false );
		}
	}

if ( document.entryForm.Country.selectedIndex == 0 )
	{
		alert( "Please select a COUNTRY." );
		document.entryForm.Country.focus();
		return ( false );
	}

if ( document.entryForm.Heard.selectedIndex == 0 )
	{
		alert( "Please tell us how you HEARD ABOUT Renewal." );
		document.entryForm.Heard.focus();
		return ( false );
	}

if ((
	( document.entryForm.Heard.selectedIndex == 15 ) &&
	( document.entryForm.HeardOther.value    == "" ) ))

	{
		{
		alert( "Please explain briefly how you HEARD ABOUT Renewal." );
		document.entryForm.HeardOther.focus();
		return ( false );
		}
}

if ( document.entryForm.DistWhy.value == "" )
	{
		alert( "WHY do you want to distribute Always Young products?" );
		document.entryForm.DistWhy.focus();
		return ( false );
	}

if ((((
	( document.entryForm.ProdADVC.value == "" ) ||
	( document.entryForm.ProdMWKO.value == "" ) ||
	( document.entryForm.ProdIGF1.value == "" ) ||
	( document.entryForm.ProdORIG.value == "" ) ))))

	{
	  {
   		alert( "Please check one or more RENEWAL PRODUCTS of interest." );
	    document.entryForm.ProdADVC.focus();
   		return ( false );
	  }
}

if ((
	( document.entryForm.DistUSA.value   == "" ) ||
	( document.entryForm.DistOther.value == "" ) ))

	{
	  {
   		alert( "Please check USA or OTHER countries/regions for distribution." );
	    document.entryForm.DistUSA.focus();
   		return ( false );
	  }
}

if ( document.entryForm.DistCurrent.value == "Yes" )
	{

	if ( document.entryForm.DistYears.value == "" )
		{
			alert( "How many YEARS have you been distributing?" );
			document.entryForm.DistYears.focus();
			return ( false );
		}

	if ( document.entryForm.DistProducts.value == "" )
		{
			alert( "What type of HEALTH PRODUCTS do you distribute?" );
			document.entryForm.DistProducts.focus();
			return ( false );
		}

	if ( document.entryForm.DistCapacity.value == "" )
		{
			alert( "How extensive is your CURRENT DISTRIBUTION?" );
			document.entryForm.DistCapacity.focus();
			return ( false );
		}
}


if (((((((
	( document.entryForm.YearOneAvg01.value == "" ) ||
	( document.entryForm.YearOneAvg02.value == "" ) ||
	( document.entryForm.YearOneAvg03.value == "" ) ||
	( document.entryForm.YearOneAvg04.value == "" ) ||
	( document.entryForm.YearTwoAvg01.value == "" ) ||
	( document.entryForm.YearTwoAvg02.value == "" ) ||
	( document.entryForm.YearThreeAvg.value == "" ) )))))))

	{
		alert( "Please enter a value for all ESTIMATED VOLUMES." );
		document.entryForm.YearOneAvg01.focus();
		return ( false );
	}


if ((((((((((
	( document.entryForm.MrktRetail.value     == "" ) ||
	( document.entryForm.MrktPrivate.value    == "" ) ||
	( document.entryForm.MrktTelevision.value == "" ) ||
	( document.entryForm.MrktRadio.value      == "" ) ||
	( document.entryForm.MrktYourSite.value   == "" ) ||
	( document.entryForm.MrktOtherSites.value == "" ) ||
	( document.entryForm.MrktCatalogs.value   == "" ) ||
	( document.entryForm.MrktDirectMail.value == "" ) ||
	( document.entryForm.MrktMLM.value        == "" ) ||
	( document.entryForm.MrktOther.value      == "" ) ))))))))))

	{
		alert( "Please check one or more ways you INTEND TO MARKET." );
		document.entryForm.YearOneAvg01.focus();
		return ( false );
	}


// if ( from == "Private_Label" )

//	{

//	if ( document.entryForm.DistBrand.value == "" )
//	{
//		alert( "Please enter a BRAND NAME." );
//		document.entryForm.DistBrand.focus();
//		return ( false );
//	}

// }



}

// eof validateDistForm()




//========================

function popup( box ) {

		 if ( box == "ADDR" ) { popurl = "ADDR/ADDR"; }
	else if ( box == "CCID" ) { popurl = "CCID/CCID"; }
	else if ( box == "ESAL" ) { popurl = "ESAL/ESAL"; }
	else if ( box == "GUAR" ) { popurl = "GUAR/GUAR"; }
	else if ( box == "ORDR" ) { popurl = "ORDR/ORDR"; }
	else if ( box == "PAYM" ) { popurl = "PAYM/PAYM"; }
	else if ( box == "PRIC" ) { popurl = "PRIC/PRIC"; }
	else if ( box == "PRIV" ) { popurl = "PRIV/PRIV"; }
	else if ( box == "SALE" ) { popurl = "SALE/SALE"; }
	else if ( box == "SHIP" ) { popurl = "SHIP/SHIP"; }
	else if ( box == "USPS" ) { popurl = "USPS/USPS"; }
	else if ( box == "ADVC" ) { popurl = "ADVC/ADVC"; }
	else if ( box == "MWKO" ) { popurl = "MWKO/MWKO"; }
	else if ( box == "WPWR" ) { popurl = "WPWR/WPWR"; }
	else if ( box == "IGF1" ) { popurl = "IGF1/IGF1"; }
	else if ( box == "ORIG" ) { popurl = "ORIG/ORIG"; }
	else if ( box == "ENZY" ) { popurl = "ENZY/ENZY"; }
	else if ( box == "EFAS" ) { popurl = "EFAS/EFAS"; }
	else if ( box == "DPL1" ) { popurl = "DPL1/DPL1"; }
	else if ( box == "DPL2" ) { popurl = "DPL2/DPL2"; }
	else if ( box == "DPLS" ) { popurl = "DPLS/DPLS"; }
	else if ( box == "DPLW" ) { popurl = "DPLW/DPLW"; }
	else if ( box == "PTCS" ) { popurl = "PTCS/PTCS"; }
	else if ( box == "PTET" ) { popurl = "PTET/PTET"; }
	else if ( box == "PTS8" ) { popurl = "PTS8/PTS8"; }

	popurl = "HTTP://WWW.ALWAYSYOUNG.COM/POPUP/" + popurl + ".HTML"

	helpinfo = window.open( popurl,"popup","left=0,top=0,width=500,height=500,scrollbars," );

	helpinfo.focus();

}

// eof popup()




//========================

function popimage( box ) {

		 if ( box == "ADVC-PIC" ) { popurl = "ADVC-PIC/ADVC-PIC"; }
	else if ( box == "MWKO-PIC" ) { popurl = "MWKO-PIC/MWKO-PIC"; }
	else if ( box == "WPWR-PIC" ) { popurl = "WPWR-PIC/WPWR-PIC"; }
	else if ( box == "IGF1-PIC" ) { popurl = "IGF1-PIC/IGF1-PIC"; }
	else if ( box == "ORIG-PIC" ) { popurl = "ORIG-PIC/ORIG-PIC"; }
	else if ( box == "MFIT-PIC" ) { popurl = "MFIT-PIC/MFIT-PIC"; }
	else if ( box == "GENR-PIC" ) { popurl = "GENR-PIC/GENR-PIC"; }
	else if ( box == "ENZY-PIC" ) { popurl = "ENZY-PIC/ENZY-PIC"; }
	else if ( box == "EFAS-PIC" ) { popurl = "EFAS-PIC/EFAS-PIC"; }
	else if ( box == "DPL1-PIC" ) { popurl = "DPL1-PIC/DPL1-PIC"; }
	else if ( box == "DPL2-PIC" ) { popurl = "DPL2-PIC/DPL2-PIC"; }
	else if ( box == "DPL3-PIC" ) { popurl = "DPL3-PIC/DPL3-PIC"; }
	else if ( box == "PTCS-PIC" ) { popurl = "PTCS-PIC/PTCS-PIC"; }
	else if ( box == "PTEY-PIC" ) { popurl = "PTEY-PIC/PTEY-PIC"; }
	else if ( box == "PTS8-PIC" ) { popurl = "PTS8-PIC/PTS8-PIC"; }
	else if ( box == "FEDX-PIC" ) { popurl = "FEDX-PIC/FEDX-PIC"; }

	popurl = "HTTP://WWW.ALWAYSYOUNG.COM/POPUP/" + popurl + ".HTML"

	if ( box == "DPL3-PIC" ) {

		helpinfo = window.open( popurl,"popimage","left=0,top=0,width=510,height=600,scrollbars," );

		}

	else {

		helpinfo = window.open( popurl,"popimage","left=0,top=0,width=510,height=500,scrollbars," );
	}

	helpinfo.focus();

}

// eof popimage()




//=============================

// function TrustLogo()

// Popup window displaying Comodo Trust Logo - verification of SSL certificate

// {
// thewindow = window.open("http://www.alwaysyoung.com/ayComodoSecure.gif", "SC", "none");
// }


// <script type="text/javascript">TrustLogo("http://www.alwaysyoung.com/ayComodoSecure.gif", "SC", "none");</script>


// eof TrustLogo()




//=============================

function popWin( url )

{

	helpinfo = window.open( url,"popWin",'width=520,height=370,scrollbars=yes' );

	helpinfo.focus();

}

// eof popWin()



// </SCRIPT>
