document.write('<link href="/today/css/script.css" rel="stylesheet" type="text/css" />');

var myimages=new Array()
function preloadImages(){
	for (i=0;i<preloadImages.arguments.length;i++){
	myimages[i]=new Image();
	myimages[i].src=preloadImages.arguments[i];
	}
}

function changeTab(newTab) {
	document.getElementById('tab_'+lastTab).setAttribute('class','tab');
	document.getElementById('tab_'+lastTab).setAttribute('className','tab');
	document.getElementById('stories_'+lastTab).style.display='none';
	document.getElementById('tab_'+newTab).setAttribute('class','tab active');
	document.getElementById('tab_'+newTab).setAttribute('className','tab active');
	document.getElementById('stories_'+newTab).style.display='block';
	lastTab=newTab;
	return false;
}

var lastEvents='today';
function changeEvents(newEvents) {
	document.getElementById('link_'+lastEvents).setAttribute('class','null');
	document.getElementById('link_'+lastEvents).setAttribute('className','null');
	document.getElementById('events_'+lastEvents).style.display='none';
	document.getElementById('link_'+newEvents).setAttribute('class','wh');
	document.getElementById('link_'+newEvents).setAttribute('className','wh');
	document.getElementById('events_'+newEvents).style.display='block';
	lastEvents=newEvents;
	return false;
}

var timer=new Array(),showing;
function toggleDropdown(dropdown) {
	var last = showing;
	if(showing) hideDropdown(showing);
	if(last!=dropdown) showDropdown(dropdown);
}

function showDropdown(dropdown) {
	document.getElementById('dropdown_'+dropdown).style.left=(document.getElementById('arrow_'+dropdown).offsetLeft-5)+'px';
	document.getElementById('dropdown_'+dropdown).style.display = 'block';
	document.getElementById('arrow_'+dropdown).src = '/today/images/linkbar_arrow_open.gif';
	showing=dropdown;
}

function hideDropdown(dropdown) {
	document.getElementById('dropdown_'+dropdown).style.display = 'none';
	document.getElementById('arrow_'+dropdown).src = '/today/images/linkbar_arrow_closed.gif';
	showing=0;
}

function timeoutDropdown(dropdown,parent,e) {
	var relTarget = e.relatedTarget||e.toElement;
    if(relTarget.parentNode==parent||relTarget.parentNode.parent==parent) return;
	else timer = setTimeout('hideDropdown(\''+dropdown+'\')',500);
}

function answerPoll() {
	var pollOptions = new Array(), i=1,queryString='';
	while(thisOption = document.getElementById('poll_option'+i)) {
		if(thisOption.checked) pollOptions.push(i);
		i++;
	} 
	if(pollOptions.join().length) queryString+='id='+pollOptions.join()+'&';
	if(document.getElementById('poll_comments')!=null&&document.getElementById('poll_comments').value.length>1) queryString=queryString+'comments='+escape(document.getElementById('poll_comments').value);
	showPollResults(queryString);
}

function showPollResults(queryString) {
	document.getElementById('pollarea').style.height = (document.getElementById('pollarea').offsetHeight-20) + 'px';
	ajaxSet('poll_results.php?'+queryString,'poll');
}

function cancelTimer(dropdown) { window.clearTimeout(timer); }

function select_links(links) {
for (i=0;i<links.length;i++) document.getElementById('link_'+links[i]).checked=true;
};