
/* colors tables in a striped fashion */
function stripe() {
	var even = false;

	var evenColor = arguments[1] ? arguments[1] : "#FEFAF0";
	var oddColor = arguments[2] ? arguments[2] : "#ffffff";

	var table = document.getElementsByTagName("table");
	if (! table) { return; }

	for(var g=0; g<table.length; g++){  //for all tables
   		var tbodies = table[g].getElementsByTagName("tbody"); //get child tags
		for (var h = 0; h < tbodies.length; h++) {
			var trs = tbodies[h].getElementsByTagName("tr");
			for (var i = 0; i < trs.length; i++) {
        		// avoid rows that have a class attribute
        		// or backgroundColor style
        		if (! hasClass(trs[i]) && ! trs[i].style.backgroundColor) {  // get all the cells in this row...
      	    		var tds = trs[i].getElementsByTagName("td");
        	  		for (var j = 0; j < tds.length; j++) {         // and iterate through them...
            			var mytd = tds[j];
            			// avoid cells that have a class attribute
           		 		// or backgroundColor style
            			if (! hasClass(mytd) && ! mytd.style.backgroundColor) {
              				mytd.style.backgroundColor =
                			even ? evenColor : oddColor;
            			}
          			}
        		}
        		// flip from odd to even, or vice-versa
        		even =  ! even;
      		}
		}
	}
}

function checkHeight(URL){

	if(screen.height < 768)window.location.href= URL;

}


function clearItemFull(obj){

	obj.value = "";
}

function clearItem(obj, val){

	if(obj.value == val)
		obj.value = "";

}

//adds deprecated Target attribute to external links on the fly
function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.href && anchor.rel == "external"){
			anchor.target = "_blank";
		}
	}
} 

//JQuery function used in the education section to pull images out of the article 
//and display on the right hand side
function rightImages(){

	var images = new Array();
	
	var picRights = $('div.picRight')
	
	$('div.picRight').each(function(i){ 
		var image = {}; 
		if($(this).find('a') != null)
			image.link = $(this).find('a').attr('href');
		else
			image.link = null;
		if($(this).find('img') != null){
			image.title = $(this).find('img').attr('alt'); 
			image.source = $(this).find('img').attr('src'); 
			images.push(image) 
		}

	});
	var rightImages = '';
	for(i = 0; i < images.length; i++){
	
		if(images[i].link != null && images[i].title != null){
			if(images[i].title.length > 17)
				rightImages += '<div><a href="' + images[i].link + '"><img src="' + images[i].source + '" alt="' + images[i].title + '" /></a><h2 class="long"><a href="' + images[i].link + '">' + images[i].title + '</a></h2></div>';
			else
				rightImages += '<div><a href="' + images[i].link + '"><img src="' + images[i].source + '" alt="' + images[i].title + '" /></a><h2><a href="' + images[i].link + '">' + images[i].title + '</a></h2></div>';
		}
		else if(images[i].title != null){
			if(images[i].title.length > 17)
				rightImages += '<div><img src="' + images[i].source + '" alt="' + images[i].title + '" /><h2 class="long">' + images[i].title + '</h2></div>';
			else
				rightImages += '<div><img src="' + images[i].source + '" alt="' + images[i].title + '" /><h2>' + images[i].title + '</h2></div>';
		}
	}
	$('div.articleContentRight').html('<div id="boxes">' + rightImages + '</div>');

}


function rightHeaders(){

	$('ul.schoolArticleList li h2').each( function(){ var headerlength = $(this).text().length; if(headerlength > 17)$(this).addClass('long') } )

}