document.createElement("header");
document.createElement("footer");
document.createElement("nav");
document.createElement("article");
document.createElement("section");

jQuery(document).ready(function() {
    jQuery('#slideshow1').cycle({
		fx: 'fade', 
	    speed:   2500, 
	    timeout: 5000
	});
    jQuery('#slideshow2').cycle({
		fx: 'fade', 
	    speed:   1500, 
	    timeout: 6500
	});
    jQuery('#slideshow3a').cycle({
		fx: 'fade', 
	    speed:   1000, 
	    timeout: 5500
	});
    jQuery('#slideshow3b').cycle({
		fx: 'fade', 
	    speed:   1000, 
	    timeout: 5500
	});
});

function mycarousel_initCallback(carousel) {
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        auto: 5,
        wrap: 'circular',
		scroll: 6,
        initCallback: mycarousel_initCallback
    });
});

jQuery(function() {
	var dropdownMenusSet = {}; 	// an object to store whether dropdowns have had widths and offsets set (so they only need to be set once)

	// Dropdown navigation
	$('#primary-nav > li').hoverIntent(function() {
		$(this).addClass('hover');
		$('.inner', this).fadeIn('fast');

		var menuWidth = new Number;
		var listID = this.className.split(' ')[0];
		if (!dropdownMenusSet[listID]) {
			$('.inner', this).children('ul').children('li').filter('.no-children:eq(0), :not(.no-children)').each(function() {	// get widths of each list item in submenu
				//alert($(this).width());
				menuWidth += $(this).width(); 	// store sum of widths in menuWidth
				var counter = 1;
				var numOfNestedLists = $(this).children('ul').length;
				if ((numOfNestedLists > 1) && $.browser.msie && (parseInt($.browser.version, 10) < 7)) {
					while (counter < numOfNestedLists) {
						counter++;
						menuWidth += $(this).width();
					}
				};
				// console.log("submenu LI Width = " + $(this).width());
				if ($(this).hasClass('.no-children') == true) {
					menuWidth += parseInt($(this).css('padding-left'), 10);
				};
			});
			// console.log("menuWidth = " + menuWidth);
			$('.inner', this).css('width', menuWidth); 	// apply menuWidth to dropdown menu (with a little extra breathing room)

			var menuX = $(this)[0].offsetLeft - 5; // get left offset of main nav item
			if (menuX > $(this).parents("#head")[0].offsetWidth - menuWidth) { 	// check if menu extends beyond container, if so, set right: 0 instead of left: 0 
				$(this).children("div.inner").css({
					'right': 0,
					'left': 'auto'
				});
			} else {
				$(this).children("div.inner").css("left", menuX); // apply left offset to sub menu
			};
			if ($.fn.bgiframe) {
				$('.inner', this).bgiframe();
			};
			dropdownMenusSet[listID] = true;
		}

	}, function() {
		$(this).removeClass('hover');
		$('.inner', this).fadeOut('fast');
	});
});

function addtocart(productID,attributeGroup) {
	var attributeValue	= document.productInfo.attributeValue.value;

	if (attributeValue == '') {
		alert('Please select a '+attributeGroup+' to add to your basket');
	} else {
		window.location	= "/basket/add/"+productID+"/"+attributeValue+"/";
	}
}

$(document).ready(function(){
	$('#RE').hide();
	$('#WE').hide();
	$('#RW').hide();
	$('#UK').hide();
	$("#thechoices").change(function() {
		var	pandp		= this.value.split('|');
		var	regionCode	= pandp[0];
		var	countryCode	= pandp[1];
		var	countryName	= pandp[2];
		if (countryCode == 'all') {
			$("#boxes").children().show();
		} else {
			$("#price" + regionCode).show().siblings().hide();
		}
	});

	$("#thechoices").change();
});

function checkout() {
//	countryCode	= $("#thechoices").value;
	
	alert($("#thechoices").value);
}