/* 	$VERSION = '3.5.1';	 */
/* include	me like this
<script type="text/javascript" 
	language="JavaScript1.3"
	src="/shaklee.js">
</script>
*/

//Active Controls run start, write params, run end
function ACStart(width,height,id)
{
    document.write('<OBJECT CLASSID="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" CODEBASE="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width=' + width + ' height=' + height + ' id=' + id + ' ALIGN="middle">');

}


/* Disable Submit Button */
function disableForm(theform) {
	if (document.all || document.getElementById) {
		for (i = 0; i < theform.length; i++) {
		var tempobj = theform.elements[i];
			if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
			tempobj.disabled = true;
		}
	setTimeout('', 20000);
	return true;
	}
	else {
	alert("The form has been submitted.  You're not using IE 4+ or NS 6+, the submit button was not disabled, do not click submit again!");
	return false;
   }
}

/* AutoShip Wizard */
function toggleWiz(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //NN6 + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}

/* Acct/Gen column highlight */
function lit_down(this_element){
	var that_element;
	for (var line=0;that_element = document.getElementById(this_element.id + line);line++) { 
		that_element.className=this_element.className;
	}
}

function language(lang_of_user) {
	if (lang_of_user == null||lang_of_user == '') {
		lang_of_user = GetCookie('xml:lang');
	} else {
		SetCookie('xml:lang',lang_of_user,new Date(2103,0,1),"/",".shaklee.net"); // good till Jan 1, 2103!!!
	}
	if (lang_of_user == null || lang_of_user == '') lang_of_user = 'en';
        var divs = document.getElementsByTagName("div"); // "*" for all tags
        for (var i=0; i<divs.length; i++ ) {
        	var theLang = '';
	        if (divs[i].getAttribute("lang")     != null) theLang = divs[i].getAttribute("lang");
	        if (divs[i].getAttribute("xml:lang") != null) theLang = divs[i].getAttribute("xml:lang");
	        if (theLang.length > 0 ) divs[i].style.display = (theLang.indexOf(lang_of_user)>=0) ? "block" : "none";
	}
}

function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	var j = 0;
	var endstr = 0;
	while (i < clen) {
		j = i + alen;
		if (document.cookie.substring(i, j) == arg){
			endstr = document.cookie.indexOf (";", j);
		if (endstr == -1) endstr = document.cookie.length;
			return unescape(document.cookie.substring(j, endstr));
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return "";
}
function SetCookie (name,value,expires,path,domain,secure) {
	document.cookie = name + "=" + escape (value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}
function DeleteCookie (name,path,domain) {
	if (GetCookie(name)) {
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}
function money(real) {
	var rup = (real + 0.0001).toString();
	var dot = rup.indexOf('.');	
	return '&#36;' + rup.substr(0,3+dot);
}

function isDigits(field)
{
	var digits = /^\d+$/;
	var ok = field.value.match(digits);
	if (ok == null) {
	   return false;
	}
	return true;
}

function verify_qty(field)
{
	var Qty = /^\d+$/;
	var ok = field.value.match(Qty);
	if (ok == null) {
		alert('Quantity can only contain numeric digits' );
		field.focus();
		field.select();
	}
	else {
		no_error(field.name);
	}
	if (ok != null) {
		return true;
	}
	else
	{
		return false;
	}
}
/* call me like this   ---------------verify_?????----------------

<INPUT TYPE="text" NAME="from" SIZE="30" MAXLENGTH="255" ONCHANGE="verify_?????(this)">
	
	and/or
	
<FORM ACTION="http://www.shaklee.com/sob/scripts/mailer.cgi" 
	  METHOD="post" 
	  onSubmit=" return verify_email(this.from,'address')  &amp;&amp; verify_ssn(this.ssn,'SS No')   &amp;&amp; verify_once()">

Notes:
	verify_submit_button(this)	should be called first. 
	verify_once()				should be called last.
*/
	var something_was_changed = "";
	function verify_changed(){
		if (something_was_changed == "") {
			alert("nothing was changed! You don't have to submit");
		}
		return (something_was_changed != "");
	}
	function changed(whatever){
		something_was_changed = whatever;
	}
	function error_alert(name,message){
		var id = name + "-error";
		if (document.layers && document.layers[id])				document.layers[id].visibility = "show";
		else if (document.getElementById && document.getElementById(id))	document.getElementById(id).style.display = "block";
		else if (document.all && document.all[id])				document.all[id].style.display = "block";
		else 																alert("ERROR:" + message);
	}
	function no_error(name) {
		var id = name + "-error";
		if (document.layers && document.layers[id])				document.layers[id].visibility = "hide";
		else if (document.getElementById && document.getElementById(id))	document.getElementById(id).style.display = "none";
		else if (document.all && document.all[id])				document.all[id].style.display = "none";
	}
	function verify_us_zipcode(field){
		reN  = /^\d+$/;
		reNd = /^[-\d]$/;
		var val = field.value;
		if (!( val && val.length)) return (1==1);
		var ok = (val.length == 5  && val.match(reN) )
		       ||(val.length == 9  && val.match(reN) )
		       ||(val.length == 10 && val.match(reNd));
		if(! ok) {
			error_alert(field.name,'bad US ZIPcode');
			field.focus();
			field.select();
		}
		else no_error(field.name);
		return ok;
	}
	function verify_email(field){
		var atsign = field.value.indexOf("@");
		var period = field.value.lastIndexOf(".");
		var ok = (atsign > 0 && period > 2 &&  (period - atsign) > 1);
		if (! ok) {
			alert("Invalid Email address - Please enter your Email address");
//			error_alert(field.name,' Invalid Email address - Please enter your Email address');
			field.focus();
			field.select();
		}
		else no_error(field.name);
		return ok;
	}

	function verify_two_entries(f1,f2){
		var ok = (f1.value == f2.value);
		if (! ok) {
			error_alert(f2.name,'entries do not match '+(arguments.length > 2 ? arguments[2] : f1.name));
			f2.focus();
			f2.select();
		}
		else no_error(f2.name);
		return ok;
	}

	function verify_required(field){
		var ok = field.value.length != 0;
		if (! ok) {
			error_alert(field.name,'This field is required '+(arguments.length > 1 ? arguments[1] : field.name));
			return false;
		}
		else no_error(field.name);
		return ok;
	}
	function verify_name(field){
		var ok = field.value.length != 0;
		if (! ok) {
			error_alert(field.name,' Please enter your name');
			return false;
		}
		else no_error(field.name);
		return ok;
	}
	function verify_autoship(field){
		var ok = field.value.length != 0;
		if (! ok) {
			alert('Please Select an Autoship');
			return false;
		}
		else no_error(field.name);
		return ok;
	}

	function verify_ssn(field){
		var reSSN  = /^\d[9]$/;
		var ok = (field.value.match(reSSN));
		if (! ok) {
			error_alert(field.name,'bad SSN in field '+(arguments.length > 1 ? arguments[1] : field.name));
			field.focus();
			field.select();
		}
		else no_error(field.name);
		return ok;
	}

	function verify_length( field, max )
	{
		var ok = field.value.length <= max;
		if (! ok) {
			error_alert(field.name, (arguments.length > 2 ? arguments[2] : field.name) + ' is too long. It exceeds ' + max + ' characters' );
			field.focus();
			field.select();
		}
		else no_error(field.name);
		return ok;
	}
	
	function verify_distid(field)
	{
		var reDistID = /^[A-Za-z][A-Za-z]\d\d\d\d\d$/;
		var ok = field.value.match(reDistID);
		if (ok == null) {
			alert('Distributor IDs must always be 2 letters followed by 5 digits' );
			field.focus();
			field.select();
		}
		else {
			no_error(field.name);
		}
		if (ok != null) {
			return true;
		}
		else
		{
			return false;
		}
	}

	function verify_ta_length( field, maxlines, breakat )
	{
		if (breakat <= 0) {
			breakat = 70;
		}
		var lines = 0;
		var text = field.value;
		var paras = text.split("\n");
		for (para in paras) {
			lines = lines +  Math.ceil(paras[para].length / breakat);
		}
		ok = lines <= maxlines;
		if (! ok) {
			error_alert(field.name, (arguments.length > 3 ? arguments[3] : field.name) + ' is too long. It exceeds ' + maxlines + ' lines (' + lines + ')' );
			field.focus();
			field.select();
		}
		else no_error(field.name);
		return ok;
	}
	

	var submitCount = 0;
	function verify_once(){	// disables submits after the first time... but resets after 3!!!
		submitCount++;
		if (submitCount > 2) {
			submitCount = 1;
		} 
		if (submitCount > 1) {
		//	alert('Double Click Detected: Please click only once to submit a form.');
		}
		return (submitCount == 1);
	}
	function verify_submit_button(thisform){	// makes sure a submit button was pressed, not just an enter.
//		var subfields = "subfields:";
		for(var i = 0;i < thisform.length;i++ ) {
			var field = thisform[i];
			if (field.type == "submit") {
//				subfields += "\n" + field.type + "\t" + field.name + "\t" + field.value + "(" + field.submitted + ")";
				if (field.submitted) {
					field.submitted = false;
//					alert(subfields);
					return(true);
				}
			}
		}
//		alert(subfields);
		return(false);
	}

	function verify_ifFormEmpty(thisform,thebadmessage){
		for(var i = 0;i < thisform.length;i++ ) {
			var field = thisform[i];
			if (field.type == "text") {
				if (field.value != "") {
					alert(thebadmessage);
					return false;
				}
			}
		}
		return true;
	}
	function verify_all_radios(thisform) {// do all radio groups have at a selected button 
		var el = thisform.elements;
		for(var i = 0 ; i < el.length ; ++i) {
			if(el[i].type == "radio") {
				var radiogroup = el[el[i].name]; // get the whole set of radio buttons.
				var itemchecked = false;
				for(var j = 0 ; j < radiogroup.length ; ++j) {
					if(radiogroup[j].checked) {
						itemchecked = true;
						break;
					}
				}
				if(!itemchecked) {
					alert("Please choose an answer for "+el[i].name+".");
					if(el[i].focus) el[i].focus();
					return false;
				}
			}
		}
		return true;
	} 
	function checkForm(field){
		if ((field.value.indexOf("&")) >= 0) {
			error_alert(field.name,'Please Do Not Use Ampersands');
			field.focus();
			field.select();
			return false;
		}
		else 
			no_error(field.name);
		return true;
	}

/* call me like this   ---------------parameters----------------
	<head>
		<script>
			var param = new parameters();
		</script>
	</head>
	
	then
	
	<body>
		<script>
			if (param.msg){
				document.writeln(param.msg);
			}
		</script>
	</body>

*/
	
	function parameters(){
		var p = document.location.search;
		if (p == null)
			 this.length = 0
		else if (p.length > 0 && p.charAt(0) == "?")
			{
			  var a = p.substring(1,p.length).split("&")
			  this.length = a.length
			  for(i in a)
			  {
				  f  = a[i].split("=")
				  this[f[0]] = f[1]
			  }
			}
		else
			this.length=0;
	}

	
	
/* call me like this   ---------------pop_n_go----------------
	<form>
		<select onChange="pop_n_go(this);">
			<option value = "http://www.shaklee.com">Home
			<option value = "/search">Search
		</select>
	</form>
*/
function pop_n_go(where) {
		//if ( where.selectedIndex )
		  window.location.href = where.options[where.selectedIndex].value;
}

/* call me like this   ---------------pop_n_call----------------
	<form>
		<select onChange="pop_n_call('hidefilter',this);">
			<option value = "('all items')">All
			<option value = "('small items')">Small
		</select>
	</form>
*/

function pop_n_call(functionname,where) {

		  var parm  = where.options[where.selectedIndex].value;
		  return eval(functionname + parm  );
}

/* call me like this ----------------concat_n_return---------------------
			---- Added By Sivakumar ----
		<select name="Delivery" size="1" class="formfieldlogin" onChange="window.location=concat_n_return('$me_noparm?step=review&skipToStep=1&Delivery=',this);">
			<option value="" SELECTED>Standard Shipping
			<option value="One">Expedited Shipping
			<option value="Two">Get Other Delivery Options
		</select>
*/
function concat_n_return(queryString,where) {

		var val  = where.options[where.selectedIndex].value;
		return ( queryString + val  );
}



/* call me like this   ---------------pop_n_put----------------
	<form name="me" action="$me" method="get" target="_blank">
		<select name="pdf" onChange="pop_n_put(this,'textfield');">
			<option value = "http://www.shaklee.com\tgo home dammit!">Home
			<option value = "/search\tsearch for it!">Search
		</select>
		<textarea name="textfield" rows="5" cols="80"></textarea>
		<input type="submit" name="view pdf" value="view pdf">
	</form>
*/
function pop_n_put(where,textfield) {
		//if ( where.selectedIndex ) {
			var val = where.options[where.selectedIndex].value;
			var item = val.split('\t');
			where.form[textfield].value = item[1];
			where.form.action = item[0];
		//}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

/* call me like this ------------------showhide--------------------
	<div id="details-control">
		<h1><a href="javascript:showhide('details')"><img src=></a>Details</h1>
	</div>
	<div id="details-instructions">	
		Instructiuoins ...
	</div>
	<div id="details-main">
		...
		the bulk of it 
		...
	</div>
*/
/* POPUP for anything , with optional width and height */
function popNwait(url,width,height,resize,sbars) {
	var wid = arguments.length >= 2 ? width : 400;
	var hei = arguments.length >= 3 ? height: 500;
	var res = arguments.length >= 0 ? resize: 1;
	var sba = arguments.length = 0 ? scrollbars: 1;
	self.name = "main"; 
	var w = window.open(url,"PopUp",
				'toolbar=0,location=0,directories=0,status=yes,menubar=0,align=center,valign=bottom' +
				',width=' + wid + ',height=' + hei + ',resizable=' + res + ',scrollbars=' + sba)
}

function showhide(superDiv) {
	var id = superDiv + "-main";
	// we might do something with the instructions later...
	if (document.layers && document.layers[id])
		document.layers[id].visibility = 
		document.layers[id].visibility == "hide" ? "show" : "hide"
	else if (document.getElementById && document.getElementById(id))
		document.getElementById(id).style.display = 
		document.getElementById(id).style.display != "none" ? "none" : "block"
	else if (document.all && document.all[id])
		document.all[id].style.display = 
		document.all[id].style.display != "none" ? "none" : "block"
	// else 
		//alert("Perhaps Jake lost his mind '" + id + "'?");
}
function show(superDiv) {
	var id = superDiv + "-main";
	if (document.layers && document.layers[id])
		document.layers[id].visibility = "show"
	else if (document.getElementById && document.getElementById(id))
		document.getElementById(id).style.display = "block"
	else if (document.all && document.all[id])
		document.all[id].style.display = "block" 
	// else 
		//alert("Perhaps Jake lost his mind '" + id + "'?");
}
function hide(superDiv) {
	var id = superDiv + "-main";
	if (document.layers && document.layers[id])
		document.layers[id].visibility = "hide"
	else if (document.getElementById && document.getElementById(id))
		document.getElementById(id).style.display = "none"
	else if (document.all && document.all[id])
		document.all[id].style.display = "none"
	// else 
		//alert("Perhaps Jake lost his mind '" + id + "'?");
}

/* call me like this  --------------- di -------------------
	<body onload="di_load();">
	
*/
function di_load() {
	if (document.images) {
		Ilogo = new Image(100, 17);
		Ilogo.src='images/shaklee_home.gif' ;
		Ilogo_over = new Image(100, 17);
		Ilogo_over.src='images/shaklee_home_over.gif' ;
	}
}
function di(id,name) {
	if (document.images) {
		document.images[id].src=eval(name+".src")
		}
}

function openpdf(pdf) {
	var plugs = 0;
	if (navigator.appName == "Netscape") {
		plugs = navigator.plugins.length ;
		windowFeatures = 'scrollbars,resizable,status,toolbar,location,directories,width=500,height=450' ;
	}
	else {
		windowFeatures = 'scrollbars,resizable,status,toolbar,location,directories,width=500,height=450' ;
	}
	if (pdf == "") {
		//document.writeln("Your documents are being e-mailed as you read this!");
	}
	else if (pdf.indexOf(" ")>0) {
		document.writeln("We encountered an error!");
		document.writeln(pdf);
	}
	else {
		if ( plugs == 0 || navigator.plugins.PDFViewer != null ) {
			var win = window.open (pdf , 'PDF', windowFeatures) ;
		}
		else {
			document.writeln("I can't find the Adobe Acrobat PDF Viewer plugin (" + plugs +")." );
			document.writeln("<table border = 3>");
			for(i=0; i<plugs; i++)
			{
			 document.writeln("<tr>");
			 document.writeln("<td>" + navigator.plugins[i].name + "</td>");
			 document.writeln("<td>" + navigator.plugins[i].description + "</td>");
			 document.writeln("<td>" + navigator.plugins[i].filename + "</td>");
			 document.writeln("</tr>");
			}
			document.writeln("</table>");
		}
	}
}

/* call me like this  --------------- MM stuff	-------------------
<body onLoad="MM_preloadImages('images/nutrition_arrow_F2.gif','images/nutritional_mouseover2.jpg','#937265812600');
MM_preloadImages('images/herbal_formulas_arrow_F2.gif','images/herbal_mouseover.gif','#937265812601');
MM_preloadImages('images/sports_arrow_F2.gif','images/sports_mouseover.jpg','#937265812602');
MM_preloadImages('images/water_treatment_arrow_F2.gif','#937265812603');
MM_preloadImages('images/household_products_arr_F2.gif','images/household_mouseover.jpg','#937265812604');
MM_preloadImages('images/personal_care_arrow_F2.gif','images/personal_care_mouseover.jpg','#937265812605');
MM_preloadImages('images/nutrition_arrow_F2.gif','#937265812606');
MM_preloadImages('images/herbal_formulas_arrow_F2.gif','#937265812607');
MM_preloadImages('images/sports_arrow_F2.gif','#937265812608');
MM_preloadImages('images/water_treatment_arrow_F2.gif','#937265812609');
MM_preloadImages('images/household_products_arr_F2.gif','#937265812610');
MM_preloadImages('images/personal_care_arrow_F2.gif','#937265812611');">

*/

function MM_preloadImages() { //v3.0
	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_swapImgRestore() { //v3.0
	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_findObj(n, d) { //v3.0
	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); return x;
}
function MM_swapImage() { //v3.0
	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];}
}

function MM_switchImage() { //v3.0
	var i,j=0,x,a=MM_switchImage.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];}
}
function MM_switchImgBack() { //v3.0
	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_pregetImages() { //v3.0
	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];}}
}

/* POPUP FROM EDIT2 */
function writingPopUp(url) {
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=560,height=480');
}

/* POPUP FROM EDIT2 */
function myPics(url) {
	self.name = "main"; 
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=450,height=280');
}

/* POPUP for convention.swf*/
function convention(url) {
	self.name = "main"; 
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=500,height=450,align=center,valign=bottom');
}
/* POPUP for profiler winners*/
function winners(url) {
	self.name = "main"; 
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=420,height=500,align=center,valign=bottom');
}

/* POPUP for HELP*/
function popHelp(url) {
	self.name = "Parent"; 
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,width=450,height=485');
}

/* POPUP for GEN HELP*/
function popGenHelp(url) {
	self.name = "Parent"; 
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,width=500,height=430');
}

/* POPUP for PRIVACY PAGE APPS */
function privacyPopUp(url) {
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=610,height=450');
}

/* POPUP for SECURITY PAGE APPS */
function securityPopUp(url) {
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=610,height=450');
}

/* POPUP for clipstream*/
function clipstream(url) {
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=378,height=215,align=center,valign=bottom');
}			
/* POPUP for content image uploader */
function popUpPromo(url) {
	self.name = "main"; 
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=400,height=320,align=center,valign=bottom');
}			
/* POPUP for content image uploader */
function popUpSegArticle(url) {
	self.name = "main"; 
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=400,height=350,align=center,valign=bottom');
}			
/* POPUP for anything , with optional width and height */
function popUp(url,width,height) {
	var wid = arguments.length >= 2 ? width : 400;
	var hei = arguments.length >= 3 ? height: 500;
	self.name = "main"; 
	var w = window.open(url,"PopUp",
				'toolbar=0,location=0,directories=0,status=yes,menubar=0,scrollbars=0,resizable=yes,align=center,valign=bottom' +
				',width=' + wid + ',height=' + hei)
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

 function closeRemote() {
 timer = setTimeout('window.close();', 10);
 }
function clips(look,audiofile) {
	/* call me like this:
			<a href="javscript:clips('mem','011214')"> Click me!</a>
	*/
	/* look = pws or mem */
	/* audiofile = 010417 */
	/* mem_player_r1_c1.gif */ 
	/* pws_player_r1_c1.gif */
	url = "http://www.shaklee.net/public/clipplayer?look=" + look + "&audiofile=" + audiofile;
	X = window.open(url,"win",
		'toolbar=0,location=0,directories=0,status=1,menubar=0,' +
		'scrollbars=0,resizable=yes,width=295,height=187');
}
/* Check for Shockwave */
function checkForShockwave()
{
	navigator.plugins.refresh();
	if ( navigator.plugins["Shockwave Flash"] ){ 
		parent.location.reload();
	} else {
		setTimeout( "checkForShockwave()", 1000 );
	}
}
var ShockMode = 0;
if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
	if (navigator.plugins && navigator.plugins["Shockwave Flash"])
		ShockMode = 1;
}
if (!ShockMode && navigator.appName && navigator.appName.indexOf("Netscape") != - 1 && navigator.appVersion.indexOf("4.") != - 1
&& navigator.javaEnabled() && netscape.softupdate.Trigger.UpdateEnabled() && document.cookie.indexOf("StartedShockwaveInstall") == -1) {
	var jarPath = new String("");
	if (navigator.platform.indexOf("Win32") >= 0 )
		jarPath = "http://download.macromedia.com/pub/shockwave/jars/english/silentflash32.jar"
	else if (navigator.platform.indexOf("Win16") >= 0 )
		jarPath = "http://download.macromedia.com/pub/shockwave/jars/english/silentflash16.jar"
	else if (navigator.platform.indexOf("MacPPC") >= 0 )
		jarPath = "http://download.macromedia.com/pub/shockwave/jars/english/silentflashppc.jar"
	if (jarPath.length) {
		netscape.softupdate.Trigger.StartSoftwareUpdate (jarPath, netscape.softupdate.Trigger.FORCE_MODE);
		document.cookie='StartedShockwaveInstall;path=/;'
		setTimeout("checkForShockwave()", 1000);
	}
}

	

/* JS Code for behavior changes when dealing with CC Slots */

function clearCCFields ( form )
{
   /* this one is pretty simple, the user selected another payment
      type so clear the cc fields just in case */
   form.CardNum.value = '';
   form.CardName.value = '';
}

function setCCFields ( form, doSlot )
{
   /* This is even easier, just make sure the CC type is selected and
      if doSlot is set, than make sure we set the new slot button too. */
   var i;
   for (i = 0; i < form.PaymentType.length; i++ ){
      if ( form.PaymentType[ i ].value == 'CD' ){
         form.PaymentType[ i ].checked = true;
	 break;
      }
   }
//   if ( doSlot ) {
   if ( doSlot && form.CardSlot.length > 0) {
      i =  form.CardSlot.length - 1 ;
      if (form.CardSlot.type == 'radio') {
          form.CardSlot[i].checked = true;
      }
   }
}

/* End JS Code for behavior changes when dealing with CC Slots */

/* JS Code for Calculating shipping costs */

function calcShipping( form )
{
var weight = 0;

   for ( var i = 0; i < form.Weight.length; i++ )
   {
      if ( form.Item[ i ].value && form.Weight[ i ].value > 0 )
      {
	 weight += form.Weight[ i ].value * form.UQty[ i ].value;
      }
   }

   // Weight rounds to the next pound
   weight = Math.round( weight + 0.499 );

   if ( weight > 0 )
   {
      form.CalcWeight.value =  weight;

   var rates = new Object;

      rates[ 2 ] = 6.50
      rates[ 9 ] = 7.00
      rates[ 29 ] = 0.75
      rates[ 99 ] = 0.70
      rates[ 149 ] = 0.65
      rates[ 199 ] = 0.60
      rates[ 299 ] = 120.00
      rates[ 399 ] = 160.00
      rates[ 499 ] = 200.00
      rates[ 500 ] = 0.40

   var rate = 0;

      for ( i in rates )
      {
	 if ( weight <= i )
	 {
	    rate = rates[ i ];
	    break;
	 }
      }

      form.CalcShipping.value = rate < 1.00 ? precisionCalc( rate, weight, 2 ) : rate;
   }
   else
   {
      form.CalcWeight.value = '';
      form.CalcShipping.value = '';
   }

   return false;
}

function precisionCalc( a1, a2, precision )
{
var amt = a1 * a2 * 10 * precision;

   return Math.round( amt ) / ( 10 * precision );
}

/* End JS Code for Calculating shipping costs */

function dumpObject( obj )
{
   for ( var i in obj )
   {
      document.writeln( i + " =" );
      try
      {
      var txt = " " + obj[ i ];

	 if ( txt.length > 30 )
	 {
	    txt = txt.substring( 0, 30 ) + "...";
	 }
	 document.writeln( txt );
      }
      finally
      {
	 document.writeln( "<br>\n" );
      }

   }
   document.writeln( "<br>\n" );

   return false;
}

function getCurrentAutoShip()
{
var elements = document.getElementsByName( 'currentAutoShip' );

   return elements.length ? elements[ 0 ].value : 0;
}

function switchItems( form )
{
   // Move all the Item and UQty values into the ItemAS and UQtyAS
   // fields instead.  There is a one to one relationship here.

   for ( var i = 0; i < form.ItemAS.length; i++ )
   {
      form.ItemAS[ i ].value = form.Item[ i ].value;
      form.Item[ i ].value = '';

      form.UQtyAS[ i ].value = form.UQty[ i ].value;
      form.UQty[ i ].value = '';
   }
}



