/**
 * 
 */

jQuery(document).ready(function(){
	//alert('run');
	jQuery('.cart66ProdRadio').click(function(){
		//alert('run');
		var prodVal = jQuery(this).val();
		var prodName = jQuery(this).attr('name');
		jQuery("#"+prodName).val(prodVal);
	});
	
	jQuery('a.moretoggle').click(function(){
        jQuery(this).next().show();
        jQuery(this).hide();
        return false;
	});
	
	var certifications = jQuery("#cb_prod_id_70, #cb_prod_id_71, #cb_prod_id_72");
	var certificationsQty = jQuery("#qty-70, #qty-71, #qty-72");
	
	var qtyWorkbookInputs = "#qty-096, #qty-053, #qty-093, #qty-084, #qty-004";
	var cbProdIds = "#cb_prod_id_96, #cb_prod_id_53, #cb_prod_id_93, #cb_prod_id_84, #cb_prod_id_4";
	
	var totalCerts = 0;
	var workbooks = 0;
	
	jQuery(certifications).each(function(){
		jQuery(this).click(function(){
			totalWorkbooks();
		});
	});
	
	jQuery(certificationsQty).each(function(){
		jQuery(this).blur(function(){
			totalWorkbooks();
		});
	});
	
	function totalWorkbooks(){
		totalCerts = 0;
		jQuery(certificationsQty).each(function(){
			if(parseInt(jQuery(this).val())){
				totalCerts += parseInt(jQuery(this).val());
			}
		});
		//alert(totalCerts);
		if(totalCerts>0){
			workbooks = totalCerts * 25;
			jQuery(qtyWorkbookInputs).val(workbooks);
			jQuery(cbProdIds).attr("checked", "checked");
		} else {
			jQuery(qtyWorkbookInputs).val('');
			jQuery(cbProdIds).removeAttr("checked");
		}
	}
	
	/**
	 * CART
	 */
	
});
