//===============================================================================================
// jQuery kludge to make the main navigation and search menus to work in IE6.
// With strict doctype, menu should already work in IE7/8 without this kludge

ie6_menus = function() {
	if (document.all && (!document.documentMode || document.documentMode < 7)) {
 		$('#navigation-menu li').hover(
 			function() {
 				$(this).addClass('over');
 			},
 			
 			function() {
 				$(this).removeClass('over');
 			}
 		);
		
		$('#search li').hover(
			function() {
				$(this).addClass('over');
			},
			
			function() {
				$(this).removeClass('over');
			}
		);
		
		$('#featured ul li a').hover(
			function() {
				$(this).addClass('over');
			},
			
			function() {
				$(this).removeClass('over');
			}
		);
 	}
}


//===============================================================================================
// toggle display of a given element

function toggle(id) {
  var e = document.getElementById(id);
  if(e.style.display == 'block')
    e.style.display = 'none';
  else
    e.style.display = 'block';
}


//===============================================================================================
// toggle explanatory text in search boxes

function toggle_message(text_box, text) {
	if (text_box.value == "") {
		text_box.value = text;
	} else if (text_box.value == text) {
		text_box.value = "";
	}
}


//===============================================================================================
// standards compliant external links

externalLinks = function() {
  if (!document.getElementsByTagName) return;   
  var anchors = document.getElementsByTagName("a");   
  for (var i = 0; i < anchors.length; i++) {   
    var anchor = anchors[i];
    if (anchor.getAttribute("href") &&   
        anchor.getAttribute("rel") == "external") {
      anchor.target = "_blank";   
    }
  }
}   


//===============================================================================================
window.onload = function() {
	ie6_menus();
	externalLinks();
	$('#navigation-menu .collapsed').css('display', 'none');
}
