$(document).ready(function() {

	// Submit top search
	$("#start_search").click(function(e) {
		document.forms[0].submit();
		return false;
	});

	// Formulär för ADSL orderanmälan - private
	$("#private_form_submit").click(function(e) {
		setSelectedSubscriptionType();
		if (checkPrivateForm())
			document.forms['aWebFormPrivate'].submit();
		return false;
	});
	
	// Formulär för ADSL orderanmälan - företag
	$("#company_form_submit").click(function(e) {
		setSelectedSubscriptionType();
		if (checkCompanyForm())
			document.forms['aWebFormCompany'].submit();
		return false;
	});
	
	// Clear default value for the inputfields
	$("input.default, textarea.default").each(function() {
		var defaultVal = $(this).val();	
		if (!($(this).val()))
			$(this).val(defaultVal);
		$(this).focus(function() {
			if($(this).val() == defaultVal)
				$(this).val("");
		});
		$(this).blur(function(){
			if ($(this).val() == "")
				$(this).val(defaultVal);
		});
	});
	
	$(".choose-form input:radio")
	.click(function() {
		$(".form.select").hide();	
		// show correct area
		$("#"+$(this).attr("id") + "-form").fadeIn(800);
	});
	
	// Show a form if one of the radio buttons are checked as default
	$("#"+$($(".choose-form input:checked")).attr("id") + "-form").show();

});

