
$(function(){

$("#pageflip").hover(function() { //On hover...
	$("#pageflip img , .msg_block").stop()
		.animate({ //Animate and expand the image and the msg_block (Width + height)
			width: '307px',
			height: '319px'
		}, 500);
	} , function() {
	$("#pageflip img").stop() //On hover out, go back to original size 50x52
		.animate({
			width: '100px',
			height: '104px'
		}, 220);
	$(".msg_block").stop() //On hover out, go back to original size 50x50
		.animate({
			width: '100px',
			height: '100px'
		}, 200); //Note this one retracts a bit faster (to prevent glitching in IE)
});

	if ((BrowserDetect.browser=="Explorer")&&(BrowserDetect.version<="8")) { } else {
		$(".Phuse_PanelContainingDiv td").each(function(){ $(this).css("width",$(this).parent().parent().parent().attr("width")+"px"); });
	}
	
    $(".location").hide();
  function populateDropdown(){
		var selectCategory = "<option value=\"null\">Select a location...</option>";
		
		$("#location_filter_ddl").html("").append(selectCategory+"");
		Array.prototype.unique = function () {
			var r = new Array();
			o:for(var i = 0, n = this.length; i < n; i++) {
				for(var x = 0, y = r.length; x < y; x++) {
					if(r[x]==this[i]) {
						continue o;
					}
				}
				r[r.length] = this[i];
			}
			return r;
		}
		var categoryArray = new Array();
		for (y=0;y<$(".location").length;y++){
			var thisCategory = $(".location:eq("+y+")").children(".title").text();
			categoryArray[y]="<option value=\""+thisCategory+"\">"+thisCategory+"</option>";
		}
		var unique = categoryArray.unique();
		var sort = unique.sort();
		var string = sort.toString();
		$("#location_filter_ddl").append(string.replace(/,/g,"\n"));
	}
	populateDropdown();
	
    
   $("#location_filter_ddl").change(function(){
        var thisCategory = $("option:selected",this).val();
        $(".location").hide();
        $(".location .title:contains('"+thisCategory+"')").parent().fadeIn();
        
    });


 var browserVersion = $.browser.version;
 var thisURL = window.location;
 
 if (($.browser.msie)&&(browserVersion=="7.0")||(browserVersion=="6.0")) {
        $(".content_right .mm_form span:last").attr("style","top: 5px; position: relative;");
    }
    $(".shop_category, .shop_item").fullLink();
     $("#home .special_offers .mid .offer:nth-child(even)").attr("style","margin-right: 0px;");
     $("#home .special_offers .offer .mid .right .more").show();
     
    $("#home .special_offers .offer").hide();
    $("#home .special_offers .mid .offer:eq(0)").show();
    $("#home .special_offers .mid .offer:eq(1)").show();
    $("#home .special_offers .mid .offer:eq(2)").show();
    $("#home .special_offers .mid .offer:eq(3)").show();
    
    
    $(".fusionsoft table").addClass("capture_form");
    $(".fusionsoft .MMDataCaptureForm_Table").show();
    
    $(".fusionsoft table td").attr("style","");
    $(".fusionsoft table input[type=checkbox]").addClass("checkbox");
    $(".fusionsoft .checkbox").parent().addClass("checkbox_td");
   
    
    $(".fusionsoft tr").each(function(){
        $("td:first",this).addClass("label");
    });
    $(".fusionsoft tr").each(function(){
        $("td:last",this).addClass("input");
    });
    
    $(".fusionsoft tr .label").wrapInner("<div></div>");

    
    
     $(".sub_nav a[href$="+thisURL+"]").addClass("active");     
     $(".footer_bottom .left a[href$="+thisURL+"]").addClass("active");
    
    
    
    $(".content_right .mid .Phuse_PanelContainingDiv td").attr("style","width:343px;");
    $(".home_left .mid .Phuse_PanelContainingDiv td").attr("style","width:329px;");
/*
    $(".enquiry_form td").attr("style","");
    $(".enquiry_form input[type=checkbox]").addClass("checkbox");
    
    $("textarea").attr("style","");
    $(".MMDataCaptureForm_ErrorTD span").attr("style","");
    
    
    */
    $(".bookmarks li:last").attr("style","margin: 0px;");
    
    
    var blogContent = $(".blogFeed").html();
        $("#blogFeed").html(blogContent);

    if ($("#checkout, #checkout2").is(":visible")) {
        $("#top, #navigation, #breadcrumb, .shop_left, #search, #footer").hide();
    }
    
   
   
   $(".shop_left ul li ul").hide();
   $(".shop_left ul li").click(function(){
        if ($(this).children("ul").is(":visible")) {
            $(this).children("ul").slideUp();
        } else {
            $(this).children("ul").slideDown();
        }
    });
    
    $(".category_title").each(function(){
        var productNameLeft = $(this).text();
        var productNameRight = $(".category_items h2").text();
        var productNameRightP = $(".product h2").text();
        if (productNameLeft==productNameRight)
        {
            $(".category_title:contains('"+productNameLeft+"') + ul").show();
        } else if (productNameLeft=="\n		"+productNameRightP)
        {
            $(".category_title:contains('"+productNameLeft+"') + ul").show();
        }
    });
    
    
    
    if ($(".MMDataCaptureForm_ErrorTD span").text()!="") {
        $("#mm_form p").hide();
        $(".MMDataCaptureForm_ErrorTD").attr("style","color: #000;");
    }
    
	$(".MMDataCaptureForm_LabelTD div span").before("<span>* </span>");

    $(".EcommerceTextMiniBox").attr("style","width: 47px;");
    
    
    if ($(".your_details").is(":visible")) {
        $(".ErrorText").attr("style","width: 100%;");
    }
    
     $(".shop_left ul li a[href$="+thisURL+"]").addClass("active");
     
     $(".shop_left a").each(function(){
        if ($(this).attr("class")=="active") {
            $(this).parent().children("ul").slideDown();
        }
     });
     
     $(".enlarge").hide();
     if ($(".shop_item_detail .left .image img").is(":visible")) {
        $(".enlarge").show();
    }
        
    $(".shop_left ul li a").each(function(){
        if ($(this).text()==$.cookie("storageNav")) {
                        $(this).addClass("active");
        }
    }).click(function(){
        $.cookie("storageNav",$(this).text());
    });
    
    
    if ($(".shop_item_detail").is(":visible")) {
        $(".shop_item_detail .left .image a").lightBox();
    }
    
$(".business_banner, .domestic_banner").fullLink();
  
    $(".sign_up_now_panel input").each(function(){
		var thisObj=$(this);
		var thisVal=thisObj.val();
		thisObj.bind("focus",function(){
			if (thisObj.val()==thisVal) { thisObj.val(""); }
		}).bind("blur",function(){
			if (thisObj.val()=="") { thisObj.val(thisVal); }
		});
	}); 

});


