$(document).ready(function() {
	$("#contactform").validate(); //Contact form validation
	$("#orderform").validate(); //Contact form validation
	$("#accordion").accordion({ autoHeight: false });
//	$('#grand-total').makeFloat({x:"current",y:"current"});
	basePrice();
	optionsCost = optionsPrice();
	$('#fixed_width, #flexible_width, #stretch_no, #stretch_yes, #footer_bottom_no, #footer_bottom_yes, #rollovers_no, #rollovers_yes, #menu_no, #menu_onelevel, #menu_multilevel, #sifr_no, #sifr_yes, #coding_html, #coding_transit, #coding_strict, #commented_no, #commented_yes, #optimized_no, #optimized_yes, #ssi_no, #ssi_yes, #sw_no, #sw_wordpress').click(function() {
		baseCost = parseInt($('#subtotal').val().replace('$',''));
		optionsCost = optionsPrice();
		$("#total").val('$' + (baseCost+optionsCost) );
	});

});

	function optionsPrice() {
		 var optionsCost = 0;
		 if ($("input[name='layout_width']:checked").val() == 'flexible') {
		 	optionsCost += 25;
		 }
		 if ($("input[name='header_stretch']:checked").val() == 'yes') {
		 	optionsCost += 5;
		 }
		 if ($("input[name='footer_bottom']:checked").val() == 'yes') {
		 	optionsCost += 5;
		 }
		 if ($("input[name='rollovers']:checked").val() == 'yes') {
		 	optionsCost += 3;
		 }
		 if ($("input[name='menu']:checked").val() == 'onelevel') {
		 	optionsCost += 5;
		 }
		 if ($("input[name='menu']:checked").val() == 'multilevel') {
		 	optionsCost += 15;
		 }
		 if ($("input[name='sifr']:checked").val() == 'yes') {
		 	optionsCost += 15;
		 }
		 if ($("input[name='coding']:checked").val() == 'xhtml_strict') {
		 	optionsCost += 10;
		 }
		 if ($("input[name='commented']:checked").val() == 'yes') {
		 	optionsCost += 5;
		 }
		 if ($("input[name='optimized']:checked").val() == 'yes') {
		 	optionsCost += 15;
		 }
		 if ($("input[name='ssi']:checked").val() == 'yes') {
		 	optionsCost += 5;
		 }
		 if ($("input[name='sw_implement']:checked").val() == 'Wordpress') {
		 	optionsCost += 180;
		 }
		 return optionsCost;
	}

	function basePrice() {
		var homePageQty = 1
		var subPageQty = 0
		var daysQty = 3
		var totalCost = 0
		$("#home-page-qty").val('1 Page');
		$("#sub-page-qty").val('0 Page');
		$("#days-qty").val('3 Days');
		totalCost =  (homePageQty * 99) + (subPageQty * 60)
		$("#subtotal").val('$' + totalCost );
		baseCost = parseInt($('#subtotal').val().replace('$',''));
		optionsCost = optionsPrice();
		$("#total").val('$' + (baseCost+optionsCost) );
		$("#home-pages").slider({
			value: 1,
			min: 0,
			max: 10,
			step: 1,
			slide: function(event, ui) {
				if(ui.value == 1 || ui.value == 0) {
					$("#home-page-qty").val(ui.value + ' Page');
				} else {
					$("#home-page-qty").val(ui.value + ' Pages');
				}
				homePageQty = ui.value
				totalCost =  (homePageQty * 99) + (subPageQty * 60)
				if(daysQty > 3) {
					totalCost = totalCost - ((daysQty-3) * 5)
				}
				if(totalCost < 50) {
					totalCost = 50
				}
				if(homePageQty == 0 && subPageQty == 0) {
					totalCost = 0
				}
				$("#subtotal").val('$' + totalCost );
				baseCost = parseInt($('#subtotal').val().replace('$',''));
				optionsCost = optionsPrice();
				$("#total").val('$' + (baseCost+optionsCost) );
			}
		});
		$("#sub-pages").slider({
			value: 0,
			min: 0,
			max: 10,
			step: 1,
			slide: function(event, ui) {
				if(ui.value == 1 || ui.value == 0) {
					$("#sub-page-qty").val(ui.value + ' Page');
				} else {
					$("#sub-page-qty").val(ui.value + ' Pages');
				}
				subPageQty = ui.value
				totalCost =  (homePageQty * 99) + (subPageQty * 60)
				if(daysQty > 3) {
					totalCost = totalCost - ((daysQty-3) * 5)
				}
				if(totalCost < 50) {
					totalCost = 50
				}
				if(homePageQty == 0 && subPageQty == 0) {
					totalCost = 0
				}
				$("#subtotal").val('$' + totalCost );
				baseCost = parseInt($('#subtotal').val().replace('$',''));
				optionsCost = optionsPrice();
				$("#total").val('$' + (baseCost+optionsCost) );
			}
		});
		$("#days").slider({
			value: 3,
			min: 3,
			max: 10,
			step: 1,
			slide: function(event, ui) {
				if(ui.value == 1) {
					$("#days-qty").val(ui.value + ' Day');
				} else {
					$("#days-qty").val(ui.value + ' Days');
				}
				daysQty = ui.value
				totalCost =  (homePageQty * 99) + (subPageQty * 60)
				if(daysQty > 3) {
					totalCost = totalCost - ((daysQty-3) * 5)
				}
				if(totalCost < 50) {
					totalCost = 50
				}
				if(homePageQty == 0 && subPageQty == 0) {
					totalCost = 0
				}
				$("#subtotal").val('$' + totalCost );
				baseCost = parseInt($('#subtotal').val().replace('$',''));
				optionsCost = optionsPrice();
				$("#total").val('$' + (baseCost+optionsCost) );
			}
		});
	}

/*
		SubmittingForm=function() {
			alert("The form has been validated.");
		}

		$(document).ready(function() {
			$("#contact-form").validate({
				rules: {
					name: "required",		// simple rule, converted to {required:true}
					email: {				// compound rule
						required: true,
						email: true
					},
					message: {
						required: true
					}
				},
				message: {
					message: "Please enter a message."
				}
			});
		}); */

