$(document).ready(function() {
		/*
		 * newsletter subscribing in the footer
		 * Added by Netsmith Limited 25/11/2009
		 */
		$("#newsletter-subscribe").click(function() {
			$.post("/ajax/subscribe-email.php", $("#newsletterForm").serialize(),
				function(data) {
					alert(data.msg);
				}, "json");
		});

    //main home room hovers
    $("#menu .nav_item").hover(
        function() {             
            $('#blurb .'+$(this).attr('rel')).fadeIn('slow');
        }, 
        function() {
            $('#blurb .'+$(this).attr('rel')).fadeOut('slow');
        });

    //room box hover (done in jQuery for IE6)	
	$(".itemrow .box").hover(
		function() {
			$(this).css('background-color', '#eee');
			$(this).css('border', '1px solid #d0d0d0');
			$(this).find('img').css('border', '1px solid #ddd');	
			},
		function() { 
			$(this).css('background-color', '#fff');
			$(this).css('border', '1px solid #fff');
			$(this).find('img').css('border', '1px solid #fff');		
			}
		);

    //catagory box hover (done in jQuery for IE6)
	$("#browse .box").hover(
		function() {
			$(this).css('background-color', '#e0e0e0');
			$(this).css('border', '1px solid #d0d0d0');	
			},
		function() { 
			$(this).css('background-color', 'transparent');
			$(this).css('border', '1px solid transparent');	
			}
		);

    //hide all main product images, fade in first one
    $("#details img.main:not(.1)").css('display', 'none'); 
   
    // set product image initial background ready for transition to the next thumb
    $("#details #prod-image").css('background-image', "url('"+$("#details img.main.1").attr('src')+"')");
 
    //product thumb clicked, show main image first
	$("#alternative img.small").click(
		function() {
		    filename = $(this).attr('src').replace(/_thumb/, "");
		    $("#details img.main.1").hide().attr('src', filename).fadeIn('slow', function () {
			$("#details #prod-image").css('background-image', "url('"+filename+"')"); });
		});
		
    // check the product attributes are 
    $("form[name='basket']").submit(function () {
        var attribute = $(this).find("select[name='attribute']");
        if (attribute.length && !attribute.val()) {
            alert('Please select a product attribute.'); 
            return false;
        } else 
            return true;
        });

    // out of stock messages
    $("form[name='basket'] select[name='attribute']").change(function () {
        if (!$(this).parent().find(".stock-msg").length) {
            $(this).after('<div class="stock-msg"></div>');
        }
        $(this).parent().find(".stock-msg").html($(this).find('option:selected').attr('title'));
		});


    // generic hide show links
    $(".moreinfo").each(function () {
            var target = jQuery(this);
            target.hide();
            target.addMoreLink();});

    $(".lessinfo").each(function () {
            var target = jQuery(this);
            target.addLessLink();});
});
