// JavaScript Document
	function randomProduct(){
	var productLength = $("#featured .productfeaturelist li.productItem").length;
	$("#featured .productfeaturelist li.productItem").hide();
	var ran = Math.floor(Math.random()*productLength) + 1;
	$(".productfeaturelist li:nth-child(" + ran + ")").show();
	//alert("random product function called. Random number is " + ran + " and number of products hidden is " + productLength);
									};


$(document).ready(function(){
//PAGE STUFF -----------------------------------------------------------------------------------------------------------------------------


//clear floats everywhere
$("p.button, p.buttonRight, a.button, a.buttonRight, button").after('<div class="clear">&nbsp;</div>');			
//make all a elements with class of .groupHeight the same height as the biggest

    $(".groupHeight").height(max); 
	
	var max = 0
	$(".groupHeight").each(function(){
        if ($(this).height() > max)
            max = $(this).height();   
    });
    $(".groupHeight").height(max);									

											

//OVERLAY CALL
	$(".productFinderTrigger, a.enquireNow, a.cartSummaryLink, a[href=/v3/product-finder.htm],a[href=/v3/contact-overlay.htm]").colorbox({
										innerWidth: 850,
										innerHeight: 750,
										iframe: true,
										opacity:0.6
										});
  var loggedIn = "{module_isloggedin}";
			   if(loggedIn == 1){
				   	$("li#myServicom a").attr('href','/v3/my-servicom-account.htm');
				   }
			//init the tooltip for the manufacturers
					   $("div#manufacturers a img[title],div#manufacturersSlideshow a img[title]").tooltip({ 
    												
        														// use div.tooltip as our tooltip 
        														tip: '#tooltip', 
																opacity: '1.0',
        														// tweak the position 
       															 position: "center left",         
        														offset: [-10, 0] 
});
//TABS

	//make the tabs
	
	//random number to open one of the tabs on page load
	var rand_no = Math.floor(4*Math.random())
	
	$("ul.tabs").tabs("div.panes >  div.pane",{
											current: 'current',//class name applied to the current tab
										  	effect: 'fade', //default, fade, slide, horizontal,ajax
										  	event: 'click', // click, mouseover, dblclick
										  	history: true, // true or false - uses hash in url
										  	initialIndex: rand_no, //index of the inital tab opened
										  	tabs: 'a', //selector for what makes the tabs
										  	rotate: true
										  	});
randomProduct();					   
//make bigTargets
$("a.bigTarget, .bigTarget a").bigTarget({
										 hoverClass: 'over', // CSS class applied to the click zone onHover
    									clickZone : 'div:eq(0)' // jQuery parent selector

										 });			
//init overlays
$("div.overlayContainer a.colorbox").colorbox();			



		   


					   
					   
					  //remove unwanted manufacturers
					   $("#manufacturers li.show0, #manufacturers li.show").remove();
						//$(".service.span1:nth-child(3n),.service:last ").addClass("last");
														  
					   //init the tooltip for the remaining services
					   $("div.service a img").tooltip({
													// use slide effect instead of the default 
        														effect: 'slide', 
 																tip:'.tooltip',
																opacity:'1.0',
																offset: [-10, 0]
       															
													});
/*PRODUCT SEARCH - autocomplete								
	$("#CAT_ProductSearch").click(function(){
											$(this).val('');
											});
									
										
											var prods = [];
											$("div#products ul.catalogueitemdump li a").each(function() { prods.push($(this).text()) });
											$("div#products ul.catalogueitemdump li").remove();
											//alert(prods);
											$("#CAT_ProductSearch").autocomplete(prods, {
																						matchContains: true,
																						minChars: 1,
																						autofill:true,
																						width: 500,
																						height:250
																						});
	$("#CAT_ProductSearch").val('Type keywords or your product name in here for suggestions');
	
	$("#CAT_ProductSearch").click(function(){
										   if($("#CAT_ProductSearch").val('Type keywords or your product name in here for suggestions')){
										$(this).val('');
		}
										   
										   });
	//$("#CAT_ProductSearch").blur(setTimeout(function(){
										  // if($("#CAT_ProductSearch").val('')){
										//$(this).val('Type keywords or your product name in here for suggestions');
										//}
										 //},3000));
	

	
	$("select#CAT_ProductCatalogue").change(function(){
													 $("#CAT_ProductSearch").val('');
														});
*/

						   });
