
jQuery(document).ready(function()
{
	jQuery("#shopping_cart").hide();
	jQuery("#login").hide();
	jQuery("#choose_language").hide();
	jQuery("#search_button").hide();
	
	jQuery('#close_shopping_cart').click(function()
	{
		jQuery('#shopping_cart').hide();
	});
	
	jQuery('#open_shopping_cart').click(function()
	{
		if(jQuery('#shopping_cart').css("display")=="none"){
			jQuery('#login').hide();
			jQuery("#choose_language").hide();
			jQuery('#shopping_cart').slideDown('slow');
		}else{
			jQuery('#shopping_cart').slideUp('slow');
		}
	});
	
	jQuery('#open_login').click(function()
	{
		if(jQuery('#login').css("display")=="none"){
			jQuery('#shopping_cart').hide();
			jQuery("#choose_language").hide();
			jQuery('#login').slideDown('slow');
			
		}else{
			jQuery('#login').slideUp('slow');
		}
	});
	
	jQuery('#open_language').click(function()
	{
		if(jQuery('#choose_language').css("display")=="none"){
			jQuery('#shopping_cart').hide();
			jQuery('#login').hide();
			jQuery('#choose_language').slideDown('slow');
			
		}else{
			jQuery('#choose_language').slideUp('slow');
		}
	});
	
	jQuery('#username').focus(function()
	{	if(jQuery('#username').val()=="E-postadresse"){
			jQuery('#username').val("");		
		}
	});
	
	jQuery('#pagesearch').click(function()
	{		
		jQuery("#search_button").show();
	});
	
	jQuery('#pagesearch').focusout(function()
	{		
		//jQuery("#search_button").hide();
	});
	
	jQuery('#username').focusout(function()
	{	
		if(jQuery('#username').val()==""){
		jQuery('#username').val("E-postadresse");
		}
	});
	
	jQuery('#password').focus(function()
	{
		if(jQuery('#password').val()=="Passord"){
			jQuery('#password').val("");
		}
	});
	
	jQuery('#password').focusout(function()
	{	
		if(jQuery('#password').val()==""){
			jQuery('#password').val("Passord");
		}
	});
	
	jQuery('.buy').click(function()
	{	
		jQuery.get(jQuery(this).attr('action'), { artno: this.id, qty: jQuery("#qty"+this.id).val() });
		window.location.replace("/order/viewShoppingcart");
		
	});
	
	
	jQuery('#showAddress').click(function()
	{	
		jQuery('#editAddress').load(
		      'order/showAddressForm');	
	});
	
	jQuery('.paymentMethod').click(function()
	{	
		jQuery("#payment_button").attr('disabled', false);
		if(jQuery('#paymentMethod_1').attr('checked')){
			jQuery('#orderSummary').load('order/getOrderSummary', { type: 1 });
		}else if(jQuery('#paymentMethod_2').attr('checked')){
			jQuery('#orderSummary').load('order/getOrderSummary', { type: 2 });	
		}
		
		
	});

	});
	
	/*
	Clears the default value of a field on focus
	*/
	function clearDefaultValue (field) {
		if(field.value == field.defaultValue) {
			field.value = "";
		};
	}

	/*
	Resets the default value of a field when focus is lost
	*/
	function resetDefaultValue(field) {
		if (field.value == "") {
			field.value = field.defaultValue;
		};
	}
	
	

