//$(document).ready(function(){
								  
jQuery(document).ready(function($){
	//alert('Hello World')
	
	//Add 'selected' class to the H3 tag above the menu list below
	$('.sidebar ul li.selected').parent('ul').parent('div').prev('script').prev('h3').addClass('selected');
	
	//Find the H3 'a' link reference in the browser and add 'selected' class to H3 tag
	var CurrentURL = window.location.pathname;
	$('.sidebar h3 a[href ~= "' + CurrentURL + '"]').parent('h3').addClass('selected');
	
	//Copy the text from the H2 tag on left-hand-side and place into the H1 tag on right-hand-side
	var h1String = $('.sideList h2').text();	
	$('.mainContent h1.left_h2Text').text(h1String);
	
	//Copy the text from the H3(selected) tag on left-hand-side and place into the H2 tag on right-hand-side
	var h2String = $('.sideList h3.selected').text();
	$('.mainContent h2.left_h3Text').text(h2String);

	//Copy the text from the sideList li(selected) tag on left-hand-side and place into the H2 tag on right-hand-side
	var h2String = $('.sideList li.selected').text();
	$('.mainContent h2.left_sideListText').text(h2String);

	
	//Banner Change	
	var url = window.location.pathname;
	  if (url.indexOf("/products/") > -1) {
		$(".banner img").attr("src","/Images/Banners/banner2_products.png").attr("alt","Products");
		$('.navigation ul li.item2').addClass('selected'); //keep 'Products' link in main nav selected
	  }
	  else if (url.indexOf("/_catalog_") > -1) {
		$(".banner img").attr("src","/Images/Banners/banner2_products.png").attr("alt","Products");
		$('.navigation ul li.item2').addClass('selected'); //keep 'Products' link in main nav selected
	  }
	  else if (url.indexOf("/_product_") > -1) {
		$(".banner img").attr("src","/Images/Banners/banner2_products.png").attr("alt","Products");
		$('.navigation ul li.item2').addClass('selected'); //keep 'Products' link in main nav selected
	  }
	  else if (url.indexOf("/partner-solutions/") > -1) {
		$(".banner img").attr("src","/Images/Banners/banner_partner.png").attr("alt","Partner Solutions");
	  }
	  else if (url.indexOf("/service-support/") > -1) {
		$(".banner img").attr("src","/Images/Banners/banner_service.png").attr("alt","Service & Support");
	  }
	  else if (url.indexOf("/news-media/") > -1) {
		$(".banner img").attr("src","/Images/Banners/banner_news.png").attr("alt","News & Media");
	  }
	  else if (url.indexOf("/about/") > -1) {
		$(".banner img").attr("src","/Images/Banners/banner_about.png").attr("alt","About Us");
	  }
	  else if (url.indexOf("/contact/") > -1) {
		$(".banner img").attr("src","/Images/Banners/banner_contact.png").attr("alt","Contact Us");
	  }
	  else if (url.indexOf("/site-search-test") > -1){
		$(".banner img").attr("src","/Images/Banners/banner_blank.png").attr("alt","Search Results");
	  }
	  else {
		$(".banner img").attr("src","/Images/Banners/banner_about.png").attr("alt","");
	  }
	  
	//Changes the "the catalogue has no products" message.
	if ($('td.productItemNotFound').length > 0){
		$('td.productItemNotFound').html('Please <a href="/contact/">contact our sales department</a> for these products.');
	}
	
	/*[Animated Button]*/		
	if ($("img.button").length > 0){	   
		$("img.button").hover(
		function() {
			$(this).stop().animate({"opacity": "0"}, "medium");
		},
		function() {
			$(this).stop().animate({"opacity": "1"}, "medium");
		});
	}

/*});*/

/* //jQuery.noConflict();
jQuery(document).ready(function($){	
	
	//take contact number and place into right column		
	//Select h2 string.
	var h2String = $('.mapContact h2').html();
	//alert(h2String);
	
	//Find the end of the br tag (">" character).
	var numberposition = h2String.indexOf(">") + 1;

	//Slice up to and including the "<br />" tag.
	h2String = (h2String.slice(numberposition));
	$('#phoneNumber p').text(h2String);

}); */

/*------------------------------------------------------------------ 


/*------------------------------------------------------------------ This is now being loaded from the jquery.js file
[Navigation]*/

//jQuery(function(){
//    jQuery('ul.navigation').superfish();
//});

 /*------------------------------------------------------------------ 
[Hilite current page in nav]*/

/*$(document).ready(function() {	*/

	//Show Banner
	$(".main_image .desc").show(); //Show Banner
	$(".main_image .block").animate({ opacity: 0.85 }, 1 ); //Set Opacity

	//Click and Hover events for thumbnail list
	$(".image_thumb ul li:first").addClass('active'); 
	$(".image_thumb ul li").click(function(){ 
		//Set Variables
		var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
		var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL
		var imgDesc = $(this).find('.block').html(); 	//Get HTML of block
		var imgDescHeight = $(".main_image").find('.block').height();	//Calculate height of block	
		
		if ($(this).is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
			//Animate the Teaser				
			$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
				$(".main_image .block").html(imgDesc).animate({ opacity: 0.85,	marginBottom: "0" }, 250 );
				$(".main_image img").attr({ src: imgTitle , alt: imgAlt});
			});
		}
		
		$(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists
		$(this).addClass('active');  //add class of 'active' on this list only
		return false;
		
	}) .hover(function(){
		$(this).addClass('hover');
		}, function() {
		$(this).removeClass('hover');
	});
			
	//Toggle Teaser
	$("a.collapse").click(function(){
		$(".main_image .block").slideToggle();
		$("a.collapse").toggleClass("show");
	});
	
/*});//Close Function*/

 /*------------------------------------------------------------------ 
[Homepage Switcher]*/

/*$(document).ready(function(){
	$("#TabMenu a").click(function(e){
                $(this).addClass('switchOneHover');
		$("#ImgObject").ImageStop(true,true);
		$("#ImgObject").ImageSwitch({	Type:"FadeIn", 
										NewImage:$(this).attr("href"),
										EffectOriginal: false,
										Speed: 'medium'});
		e.preventDefault();
	});
});*/

/*$(document).ready(function(){
	$("#TabMenu a").click(function(e){
	    removeHover();
	    addHover($(this)); 
            
		$("#ImgObject").ImageStop(true,true);
		$("#ImgObject").ImageSwitch({	Type:"FadeIn", 
										NewImage:$(this).attr("href"),
										EffectOriginal: false,
										Speed: 'medium'});
		e.preventDefault();
	});
});

function removeHover() {
    $obj = $("#TabMenu a");
    $obj.each(function(i) {
        var $str = $(this).attr('class');
        $(this).removeClass($str);
        $str = $str.replace("Hover", "");
        $(this).addClass($str);
    });
}

function addHover($obj){
    var $str = $obj.attr('class');
    $obj.removeClass($str);
    $str = $str + 'Hover';
    $obj.addClass($str);
}*/

var $nextObj;

/*$(document).ready(function(){*/
    

	$("#TabMenu a").click(function(e){
	    removeHover();
	    addHover($(this)); 
            
		$("#ImgObject").ImageStop(true,true);
		$("#ImgObject").ImageSwitch({	Type:"FadeIn", 
										NewImage:$(this).attr("href"),
										EffectOriginal: false,
										Speed: 'medium'});
		$("#findmore").attr('href' , $(this).attr("rel"));
		e.preventDefault();

		$nextObj = $(this);
	});
	$nextObj = $(".switchOneHover")
	runSlideShow();


function removeHover() {
    $obj = $("#TabMenu a");
    $obj.each(function(i) {
        var $str = $(this).attr('class');
        $(this).removeClass($str);
        $str = $str.replace("Hover", "");
        $(this).addClass($str);
    });
}

function addHover($obj){
    var $str = $obj.attr('class');
    $obj.removeClass($str);
    $str = $str + 'Hover';
    $obj.addClass($str);
}
							 
function runSlideShow(){
	$objCur = $nextObj;
	$currentClass = $objCur.attr('class');
	if($currentClass == 'switchOne' || $currentClass == 'switchOneHover') {
		$nextObj = $('.switchTwo');
	} else if ($currentClass == 'switchTwo' || $currentClass == 'switchTwoHover') {
		$nextObj = $('.switchThree');
	} else {
		$nextObj = $('.switchOne');
	}
	removeHover();
	addHover($objCur); 

if ($("#ImgObject").length > 0){

	$("#ImgObject").ImageStop(true,true);
	$("#ImgObject").ImageSwitch({	Type:"FadeIn", 
									NewImage:$objCur.attr("href"),
									EffectOriginal: false,
									Speed: 'medium'});
    $("#findmore").attr('href' , $objCur.attr("rel"));
	
	setTimeout(function() {runSlideShow();}, 5000);
	//setTimeout('runSlideShow()', 5000);

}
}

});
function checkSearch(){
	
	var xx = $('#searchForm #CAT_Search').val();
	var y = $('#searchForm').attr('action');
	var top_url = y + "&searchterm=" + xx;
	$('#searchForm').attr('action',top_url);

}
