

// Loads up the various functions we are going to use
$(document).ready(function(){
	jsEnabled();
	navDrop();
	twoCols();
	navHasChild();
	noH3();
	homeCol();

});



// Adds a class to the body so I can style differently depending on whether Javascript is enabled.
function jsEnabled() {
	$("body").addClass("jsenabled");	
}

// adds a class to hovered nav items so dropdowns can work in ie6
function navDrop() {
  $("#navigation li").hover(
			  function() {
					$(this).addClass("showUl");			
				},
			  function() {
					$(this).removeClass("showUl");
				}
			);
}

// column detection & naming for ie6 - these will hopefully be written by the backend, but just in case...
function twoCols() {
	$(".contentRow").each(
		function(){
			var left = $(this).find(".columnLeft");
			var right = $(this).find(".columnRight");
			var main = $(this).find(".columnMiddle");
		  if ( left.length > 0 ) {
			  main.addClass("leftSide");
		  }
		  if ( right.length > 0 ) {
			  main.addClass("rightSide");
		  }
		}
	);
}

// column detection & naming for ie6 - these will hopefully be written by the backend, but just in case...
function navHasChild() {
	$("#navigation li ul li").each(
			function(){
			  var theChild = $(this).find("ul");
			  if ( theChild.length > 0 ) {
				  $(this).addClass("hasChild");
			  }
	    }
  );
}

// removes padding from the top of a homepage box if the box doesn't contain a title - these will hopefully be written by the backend, but just in case...
function noH3() {
	$(".homeCol .box").each(
			function(){
			  var theChild = $(this).find("h1, h2, h3, h4, h5");
			  if ( theChild.length < 1 ) {
				  $(this).addClass("noH3");
			  }
	    }
  );
}

// adds a class to the first homepage column for ie6 - these will hopefully be written by the backend, but just in case...
function homeCol() {
   $(".homeCol").addClass("first");
   $(".homeCol + .homeCol").removeClass("first");
}

// This does the hiding of the FAQ answers
function hideAnswers() {
  if (!document.getElementsByTagName) return false;

  var links = document.getElementsByTagName("ul");
  for (var i=0; i < links.length; i++) {
    	if (links[i].className.match("answer") && links[i].style.display == 'block') {
  		links[i].style.display = 'none';
    	}
    }
}

// Hides the FAQ answers except the one that's clicked
function showAnswer(answerID) { 
	hideAnswers();
	document.getElementById(answerID).style.display = 'block';
}


function external_link_ok(strto) {
    window.open(strto);
    parent.parent.GB_hide();
}

function external_link_cancel() {
  parent.parent.GB_hide();
}