function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

//allows for multiple functions to be stacked onto an event handler
//call addEvent(load_function, eventType); after function is defined
function addEvent(func, type) {
	if (type=="onload") {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				oldonload();
				func();
			}
		}
	} else if (type=="onresize") {
		var oldonresize = window.onresize;
		if (typeof window.onresize != 'function') {
			window.onresize = func;
		} else {
			window.onresize = function() {
				oldonresize();
				func();
			}
		}
	}
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

MM_preloadImages('/images/front/blue.png', '/images/front/Inside_on.gif', '/images/front/Support_on.gif', '/images/front/Community_on.gif', '/images/front/Music_on.gif', '/images/front/Programs_on.gif', '/images/front/Contests_on.gif', '/images/front/Events_on.gif');

function playerDataRefresh()
{
	//update the divs with player data.

	//update the current song data
	loadFragmentInToElement(1,'http://www.plr.org/playing_now.html?view=current&page=front&code=new', 'playing');
	//update recently played
	loadFragmentInToElement(2,'http://www.plr.org/playing_now.html?view=recent&page=front&code=new', 'played');
	//update dynamic timer
	loadFragmentInToElement(3,'http://www.plr.org/player/createTimeout.html?view=recent&page=front', 'dynamicTimer');
	//update dynamic timer
	loadFragmentInToElement(4,'http://www.plr.org/player/playerData.html?buyFront=1', 'buy');

	//set the next time out for this function
	resetID = setTimeout("convertStartTimer()",12000);
}

function convertStartTimer()
{
	clearTimeout(resetID);
	
	//This is how soon the next song will start.  So we set our timer to wait until this time to do a refresh
	refreshRate = document.getElementById('dynamicTimer').innerHTML;
	
	if(refreshRate == "" || refreshRate < 5000)
	{
		var ran_number=Math.round(Math.random()*10);
		ran_number=(ran_number + 5) * 1000;
		refreshRate = 40000 + ran_number;					
	}

	playerRefreshID = setTimeout('playerDataRefresh()',refreshRate);
}

addLoadEvent(playerDataRefresh);

//function setForSmallScreen()
//created by daniel greeenlaw
//24 october 2005
//
//automatically does layout adjustment for visitors with smalller screens in an attempt to avoid scrollbar mayhem

function setForSmallScreen() {
	if (self.screen.availWidth<=800) {
		var c = document.getElementById('m_content');
		
		c.style.width = "550px";
		c.style.overflow = "visible";
		c.style.height = "auto";
		
		var e = document.getElementById('events');
		var mi = document.getElementById('m_icons');
		var mc = document.getElementById('m_contact');
		
		e.style.top = (508 + (c.scrollHeight - 425))+"px";
		mi.style.top = (508 + (c.scrollHeight - 425))+"px";
		mc.style.top = (508 + (c.scrollHeight - 425))+"px";
	}
}

addLoadEvent(setForSmallScreen);

//fetches height of window across browsers
function get_window_height() {
	var h;
	
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IEh
		h = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'h
		h = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatibleh
		h = document.body.clientHeight;
	  }
	  return h;
}

//checks height of content in #container and if it is less than
//height of browser window, resize so that background and/or footer will
//fill height of screen
function page_size_check() {
	var el = document.getElementById('fr_right_line').style.height = get_window_height() + "px";
}

addEvent(page_size_check, "onload");
addEvent(page_size_check, "onresize");