// PLAYLIST -->
var playlistPopup = null;
var playlistPopupQ = [];
var WINDOW_CREATE_COMPLETE = "WINDOW_CREATE_COMPLETE";
var CHILD_READY = "CHILD_READY";
var ADD_SONG = "ADD_SONG";
function addToPlaylist(playlistId, playlistTitle, playlistArtist, playlistPath) {
	var windowOptions = "width=302,height=530,status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0";
	var windowTitle = "Playlist";
	var windowUrl = "playlist.php";
	playlistPopup = open("", windowTitle, windowOptions);
	if(!playlistPopup || playlistPopup.closed || !playlistPopup.ready) {
		// open popup and when it is ready pass the song
		playlistPopupQ.push([ADD_SONG, playlistId, playlistTitle, playlistArtist, playlistPath]);
		playlistPopup = window.open(windowUrl, windowTitle, windowOptions);
	} else {
		playlistPopup.popupInterface(ADD_SONG, [playlistId, playlistTitle, playlistArtist, playlistPath]);
	}
	playlistPopup.focus();
}
function showMyPlaylist() {
	var windowOptions = "width=302,height=530,status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0";
	var windowTitle = "Playlist";
	var windowUrl = "playlist.php";
	playlistPopup = open("", windowTitle, windowOptions);
	if(!playlistPopup || playlistPopup.closed || !playlistPopup.ready) {
		playlistPopup = window.open(windowUrl, windowTitle, windowOptions);
	}
	playlistPopup.focus();
}
function popupInterface(command, params) {
	// command string, params array
	// should never be called in this site context
//	alert("BANDS: popup interface:: " + command + " " + params ? params.length : "");
	switch(command) {
		case CHILD_READY:
//			alert("CHILD READY");
			while(playlistPopupQ.length > 0) {
				var itemQ = playlistPopupQ.shift();
				var commandQ = itemQ.shift();
				playlistPopup.popupInterface(commandQ, itemQ);
			}
			break;
	}
}
// <-- PLAYLIST








// SEARCH -->
function headerGetSearchTerm() {
	var val = $.trim($("#headerSearchInput").val());
	return val == "Search" ? "" : val;
}
function headerSearchAll() {
	var term = headerGetSearchTerm();
//	if(!checkIfEmpty || term != "") {
		window.location = "searchall.php?q=" + term;
//	}else{
//		$("#headerSearchInput").focus();
//		$('#search_container').show();
//	}
}
function headerSearchBands() {
	var term = headerGetSearchTerm();
//	if(!checkIfEmpty || term != "") {
		window.location = "searchbands.php?q=" + term;
//	}else{
//		$("#headerSearchInput").focus();
//	}
}
function headerSearchCreatives() {
	var term = headerGetSearchTerm();
//	if(!checkIfEmpty || term != "") {
		window.location = "searchcreatives.php?q=" + term;
//	}else{
//		$("#headerSearchInput").focus();
//	}
}
// <-- SEARCH






