
//-----------------------------[ window onload manager ]-----------------------------//
function womOn(){ window.onload = womGo; }
function womGo(){ for(var i = 0;i < woms.length;i++) eval(woms[i]); }
function womAdd(func){ woms[woms.length] = func; }
var woms = new Array();
womOn();
//-----------------------------[ /window onload manager ]-----------------------------//


//-----------------------------[ playlist and sample player ]-----------------------------//
var intPlayingSampleID = 0;

function playSample(songUrl,sampleID){
	if (sampleID == intPlayingSampleID){
		var picName = 'samplePic'+sampleID;
		document.getElementById(picName).src = '/images/icon_s3_play.gif';
		sendEvent('playpause');
		intPlayingSampleID = 0;
	}else{
		if (intPlayingSampleID != 0){
			var picName = 'samplePic'+intPlayingSampleID;
			document.getElementById(picName).src = '/images/icon_s3_play.gif';
		}
		var picName = 'samplePic'+sampleID;
		document.getElementById(picName).src = '/images/icon_s3_stop.gif';
		intPlayingSampleID = sampleID;
		loadFile({file:songUrl,title:'',link:'',id:'',image:''});
		sendEvent('playpause');
		prepSong(songUrl);
	}
}

function sampleStoped(){
	var picName = 'samplePic'+intPlayingSampleID;
	document.getElementById(picName).src = '/images/icon_s3_play.gif';
	intPlayingSampleID = 0;
}

function popPlaylist() {
	var WindowURL = "/player_flash.php";
	var WindowWidth = 500;
	var WindowHeight = 425;
	var WindowTop = (screen.availHeight/2) - (WindowHeight/2);
	var WindowLeft = (screen.availWidth/2) - (WindowWidth/2);
	var WindowProps = 'toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable,width='+WindowWidth+',height='+WindowHeight+',left='+WindowLeft+',top='+WindowTop+',screenx='+WindowLeft+',screeny='+WindowTop;
	poppedPlaylist = window.open(WindowURL,"poppedPlaylist",WindowProps);
	poppedPlaylist.focus();
	return;
}
//-----------------------------[ playlist and sample player ]-----------------------------//


//-----------------------------[ gTip ]-----------------------------//
var offsetxpoint=10 //Customize x offset of tooltip
var offsetypoint=15 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
var tipobj

function init_gTip(){ if (ie||ns6) tipobj=document.all? document.all["gTip"] : document.getElementById? document.getElementById("gTip") : "" }

function ietruebody(){ return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body }

function show_gTip(thetext, thecolor, thewidth){
	if (ns6||ie){
		if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
		if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
		tipobj.innerHTML=thetext
		enabletip=true
		return false
	}
}

function position_gTip(e){
	if (enabletip){
		var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
		var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
		var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20
		var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
		if (rightedge<tipobj.offsetWidth)
		tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
		else if (curX<leftedge)
		tipobj.style.left="5px"
		else
		tipobj.style.left=curX+offsetxpoint+"px"
		if (bottomedge<tipobj.offsetHeight)
		tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
		else
		tipobj.style.top=curY+offsetypoint+"px"
		tipobj.style.visibility="visible"
	}
}

function hide_gTip(){
	if (ns6||ie){
		enabletip=false
		tipobj.style.visibility="hidden"
		tipobj.style.left="-1000px"
		tipobj.style.backgroundColor=''
		tipobj.style.width=''
	}
}

document.onmousemove=position_gTip

womAdd('init_gTip()');
//-----------------------------[ /gTip ]-----------------------------//


function doSearch(frm){
	strUrl = '/browsebands/';
	strUrl += 'filterBandsIncludeString-'+frm.filterBandsIncludeString.value+'/';
	location.href = strUrl;
}

function rollPlay(state){
	document.getElementById('playlistButton').src = '/images/playlist_'+state+'.gif';
}

function uniqueString(){
	var theDate = new Date();
	return Date.UTC(theDate.getYear(),theDate.getMonth(),theDate.getDate(),theDate.getHours(),theDate.getMinutes(),theDate.getSeconds(), theDate.getMilliseconds());
}

function prepSong(songUrl){
	var dest = 'http://www.moshable.com/player_prep-song.php?s='+songUrl;
	try{ xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); }
	catch (e){}
	xmlhttp.open("GET", dest);
	xmlhttp.send(null);
}
