var currentFile = ""; 
var currentItem = 0; 
var previousItem = -1; 

var player = null;
function playerReady(thePlayer) {
	player = window.document[thePlayer.id];
	addListeners();
}


function addListeners() {
	if (player) { 
		player.addControllerListener("ITEM", "itemListener"); 
	} else {
		setTimeout("addListeners()",100);
	}
}


function itemListener(obj) { 
	if (obj.index != currentItem) {
 		previousItem = currentItem;
		currentItem = obj.index;
	}
}

/* GET URL FROM META TAG */
function metaKeywords() {
metaCollection = document.getElementsByTagName('meta');
for (i=0;i<metaCollection.length;i++) {
nameAttribute = metaCollection[i].name.search(/home/);
if (nameAttribute!= -1) {
return (metaCollection[i].content);
}
}
} 
var loc = metaKeywords()
//alert(loc);


function createPlayer(theFile) {
   var flashvars = {
           file:theFile, 
           autostart:"false",
           playlistsize:"70",
           playlist:"bottom",
           skin: loc+'public/stylish_slim_c.swf',
           backcolor: "0B0B0B",
           lightcolor:"1e8af4",
           frontcolor:"666666",
           shuffle: "false",
           repeat: "always",
           volume: "10"
   }
   var params = {
           wmode:"transparent", 
           allowfullscreen:"true", 
           allowscriptaccess:"always"
   }

   var attributes = {
           id:"player1",  
           name:"player1"
   }
   swfobject.embedSWF(loc+'public/player.swf', "placeholder1", "100%", "100", "9.0.115", false, flashvars, params, attributes);
}

function createPlayerLarge(theFile) {
   var flashvars = {
           file:theFile, 
           autostart:"false",
           playlistsize:"130",
           playlist:"bottom",
           skin: loc+"public/stylish_slim_c.swf",
           backcolor: "141414",
           lightcolor:"1e8af4",
           frontcolor:"666666",
           shuffle: "true",
           repeat: "always",
   }
   var params = {
           wmode:"transparent", 
           allowfullscreen:"true", 
           allowscriptaccess:"always"
   }

   var attributes = {
           id:"player1",  
           name:"player1"
   }
   swfobject.embedSWF(loc+'public/player.swf', "placeholder1", "100%", "160", "9.0.115", false, flashvars, params, attributes);
}


var newwindow = null;

function popitout() {

	function itemListener(obj) { 
		if (obj.index != currentItem) {
	 		previousItem = currentItem;
			currentItem = obj.index;
		}
	};
	
	if (player) { 
			player.sendEvent("STOP"); 
			player = null;
		}	

	var uRL = '/downtownrecords/public/popoutplayer.html?'+currentItem;
		
	newwindow = window.open(uRL,'name','height=400,width=500,left=100,top=200,resizable=yes');
	newwindow.focus();	
	
	}

