

jQuery(document).ready(function($) {
	
	$('.fadeImg').css({
		display    : 'none',
		visibility : 'visible'
	}).fadeIn(2000) ;
	
	var $logoCell = $('#logoCellDiv') ;
	if ($logoCell.length > 0) {
		var $logoTd = $logoCell.parent() ;
		$logoCell.css('height', ($logoTd.height() - 10) + 'px') ;
	}
	if ($.browser.msie && $.browser.version >= 8) {
		$('body').css('overflow-y', 'scroll') ;
		if ($('#top_menu>ul>li:first-child>a').hasClass('act')) {
			$('#byline').css('padding-left', '69px') ;
		}
	}
	if ($('#top_menu>ul>li:nth-child(3)>a').hasClass('act')) {
		$('#byline').css('margin-top', '-30px') ;
	}
	/*
	try {
		if (null != navigator && null != navigator.userAgent && navigator.userAgent.toLowerCase().indexOf('mac') ! -1) {
			$('#byline').addClass('bylineMac') ;
			window.setTimeout(function() {
				bylineShow($) ;
			}, 100) ;
		} else {
		}
	} catch (e) {}*/
	
	bylineShow($) ;	
	
	toolTip($, 'body', true) ;
	
}) ;

function bylineShow($) {
	var $byline = $('#byline') ;
	if (!$byline.hasClass('bylineHidden')) {
		$byline.show(0) ;
		$byline = $('#byline>table') ;
		$byline.fadeTo(0, 0.4) ;
		$byline.hover(
			function() {
				$byline.stop().fadeTo('slow', 1.0) ;
			}, function() {
				$byline.stop().fadeTo('slow', 0.4) ;
			}
		) ;
	}
}


/*
 * Tooltip script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * modified by Tommy Ullberg, imCode Partner AB (http://www.imcms.net/) | Ullberg Net Consulting
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */

var oToolTipTimer = null ;

this.toolTip = function($, selector, allTitlesInsteadOfClasses){
	if (oToolTipTimer) {
		window.clearTimeout(oToolTipTimer) ;
	}
	xOffset = 10;
	yOffset = 20;
	var $actSelector =
		(allTitlesInsteadOfClasses) ? 
			$('a[title],img[title],b[title]') :
			$(selector + ' .toolTip,' + selector + ' .toolTipHide') ;
	$actSelector.each(function(){
		if ('' == $(this).attr('title') || 'undefined' == $(this).attr('title')) {
			$(this).removeClass('toolTip').removeAttr('title') ;
		}
	});
	$actSelector.hover(function(e){
		this.t = this.title;
		this.title = "";
		var fileData = $(this).attr("rel") ;
		this.iconClass = "" ;
		if (null != fileData && fileData.length > 7 && fileData.indexOf("FIL") != -1) {
			var fileExt = fileData.substring(4,7) ;
			if (/^(PDF|DOC|ZIP|JPG|PNG|GIF|MP3|AVI|MPG)$/i.test(fileExt)) {
				this.iconClass = "toolTipIcon_" + fileExt.toUpperCase() ;
			}
		} else if (null != fileData && fileData.indexOf("URL") != -1) {
			this.iconClass = "toolTipIcon_EXT_LINK" ;
		}
		$("body").append('<div id="toolTipPop">'+ this.t.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/#LT#/g, "&lt;").replace(/#GT#/g, "&gt;") + '</div>');
		$("#toolTipPop")
			.css("top",(e.pageY + yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px")
			.fadeIn(document.all ? "fast" : "slow");
		if ($(this).hasClass('toolTipHide')) {
			$("#toolTipPop").delay(1000).fadeTo(500, 0) ;
			//this.title = this.t;
		}
	}, function(){
		this.title = this.t;
		$("#toolTipPop").remove();
	});
	$actSelector.mousemove(function(e){
		$("#toolTipPop")
			.css("top",(e.pageY + yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px") ;
		if ("" != this.iconClass) {
			$("#toolTipPop").addClass(this.iconClass) ;
		}
	});
};

/* *******************************************************************************************
 *         Top menu                                                                          *
 ******************************************************************************************* */

var iTopMenuTimeout = 500;
var oTopMenuTimer   = null;
var $subMenuItem    = null;

function simpleMenuOpen() {
	simpleMenuCancel() ;
	simpleMenuClose() ;
	$subMenuItem = $(this).find('ul').css('visibility', 'visible') ;
}

function simpleMenuClose() {
	if ($subMenuItem) {
		$subMenuItem.css('visibility', 'hidden') ;
	}
}

function simpleMenuTimer() {
	oTopMenuTimer = window.setTimeout(simpleMenuClose, iTopMenuTimeout) ;
}

function simpleMenuCancel() {
	if (oTopMenuTimer) {
		window.clearTimeout(oTopMenuTimer) ;
		oTopMenuTimer = null ;
	}
}

jQuery(document).ready(function($) {
	if ('hidden' == $('#sub_menu').css('visibility')) {
		$('#top_menu ul:first > li').live('mouseenter', simpleMenuOpen) ;
		$('#top_menu ul:first > li').live('mouseleave',  simpleMenuTimer) ;
	}
}) ;

document.onclick = simpleMenuClose ;


