jQuery(document).ready(function() {
	//window.status = "Jquery loaded";
	
	jQuery("#nav li a span").toggle(
	      function () {
	        var parent = jQuery(this).parent().parent().get(0);
			jQuery(parent).addClass("active");
	      },
	      function () {
	        var parent = jQuery(this).parent().parent().get(0);
			jQuery(parent).removeClass("active");
	      }
	    );
	
	// change the vat option
	
	 jQuery("#vat-option").change(function () {
         var option = "";
         jQuery("#vat-option option:selected").each(function () {
               window.location='/shopuserpref/setprice/' + this.value;
             });
       });
	 	
	
	 jQuery("form.productForm").submit(function() {

		 var product_id 		= jQuery(this).attr("id").split( '-' );
		 var product_number		= product_id[1];
		 	var formfields = new Object();
			var product_package = jQuery("#product-"+product_number+"-package").attr("value");
			
			if ( product_package.indexOf('-') == '-1' && product_package.indexOf( '/' ) == '-1' )
			{
			 	var amount			= jQuery("#product-"+product_number).attr("value");
			 	var modulus = amount % product_package;
			 	var example1 = parseInt( product_package )+parseInt(product_package);
			 	var example2 = parseInt( example1 )+parseInt(product_package);
			 	if ( modulus == 0 )
			 	{
			 		return true;
			 	}
			 	else
			 	{
					alert( "Produktet kommer bare i pakker p\u00e5 " + product_package + ", endre antallet til " + product_package + ", " + example1 + ", " + example2 + " osv." );
			 		return false;
				 	
			 	}
			}
			return true;
	 });

});

