$(document).ready(function() {
//Function to get the Hubspot Cookie from the Browsers
    function ReadCookie(c_name){
	if (document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name + "=")
		if (c_start!=-1){ 
			c_start=c_start + c_name.length+1 
			c_end=document.cookie.indexOf(";",c_start)
		if (c_end==-1) 
			c_end=document.cookie.length
		return unescape(document.cookie.substring(c_start,c_end))
		} 
	}
	return null;
    }
$form = $('#Form');

$("input[type='image']").click(function() {

var s="";

  $(this).parents(".shopOutline").find("input").not("input[type='image']").each(
  function( intIndex ){
  s+=$(this).attr('name') + '=' + $( this ).val() + '&';
  });
  $(this).parents(".shopOutline").find("select").each(
  function( intIndex ){
  s+=$(this).attr('name') + '=' + $(this).children('option:selected').val() + '&';

  });

var UserToken = ReadCookie("hubspotutk");
//alert(UserToken);
s += "&UserToken=" + UserToken;

//alert(s);
//$form.attr("action","http://shopping.netsuite.com/app/site/backend/additemtocart.nl?" + s);
//$form.attr("method","GET");
//$form.attr("target","_blank");
//$("input[type='hidden']").remove();
//$("input").remove();
//$("select").remove();
//$(".ContactFormWrapper input").remove();
//$(".ContactFormWrapper select").remove();
//$(".ContactFormWrapper textarea").remove();
// + "c=1013154n=1&buyid=118&n=1&custcol1=1&custcol2=1"


//alert(s);

document.location.href="http://shopping.netsuite.com/app/site/backend/additemtocart.nl?" + s;
return false;
});




});


/*This file contains functions used to calculate Kits & Total cost*/


function Calculate_Kits_Subtotal(selCoverageId, Price, NumKitsId, SubtotalId)
{
	try
	{
		var numKits=isNaN(document.getElementById(selCoverageId).value)==true ? 0 : document.getElementById(selCoverageId).value*1;
		isNaN(Price)==true ? Price=0 : Price=Price*1;
		var subTotal=Price * numKits;
		document.getElementById(NumKitsId).innerHTML=numKits;
		document.getElementById(SubtotalId).innerHTML=subTotal.toFixed(2);
	}
	catch(e)
	{
		alert("ERROR!!! "+e.message)
	}
}

