/* functions that are used in the rhapplayer and main site only */

/* debug function. guess what this does. */
function debug(message){
//	alert (message);
}

/* image rollovers. */
function rollyImageObj(theId,width,height,state){
	this.state = state;			
	this.theId = theId;
	this.height = height;
	this.width = width;			
	this.over= new Image(this.width,this.height);
	this.over.src = imagePath+this.theId+"_over.gif";
	this.off= new Image(this.width,this.height);
	this.off.src = imagePath+this.theId+"_off.gif";
	this.on = new Image(this.width,this.height);
	this.on.src = imagePath+this.theId+"_on.gif";
	this.disable= new Image(this.width,this.height);
	this.disable.src = imagePath+this.theId+"_disable.gif";
}	

/* other btns */
var btn_play = new rollyImageObj("btn_play",35,38,"off");
var btn_next = new rollyImageObj("btn_next",26,38,"off");
var btn_previous = new rollyImageObj("btn_previous",26,38,"off");
var btn_pause = new rollyImageObj("btn_pause",27,38,"off");
var btn_stop = new rollyImageObj("btn_stop",27,38,"off");
var btn_mute = new rollyImageObj("btn_mute",18,29,"off");
			
function getState(theId){
	theObj = eval(theId);
	return theObj.state;		
}

function changeState(theId,theState){
	theObj = eval(theId);
	checkState = theObj.state;
	theObj.state = theState;
	document.getElementById(theId).src=imagePath+theId+"_"+theState+".gif";
}
		
function toggleVidBtn(theId,state){
	theObj = eval(theId);
	theState = theObj.state;
	if(theState == "on" || theState == "disable"){
		return;
	}
	document.getElementById(theId).src=imagePath+theId+"_"+state+".gif";		
}




/* player controls */
function controlPlay(){
	if(playerObj.CanPlay()){
		playerObj.DoPlay();
		changeState("btn_play","on");
		changeState("btn_pause","off");
	}
}

function controlPause(){
	if(playerObj.CanPause()){
		playerObj.DoPause();
		changeState("btn_pause","on");
		changeState("btn_play","off");
	}else{
		playerObj.DoPlay();
		changeState("btn_play","on");
		changeState("btn_pause","off");
	}
}



function controlMute(){
	if(btn_mute.state == "off"){
		playerObj.SetMute(1);
		changeState("btn_mute","on");
	}else{
		playerObj.SetMute(0);
		changeState("btn_mute","off");
	}				
}
function setVolume(theVol){
	volLevel = (theVol*10);
	playerObj.SetVolume(volLevel);
	prevVol = volumeSetAt;
	volumeSetAt = theVol;
	volumeDisplay();
	if(theVol > 0){
		playerObj.SetMute(0);
		if(btn_mute.state == "on"){
			changeState("btn_mute","off")
		}
	}
}


var vol_over_color = "#2ca7e4";
var vol_off_color = "#797979";
var vol_on_color = "#008cd2";
var vol_disable_color = "#d7d7d7";
	
function redrawvolume(){
	volumeDisplay();
}

function toggleVol(theId,state,pos){
	for(i=pos;i>=1;i--){
		var theNewId = "vol_"+i;
		var thecolor = eval("vol_"+state+"_color");
		document.getElementById(theNewId).style.backgroundColor=thecolor;
	}		
}
	
var volIDPrefixes = new Array("vol_1","vol_2","vol_3","vol_4","vol_5","vol_6","vol_7","vol_8","vol_9","vol_10");
function volumeDisplay() {
	for(i=0;i<volIDPrefixes.length;i++){
		actualPos = i+1;
		if(playerObj.GetMute() == 1){
			document.getElementById(volIDPrefixes[i]).style.backgroundColor=vol_disable_color;
		}else{
			if(volIDPrefixes[i]){
				if(actualPos<=volumeSetAt){
					document.getElementById(volIDPrefixes[i]).style.backgroundColor=vol_on_color;					
				}else{
					document.getElementById(volIDPrefixes[i]).style.backgroundColor=vol_off_color;
				}
			}
		}
	}
}



/* other handy functions used lots of places */
function hideThis(someIds){
	for (var i=0; i<arguments.length;i++){
		document.getElementById(arguments[i]).style.display="none";
		document.getElementById(arguments[i]).style.visibility="hidden";
	}
}			
function showThis(theId){
	for (var i=0; i<arguments.length;i++){
		document.getElementById(arguments[i]).style.display="block";
		document.getElementById(arguments[i]).style.visibility="visible";
	}
}

function openWin(name,url,width,height){
	newwindow = window.open(url,name,"width="+width+",height="+height+",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0");
	newwindow.focus();
	return newwindow;
}



