$(document).ready(function() {

	$('div.buttons').hide();
	//$('#saveQuoteForm').hide();  

	$(".trigger").change(function() {
	    $('#quoteform').ajaxSubmit({
	            target: '#quote',
	            success: showButtons
	    });
	});

	$('.saveQuote').click(function() {
		var id = $(this).attr('id');
		$('#quoteform').ajaxSubmit({
			target: '#quoteSaved',
			data: { action: id }
		});
		return false;
	});

	setTimeout(function() { 
		$('.alert').hide("slide", { direction: "up" }, 500); 
		//$('.alert').fadeOut("slow");
	}, 3000);
	
	
	$("#toggler").click(function(){
	   $("#cds").toggle();
       
	});
	
	$('.cat').click(function(){
		$(this).toggleClass('open');
		$(this).parent().find('ul').slideToggle();
		return(false);
	});

	$("#setSize").change(function() {
	
		$("#measure").val('mm');
		$('.measuredin').html("mm"); 
		
		if ($("#setSize").val() == '0') {
			$("#width").val('');
			$("#height").val('');
			$('#width').removeAttr("readonly"); 
			$('#height').removeAttr("readonly"); 
			$('#measure').removeAttr("readonly"); 
		} else if ($("#setSize").val() == 'A6') {
			$("#width").val('105');
			$("#height").val('148');
			$('#width').attr("readonly", true);
			$('#height').attr("readonly", true);
			$('#measure').attr("readonly", true);
		} else if ($("#setSize").val() == 'A5') {
			$("#width").val('148');
			$("#height").val('210');
			$('#width').attr("readonly", true);
			$('#height').attr("readonly", true);
			$('#measure').attr("readonly", true);
		} else if ($("#setSize").val() == 'A4') {
			$("#width").val('210');
			$("#height").val('297');
			$('#width').attr("readonly", true);
			$('#height').attr("readonly", true);
			$('#measure').attr("readonly", true);
		} else if ($("#setSize").val() == 'A3') {
			$("#width").val('297');
			$("#height").val('420');
			$('#width').attr("readonly", true);
			$('#height').attr("readonly", true);
			$('#measure').attr("readonly", true);
		} else if ($("#setSize").val() == 'A2') {
			$("#width").val('420');
			$("#height").val('594');
			$('#width').attr("readonly", true);
			$('#height').attr("readonly", true);
			$('#measure').attr("readonly", true);
		} else if ($("#setSize").val() == 'A1') {
			$("#width").val('594');
			$("#height").val('841');
			$('#width').attr("readonly", true);
			$('#height').attr("readonly", true);
			$('#measure').attr("readonly", true);
		} else if ($("#setSize").val() == 'A0') {
			$("#width").val('841');
			$("#height").val('1189');
			$('#width').attr("readonly", true);
			$('#height').attr("readonly", true);
			$('#measure').attr("readonly", true);
		}
		
		$('#quoteform').ajaxSubmit({
	            target: '#quote'
	    });
	    
	});
	
});

function showButtons () {
	$('div.buttons').show();
}
