/**
* 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);

$(document).ready(function(){

// clear restore search field
$('input.clickClear').focus(function() {
    startText = $(this).val();
    $(this).val('');
});
$('input.clickClear').blur(function() {
    blurText = $(this).val();
    if (blurText == '') {
    $(this).val(startText);
    };
});

  $(".monkForm legend:first").hide();

	var requiredStar = ' <span class="star">*</span>';
	  $('div.required').find('label').append(requiredStar);
	  $('form.monkForm label[for=text_16582]').append(requiredStar);
	  $('form.monkForm span.star').css('color','red');



 $("#footer li").addClass("gotham");
 $("#footer li:last").addClass("last");   


//navigation logic 

var config ={
	sensetivity: 3,
	over: mOver,
	interval: 10,
	timeout: 10,
	out: mOut
};

	//$("#nav li#nav_solution").hoverIntent(config); 
	
	
	function mOver(){  
           if($("#megamenu").length > 0){ 
				$("#megamenu").remove();
				$("#nav li.hover").removeClass("hover");
			}  
			
			
           $(this).addClass("hover"); 

		   var btntxt = $(this).find("a").attr("href");
	       var btnid = btntxt.replace(/\//g,"");  
	       var obj = $(this);
	       var pos = obj.position();    
		   //var eWidth = $(this).width();
	       var nbHeight = $("#navbar").height();
	       var left = pos.left + "px";
	       var top = pos.top + nbHeight + "px";  
	       
		   var id = $(this).attr("id");
		   
	
	        //var left = (pos.left) + "px";
	        //var top =  (pos.top) + "px";
	        //show the menu directly over the placeholder  
        
	        $("#navbar").append("<div id='megamenu' class='mm_" + id + " clearfix'><div id='spinner'><img src='/_img/spinner.gif' alt='loading'/></div><div id='mm'></div></div>");
              
           
	             $("#megamenu").css({ 
	                position: 'absolute',
	                zIndex: 5000,
	                left: left,
	                top: top
	              }).mouseleave(function(){ 
						$("#megamenu").remove(); $("#nav li").removeClass("hover");
				  }).hide();

		
		    $("#megamenu").load('/_inc/megamenu.php',{'mainnav':btnid},
				     function(retval){   
					  if(retval !=""){
						 
						$(this).fadeIn("fast"); 

				 		var sLiWidth = 0;   
				        var pLiWidth = 0;  
						var lWidth   = 0;
				        
						// if no subnav items will use largest width of parent li.
				        $("#branchnav li").each(function(){  
						      if($(this).width() > pLiWidth){
								    pLiWidth = $(this).width();
							   }	  
				        });
				        
				        // gets largest width of subnav li to apply to parent li fo
				        $("#branchnav li li").each(function(){  
						      if($(this).width() > sLiWidth){
								    sLiWidth = $(this).width();
							   }	  
				        });
				        
				        // use parent width if no subnav is available
				        if(pLiWidth > sLiWidth){
						     lWidth = pLiWidth + 15 + "px";
						} else {
							 lWidth = sLiWidth + 25 + "px";
						}
				   
			         	
						   	 $("#branchnav li").css({
								   width:lWidth
								});
						   
					} else{
						
					   $(this).remove();  
					    $("#nav li").removeClass("hover"); 
					}        
		 }).hover(function(){
			$(this).addClass("menuOn");
		},function(){
			$(this).removeClass("menuOn");
		}); 
		
		      
	};  
	
	function mOut(){  
		 if($("#megamenu.menuOn").length > 0){
			
		} else {
			  $("#megamenu").remove();  
			  $("#nav li").removeClass("hover");  
			}  
		};

});          











 /*$('.preview').each(function(){
     $(this).find(".count span").hide();
     var val = $(this).find(".count span").text();
  $(this).find(".count span").load('/_inc/ajax-category-count.php',{'boardslug':val},
     function(){
         $(this).show();                          
      });
 });  */