//////////////////////////////////////////////////////////////////////////////	
//updateDiv
//
//Desc: Calls a special version of updateContentArea just for use with
//run.php
//////////////////////////////////////////////////////////////////////////////

var paused=false;

function updateDiv(divName,funct_name,param1,param2,param3,param4, callBack){
	vars = "function_name="+funct_name+"&param[1]="+param1+"&param[2]="+param2+"&param[3]="+param3+"&param[4]="+param4;	
	if(callBack){
		updateContentArea(divName,vars,'php/run.php', callBack);
	}else{
		updateContentArea(divName,vars,'php/run.php');	
	}	
}//end function
	
	
function emailFriend(URL){
	TA_showBox('email_box', '200', 'function_name=emailFriendBox&Url='+URL, '../php/run.php', 1, 0);
}


function nextStory(force){
	if(paused==false || force==true){
		clearTimeout(timer);
		$("#innerRotator").fadeOut(500, function () {
			nextStoryGo();
		});
		paused=false;
	}else{
		timer = setTimeout('nextStory()', 6000);
	}	
}

function nextStoryGo(){
	if(document.getElementById('currentID')){
		var ID = document.getElementById('currentID').value;
		updateDiv('innerRotator', 'getFrontRotatorStory', ID, 'next', '', '', 'showStory()');
		clearTimeout(timer);
		timer = setTimeout('nextStory()', 6000);
		//showStory();
	}	
}

function prevStory(){
	clearTimeout(timer);
	$("#innerRotator").fadeOut(500, function () {
		prevStoryGo();
	});						
}

function prevStoryGo(){
	if(document.getElementById('currentID')){	
		var ID = document.getElementById('currentID').value;
		updateDiv('innerRotator', 'getFrontRotatorStory', ID, 'prev');
		clearTimeout(timer);
		timer = setTimeout('nextStory()', 6000);
		showStory();
	}
}

function pauseRotator(){
	clearTimeout(timer);
	paused=true;
}

function unpauseRotator(){
	paused=false;
	timer = setTimeout('nextStory()', 1000);
}

function showStory(){
	$("#innerRotator").fadeIn(500);
}

function changeMost(element){

	var newEl = document.getElementById(element);
	var element2 = element+"_box";
	var newEl2 = document.getElementById(element2);
	
	document.getElementById('most_read').className = '';
	document.getElementById('most_emailed').className = '';
	document.getElementById('most_comments').className = '';
	
	document.getElementById('most_read_box').style.display = 'none';
	document.getElementById('most_emailed_box').style.display = 'none';
	document.getElementById('most_comments_box').style.display = 'none';
	
	newEl.className = "on";
	newEl2.style.display = "block";
}


function changeLatest(element){

	var newEl = document.getElementById(element);
	var element2 = element+"_tab";
	var newEl2 = document.getElementById(element2);
	
	document.getElementById('latestPhotos').className = '';
	document.getElementById('latestVideos').className = '';
	
	document.getElementById('latestPhotos_tab').style.display = 'none';
	document.getElementById('latestVideos_tab').style.display = 'none';
	
	newEl.className = "on";
	newEl2.style.display = "block";
}