﻿function dnt() { }
function showelem(elem) { document.getElementById(elem).className = 'showMe'; }
function hideelem(elem) { document.getElementById(elem).className = 'hideMe'; }
/*IMAGE SWAP*/
	function swapImages(elementId,imageSource)
	{

		var elementExists = document.getElementById(elementId);
		if (elementExists != null)
		{
			document.getElementById(elementId).src = imageSource;
		}
	}

        function relocateTo(pagename, query) {
            // alert(query.indexOf("Search by Product/Code"));
            if (query.indexOf("Search by Product/Code") < 0) {
                var url = pagename
                if (query != "") {
                    url += "?" + query;
                }
                document.location.href = url;
            } else {
                return false;
            }
        }

        function productSearchHeader()
        {
            var searchTerm = document.getElementById('txtHeaderSearch').value;
            if (searchTerm.indexOf("Search by name or code") < 0 && searchTerm.length > 1)
            {
                var url = "product-search.aspx";
                url += "?srchtrm=" + searchTerm;
                document.location.href = url;
                
            }else{
                document.getElementById('txtHeaderSearch').value = "";
                return false;
            }
        }

        function productSearchDetectEnterPressed(e) {
            var characterCode
            if(e && e.which){ // NN4 specific code
                e = e
                characterCode = e.which
            }else{
                e = event
                characterCode = e.keyCode // IE specific code
            }
            
            if (characterCode == 13)
            {
                var searchTerm = document.getElementById('txtHeaderSearch').value;
                if (searchTerm.indexOf("Search by name or code") < 0 && searchTerm.length >1)
                {
                    var url = "product-search.aspx";
                    url += "?srchtrm=" + searchTerm;
                    document.location.href = url;
                    return false;
                }else{
                    return false;
                }
                return true // Enter key is 13
                
            }
        }
          
        function productSearchHeaderReset(mode)
        {
            var searchTerm = document.getElementById('txtHeaderSearch').value;
            if(mode == "rst")
            {
                if (document.getElementById('txtHeaderSearch').value == "")
                {
                    document.getElementById('txtHeaderSearch').value = "Search by name or code";
                }
            }else{
                if (searchTerm.indexOf("Search by name or code") >= 0)
                {
                    document.getElementById('txtHeaderSearch').value = "";
                }
            }
        }
        
        function DetectEnterPressed(e) {
            var characterCode
            if(e && e.which){ // NN4 specific code
                e = e
                characterCode = e.which
            }else{
                e = event
                characterCode = e.keyCode // IE specific code
            }
            
            if (characterCode == 13)
            {
                return true // Enter key is 13
            }else{
                return false
            }
        }

        function EnterButtonCheck(e)
        {
            if(DetectEnterPressed(e))
            {
                return false;
            }else{
                //return;
            }
        }


            function zoomTo(x,y)
            {
                //x = x -50;
                //y = y -50;
                
                //document.getElementById("productImageZoom").style.backgroundPosition = -(x *4) + 'px ' + -(y *4) + 'px'; 
                document.getElementById("productImageZoom").style.backgroundPosition = x + 'px ' + y + 'px'; 
                document.getElementById("productImageZoom").style.display="block";
            }
            
            function zoomToClose()
            {
                document.getElementById("productImageZoom").style.display="none";
            }

            function xpropop(xid)
            {
                document.getElementById("xpro_product_detail_pop" + xid).className="showMe";
            }
            
            function xprodrop(xid)
            {
                document.getElementById("xpro_product_detail_pop" + xid).className="hideMe";
            }
            
            function xpropopMain()
            {
                document.getElementById("xpro_product_atmos").className="showMe";
            }
            
            function xprodropMain()
            {
                document.getElementById("xpro_product_atmos").className="hideMe";
            }
            
            function showFabricDetail(fabric)
            {
                var fbTop = pageYOffset +215;
                if(pageYOffset >100){fbTop = fbTop -100;}
                document.getElementById("fabric-popper").style.top = fbTop + "px";
                document.getElementById("fabric-" + fabric).className="showMe";
                document.getElementById("fabric-popper").className="showMe";
            }

            function closeFabricDetail(fabric)
            {
                document.getElementById("fabric-popper").className="hideMe";
                document.getElementById("fabric-" + fabric).className="hideMe";
            }
            
function BrochureCheckform(){
	if (document.forms[0].Title.value== "" || document.forms[0].Title.value== " "){
	     alert ("Please give us your Title")
	     document.forms[0].Title.focus();
	     return false;
	}
	if (document.forms[0].Forename.value== "" || document.forms[0].Forename.value== " "){
	     alert ("Please give us your Forename")
	     document.forms[0].Forename.focus();
	     return false;
	}
	if (document.forms[0].Surname.value== "" || document.forms[0].Surname.value== " "){
	     alert ("Please give us your Surname")
	     document.forms[0].Surname.focus();
	     return false;
	}
	if (document.forms[0].Address1.value== "" || document.forms[0].Address1.value== " "){
	     alert ("Please give us at least 1 line of your address")
	     document.forms[0].Address1.focus();
	     return false;
	}
	if (document.forms[0].Postcode.value== "" || document.forms[0].Postcode.value== " "){
	     alert ("Please give us your Post Code")
	     document.forms[0].Postcode.focus();
	     return false;
	}
	if (document.forms[0].Email.value== "" || document.forms[0].Email.value== " "){
	     alert ("Please give your Email address")
	     document.forms[0].Email.focus();
	     return false;
	}
	if(checkemailaddress(document.forms[0].Email.value)!=0){
		alert("Please fill in a valid Email address");
		document.forms[0].Email.focus();
		return false;
		}
	if (document.forms[0].Download[0].checked != true && document.forms[0].Download[1].checked != true){
	     alert ("Please select whther you wish to download a brochure in PDF format or would prefer a hard-copy posted to you")
	     return false;
	}
	if (document.forms[0].Info[0].checked != true && document.forms[0].Info[1].checked != true){
	     alert ("Please select yes or no")
	     return false;
	}
}

function BrochureSubmitNext(){
    document.forms[0].submit();
}

/*2012*/
    function GetCurrentPageName()
    {
        var sPath = window.location.pathname;
        //var sPage = sPath.substring(sPath.lastIndexOf('\\') + 1);
        var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
        // alert(sPage.toLowerCase());
        return sPage.toLowerCase();
    }
    
    var panelTransitionSpeed = 500;
    $(document).ready(function()
    {
        //if(GetCurrentPageName() == "default.aspx")
	    //{
        $("#ip-1").animate({opacity: "0.6"}, 500);
        $("#ip-2").animate({opacity: "0.6"}, 500);
        $("#ip-3").animate({opacity: "0.6"}, 500);
        $("#ip-4").animate({opacity: "0.6"}, 500);
        /*$("#ip-5").animate({opacity: "0.6"}, 500);*/

        $("#panel1").hoverIntent(
            function() {
                $("#ittl-1").attr("src", "images/homepage-panels/text-white-xpro.png");
                $("#ip-1").css("display","block");
                $("#ip-1").animate({opacity: "1.0"}, panelTransitionSpeed);
                
                $("#pwrap-1").animate({left: "-5px"}, panelTransitionSpeed);
                $("#panel1").css("zIndex","15");}, 
            function() {
                $("#ip-1").animate({opacity: "0.6"}, panelTransitionSpeed);
                $("#ittl-1").attr("src", "images/homepage-panels/text-grey-xpro.png");
                $("#pwrap-1").animate({left: "0px"}, panelTransitionSpeed);
                $("#panel1").css("zIndex","10");
                    }
        );
                $("#panel2").hoverIntent(
                    function() {
                $("#ittl-2").attr("src", "images/homepage-panels/text-white-mens.png");
                $("#ip-2").css("display","block");
                $("#ip-2").animate({opacity: "1.0"}, panelTransitionSpeed);
                
                $("#pwrap-2").animate({left: "-90px"}, panelTransitionSpeed);
                //$("#panel2").css("zIndex","15");
                }, 
                    function() {
                $("#ip-2").animate({opacity: "0.6"}, panelTransitionSpeed);
                $("#ittl-2").attr("src", "images/homepage-panels/text-grey-mens.png");
                $("#pwrap-2").animate({left: "0px"}, panelTransitionSpeed);
                //$("#panel2").css("zIndex","11");
                    }
                );
                $("#panel3").hoverIntent(
                    function() {
                $("#ittl-3").attr("src", "images/homepage-panels/text-white-womens.png");
                $("#ip-3").css("display","block");
                $("#ip-3").animate({opacity: "1.0"}, panelTransitionSpeed);
                
                $("#pwrap-3").animate({left: "-90px"}, panelTransitionSpeed);
                //$("#panel3").css("zIndex","15");
                }, 
                    function() {
                $("#ip-3").animate({opacity: "0.6"}, panelTransitionSpeed);
                $("#ittl-3").attr("src", "images/homepage-panels/text-grey-womens.png");
                $("#pwrap-3").animate({left: "0px"}, panelTransitionSpeed);
                //$("#panel3").css("zIndex","12");
                    }
                );
                $("#panel4").hoverIntent(
                    function() {
                $("#ittl-4").attr("src", "images/homepage-panels/text-white-kids.png");
                $("#ip-4").css("display","block");
                $("#ip-4").animate({opacity: "1.0"}, panelTransitionSpeed);
                
                $("#pwrap-4").animate({left: "-90px"}, panelTransitionSpeed);
                //$("#panel4").css("zIndex","15");
                }, 
                    function() {
                $("#ip-4").animate({opacity: "0.6"}, panelTransitionSpeed);
                $("#ittl-4").attr("src", "images/homepage-panels/text-grey-kids.png");
                $("#pwrap-4").animate({left: "0px"}, panelTransitionSpeed);
                //$("#panel4").css("zIndex","13");
                    }
                );
            $("#panel5").hoverIntent(
            function() {
                $("#ittl-5").attr("src", "images/homepage-panels/text-white-hivis.png");
                $("#ip-5").css("display","block");
                $("#ip-5").animate({opacity: "1.0"}, panelTransitionSpeed);
                
                $("#pwrap-5").animate({left: "-5px"}, panelTransitionSpeed);
                $("#panel5").css("zIndex","15");}, 
            function() {
                $("#ip-5").animate({opacity: "0.6"}, panelTransitionSpeed);
                $("#ittl-5").attr("src", "images/homepage-panels/text-grey-hivis.png");
                $("#pwrap-5").animate({left: "0px"}, panelTransitionSpeed);
                $("#panel5").css("zIndex","14");
                    }
                );
            //}
            });
/*
            $("ul#nav li").hover(function() { //Hover over event on list item
	            $(this).css({backgroundPosition: "0 -37px"}); //Add background color + image on hovered list item
	            $(this).find("span").show(); //Show the subnav
            } , function() { //on hover out...
	            $(this).css({backgroundPosition: "0 0px"}); //Ditch the background
	            $(this).find("span").hide(); //Hide the subnav
            });
*/
            $(function() {
             
	            // Options for SuperBGImage
	            $.fn.superbgimage.options = {
		            id: 'superbgimage', // id for the containter
		            z_index: 0, // z-index for the container
		            inlineMode: 0, // 0-resize to browser size, 1-do not resize to browser-size
		            showimage: 1, // number of first image to display
		            vertical_center: 1, // 0-align top, 1-center vertical
		            transition: 1, // 0-none, 1-fade, 2-slide down, 3-slide left, 4-slide top, 5-slide right, 6-blind horizontal, 7-blind vertical, 90-slide right/left, 91-slide top/down
		            transitionout: 1, // 0-no transition for previous image, 1-transition for previous image
		            randomtransition: 0, // 0-none, 1-use random transition (0-7)
		            showtitle: 0, // 0-none, 1-show title
		            slideshow: 0, // 0-none, 1-autostart slideshow
		            slide_interval: 10000, // interval for the slideshow
		            randomimage: 0, // 0-none, 1-random image
		            speed: 'slow', // animation speed
		            preload: 1, // 0-none, 1-preload images
		            onShow: superbgimage_show, // function-callback show image
		            onClick: superbgimage_click, // function-callback click image
		            onHide: superbgimage_hide, // function-callback hide image
		            onMouseenter: superbgimage_mouseenter, // function-callback mouseenter
		            onMouseleave: superbgimage_mouseleave, // function-callback mouseleave
		            onMousemove: superbgimage_mousemove // function-callback mousemove
	            };
             
	            // initialize SuperBGImage
	            $('#thumbs1').superbgimage();
	            
	            if(GetCurrentPageName() == "product-detail.aspx")
	            {
	                $('div#productDetailRight').css('height', $("div#productDetailLeft").height());
                }
             
            });
             
            // function callback on showing image
            // get title and display it
            function superbgimage_show(img) {
	            $('#superbgimage').css('background', 'none');
	            $('#superbgimage').append($('#showtitle'));
	            $('#showtitle p.imagecount').html('image ' + img + ' of ' + $.superbg_imgIndex);
	            if ($('#thumbs1').css('display') == 'block') {
		            $('#showtitle p.title').html($('#thumbs1 a' + "[rel='" + img + "']").attr('title'));
	            } else {
		            $('#showtitle p.title').html($('#thumbs2 a' + "[rel='" + img + "']").attr('title'));
	            }
	            //$('#showtitle').fadeIn('fast');
	            $('#showtitle').show();
            }
            
            // function callback on clicking image, show next slide
            function superbgimage_click(img) {
	            //$('#thumbs').nextSlide();
            }
            
            // function callback on hiding image
                function superbgimage_hide(img) {
	                //$('#showtitle').hide();
	                //$('#showtitle').show();
                }
                
                my_slideshowActive = false;
 
                // function callback onmouseenter, stop slideshow, show pause-indicator
                function superbgimage_mouseenter(img) {
	                if ($.superbg_slideshowActive) {
		                my_slideshowActive = true;
		                if ($('#pause').length == 0) { 
		                //	$('body').prepend('<div id="pause"><img src="pause.png" \/><\/div>');
		                }
		                //$('#pause').css('position', 'absolute').css('z-index', 3).show();
		                //return $('#thumbs').stopSlideShow();
	                }
                }
                 
                // function callback onmouseleave, start slideshow, hide pause-indicator
                function superbgimage_mouseleave(img) {
	                if (my_slideshowActive && ($('#pause').length > 0) && ($('#pause').css('display') == 'block'))  { 
                //		$('#pause').hide();
                //		return $('#thumbs').startSlideShow();
	                }	
                }
                 
                // function callback onmousemove, show and move pause-indicator
                function superbgimage_mousemove(img, e) {
	                if (my_slideshowActive && ($('#pause').length > 0)) { 
                //		$("#pause").css("top",(e.pageY + 20) + "px").css("left",(e.pageX + 20) + "px").show();
	                }
                }
                
    function mouseX(evt) {
    if (evt.pageX) return evt.pageX;
    else if (evt.clientX)
       return evt.clientX + (document.documentElement.scrollLeft ?
       document.documentElement.scrollLeft :
       document.body.scrollLeft);
    else return null;
    }
    
    function mouseY(evt) {
    if (evt.pageY) return evt.pageY;
    else if (evt.clientY)
       return evt.clientY + (document.documentElement.scrollTop ?
       document.documentElement.scrollTop :
       document.body.scrollTop);
    else return null;
    }
