var pqVideoControl = {
	player : Array(),
	playerid : 0,
	addPlayer: function(contentId,file,width,height,dwidth,dheight) {
		
		if (!width || width<20) {
			width = 400;
		}
		if (!height || height<20) {
			height = 220;
		}
		if (!dwidth) {
			dwidth = width;
		}
		if (!dheight) {
			dheight = height - 200;
		}
		if (!document.getElementById(contentId)) {
			return false;
		}
		pqVideoControl.playerid++;		
		var so = new SWFObject('./static/mediaplayer.swf','pqVidCont_'+pqVideoControl.playerid,width,height,'8');
		so.addParam('allowscriptaccess','always');
		so.addParam('allowfullscreen','true');
		so.addVariable('width',width);
		so.addVariable('height',height);
		so.addVariable('displayheight',dheight);
		so.addVariable('displaywidth',dwidth);
		so.addVariable('file',file);
		so.addVariable('javascriptid','pqVidCont_'+pqVideoControl.playerid);
		so.addVariable('enablejs','true');
		so.addVariable('screencolor','0x000000');
		so.addVariable('autostart','false');
		so.addVariable('showicons','true');
		so.write(contentId);		
		pqVideoControl.player['pqVidCont_'+pqVideoControl.playerid] = Array();
		return 'pqVidCont_'+pqVideoControl.playerid;
	},
	addItem: function(playerId, file, thumb, data) {
		//var pos = pqVideoControl.getLength(playerid);
		// {file:'/upload/afraid.flv',image:'/upload/afraid.jpg',title:'Afraid of the dark?'}
		var myplayer =thisMovie(playerId);		
		myplayer.addItem({file:file, image: thumb, title:data.title});
	},
	getLength:function(playerId) {
		var len = thisMovie(playerId).getLength();
		return len;
	}
}
function getUpdate(typ,pr1,pr2,swf) {
	if (pqVideoControl.player[swf]) {
		pqVideoControl.player[swf][typ] = pr2;
	}
};
function thisMovie(swf) {
  if(navigator.appName.indexOf("Microsoft") != -1) {
    return window[swf];
  } else {
    return document[swf];
  }
};