// JavaScript Document
/*
function checkForm(){
	var amount=-1;
	var country="";
	var ship=-1;
	var act=-1;
	
	var total=0;
	var shipping=0;
	var shipDesc="";
	var itemCost=0;
	var itemDesc="";


	if(document.order.quantity1.checked==true){amount=1;}
	if(document.order.quantity2.checked==true){amount=2;}
	if(document.order.quantity3.checked==true){amount=3;}

	ship    = (""+window.document.order.shipping.value);
		if(ship==1){shipping=9.95; shipDesc=" + UPS Ground Shipping - $" + shipping + " - USA ONLY";}//Ground
		if(ship==2){shipping=16.95; shipDesc=" + UPS Priority Mail - $" + shipping + " - USA ONLY";}//Priority
		if(ship==4){shipping=34.95; shipDesc=" + INTERNATIONAL UPS Priority Mail - $" + shipping + "";}//International
		
		if(amount=="1"){itemCost=99.95; itemDesc="1 Deluxe Comfort Pillow - $" + itemCost + "\n ";}
		if(amount=="2"){itemCost=179.95;itemDesc="2 Deluxe Comfort Pillows - $" + itemCost + "\n ";}
		if(amount=="3"){itemCost=225.95;itemDesc="3 Deluxe Comfort Pillows - $" + itemCost + "\n ";}
		
		
	window.document.order.description.value=(itemDesc + "\n " + shipDesc);

	window.document.order.subtotal.value=itemCost;
	window.document.order.shipping.value=shipping;
	window.document.order.chargetotal.value=round_decimals((itemCost+shipping), 2)
	window.document.order.cashflow.value=itemCost;
	
	for(i=0;i<6;i++){
		if(window.document.orderForm.packs[i].checked==true){
			amount=window.document.orderForm.packs[i].value;
			break;
		}
	}
	ship    = (""+window.document.orderForm.ship.value);

	if(ship==1){shipping=9.95; shipDesc="UPS Ground Shipping - $" + shipping + " - USA ONLY";}//Ground
	if(ship==2){shipping=16.95; shipDesc="UPS Priority Mail - $" + shipping + " - USA ONLY";}//Priority
	if(ship==4){shipping=34.95; shipDesc="INTERNATIONAL UPS Priority Mail - $" + shipping + "";}//International

	
	if(amount=="VPRX_1"){itemCost=59.95; itemDesc="1 Bottle of MacaEnhancer - $" + itemCost + " ";}
	if(amount=="VPRX_2"){itemCost=109.95;itemDesc="2 Bottles of MacaEnhancer - $" + itemCost + " ";}
	if(amount=="VPRX_3"){itemCost=154.95;itemDesc="3 Bottles of MacaEnhancer - $" + itemCost + " + 1 FREE Bonus Bottle - ";}
	if(amount=="VPRX_4"){itemCost=199.95;itemDesc="4 Bottles of MacaEnhancer - $" + itemCost + " + 1 FREE Bonus Bottle - ";}
	if(amount=="VPRX_5"){itemCost=245.95;itemDesc="5 Bottles of MacaEnhancer - $" + itemCost + " + 1 FREE Bonus Bottle  - ";}
	
	
	window.document.orderForm.description.value=(itemDesc + "\n " + shipDesc);

	window.document.orderForm.subtotal.value=itemCost;
	window.document.orderForm.shipping.value=shipping;
	window.document.orderForm.chargetotal.value=round_decimals((itemCost+shipping), 2)
	window.document.orderForm.cashflow.value=itemCost;
	

				

}

function round_decimals(original_number, decimals) {
    var result1 = original_number * Math.pow(10, decimals)
    var result2 = Math.round(result1)
    var result3 = result2 / Math.pow(10, decimals)
    return pad_with_zeros(result3, decimals)
}

function pad_with_zeros(rounded_value, decimal_places) {

    // Convert the number to a string
    var value_string = rounded_value.toString()
    
    // Locate the decimal point
    var decimal_location = value_string.indexOf(".")

    // Is there a decimal point?
    if (decimal_location == -1) {
        
        // If no, then all decimal places will be padded with 0s
        decimal_part_length = 0
        
        // If decimal_places is greater than zero, tack on a decimal point
        value_string += decimal_places > 0 ? "." : ""
    }
    else {

        // If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1
    }
    
    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length
    
    if (pad_total > 0) {
        
        // Pad the string with 0s
        for (var counter = 1; counter <= pad_total; counter++) 
            value_string += "0"
        }
    return value_string
}

function wipe(exclude){
	//alert(exclude);
	document.order.quantity1.checked=false;
	document.order.quantity2.checked=false;
	document.order.quantity3.checked=false;
	
	if(exclude==1){document.order.quantity1.checked=true;}
	if(exclude==2){document.order.quantity2.checked=true;}
	if(exclude==3){document.order.quantity3.checked=true;}
}*/

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_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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); 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 leapto(form) {
var myindex=form.dest.selectedIndex;
self.location.href=(form.dest.options[myindex].value);
}

today = new Date();
year = (today.getFullYear) ? today.getFullYear() : today.getYear();
month = today.getMonth();
switch (month) {
			 case 0 : month = "Jan"; break;
			 case 1 : month = "Feb"; break;
			 case 2 : month = "Mar"; break;
                         case 3 : month = "Apr"; break;
			 case 4 : month = "May"; break;
			 case 5 : month = "Jun"; break;
			 case 6 : month = "Jul"; break;
			 case 7 : month = "Aug"; break;
			 case 8 : month = "Sep"; break;
			 case 9 : month = "Oct"; break;
			 case 10 : month = "Nov"; break;
			 case 11 : month = "Dec"; break;
			 }
date = today.getDate();
day = today.getDay();
switch (day) {
			 case 0 : day = "Sun"; break;
			 case 1 : day = "Mon"; break;
			 case 2 : day = "Tue"; break;
			 case 3 : day = "Wed"; break;
			 case 4 : day = "Thu."; break;
			 case 5 : day = "Fri"; break;
			 case 6 : day = "Sat"; break;
			 }
hours = today.getHours();
  if (hours<12)  greeting = '<br>Sleep Good?';
	if (hours<18 && hours>11)  greeting = '<br>Afternoon! - Nap?';
	if (hours<20 && hours>17)  greeting = '<br>Restful Sleep!';
	if (hours>19)  greeting = '<br>(Sleep Good Tonight)';
hour = (hours>12) ? (hours-12) : hours;
halfDay = (hours>11 && hours<24) ? 'PM' : 'AM';
minutes = today.getMinutes();
dayStr =  day+ ', ' +date+ '&nbsp;' +month+ ',&nbsp;' +year;
timeStr = (minutes<10) ? hour+ ':0' +minutes+ ' ' +halfDay : hour+ ':' +minutes+ ' ' +halfDay;

