// JavaScript Document
function validaCB()
{
	if (document.order.quantity3.checked==false && document.order.quantity2.checked==false && document.order.quantity1.checked==false)
	{
		ship  = (window.document.order.ship);
		ship.value = 2;
	}
}
function wipe1(i)
{
	validaCB();
}
function formGCheck(){
	var amount=-1;
	var country="";
	var ship=-1;
	var act=-1;
	
	var total=0;
	var shipping=0;
	var shipDesc="";
	var itemCost=0;
	var itemDesc="";
	var itemOfeCost=0;


	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.ship.value);
				//Shipping costs
		if(ship==1){shipping=0; shipDesc=" + FREE Shipping USA - $" + shipping + " - USA ONLY";}//Ground
		if(ship==2){shipping=9.95; shipDesc=" + UPS Standard - $" + shipping + " - USA ONLY";}//Standard
		if(ship==3){shipping=16.95; shipDesc=" + USA Priority - $" + shipping + " - USA ONLY";}//Standard
		if(ship==4){shipping=34.95; shipDesc=" + Shipping for International orders - $" + shipping + "";}//International
		//item costs and item description to be passed to Paysystems.
		//alert(	amount + "\n"+ shipping + "\n" + window.document.order.bulk.value);
		
		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=254.95;itemDesc="3 Deluxe Comfort Pillows - $" + itemCost + "\n ";}
		
		//nuevos articulos
	if(document.order.checkbox.checked==true)
	{
		var terry = document.getElementById("terry_cover");
		var cantterry = terry.options[terry.selectedIndex].value;
		var costerry = (cantterry * 9.95);
		itemOfeCost=itemOfeCost+costerry;
		itemDesc = itemDesc + cantterry + " terry_cover \n" ;
	}
	if(document.order.checkbox2.checked==true)
	{
		var fiber = document.getElementById("fiber_cover");
		var cantfiber = fiber.options[fiber.selectedIndex].value;
		var cosfiber = (cantfiber * 24.95);
		itemOfeCost=itemOfeCost+cosfiber;
		itemDesc = itemDesc + cantfiber + " fiber_cover \n" ;
	}
	if(document.order.checkbox3.checked==true)
	{		
		var legpillow = document.getElementById("legpillow");
		var cantlegpillow = legpillow.options[legpillow.selectedIndex].value;
		var coslegpillow = (cantlegpillow * 24.95);
		itemOfeCost=itemOfeCost+coslegpillow;
		itemDesc = itemDesc + cantlegpillow + " legpillow \n" ;
	}
	if(document.order.checkbox4.checked==true)
	{
		var sleepatil = document.getElementById("sleepatil");
		var cantsleepatil = sleepatil.options[sleepatil.selectedIndex].value;
		var cossleepatil = (cantsleepatil * 19.95);
		itemOfeCost=itemOfeCost+cossleepatil;
		itemDesc = itemDesc + cantsleepatil + " sleepatil \n" ;
	}
	itemCost = itemCost +  itemOfeCost ;
		//end
		
	window.document.order.description.value = (itemDesc + "\n " + shipDesc);

	var itemName = document.getElementById("itemName");
	var itemDescription = document.getElementById("itemDescription");
	var itemPrice = document.getElementById("itemPrice");
	var itemShipping = document.getElementById("itemShipping");
	itemDescription.value = itemDesc ;
	itemPrice.value=itemCost ;
	itemName.value = itemDesc ;
	itemShipping.value=shipping ;
	document.GcheckOut.submit();
	return true;
}
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="";
	var itemOfeCost=0;


	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.ship.value);
				//Shipping costs
		if(ship==1){shipping=0; shipDesc=" + FREE Shipping USA - $" + shipping + " - USA ONLY";}//Ground
		if(ship==2){shipping=9.95; shipDesc=" + UPS Standard - $" + shipping + " - USA ONLY";}//Standard
		if(ship==3){shipping=16.95; shipDesc=" + UPS Priority Mail - $" + shipping + " - USA ONLY";}//Priority
		if(ship==4){shipping=24.95; shipDesc=" + Shipping for International orders - $" + shipping + "";}//International
		//item costs and item description to be passed to Paysystems.
		//alert(	amount + "\n"+ shipping + "\n" + window.document.order.bulk.value);
		
		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=254.95;itemDesc="3 Deluxe Comfort Pillows - $" + itemCost + "\n ";}
		
		//nuevos articulos
	if(document.order.checkbox.checked==true)
	{
		var terry = document.getElementById("terry_cover");
		var cantterry = terry.options[terry.selectedIndex].value;
		var costerry = (cantterry * 9.95);
		itemOfeCost=itemOfeCost+costerry;
		itemDesc = itemDesc + cantterry + " terry_cover \n" ;
	}
	if(document.order.checkbox2.checked==true)
	{
		var fiber = document.getElementById("fiber_cover");
		var cantfiber = fiber.options[fiber.selectedIndex].value;
		var cosfiber = (cantfiber * 24.95);
		itemOfeCost=itemOfeCost+cosfiber;
		itemDesc = itemDesc + cantfiber + " fiber_cover \n" ;
	}
	if(document.order.checkbox3.checked==true)
	{		
		var legpillow = document.getElementById("legpillow");
		var cantlegpillow = legpillow.options[legpillow.selectedIndex].value;
		var coslegpillow = (cantlegpillow * 24.95);
		itemOfeCost=itemOfeCost+coslegpillow;
		itemDesc = itemDesc + cantlegpillow + " legpillow \n" ;
	}
	if(document.order.checkbox4.checked==true)
	{
		var sleepatil = document.getElementById("sleepatil");
		var cantsleepatil = sleepatil.options[sleepatil.selectedIndex].value;
		var cossleepatil = (cantsleepatil * 19.95);
		itemOfeCost=itemOfeCost+cossleepatil;
		itemDesc = itemDesc + cantsleepatil + " sleepatil \n" ;
	}
	itemCost = itemCost +  itemOfeCost ;
		//end
		
	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;
	if (itemCost <= 0)
	{
		return false;
	}else{
		return true;
	}

}
function wipe(exclude){
	document.order.quantity1.checked=false;
	document.order.quantity2.checked=false;
	document.order.quantity3.checked=false;
	//show(2);
	if(exclude==1){
	document.order.quantity1.checked=true;
	}
	if(exclude==2){
	document.order.quantity2.checked=true;
	//show(2);
	}
	if(exclude==3){
	document.order.quantity3.checked=true;
	//show(2);
	}
}

function getCookie (name) {
	var dc = document.cookie;
	var cname = name + "=";
	var clen = dc.length;
	var cbegin = 0;
	while (cbegin < clen) { 
	var vbegin = cbegin + cname.length;
	if (dc.substring(cbegin, vbegin) == cname) { 
		var vend = dc.indexOf (";", vbegin);
	if (vend == -1) vend = clen;
		return unescape(dc.substring(vbegin, vend));
	}
	cbegin = dc.indexOf(" ", cbegin) + 1;
	if (cbegin== 0) break;
	}
	return null;
}
affiliatecookie = getCookie('curecash.com');

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 checkPayPal(){
	var amount=-1;
	var country="";
	var ship=-1;
	var act=-1;
	
	var total=0;
	var shipping=0;
	var shipDesc="";
	var itemCost=0;
	var itemDesc="";
	var itemOfeCost=0;

	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.ship.value);
				//Shipping costs
		if(ship==1){shipping=0; shipDesc=" + FREE Shipping USA   - USA ONLY";}//Ground
		if(ship==2){shipping=9.95; shipDesc=" + UPS Standard - $" + shipping + " - USA ONLY";}//Standard
		if(ship==3){shipping=16.95; shipDesc=" + UPS Priority Mail - $" + shipping + " - USA ONLY";}//Priority
		if(ship==4){shipping=24.95; shipDesc=" + Shipping for International orders - $" + 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=254.95;itemDesc="3 Deluxe Comfort Pillows - $" + itemCost + "\n ";}
	
				//nuevos articulos
	if(document.order.checkbox.checked==true)
	{
		var terry = document.getElementById("terry_cover");
		var cantterry = terry.options[terry.selectedIndex].value;
		var costerry = (cantterry * 9.95);
		itemOfeCost=itemOfeCost+costerry;
		itemDesc = itemDesc + cantterry + " terry_cover \n" ;
	}
	if(document.order.checkbox2.checked==true)
	{
		var fiber = document.getElementById("fiber_cover");
		var cantfiber = fiber.options[fiber.selectedIndex].value;
		var cosfiber = (cantfiber * 24.95);
		itemOfeCost=itemOfeCost+cosfiber;
		itemDesc = itemDesc + cantfiber + " fiber_cover \n" ;
	}
	if(document.order.checkbox3.checked==true)
	{		
		var legpillow = document.getElementById("legpillow");
		var cantlegpillow = legpillow.options[legpillow.selectedIndex].value;
		var coslegpillow = (cantlegpillow * 24.95);
		itemOfeCost=itemOfeCost+coslegpillow;
		itemDesc = itemDesc + cantlegpillow + " legpillow \n" ;
	}
	if(document.order.checkbox4.checked==true)
	{
		var sleepatil = document.getElementById("sleepatil");
		var cantsleepatil = sleepatil.options[sleepatil.selectedIndex].value;
		var cossleepatil = (cantsleepatil * 19.95);
		itemOfeCost=itemOfeCost+cossleepatil;
		itemDesc = itemDesc + cantsleepatil + " sleepatil \n" ;
	}
	itemCost = itemCost +  itemOfeCost ;
		//end
	
	//window.document.orderForm.description.value=(itemDesc + "\n " + shipDesc);
	window.document.order.amount.value=round_decimals((itemCost+shipping), 2);
	window.document.order.item_name.value=itemDesc+shipDesc;
}

function show(miVar){
	var menu = document.getElementById("oferta");
	 if (miVar == 1){
	 menu.style.display = "none";
	 }else{
	 menu.style.display = "";
	 }

	 }

today = new Date();
year = (today.getFullYear) ? today.getFullYear() : today.getYear();

month = (today.getMonth()+1)%11;
switch (month) {
			 case 0 : month = "January"; break;
			 case 1 : month = "February"; break;
			 case 2 : month = "March"; break;
             case 3 : month = "April"; break;
			 case 4 : month = "May"; break;
			 case 5 : month = "June"; break;
			 case 6 : month = "July"; break;
			 case 7 : month = "August"; break;
			 case 8 : month = "September"; break;
			 case 9 : month = "October"; break;
			 case 10 : month = "November"; break;
			 case 11 : month = "December"; break;
			 }
timeStr = month;

