update_skier_equipment = function(ele) {
	val = $('#equipment_type').val();


	if (val=="Adult") {
		$('#childrens_equipment,#adult_equipment,#package_deals,#general_equipment').addClass("hidden");
		$("#childrens_equipment .product-select option[value='']").attr("selected","selected");

//		$('#childrens_equipment select option').each( function(i) {
//			$(this).attr("selected","");
//			if ($(this).val() == "") $(this).attr("selected","selected"); 
//		});
		$('#adult_equipment,#package_deals,#general_equipment').removeClass("hidden");
	} else {
		$('#childrens_equipment,#adult_equipment,#package_deals,#general_equipment').addClass("hidden");
		$("#package_deals .product-select option[value=''], #adult_equipment .product-select option[value='']").attr("selected","selected");

//		$('#package_deals select option,#adult_equipment select option').each( function(i) {
//			$(this).attr("selected","");
//			if ($(this).val() == "") $(this).attr("selected","selected"); 
//		});
		$('#childrens_equipment,#general_equipment').removeClass("hidden");
	}
	update_skier_products()
}

update_skier_products = function() {
	total = 0;
	$boot_discount = 0;

	if ( $('.boot_discount_class').is(":checked") )
	{
		$('.boot-discount').each( function (i) {
			if ($(this).val() != '')
		    	$boot_discount = 10;
		});
	}

	$('.product-select').each( function (i) {
		if ($(this).val() != '')
	    	total += parseInt($(this).val().split('_')[1]);
	});
	total = total-$boot_discount;
	$('#total_sub').text("AUD $"+total.toFixed(2));
	if ($('#total_discount').length > 0)
	{
	   	$('#total_discount').text("AUD $"+(total/100*discount).toFixed(2));
		$('#total_skier').text("AUD $"+(total-(total/100*discount)).toFixed(2));
	}
	else
	{
		$('#total_skier').text("AUD $"+total.toFixed(2));
	}
	 
}

confirm_delete = function() {
	if (confirm("Are you sure you want to delete this item?")) return true
	return false;
}

$(document).ready(function() {
	$('#brands').cycle({ 
	    fx: 'scrollDown' 
	});
	
	$('.boot_discount_class').click(function() {
		update_skier_products();
		$('.boot_discount_class').prop('checked', this.checked);
	})
	
	if ( $("#boot_discount_hidden").val() == 'Yes' )
	{
		$('.boot_discount_class').prop('checked', true);
	}
	
	$("#subscription form label").toggle();
	
	if ($(".cm-input").length > 0)
	{
		$('.cm-input').each( function() {
			if ($(this).val() == '' || $(this).val() == $(this).attr("title")) {
				$(this).val($(this).attr("title"));
				$(this).addClass("form-light");
			}		
		});
		
		$(".cm-input").focus( function() {
			if ($(this).val() == $(this).attr("title")) {
				$(this).val('');
				$(this).removeClass("form-light");
			}
		});

		$(".cm-input").blur( function() {
			if ($(this).val() == "") {
				$(this).val($(this).attr("title"));
				$(this).addClass("form-light");
			}
		});
	}

	
});
