/*
*
@author jason@mediag.com

mouse over, out, up behaviors for home page content <div clalss="box">
	-set location to child <A> href
	-change text color
*
*/


var nodeNum=4;
function getTextColor(color){
	switch(color){
		case 'red':
			return '#d24242';
		break;
		case 'blue':
			return '#337ebe';
		break;
		case 'yellow':
			return '#daaf3d';
		break;
		case 'green':
			return '#519c58';
		break;
	}
}
function init(){
	var div=document.getElementsByTagName('div');
	
	for(i=0;i<div.length;i++){
		if(div[i].className=='box'){
			div[i].style.cursor='pointer';
			div[i].hrefTarg=div[i].childNodes[nodeNum].href;
			div[i].onmouseover=function(){
				this.childNodes[nodeNum].style.color=getTextColor(this.childNodes[nodeNum].className);
			}
			div[i].onmouseout=function(){
				this.childNodes[nodeNum].style.color='#000000';
			}
			div[i].onmouseup=function(){
				window.location.href=this.hrefTarg;
			}
		}
	}
}


function addEvent(elm, evType, fn, useCapture){  //cross-browser event handling
	if(elm.addEventListener){//firefox, safari, chrome, opera
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}else if(elm.attachEvent){//ie
	//	if(navigator.userAgent.substr(navigator.userAgent.indexOf('MSIE')+5,1)<=7)
			nodeNum=2;
			
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}else{
		elm['on' + evType] = fn;
	}
}
addEvent(window, 'load', init, false);
