(function($, undefined) {

	$(function() {

		$('.add-to-order').click(function(){
				$(this).parents("form").submit();
		});
		// finishing
		$('ul.color-list li').click(function(){
				$thisLi = $(this);


				$('ul.color-list li.color-open').animate({height: '25'}, 100, function(){
						$(this).removeClass('color-open');
				})
				$thisLi.animate({height: '140'}, 300, function(){
						$thisLi.addClass("color-open");
				});


		});
		$('.login-cart').click(function(){
				$(this).parents("form").submit();

				return false;
		});
		$('.set-shipping-billing').click(function(){
				$('#shipping-billing').submit();
				return false;
		});
		$('.register-user').click(function(){
				$parentForm = $(this).parents("form");
				// if($parentForm.find('.terms-use:checked').length == 0){
						// alert('You must accept the Terms of Use');
						// return false;
				// }
				$parentForm.submit();
				return false;
		});
		$('.dropdown-menu').hover(function(e){
				e.preventDefault();
				$thisButton = $(this);
				$subMenu = $thisButton.find('ul');
				$subMenu.slideDown(300);
				$thisButton.toggleClass("menu-open");
		}, function(){
			 $subMenu.slideUp(100);
		});
		$('ul.collections-presentation li').click(function(){
				$liButton = $(this);
				$url = $liButton.find('a').attr('href');
				window.location = $url;

				return false;
		});
		$('.submit-button').click(function(){
				$(this).parents("form").submit();

				return false;
		});


		$('.copy-billing-address').click(function(event) {
			$("input[name='attribute[address_shipping]']").val($("input[name='attribute[address]']").val());
			$("input[name='attribute[city_shipping]']").val($("input[name='attribute[city]']").val());
			$("input[name='attribute[postcode_shipping]']").val($("input[name='attribute[postcode]']").val());
			$("input[name='attribute[phone_shipping]']").val($("input[name='attribute[phone]']").val());


			var v = $("select[name='attribute[country]'] option:selected").text();
			// has to be a string or regular expression (object in IE, function in Firefox)
			$("select[name='attribute[country_shipping]']").each(function() {
				if(this.nodeName.toLowerCase() != "select") return this;
				// get options
				var o = this.options;
				// get number of options
				var oL = o.length;
				for(var i = 0; i<oL; i++) {
					if($(o[i]).text() == v) {
						o[i].selected = true;
					}
					else {
						o[i].selected = false;
					}
				}
			});

			event.preventDefault();

			return false;
		});

		setInterval("if(jQuery('#background').height() < jQuery(window).height()) jQuery('#main').css('min-height', jQuery(window).height() - jQuery('#background').height() + jQuery('#main').height())", 200);

	});

})(jQuery);
