jQuery(
function()
{
	jQuery("input[title]")
	.focus(
	function() {
		if (jQuery(this).val()==jQuery(this).attr("title"))
		jQuery(this).val("");
	}
	)
	.blur(
	function() {
		if (jQuery(this).val()=="")
		jQuery(this).val(jQuery(this).attr("title"))
	}
	);
}
);

jQuery(document).ready(function(){
		jQuery("#OrderFormat").change( function() {
		jQuery('#quickorder_size').load('/ajax/quickorder.php?groupId=' + jQuery(this).val());
		
	});
	
	jQuery(".delivery_type").click( function() {
		
		jQuery("#paymentForm").submit();
		
		
		
	});
	jQuery(".delivery_type").click( function() {
		jQuery("#paymentForm").submit();
	});
	jQuery(".quantityoptions").change(function () {
		jQuery("#cartForm").submit();
	});
	jQuery("a#loginSubmit").click(function () {
		jQuery("form#loginForm").submit();
		return false;
	});
	jQuery("a#userchangeSubmit").click(function () {
		jQuery('input#paymentupdate').val(false);
		jQuery("form#userchangeForm").submit();
		return false;
	});
	jQuery("a#userpaymentSubmit").click(function () {
		jQuery('input#paymentupdate').val(true);
		jQuery("form#userchangeForm").submit();
		return false;
	});
	jQuery("a#shippingSubmit").click(function () {
		jQuery("form#shippingForm").submit();
		return false;
	});
	jQuery("a#passchangeSubmit").click(function () {
		jQuery("form#passchangeForm").submit();
		return false;
	});
	jQuery("a#accountchangeSubmit").click(function () {
		jQuery("form#accountchangeForm").submit();
		return false;
	});
	jQuery("a#useraddSubmit").click(function () {
		jQuery("form#useraddForm").submit();
		return false;
	});
	jQuery("a#newpasswordSubmit").click(function () {
		jQuery("form#newpasswordForm").submit();
		return false;
	});
	jQuery("a#arenewpass").click(function () {
		jQuery("div#renewpass").show();
		jQuery("input#pass1").removeAttr("disabled");
		jQuery("input#pass2").removeAttr("disabled");
		jQuery("a#arenewpass").hide();
		return false;
	});
	jQuery("a#ashippingaddress").click(function () {
		jQuery("div#shippingaddress").show();
		jQuery("input#shipping_firstname").removeAttr("disabled");
		jQuery("input#shipping_lastname").removeAttr("disabled");
		jQuery("input#shipping_street").removeAttr("disabled");
		jQuery("input#shipping_zip").removeAttr("disabled");
		jQuery("input#shipping_city").removeAttr("disabled");
		jQuery("a#ashippingaddress").hide();
		return false;
	});
});

function cart_form_delete(ID){
	jQuery("#cartFormDelete input[name=cartId]").val(ID);
	jQuery("#cartFormDelete").submit();
	return false;
}
function cart_wallmount_delete(ID){
	jQuery("#cartWallmountDeleteForm input[name=cartId]").val(ID);
	jQuery("#cartWallmountDeleteForm").submit();
	return false;
}
function cart_addon_delete(ID){
	jQuery("#cartAddonDeleteForm input[name=cartId]").val(ID);
	jQuery("#cartAddonDeleteForm").submit();
	return false;
}

/*****************BUTIKK***************/
										
	$("#locationListForm").ready(function(){
		$('#locid').click(function() { 
			jQuery('#confirm').attr('disabled', false); 
			return true;
		});
		$('#list').click(function() {
			if(jQuery('select#list').val()!='ps'){
				jQuery('#confirm').attr('disabled', false); 
				return true;
			}
		});

		var butikk_form = $("#locationListForm");
		var confirm = $("#confirm");
		var ButikkButtonHide = $("#ButikkButtonHide");
		var ButikkButtonShow = $("#ButikkButtonShow");
		
		//confirm.blur(validate_conditions);
		//confirm.focus(validate_conditions);
		//confirm.keyup(validate_conditions);
		confirm.change(Butikk_Submitt_Hide_Show);
		confirm.click(Butikk_Submitt_Hide_Show);
		
		var browser = navigator.appName;
				
		function Butikk_Submitt_Hide_Show(){
			if(browser=="Opera"){
				if (jQuery('input#confirm:checked').val()){
					ButikkButtonShow.html('');
					ButikkButtonShow.hide(1);
					ButikkButtonHide.show(1);
					ButikkButtonHide.html('<button class="button-red-submitt_BK_opera"   type="submit" value="Slutför beställning">Slutför beställning</button>');		
					return true;
				}
				
				if (!jQuery('input#confirm:checked').val()){
					ButikkButtonShow.show(1);
					ButikkButtonShow.html('<span class="button-disable" id="paymentSubmit"><span>Slutför beställning&nbsp;</span></span>');
					ButikkButtonHide.hide(1);
					ButikkButtonHide.html('');
					return true;
				}
			}
			else {
				if (jQuery('input#confirm:checked').val()){
					ButikkButtonShow.html('');
					ButikkButtonShow.hide();
					ButikkButtonHide.show();
					ButikkButtonHide.html('<button class="button-red-submitt1"   type="submit" value="Slutför bestälning">Slutför beställning</button>');
					return true;
				}
				
				if (!jQuery('input#confirm:checked').val()){
					ButikkButtonShow.show();
					ButikkButtonShow.html('<span class="button-disable" id="paymentSubmit"><span>Slutför beställning</span></span>');
					ButikkButtonHide.hide();
					ButikkButtonHide.html('');
					return true;
				}
			}
		}
		
		butikk_form.submit(function(){
			if($('#dropdown').is(':checked') ){
				if(jQuery('select#list').val()=='ps'){
					alert("Velg utleveringsted");
					return false;
				} else 
				return true;
			}
			
			if( Butikk_Submitt_Hide_Show()  )
				return true;
			else
				return false;
		});
	});
	
/*****************Creditcard***************/
											
	$("#choose_creditcard_form").ready(function(){
		$('#creditcard_visa').click(function() {
			jQuery('#confirm').attr('disabled', false);
			$('.creditcard_id').val(0);
			return true;
		});
		
		$('#creditcard_master').click(function() {
			jQuery('#confirm').attr('disabled', false); 
			$('.creditcard_id').val(1); 
			return true;
		});
									
		var form = $("#choose_creditcard_form");
		var confirm = $("#confirm");
		var CreditcardButtonHide = $("#CreditcardButtonHide");
		var CreditcardButtonShow = $("#CreditcardButtonShow");
									
		confirm.change(validate_conditions);
		confirm.click(validate_conditions);
										
		form.submit(function(){
			if(validate_conditions())
				return true;
			else
				return false;
			});
									
		function validate_conditions(){
			var browser = navigator.appName;
				if(browser=="Opera"){
					if (jQuery('input#confirm:checked').val()){
						CreditcardButtonShow.hide();
						CreditcardButtonHide.show();
						CreditcardButtonHide.html('<button class="button-red-submitt_CC_opera"  type="submit" value="Gå til betaling">Gå til betaling</button>');
						return true;
					}
					if (!jQuery('input#confirm:checked').val()){
						CreditcardButtonHide.hide();
						CreditcardButtonHide.html('');
						CreditcardButtonShow.show();
						CreditcardButtonHide.html('<span class="button-disable" id="paymentSubmit"><span>Gå til betaling</span></span>');
						return true;
					}
				} 
				else {
					if (jQuery('input#confirm:checked').val()){
						CreditcardButtonShow.hide();
						CreditcardButtonHide.show();
						CreditcardButtonHide.html('<button class="button-red-submitt_CC"  type="submit" value="Gå til betaling">Gå til betaling</button>');
						return true;
					}
					if (!jQuery('input#confirm:checked').val()){
						CreditcardButtonHide.hide();
						CreditcardButtonHide.html('');
						CreditcardButtonShow.show();
						CreditcardButtonShow.html('<span class="button-disable" id="paymentSubmit"><span>Gå til betaling</span></span>');
						return true;
					}
				}
			}
	});
