// Execute when DOM is ready

jQuery(function(){

	// account sub menu
	jQuery('li.subroot ul').addClass('sub');
	var hover_config = {    
		sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
		interval: 100, // number = milliseconds for onMouseOver polling interval    
		over: showSub, // function = onMouseOver callback (REQUIRED)    
		timeout: 200, // number = milliseconds delay before onMouseOut    
		out: hideSub // function = onMouseOut callback (REQUIRED)    
	};
	jQuery('ul.sub').parent().hoverIntent(hover_config);

	// fix links to named anchors when base href is used (static pages)
	if (jQuery('base').length) {
		jQuery('a[ href ^= "#" ]').each(function() {
			var href = window.location + jQuery(this).attr('href').replace('/#.*/i','');
			jQuery(this).attr('href',href);
		});
	}

});




// Common scripts

function drawEmLink(addr,subj,ltext) {
	if (subj == null) { subj = ''; };
	if (ltext == null) {
		document.write('<a href="mailto:' + addr + '?subject=' + subj + '">' + addr + '&#64;' + subdomain + '</a>');
	} else {
		document.write('<a href="mailto:' + addr + '?subject=' + subj + '">' + ltext + '</a>');
	}
}

function drawCopyright() {
	today = new Date();
	cYear = today.getFullYear();
	document.write('&copy;' + cYear);
}

function showSub() {
		jQuery(this).children('a:first').addClass('subhover');
		jQuery('ul.sub').hide();
		jQuery(this).children('ul.sub').show(); 
//		jQuery(this).children('ul.sub').fadeIn('fast', function() { 
//			 if (!(jQuery.support.opacity)) 
//				 this.style.removeAttribute('filter'); 
//			});
	}
	
function hideSub() {
		jQuery(this).children('ul.sub').hide();
		jQuery(this).children('a:first').removeClass('subhover');
	}
	

////////////////////////////////////////////////

/**
* 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(jQuery){jQuery.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=jQuery.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){jQuery(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;jQuery(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{jQuery(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);

////////////////////////////////////////////////

