(function($) {

$(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");
		s += "&UserToken=" + UserToken;
        	document.location.href="http://shopping.netsuite.com/app/site/query/additemtocart.nl?ext=T&" + s;
	        return false;
            
	});

});

})(jQuery);// JavaScript Document

/*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)
	}
}
