//<!--

/*
	This is a sample HTML file that demonstrates how JavaScript can be used to solve a common problem. The problem occures when you have a news item and you want to have the whole block as a link. Unfortunately you cannot wrap a href around block level items without invalidating the document. The function (moveListLink) will apply the url of the first child link to a containing tag (in this case any tag with a class = listBlock) as an onclick event. This means you can click anywhere within the containing tag and you will be taken to the url instead of clicking just on the link itself.
/*
	Written by Jonathan Snook, http://www.snook.ca/jonathan
	Add-ons by Robert Nyman, http://www.robertnyman.com
*/

function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/-/g, "\-");
	var oRegExp = new RegExp("(^|\s)" + strClassName + "(\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}

/* This is the main function. It just calls getElementsByClassName in order to find our specified class elements.  */

function moveListLink(eClass) {
	var listArray = getElementsByClassName(document, "*", "listBlock");
	for(var i=0; i<listArray.length; i++)
	{
		listArray[i].style.cursor="pointer";
		listArray[i].onclick = function() 
		{
			var theLink = this.getElementsByTagName("a");
			if(theLink[0].className.indexOf("newWindow") > -1) {
			    window.open(theLink[0].href); return false;
			} else {
			    document.location.href = theLink[0].href;
			}
		}
		
		listArray[i].keypress = function() 
		{
			var theLink = this.getElementsByTagName("a");
			if(theLink[0].className.indexOf("newWindow") > -1) {
			    window.open(theLink[0].href); return false;
			} else {
			    document.location.href = theLink[0].href;
			}
		}
			
		listArray[i].onmouseover = function() 
		{
			this.className = this.className + " myhover"
		}
	
		listArray[i].onmouseout = function() 
		{
			this.className = "listBlock";
		}
	}
}

window.onload = function() {
	moveListLink("listBlock");
}


//-->
