
/******************************/
/* insert 'this link opens in */
/* new window' for external   */
/* link (for title attribute) */
/******************************/
/* noscript safe: accessibility not affected, user will simply not see the 'external link', 'mailto' and pdf  icons */

function checkExtLink() {
	
	// Fetch all the a elements in the document.
	var links = document.getElementsByTagName('a');

	// Loop through the a elements in reverse order for speed.
	for (var i = links.length; i != 0; i--) {
		
		// Pull out the element for this iteration.
		var a = links[i-1];
		
		// If the element doesn't have an href, skip it.
		if (!a.href) continue;

		// If the element has a 'target' attribute, assign a title attribute
		if  (a.target && a.target!='_parent' && a.title=='') {a.title = '[this link opens in a new window]'};

		// If the element has a 'mailto', put mail icon
		var str = new RegExp('mailto:');
		if  (a.href.match(str)) {a.className = 'mailtolink'; a.title = '[this link opens your email application]'};

		//If the element has a '.pdf' in href value and doesnt open in new window and is not an image, put pdf icon
		var str = new RegExp('.pdf');
		if  (a.href.match(str) && !a.target && a.className !='imagelink') {a.className = 'pdflink'; a.title = '[PDF Document]'};			
	}
    
    //draftMode();
}


var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

var currentSubMenu = 0;
var levelMenu = 0;
var ieVersion = 0;

function getIEVersion() {
	if (jQuery.browser.msie) { 
	  return(parseInt(jQuery.browser.version)); 
	} else {
		return 100;
	}
}

function menu_open() {
	if (($(this).find('ul').length<1)||((ieVersion<7)&&($(this).html()!=levelMenu.html()))) {
		currentSubMenu = $('li.active-navnode ul.subnav').css('visibility', 'hidden');
	}
}

function menu_close() {
	if(currentSubMenu) currentSubMenu.css('visibility', 'visible');
}

function jsddm_open() {  
   jsddm_canceltimer();
   jsddm_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');
}

function jsddm_close() {  
	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');
}

function jsddm_timer() {  
	closetimer = window.setTimeout(jsddm_close, timeout);
}

function jsddm_canceltimer() {  
	if(closetimer) {  
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

document.onclick = jsddm_close;

$(document).ready(function() {
	checkExtLink();
	ieVersion = getIEVersion();
	levelMenu = $('.active-navnode:first');
	//alert("height: "+$(".contentContainer .separator-left").height());
	if ($(".contentContainer .separator-left").height() > $(".contentContainer").height()) {
		$(".contentContainer").height($(".contentContainer .separator-left").height());
	};
	$('#mainMenu > li').bind('mouseover', menu_open);
	$('#mainMenu > li').bind('mouseout', menu_close);
});





