function check_checkboxes_checked() {
	message = "";
	if (document.products.p1.checked == false && document.products.p2.checked == false && document.products.p3.checked == false && document.products.p4.checked == false && document.products.p5.checked == false && document.products.p6.checked == false && document.products.p7.checked == false && document.products.p8.checked == false && document.products.p9.checked == false && document.products.p10.checked == false && document.products.p11.checked == false && document.products.p12.checked == false && document.products.p13.checked == false) {
		message += "\n Please choose an offer";
		message += "\n by checking one or";
		message += "\n more checkbox.";
		alert(message);
		return false;
	}
	return true;
}

function validateForm(charge_cc)
{
	message = "";
	if (!document.charge_cc.agree.checked) {
		message += "\n  You must agree to the terms and";
		message += "\n conditions by checking the checkbox.";
		message += "\n    Please complete and resubmit.";
		alert(message);
		return false;
	}

	if(""==document.forms.charge_cc.ccnumber.value)
	{
		alert("Please enter your credit card number.");
		document.forms.charge_cc.ccnumber.focus();
		return false;
	}
	
	if(""==document.forms.charge_cc.ccv2.value)
	{
		alert("Please enter your CVV2 code. This is the 3 or 4 digit number on the back of your card. This number is on the front of American Express cards.");
		document.forms.charge_cc.ccv2.focus();
		return false;
	}
	
	if(""==document.forms.charge_cc.ccmonth.value)
	{
		alert("Please enter your expiration date, MM/YYYY.");
		document.forms.charge_cc.ccmonth.focus();
		return false;
	}
	
	if(!IsNumeric(document.forms.charge_cc.ccmonth.value))
	{
		alert("Please enter your expiration date, MM/YYYY.");
		document.forms.charge_cc.ccmonth.focus();
		return false;
	}
		
	if(""==document.forms.charge_cc.ccyear.value)
	{
		alert("Please enter your expiration date, MM/YYYY.");
		document.forms.charge_cc.ccyear.focus();
		return false;
	}
	
	if(!IsNumeric(document.forms.charge_cc.ccyear.value))
	{
		alert("Please enter your expiration date, MM/YYYY.");
		document.forms.charge_cc.ccmonth.focus();
		return false;
	} 
	
	if (document.forms.charge_cc.paymenttype[1].checked) {
		var d = new Date();
		var curr_month = d.getMonth();
		curr_month++;
		var month_window = curr_month + 3;
		var curr_year = d.getFullYear();
		var year_window = curr_year;
		if (month_window > 12) {
			month_window = month_window - 12;
			year_window++;
		}
		if (year_window >= document.forms.charge_cc.ccyear.value) {
			if (month_window > document.forms.charge_cc.ccmonth.value || year_window > document.forms.charge_cc.ccyear.value) {
			alert("Your credit card must not expire less than 3 months in the future if you choose the 3-payment option. Please choose a single payment option, or enter another credit card.");
			document.forms.charge_cc.ccmonth.focus();
			return false;
			}
		}
	}
	
	if(""==document.forms.charge_cc.firstname.value)
	{
		alert("Please enter your first name.");
		document.forms.charge_cc.firstname.focus();
		return false;
	}
	
	if(""==document.forms.charge_cc.lastname.value)
	{
		alert("Please enter your last name.");
		document.forms.charge_cc.lastname.focus();
		return false;
	}
	
	if(""==document.forms.charge_cc.address1.value)
	{
		alert("Please enter your address.");
		document.forms.charge_cc.address1.focus();
		return false;
	}

		if(""==document.forms.charge_cc.city.value)
	{
		alert("Please enter your city.");
		document.forms.charge_cc.city.focus();
		return false;
	}
	
		if(""==document.forms.charge_cc.postalcode.value)
	{
		alert("Please enter your postal code.");
		document.forms.charge_cc.postalcode.focus();
		return false;
	}
	
		if(""==document.forms.charge_cc.country.value || "Select Country"==document.forms.charge_cc.country.value)
	{
		alert("Please enter your country.");
		document.forms.charge_cc.country.focus();
		return false;
	}
	
	  if(""==document.forms.charge_cc.email.value)
	{
		alert("Please enter your email address.");
		document.forms.charge_cc.email.focus();
		return false;
	}
	
		if(""==document.forms.charge_cc.shippingcost.value)
	{
		alert("Please choose the correct shipping zone.");
		document.forms.charge_cc.shippingcost.focus();
		return false;
	}
	
}

function emailvalidation(entered, alertbox)
{
	// E-mail Validation by Henrik Petersen / NetKontoret
	// Explained at www.echoecho.com/jsforms.htm
	// Please do not remove this line and the two lines above.
	with (entered)
	{
		apos=value.indexOf("@"); 
		dotpos=value.lastIndexOf(".");
		lastpos=value.length-1;
		if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
		{	if (alertbox) {alert(alertbox);} return false;}
		else {return true;}
	}
} 

function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) {
         IsNumber = false;
         }
      }
   return IsNumber;
}


// start email 
function checkFirst(){
 if (document.email_form.first_name.value.length <1){
 	document.email_form.first_name.value = 'Your First Name Here';
 }
}

function checkEmail(){
 if (document.email_form.email.value.length <1){
 	document.email_form.email.value = 'Your Email Address';
 }
}

function hideDiv(elementID){
	document.getElementById(elementID).style.display="none";
	
}

function showDiv(elementID){
	document.getElementById(elementID).style.display="block";
	
}

function go()
{
	box = document.forms[0].navi;
	destination = box.options[box.selectedIndex].value;
	if (destination == 'rg4kids'){
		hideDiv('rg4kids'); 
		showDiv('test');
	}
	
	if (destination == 'test'){
		hideDiv('test'); 
		showDiv('rg4kids');
	}
}
// end email

// check Flash
function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}

// function to update shipping cost & total
// NOT working
function zoneChange(zone_id)
{
	if (document.getElementById && document.getElementsByTagName && document.createTextNode) {
		shipCost = zone_id;
		totalCost = subtotal + shipCost;
		
		shipCost = pricify(shipCost);
		postage_value.nodeValue="$"+pricify(shipCost);

		totalCost = pricify(totalCost);	
		total_value.nodeValue="$"+pricify(totalCost);
	}
}

function pricify(n)
{
	// round up first to the nearest hundredth first
	n = Math.round( 100 * n )/100;
	
	// now format as a price
	n = n+"";
	indx = n.indexOf('.')
	if ( indx > 0 ) {
		n = n+"00";
		n = n.substring(0,indx+3);
	} else {
		n = n+".00";
	}
	return n;
}

function displayPricing(subtotal) {
	if (document.getElementById && document.getElementsByTagName && document.createTextNode) {
		var table = document.getElementById("ship_zone_table");
		var rowItems = table.getElementsByTagName("tr");
	
		// add the subtotal rows to the table
	
		var rowCount = rowItems.length;
		var newRow = table.insertRow(rowCount);
		var subtotalTextCell = newRow.insertCell(newRow.cells.length);
		var subtotalValueCell = newRow.insertCell(newRow.cells.length);
		subtotalTextCell.setAttribute('class',postage_text)
		subtotalValueCell.setAttribute('class',postage_value)
	
		var sub_total_text = document.createTextNode('Subtotal: ');
		var sub_total_value = document.createTextNode("$"+pricify(subtotal));
	
		subtotalTextCell.appendChild(sub_total_text);
		subtotalValueCell.appendChild(sub_total_value);
	
		// add the postage rows
	
		var rowCount = rowItems.length;
		var newRow = table.insertRow(rowCount);
	
		var postageTextCell = newRow.insertCell(newRow.cells.length);
		var postageValueCell = newRow.insertCell(newRow.cells.length);
	
		var postage_text = document.createTextNode('Postage: ');
		var postage_value = document.createTextNode("?");
	
		postageTextCell.appendChild(postage_text);
		postageValueCell.appendChild(postage_value);
	
		// add the total rows
	
		var rowCount = rowItems.length;
		var newRow = table.insertRow(rowCount);
		var totalTextCell = newRow.insertCell(newRow.cells.length);
		var totalValueCell = newRow.insertCell(newRow.cells.length);
	
		var total_text = document.createTextNode('Total: ');
		var total_value = document.createTextNode("?");
	
		totalTextCell.appendChild(total_text);
		totalValueCell.appendChild(total_value);
	}
}