// Trance Awards Functions

function prep_lead_feature() {
	lead_feature = document.getElementById("lead_article");
	if(!lead_feature) return;
	lead_feature.onclick  = function(){location.href = 'http://www.tranceawards.com/event';};
}

function prep_front_page_cols() {
	var cols = getElementsByClassName("front_page_col");
	if(!cols) return;
	// count them
	var countStories = cols.length;
	// loop through them
	for(var i = 0; i < countStories; i++)
	{
		// and set the onclick
		cols[i].onclick = function(){location.href = this.id;};
	}	
}
	
function prep_trance_story_cols() {
	var trance_stories = getElementsByClassName("trance_story_col");
	if(!trance_stories) return;
	// count them
	var countStories = trance_stories.length;
	// loop through them
	for(var i = 0; i < countStories; i++)
	{
		// and set the onclick
		trance_stories[i].onclick = function(){location.href = 'http://www.tranceawards.com/' + this.id;};
	}	
}	
	
function getElementsByClassName(name)
{
	var results = new Array();
	var elems = document.getElementsByTagName("*");
	for (var i=0; i<elems.length; i++) 
	{
		if (elems[i].className.indexOf(name) != -1) 
		{
			results[results.length] = elems[i];
		}
	}
	return results;
}

function addEvent(obj, evType, fn)
{ 
 	if (obj.addEventListener)
	{ 
		obj.addEventListener(evType, fn, false); 
   		return true; 
 	} 
	else if (obj.attachEvent)
	{ 
		var r = obj.attachEvent("on"+evType, fn); 
		return r; 
 	} 
	else 
	{ 
   		return false; 
	} 
}

addEvent(window, 'load', prep_lead_feature);
addEvent(window, 'load', prep_front_page_cols);
addEvent(window, 'load', prep_trance_story_cols);