$(function(){
	
	$('body').addClass('jsok');

	// quick product finder
	var qpfOpen = false;
	var qpfHeight = $('#qpf_wrapper').height();
	
	$('#qpf_wrapper').hide();
	
	$("#qpf_tab, #close_qpf").click(function(){
		
		if ( qpfOpen )
		{
			$('#qpf_wrapper').slideUp();
			qpfOpen = ! qpfOpen;
		}
		else
		{
			$('#qpf_wrapper').slideDown('slow');	
			qpfOpen = ! qpfOpen;
		}
		return false;
	});
	
	$(".qpf_category li").hoverIntent({    
	     sensitivity: 3,
	     // interval: 200,
	     over: function(){
			$(this).find('span.items').css('display','block');
		},
	     // timeout: 500, 
	     out: function(){
			$(this).find('span.items').css('display','none');
		}
	})
	
	// enquiry forms ////////////////////////////////////
	
	if ( $('#enquiry_form').size() )
	{
		$('#enquiry_form form:eq(1)').hide();
		$('#enquiry_type li:eq(0)').addClass('current');
		
		$('#enquiry_type li a').click(function(){
			
			$('#enquiry_type li').removeClass('current');
			$('#enquiry_form form').hide();
			$($(this).attr('href')).show();
			$(this).parent('li').addClass('current');
			
			return false;
		});
	}
	
	// center logos
	$('.product_list li').each(function(){
		
		var img = $(this).find('.logo img')
		if ( img.size() )
		{
			var boxheight = $(this).height();
			var margintop = (boxheight - img.height()) / 2;
			img.css('marginTop',margintop);
		}
		
	});
	
	if ( $('#map').size() )
	{
	
		function initialize()
		{
			var themap = new google.maps.Map2(document.getElementById("map"));
			themap.setCenter(new google.maps.LatLng(50.9522782, -0.1468077), 14);
			var point = new GLatLng( 50.9522782, -0.1468077);
			themap.addOverlay(new GMarker(point));
			themap.setUIToDefault();
		}
	
		google.setOnLoadCallback(initialize);		
	}
	

	
});

// google maps //////////////////////////////////////////////////////
 
	google.load("maps", "2.x");


/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);


