/** SEARCH A SUBSTRING IN THE STRING **/
function InStr(strSearch, charSearchFor) {
	for (i=0; i < strSearch.length; i++) {
	      if (charSearchFor == Mid(strSearch, i, 1)) {
	            return i;
	      }
	}
	return -1;
}

/** CHANGE THE EVENT IMAGES **/
function changeEventStauts( obj ) {
	classToSearch = obj.className.toString();
	
	if( obj.className.substr( (obj.className.length - 4), 4 ) == '_off' ) {
		obj.className = 'eventBox ' + obj.id + '_on';
	} else {
		obj.className = 'eventBox ' + obj.id + '_off';	
	}
}

/** GO TO EVENT DESCRIPTION **/
function gotoEvent( obj ) {
	//fixit: hardcoded event ids
	//SEASON ROLLOVER HARDCODE
	if( obj.id == 'oneday' ) {
		location.href = 'index.php?option=com_events&view=minisite&event_id=7001&Itemid=71&index=1';
	}
	if(obj.id == 'thedrive') {
		location.href = 'index.php?option=com_events&view=minisite&event_id=7002&Itemid=71&index=2';
	}
	if(obj.id == 'kingday') {
		location.href = 'index.php?option=com_events&view=minisite&event_id=7003&Itemid=71&index=3';
	}
	if(obj.id == 'earthday') {
		location.href = 'index.php?option=com_events&view=minisite&event_id=7004&Itemid=71&index=4';
	}
	if(obj.id == 'wildcards') {

	}
}


function setDivsHeight() {
	setTimeout("changeDivHeight()",1000);
}


function changeDivHeight() {
	var rightHeight = $('colRight').offsetHeight;
	var leftHeight = $('colLeft').offsetHeight;
	
	if( $('colMid') == undefined ) {
		if( rightHeight > leftHeight ) {
			$('colRight').style.height = rightHeight+'px';
			$('colLeft').style.height = rightHeight+'px';
		} else {
			$('colRight').style.height = leftHeight+'px';
			$('colLeft').style.height = leftHeight+'px';
		}
	} else {
		var midHeight = $('colMid').offsetHeight;
		var maxHeight = '';
		
		if( rightHeight > leftHeight ) {
			if( rightHeight > midHeight ) {
				maxHeight = rightHeight+'px';
			} else {
				maxHeight = midHeight+'px';
			}
		} else {
			if( leftHeight > midHeight ) {
				maxHeight = leftHeight+'px';
			} else {
				maxHeight = midHeight+'px';
			}
		}

		$('colRight').style.height = maxHeight;
		$('colMid').style.height = maxHeight;
		$('colLeft').style.height = maxHeight;
	}
}