/**

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


// Tooltip from CSS Globe written by Alen Grakalic (http://cssglobe.com)

this.tooltip = function(){xOffset = -10;yOffset = 10;jQuery.noConflict();jQuery(".tooltip").hover(function(e){this.t = this.title;this.title = "";jQuery("body").append("<p class='itooltip'>"+ this.t +"</p>");jQuery(".itooltip").css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px").fadeIn(500);},function(){this.title = this.t; jQuery(".itooltip").remove();});jQuery("a.tooltip").mousemove(function(e){jQuery(".itooltip").css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px");});};
//END TOOLTIP

//MOLITOR SCRIPTS

this.molitorscripts = function () {

	
	//DEFINE VARIABLES
	var browserName = navigator.appName;	

	//REMOVE TITLE ATTRIBUTE
	jQuery("#dropmenu a").removeAttr("title");
	
	//DEFINE VARIABLES BASED ON BROWSER BEING USED
	if (browserName != "Microsoft Internet Explorer"){
    	var arrow = "#dropmenu ul li ul";
    	jQuery(arrow).parent().children("a").prepend("<span style='float:right;'>&rsaquo;</span>");	
	}
	
	//MENU
	jQuery("#dropmenu ul").css("display", "none"); // Opera Fix
	jQuery("#dropmenu li").hoverIntent(function(){
		jQuery(this).find('ul:first').show();
		},function(){
		jQuery(this).find('ul:first').hide();
	});
	
	//MAIN MENU STUFF
	jQuery("#dropmenu li:nth-child(3)").css({"marginRight":"240px"});
	
	//HOME BUCKETS
	jQuery("div#homeBuckets > div.homeBucket:nth-child(3)").css({"marginRight":"0px"});
	
	//FAQ STUFF
	jQuery("body.page-template-faq-php .listing .post > p").slideToggle(800);
	jQuery("body.page-template-faq-php .listing .post > h2.posttitle").css("cursor","pointer").click(function(){
		jQuery(this).toggleClass("open").next("p").slideToggle(500);
	});
	
	//FOOTER MENU
	jQuery("#footerNav ul li:nth-child(8)").css("border","none");
	
	//SLIDESHOW
	jQuery('.fadein img:gt(0)').hide();
    setInterval(function(){
      jQuery('.fadein :first-child').fadeOut()
         .next('img').fadeIn()
         .end().appendTo('.fadein');}, 
      8000);
}

//END MYSCRIPTS

jQuery.noConflict(); jQuery(document).ready(function(){molitorscripts(); tooltip();  });
