if (typeof swfobject == 'undefined')
	/**
	 * SWFObject v2.2 <http://code.google.com/p/swfobject/> 
	 * is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
	 *
	 */
	var swfobject = function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();


if (typeof hsPlayer == 'undefined')
	/**
	 * hsPlayer Javascript Controller Object
	 *
	 * @author Rodrigo Moraes Orph <rodrigo.orph@gmail.com>
	 * 
	 *
	 * Main player loader/configurator/handler object
	 * This is intended to do all flash <-> javascript interations, also mandatory
	 * for embed controllers.
	 *
	 * This script should work for the site AND embeds at same time, it works
	 * with cross domain requests via jsonp. jQuery is automatically loaded and
	 * all required libs as well. This should work as standalone automatically
	 * detecting the existing env and causing minor, if none, intrusion on the
	 * code it's embedded to.
	 *
	 * Related to #8820
	 * 
	 * - Rodrigo
	 */
	var hsPlayer = {
		_proto: "http" + ("https:" == document.location.protocol ? "s" : "") + "://",
		_base_url: "www.hulkshare.com/",
		_static_url: "www.hulkshare.com/static/hsPlayer/",
		_player_uri: { // possible player types
			regular: "swf/mp3Player_v1.11.11.25.swf",
			light: "swf/mp3Light_v1.12.02.02.swf"
		},
		_player_type: "light", // player type to be used on this.play() call
		
		_init: false, 			// object initialization flag
		_bridge: false,			// login bridge flag
		_debug: false,				// debug switch
		_flash: false,			// flash load switch
		_params: {},				// player params
		_sT: [],						// private loading timeouts
		_ids: [],						// current player loaded ids
		_extra: false,			// extra libs loaded (jQuery)
		_cid: null,					// current CID, for callbacks
		_lai: -1,						// current last auto loader index
		_user: null,				// user info object
		
		// flash vars defaults -- values must be a string
		_autoload: "0",			// auto buffer
		_autostart: "0",		// auto start playback
		_isComment: "1",		// show comments
		
		
		// used for Add to MyMusic login propmpt
		_callbackFunction: null,
		_callbackFunctionParams: null,
		
		/**
		 * Object constructor
		 *
		 * @opt param user json object with login info to be stored on this
		 *
		 */
		init: function(user) {
			if (typeof user != 'undefined')
				this._user = user;
			
			if (this._init === true) {
				this.checkVars();
				return false;
			}
			
			var $this = this;
			this._init = true;
			
			// IE Fix
			if (!Array.prototype.indexOf) {
				Array.prototype.indexOf = function(elt /*, from*/)
				{
					var len = this.length;
					var from = Number(arguments[1]) || 0;
					from = from < 0 ? Math.ceil(from) : Math.floor(from);
					if (from < 0)
						from += len;
					
					for (; from < len; from++)
						if (from in this && this[from] === elt)
							return from;
					
					return -1;
				};
			}
			
			// setup hsPlayer paths
			this._base_url = this._proto + this._base_url;
			this._static_url = this._proto + this._static_url;
			
			// default config params
			this._params = {
				loop: false,
				quality: "best",
				bgcolor: "#ffffff",
				allowfullscreen: true,
				wmode: "transparent",
				allowNetworking: "all",
				allowScriptAccess: "always"
			};
			
			if (typeof addthis == 'undefined')
				this.asLoad(
					this._proto + "s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4ea5329c3ceb2646",
					"js"
				);
			
			if (typeof jQuery == 'undefined') // load jquery
				this.asLoad(
					this._proto + "ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js",
					"js",
					function(){ 
						$this.loadAssets();
					});
			else	
				this.loadAssets();
			
			// check now to load existing _hsPlayer array
			this.checkVars();
			
			// check again on window load, in case js is spread around
			window.onload = (function(){$this.checkVars();});
			
			return true;
		},
		
		/**
		 * Via the AddThis API we configure our instance.
		 *
		 * @source http://www.addthis.com/help/client-api#util-js
		 *
		 */
		bindAddThis: function(params){
			addthis.toolbox(
				"#HStoolBox", 															// fixed container
				{}, 																				// configuration object - https://www.addthis.com/help/client-api#configuration-ui
				typeof params == 'undefined' ? {} : params 	// sharing configuration object - https://www.addthis.com/help/client-api#configuration-sharing
			);
		},
		
		/**
		 * Auto loader script
		 * 
		 * Once init is complete we're ready to start embedding players
		 * this method will read the auto init file and call this.play
		 * accordinly; Note that this might be triggered multiple times
		 * that's why we save the index to avoid double initializing it.
		 * 
		 * _hsPlayer variable scheme
		 *
		 * 0 => type (id, aid, fid, lid)
		 * 1 => id (number or string)
		 * 2 => container name (optional) -- defaults to #hsPlayer, if none exists it will be created
		 * 3 => size array (optional) -- falls back to defaults if not defined
		 *
		 * _hsSettings variable scheme
		 * 
		 * Must be an JSON object with the config values that you want to override
		 * on hsPlayer root.
		 * 
		 */
		checkVars: function(){
			/**
			 * Manipulate config settings
			 *
			 */
			if (typeof _hsSettings != 'undefined')
				for (var k in _hsSettings)
					if (_hsSettings.hasOwnProperty(k))
						this[k] = _hsSettings[k];
			
			if (typeof _hsPlayer != 'undefined') {
				var $this = this,
						j = _hsPlayer.length,
						i, v;
				
				for (i = 0;i < j;i++) {
					if (i > $this._lai) {
						$this._lai = i;
						v = _hsPlayer[i];
						
						if (typeof v[1] == 'undefined')
							return;
						
						var type = 0;
						
						switch (v[0].toLowerCase()) {
							case "aid": // album
							case "fid": // folder
								type = 1;
								break;
							
							case "lid": // list of tracks
								type = 3;
								break;
							
							/**
							 * Add other types as we need
							 *
							 * ...
							 */
						}
						
						// trigger the player
						$this.play(
							v[1],
							typeof v[2] != 'undefined' ? v[2] : undefined,
							type,
							typeof v[3] != 'undefined' ? v[3] : undefined
						);
					}
				}
			}
		},
		
		/**
		 * Asyncronous asset loader
		 * 
		 * @param url string
		 * @opt param ty string js | css
		 *
		 */
		asLoad: function(url, ty, callback){
			if (typeof ty == 'undefined')
				ty = "js";
			
			switch (ty) {
				case "js":
					var j = document.createElement('script');
					with (j) {
						type = 'text/javascript';
						async = true;
						src = url;
					}
					break;
				
				case "css":
					var j = document.createElement('link');
					with (j) {
						type = 'text/css';
						rel = "stylesheet";
						async = true;
						href = url;
					}
					break;
			}
			
			// callback handler -- http://blog.logiclabz.com/javascript/dynamically-loading-javascript-file-with-callback-event-handlers.aspx
			if (typeof callback != 'undefined') {
				var l = function(){
					if (this.readyState == 'complete' || this.readyState == 'loaded')
						callback();
				};
				
				j.onreadystatechange = l;
				j.onload = callback;
			}
			
			var s = document.getElementsByTagName("script")[0];
			s.parentNode.insertBefore(j, s);
		},
		
		/**
		 * Trigger HTML assets loader
		 * this will use a jsonp function to fetch data from
		 * remote domain, callback for this function is addAsset which
		 * can only be configured on the source.
		 * 
		 */
		loadAssets: function(){
			if (typeof jQuery == 'undefined') { // jquery not loaded, delay execution
				var $this = this;
				this._sT.push(setTimeout(function(){
					$this.loadAssets();
				}, 50));
				
				return false;
			}
			
			if (this._extra) // already loaded man
				return true;
			
			// from here jQuery is loaded, init jQuery dependent objects
			
			/*!
			 * jQuery Tools v1.2.6 - The missing UI library for the Web
			 * 
			 * overlay/overlay.js
			 * toolbox/toolbox.expose.js
			 * 
			 * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
			 * 
			 * http://flowplayer.org/tools/
			 * 
			 */
			if (typeof jQuery.tools == 'undefined' || typeof jQuery.tools.overlay == 'undefined')
				(function(a){a.tools=a.tools||{version:"v1.2.6"},a.tools.overlay={addEffect:function(a,b,d){c[a]=[b,d]},conf:{close:null,closeOnClick:!0,closeOnEsc:!0,closeSpeed:"fast",effect:"default",fixed:!a.browser.msie||a.browser.version>6,left:"center",load:!1,mask:null,oneInstance:!0,speed:"normal",target:null,top:"10%"}};var b=[],c={};a.tools.overlay.addEffect("default",function(b,c){var d=this.getConf(),e=a(window);d.fixed||(b.top+=e.scrollTop(),b.left+=e.scrollLeft()),b.position=d.fixed?"fixed":"absolute",this.getOverlay().css(b).fadeIn(d.speed,c)},function(a){this.getOverlay().fadeOut(this.getConf().closeSpeed,a)});function d(d,e){var f=this,g=d.add(f),h=a(window),i,j,k,l=a.tools.expose&&(e.mask||e.expose),m=Math.random().toString().slice(10);l&&(typeof l=="string"&&(l={color:l}),l.closeOnClick=l.closeOnEsc=!1);var n=e.target||d.attr("rel");j=n?a(n):null||d;if(!j.length)throw"Could not find Overlay: "+n;d&&d.index(j)==-1&&d.click(function(a){f.load(a);return a.preventDefault()}),a.extend(f,{load:function(d){if(f.isOpened())return f;var i=c[e.effect];if(!i)throw"Overlay: cannot find effect : \""+e.effect+"\"";e.oneInstance&&a.each(b,function(){this.close(d)}),d=d||a.Event(),d.type="onBeforeLoad",g.trigger(d);if(d.isDefaultPrevented())return f;k=!0,l&&a(j).expose(l);var n=e.top,o=e.left,p=j.outerWidth({margin:!0}),q=j.outerHeight({margin:!0});typeof n=="string"&&(n=n=="center"?Math.max((h.height()-q)/2,0):parseInt(n,10)/100*h.height()),o=="center"&&(o=Math.max((h.width()-p)/2,0)),i[0].call(f,{top:n,left:o},function(){k&&(d.type="onLoad",g.trigger(d))}),l&&e.closeOnClick&&a.mask.getMask().one("click",f.close),e.closeOnClick&&a(document).bind("click."+m,function(b){a(b.target).parents(j).length||f.close(b)}),e.closeOnEsc&&a(document).bind("keydown."+m,function(a){a.keyCode==27&&f.close(a)});return f},close:function(b){if(!f.isOpened())return f;b=b||a.Event(),b.type="onBeforeClose",g.trigger(b);if(!b.isDefaultPrevented()){k=!1,c[e.effect][1].call(f,function(){b.type="onClose",g.trigger(b)}),a(document).unbind("click."+m).unbind("keydown."+m),l&&a.mask.close();return f}},getOverlay:function(){return j},getTrigger:function(){return d},getClosers:function(){return i},isOpened:function(){return k},getConf:function(){return e}}),a.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","),function(b,c){a.isFunction(e[c])&&a(f).bind(c,e[c]),f[c]=function(b){b&&a(f).bind(c,b);return f}}),i=j.find(e.close||".close"),!i.length&&!e.close&&(i=a("<a class=\"close\"></a>"),j.prepend(i)),i.click(function(a){f.close(a)}),e.load&&f.load()}a.fn.overlay=function(c){var e=this.data("overlay");if(e)return e;a.isFunction(c)&&(c={onBeforeLoad:c}),c=a.extend(!0,{},a.tools.overlay.conf,c),this.each(function(){e=new d(a(this),c),b.push(e),a(this).data("overlay",e)});return c.api?e:this}})(jQuery);
			if (typeof jQuery.tools.expose == 'undefined')
				(function(a){a.tools=a.tools||{version:"v1.2.6"};var b;b=a.tools.expose={conf:{maskId:"exposeMask",loadSpeed:"slow",closeSpeed:"fast",closeOnClick:!0,closeOnEsc:!0,zIndex:9998,opacity:.8,startOpacity:0,color:"#fff",onLoad:null,onClose:null}};function c(){if(a.browser.msie){var b=a(document).height(),c=a(window).height();return[window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,b-c<20?c:b]}return[a(document).width(),a(document).height()]}function d(b){if(b)return b.call(a.mask)}var e,f,g,h,i;a.mask={load:function(j,k){if(g)return this;typeof j=="string"&&(j={color:j}),j=j||h,h=j=a.extend(a.extend({},b.conf),j),e=a("#"+j.maskId),e.length||(e=a("<div/>").attr("id",j.maskId),a("body").append(e));var l=c();e.css({position:"absolute",top:0,left:0,width:l[0],height:l[1],display:"none",opacity:j.startOpacity,zIndex:j.zIndex}),j.color&&e.css("backgroundColor",j.color);if(d(j.onBeforeLoad)===!1)return this;j.closeOnEsc&&a(document).bind("keydown.mask",function(b){b.keyCode==27&&a.mask.close(b)}),j.closeOnClick&&e.bind("click.mask",function(b){a.mask.close(b)}),a(window).bind("resize.mask",function(){a.mask.fit()}),k&&k.length&&(i=k.eq(0).css("zIndex"),a.each(k,function(){var b=a(this);/relative|absolute|fixed/i.test(b.css("position"))||b.css("position","relative")}),f=k.css({zIndex:Math.max(j.zIndex+1,i=="auto"?0:i)})),e.css({display:"block"}).fadeTo(j.loadSpeed,j.opacity,function(){a.mask.fit(),d(j.onLoad),g="full"}),g=!0;return this},close:function(){if(g){if(d(h.onBeforeClose)===!1)return this;e.fadeOut(h.closeSpeed,function(){d(h.onClose),f&&f.css({zIndex:i}),g=!1}),a(document).unbind("keydown.mask"),e.unbind("click.mask"),a(window).unbind("resize.mask")}return this},fit:function(){if(g){var a=c();e.css({width:a[0],height:a[1]})}},getMask:function(){return e},isLoaded:function(a){return a?g=="full":g},getConf:function(){return h},getExposed:function(){return f}},a.fn.mask=function(b){a.mask.load(b);return this},a.fn.expose=function(b){a.mask.load(b,this);return this}})(jQuery);
			
			this._extra = true;
			
			// load control boxes from server and check if user is logged in
			$.ajax({
				url: this._static_url + "hsPlayer.php",
				dataType: "jsonp",
				async: true,
				cache: true
			});
			
			return true;
		},
		
		/**
		 * Adds extra asset to the body
		 * this.loadAssets callback function
		 *
		 * @param obj DOM object
		 *
		 */
		addAsset: function(obj) {
			$("body").prepend(obj.content);
			
			if (typeof obj.user != 'undefined') {
				this._user = obj.user;
				if (this._flash) {
					this._bridge = true; // no need to bridge the login
					this.doLogin();
				}
			}
			
			this.bindExtra();
		},
		
		/**
		 * Loads fancy div transactions
		 *
		 */
		bindExtra: function(){
			if (!this._extra) {
				var $this = this;
				this._sT.push(setTimeout(function(){
					$this.bindExtra();
				}, 50));
				
				return false;
			}
			
			$.each(["HSaddThis", "HSembed", "HSregister", "HSmsg", "HSplaylist"], function(i, v) {
				$("#" + v).overlay({
					mask: {
						color: '#000',
						loadSpeed: $.browser.msie ? 0 : 200,
						closeSpeed: $.browser.msie ? 0 : 200,
						opacity: 0.5
					},
					speed: $.browser.msie ? 0 : 200,
					top: '25%',
					fixed: !$.browser.msie
				});
			});
			
			
			$("#HSlogin").overlay({
					mask: {
						color: '#000',
						loadSpeed: $.browser.msie ? 0 : 200,
						closeSpeed: $.browser.msie ? 0 : 200,
						opacity: 0.5
					},
					closeOnClick: false,
					speed: $.browser.msie ? 0 : 200,
					top: '25%',
					fixed: !$.browser.msie
				});
			
		},
		
		/**
		 * Generic Flash -> Javascript handler
		 * 
		 * @param func string function to be triggered
		 * @param cid int player cid (sent via XML)
		 * @opt param extra mixed extra params go here
		 *
		 */
		handler: function(func, cid, extra) {
			var $this = this;
			
			if (typeof cid == 'undefined' || typeof this._ids[cid] == 'undefined')
				return false;
			
			this._cid = cid;
			
			switch (func) {
				case "addThis":
					var sURL = this._base_url + document.getElementById($this._ids[cid]).file_code();
					
					$("#HSaddThis").overlay().load();
					$("#HSgtlInp").val(sURL);
					
					this.bindAddThis({
						url: sURL,
						title: document.getElementById($this._ids[cid]).file_title()
					});
					
					break;
				
				case "loginBox":
					if ($("#HSregister").overlay().isOpened()) {
						$("#HSregister").overlay().close();
						
						// delay this until the transition is done
						setTimeout(function(){
							$("#HSlogin").overlay().load();
						}, 500);
					} else {
						$("#HSlogin").overlay().load();
					}
					break;
				
				case "regBox":
					if ($("#HSlogin").overlay().isOpened()) {
						$("#HSlogin").overlay().close();
						
						// delay this until the transition is done
						setTimeout(function(){
							$("#HSregister").overlay().load();
						}, 500);
					} else {
						$("#HSregister").overlay().load();
					}
					break;
				
				case "embed":
					if (typeof extra == 'undefined')
						return false;
					
					$("#HSembedCode").val(extra);
					$("#HScopied").hide();
					$("#HSembed").overlay().load();
					break;
				
				case "updateVolume":
					// do nothing, bitch slap!
					break;
			}
			
			return true;
		},
		
		/**
		 * Opens signup window
		 *
		 */
		signup: function(){
			this.handler('regBox', 0);
			return false;
		},
		
		submitLogin: function(){
			// check if both fields are valid
			var login = $.trim($("#HSusername").val()),
					pass  = $.trim($("#HSpassword").val());
			
			if (login == "" || pass == "")
				alert("Please fill your login and password");
			else
				$.ajax({
					url: this._base_url + "ajax/login.php",
					data: "username=" + login + "&password=" + pass,
					type: "POST",
					dataType: "jsonp",
					async: true,
					cache: false,
					beforeSend: function(){
						$("#HSloginBT").hide();
						$("#HSloginLD").show();
						$("#HSusername").val("");
						$("#HSpassword").val("");
					},
					complete: function(){
						$("#HSloginBT").show();
						$("#HSloginLD").hide();
					}
				});
			
			return false;
		},
		
		/**
		 * A port from the original by Javier PBL
		 * This is a callback from submitLogin jsonP
		 * 
		 */
		checkLogin: function(response) {
			if (typeof response != 'undefined') {
				if(response.result == 'success') {
					$("#HSlogin").overlay().close();
					this._user = {
						userID: response.fields.userID,
						userName: response.fields.userName,
						userAvatar: response.fields.userAvatar,
						userPassword: response.fields.userPassword
					};
					
					// playlist handlers
					this.playlist._pid = response.fields.pid;
					this.playlist.handler(0, "load", this.playlist._pid);
					
					this.doLogin();
					
					
					
					if (this._callbackFunction == 'toMyMusic') {
						this.toMyMusic(this._callbackFunctionParams);
						this._callbackFunction = null;
						this._callbackFunctionParams = null;
					}
					
				} else {
					if (response.error) {
						var errMsg = '';
						$.each(response.error, function(index, value) {
							errMsg += '- ' + value + '\n';
						});
						errMsg += '\nPlease try again.';
						
						alert(errMsg);
					}
				}
			} else {
				alert('Unexpected error, please try again.');
			}
		},
		
		/**
		 * we send the registration info to the server
		 * 
		 */
		submitReg: function(){
			// check if both fields are valid
			var login = $.trim($("#HSregusername").val()),
					pass  = $.trim($("#HSregpassword").val()),
					email  = $.trim($("#HSregemail").val());
					
			if (login == "" || pass == "" || email == "")
				alert("Please fill your login, password and email");
			else if (pass != $.trim($("#HSregpassword_confirm").val()))
				alert("Password confirmation don't match");
			else
				$.ajax({
					url: this._base_url + "ajax/res.php",
					data: "username=" + login + "&password=" + pass + "&email=" + email,
					type: "POST",
					dataType: "jsonp",
					async: true,
					cache: false,
					beforeSend: function(){
						$("#HSregBT").hide();
						$("#HSregLD").show();
						$("#HSRegusername").val("");
						$("#HSRegpassword").val("");
						$("#HSRegpassword_confirm").val("");
						$("#HSRegemail").val("");
					},
					complete: function(){
						$("#HSregBT").show();
						$("#HSregLD").hide();
					}
				});
			
			return false;
		},
		
		/**
		 * we check the registratio process has worked ok
		 * This is a callback from submitReg jsonP
		 * 
		 */
		checkReg: function(response) {
			if (typeof response != 'undefined') {
				if(response.result == 'success') {
					$("#HSregister").overlay().close();
					this._user = {
						userID: response.fields.userID,
						userName: response.fields.userName,
						userAvatar: response.fields.userAvatar,
						userPassword: response.fields.userPassword
					};
					
					this.msg(
						"Welcome to HULKSHARE, " + this._user.userName + "!",
						"Your registration has been completed, you can post comments and files now! For more info visit our site, <a href='http://hulkshare.com/' target='_blank'>http://hulkshare.com</a>.",
						500
					);
					
					this.doLogin();
				} else {
					if (response.error) {
						var errMsg = '';
						$.each(response.error, function(index, value) {
							errMsg += '- ' + value + '\n';
						});
						errMsg += '\nPlease try again.';
						
						alert(errMsg);
					}
				}
			} else {
				alert('Unexpected error, please try again.');
			}
		},
		
		/**
		 * Make player aware of the user info
		 *
		 */
		doLogin: function (id) {
			var $this = this;
			
			/**
			 * Creates a cookie bridge between hulkshare and where this script is
			 * embeded, works with the same domain and cross domain. This allow us to
			 * set cookies to the user with hulkshare domain without recurring to
			 * javascript schemes.
			 *
			 */
			if (!this._bridge) {
				this._bridge = true;
				
				var i = document.createElement("IFRAME");
				
				i.setAttribute("src", this._base_url + "ajax/bridge.php?uid=" + this._user.userID + "&pass=" + this._user.userPassword);
				with (i.style) {
					width = "1px";
					height = "1px";
					position = "absolute";
					left = "-9999px";
					top = "-9999px";
				}
				
				document.body.appendChild(i);
			}
			
			// load a single id
			if (typeof id != 'undefined') {
				/**
				 * Flash object haven't been loaded yet
				 * 
				 */
				if (typeof document.getElementById(id).login == 'undefined') {
					setTimeout(function(){
						$this.doLogin(id);
					}, 100);
					
					return;
				}
				
				document.getElementById(id).login(
					$this._user.userID,
					$this._user.userName,
					$this._user.userAvatar
				);
				
				return;
			}
			
			// loop throught all ids
			$.each(this._ids, function(i, v) {
				/**
				 * Flash object haven't been loaded yet
				 * 
				 */
				if (typeof document.getElementById(v).login == 'undefined') {
					setTimeout(function(){
						$this.doLogin(v);
					}, 100);
					
					return;
				}
				
				document.getElementById(v).login(
					$this._user.userID,
					$this._user.userName,
					$this._user.userAvatar
				);
			});
		},
		
		/**
		 * Adds song to my music collection
		 *
		 * @param file_code str file code
		 */
		toMyMusic: function(file_code) {
			if (this._user == null) {
				this._callbackFunction = 'toMyMusic';
				this._callbackFunctionParams = file_code;
				this.handler('loginBox','0');
			} else {
			
			$.ajax({
				url: hsPlayer._base_url + "ajax/link_file.php",
				data: "file_code=" + file_code + "&jsonp=1",
				type: "GET",
				dataType: "jsonp",
				async: true,
				cache: true
			});
			
			}
			return false;
		},
		
		/**
		 * Sends data to clipboard, there's no javascript solution
		 * for this, so the player will handle it.
		 *
		 */
		toClipboard: function(id) {
			//$("#" + this._ids[this._cid]).copyToClipboard($("#" + id).val());
			$("#HScopied").show();
			
			return false;
		},
		
		/**
		 * Adds a new player
		 *
		 * @param id mixed id to be sent to the player
		 * @opt param container string container to have player added, default hsPlay
		 * @opt param type string type of player aid , pid, fid, id etc
		 * @opt param size array pair of numbers defining width and height
		 * @opt param swf string swf file to use for the player, fallback for config defaults
		 * 
		 * @return bool
		 */
		play: function(id, container, type, size, swf) {
			var $this = this;
			
			if (typeof swfobject == 'undefined') { // swfobject isn't ready yet, delay player execution
				this._sT.push(setTimeout(function(){
					$this.play(id, container, type, size, swf);
				}, 50));
				
				return false;
			}
			
			if (typeof id == 'undefined')
				return false;
			
			if (typeof type == 'undefined')
				type = 0;
			
			if (typeof container == 'undefined')
				container = "hsPlay";
			
			if (document.getElementById(container) == null) // invalid object
				return false;
			
			var version = swfobject.getFlashPlayerVersion();
			
			if (version.major == 0) { // there's no flash on this user
				$("#" + container).html('<iframe id="hulkshare-player-embed" name="hulkshare-player-embed" src="' + this._base_url + 'playa/?file_id=' + id + '" scrolling="no" frameborder="0" allowTransparency="true" style="width:650px;height:50px;"></iframe>');
				return true;
			}
			
			if (typeof size == 'undefined' || typeof size[1] == 'undefined')
				size = [900, this._player_type == "light" ? 100 : 197];
			
			if (typeof swf == 'undefined')
				swf = this._static_url + this._player_uri[this._player_type];
			
			if (this._ids.indexOf(container) == -1)
				this._ids.push(container);
			
			var cid = this._ids.indexOf(container);
			switch (parseInt(type)) {
				case 0: // single
					var fv = {
						isComment: this._isComment,
						autoload: this._autoload,
						autostart: this._autostart,
						config: this._base_url + "mp3PlayerScripts/flConfig.php?eid%3D" + cid + "%26player%3D" + this._player_type + "%26embed%3D1%26share%3D1%26id%3D" + id + (this._debug ? "%26cb%3D" + Math.random() : ""),
						comment: this._base_url + "mp3PlayerScripts/comment.php"
					};
					break;
				
				case 1: // playlist
					var fv = {
						isComment: this._isComment,
						autoload: this._autoload,
						autostart: this._autostart,
						playlist: this._base_url + "mp3PlayerScripts/flConfig.php?eid%3D" + cid + "%26player%3D" + this._player_type + "%26embed%3D1%26share%3D1%26aid%3D" + id + "%26type%3Dalbum" + (this._debug ? "%26cb%3D" + Math.random() : ""),
						comment: this._base_url + "mp3PlayerScripts/comment.php"
					};
					
					size[1] = this._player_type == "light" ? 240 : 377;
					break;
				
				case 3: // list of files
					var fv = {
						isComment: this._isComment,
						autoload: this._autoload,
						autostart: this._autostart,
						playlist: this._base_url + "mp3PlayerScripts/flConfig.php?eid%3D" + cid + "%26player%3D" + this._player_type + "%26embed%3D1%26share%3D1%26lid%3D" + id + "%26type%3DlistOfTracks" + (this._debug ? "%26cb%3D" + Math.random() : ""),
						comment: this._base_url + "mp3PlayerScripts/comment.php"
					};
					
					size[1] = this._player_type == "light" ? 240 : 377;
					break;
			}
			
			// add player
			swfobject.embedSWF(
				swf,
				container,
				size[0],
				size[1],
				"9",
				null,
				fv,
				this._params,
				{"id": container},
				function(){
					$this._flash = true;
					
					if ($this._user != null)
						$this.doLogin(container);
					
				}
			);
						
			return true;
		},
		
		/**
		 * Shows a fancy message box for the user
		 *
		 * @param title str message title
		 * @param message str message
		 * @opt param delay int delay to show default 0
		 * 
		 * @return void
		 */
		msg: function(title, message, delay) {
			if (typeof delay == 'undefined')
				delay = 0;
			
			$("#HSmsg_title").html(title);
			$("#HSmsg_msg").html(message);
			
			setTimeout(function(){
				$("#HSmsg").overlay().load();
			}, delay);
		},
		
		/**
		 * Playlist object
		 * 
		 * @author Rodrigo Moraes Orph <rodrigo.orph@gmail.com>
		 * 
		 * Related to #8925
		 *
		 */
		playlist: {
			_pid: 0, // current playlist id -- zero stands for session playlist, this will be auto set on load
			_cpl: [], // current playlist
			_apl: null, // available playlists
			_plc: "#hsPlaylistC", // playlist container
			_psc: "#hsPlaylistS", // playlists select object
			_init: false, // init flag
			
			/**
			 * Handles all communication between the ajax service and user frontend.
			 *
			 * @param id mixed generic action related id value
			 * @param action string action to be performed
			 * @opt param extra mixed (not array) extra params to be send to ajax service
			 * @opt param anonymous function callback to be executed on ajax.complete
			 *
			 * @return void | false
			 */
			handler: function(id, action, extra, callback) {
				var $this = this;
				
				if (typeof action == 'undefined')
					action = 'add';
				
				if (typeof extra == 'undefined')
					extra = '';
				
				if (typeof jQuery == 'undefined') {
					setTimeout(function(){
						$this.add(id, action);
					}, 50);
					
					return false;
				}
				
				$.ajax({
					url: hsPlayer._base_url + "ajax/playlist.php",
					data: "action=" + action + "&id=" + id + "&pid=" + $this._pid + "&extra=" + extra,
					type: "POST",
					dataType: "jsonp",
					async: true,
					cache: true,
					beforeSend: function(){
						if ($("#HSplaylist").is(":visible"))
							$("#hsPlaylistLD").show();
						
						if ($("#HSplaylist_add_" + id).length > 0)
							$("#HSplaylist_add_" + id).html("<img src='"+ hsPlayer._base_url + "/images/ld.gif'>");
					},
					complete: function(){
						if ($("#HSplaylist").is(":visible"))
							$("#hsPlaylistLD").hide();
						
						if ($("#HSplaylist_add_" + id).length > 0)
							$("#HSplaylist_add_" + id).html("Done!");
						
						if (typeof callback != 'undefined')
							callback();
					}
				});
			},
			
			/**
			 * Load current list and show the box
			 *
			 */
			init: function(){
				var $this = this;
				
				/**
				 * There's been an error initalizing the root object
				 * try to fetch it again.
				 *
				 */
				if ($("#HSplaylist").length == 0) {
					hsPlayer.loadAssets();
					setTimeout(function(){
						hsPlayer.playlist.init();
					}, 500);
					
					return false;
				}
				
				$("#HSplaylist").overlay().load();
				$("#HSplaylist").css('zIndex', 9999999); // bring to front

				if (this._init === false) {
					this._init = true;
					
					if (typeof jQuery.ui == 'undefined' || typeof jQuery.ui.sortable == 'undefined')
						hsPlayer.asLoad(hsPlayer._base_url + "js/jquery-ui-1.7.1.custom.min.js");
					
					$("#hsPlaylistS").change(function(){
						$this.handler(
							0,
							"load",
							$(this).val()
						);
					});
					
					this.handler(
						this._pid,
						"load"
					);
				} else { // refresh listing, just in case
					this.buildPlaylist();
				}
				
				return false;
			},
			
			/**
			 * Callback for jsonP's handler
			 *
			 * @param pl json object compatible with this._cpl
			 *
			 */
			loadPlaylist: function(plist, plists) {
				if (typeof plists == 'undefined')
					plists = null;
				
				this._cpl = plist;
				this._apl = plists;
				
				this.buildPlaylist();
			},
			
			/**
			 * Check all checkboxes
			 *
			 * @return false
			 */
			checkAll: function() {
				var check = $("#hsPSC_all").is(":checked") ? true : false;
				
				$(this._plc).find("input[type=checkbox]").each(function(i, v) {
					if (i > 0)
						$(this).attr("checked", check ? "checked" : "");
				});
				
				return false;
			},
			
			/**
			 * Get current selection
			 *
			 * @return array | false
			 *
			 */
			getSel: function() {
				var sel = [];
				$(this._plc).find("input[type=checkbox]").each(function(i, v) {
					if (i > 0 && $(this).is(":checked"))
						sel.push($(this).val());
				});
				
				return sel.length > 0 ? sel : false;
			},
			
			/**
			 * Delete selected items
			 *
			 * @return false
			 */
			delSel: function(){
				var sel = this.getSel(),
						$this = this,
						extra = "",
						id;
				
				if (sel === false) {
					hsPlayer.msg("Error", "Please select at least one entry");
					return false;
				}
				
				$.each(sel, function(i, v) {
					$this.del(v, false);
					
					if (i > 0)
						extra += v + ",";
					else
						id = v;
				});
				
				if (extra != "")
					extra = extra.substr(0, extra.length - 1);
				
				this.handler(id, "del", extra);
				
				return false;
			},
			
			/**
			 * Play Selected Tracks
			 *
			 * @return false
			 */
			playSel: function(){
				var sel = this.getSel();
				
				if (sel === false) {
					hsPlayer.msg("Error", "Please select at least one entry");
					return false;
				}
				
				window.open(hsPlayer._base_url + "playlist/files/" + sel.join(","));
				return false;
			},
			
			/**
			 * Play current playlist
			 * 
			 * @return false
			 */
			play: function() {
				
				window.open(hsPlayer._base_url + "playlist/" + this._pid);
				return false;
			},
			
			/**
			 * Frontend playlist builder
			 *
			 */
			buildPlaylist: function() {
				var bf = "",
						$this = this;
				
				// build song list
				if (this._cpl == null) {
					bf = "<li style='border-top:0;'>No songs added to your playlist yet</li>";
				} else {
					bf = "<li style='background-color:#c0c0c0;cursor:auto !important;'><input type='checkbox' style='width:20px' onClick='hsPlayer.playlist.checkAll();' id='hsPSC_all'> Song Name</li>";
					
					$.each(this._cpl, function(i, v) {
						bf += "<li id='hsPS_" + v.id + "' class='lst'><input style='width:20px' type='checkbox' value='" + v.id + "' id='hsPSC_" + v.id + "'> <a href='" + hsPlayer._base_url + v.file_code + "'>" +  v.title + "</a></li>";
					});
				}
				$(this._plc).html(bf);
				
				// build playlist dropdown
				bf = "";
				
				if (this._apl == null)
					bf = "<option value=0>Unsaved list</option>";
				else
					$.each(this._apl, function(i, v) {
						bf += "<option value=" + v.id + (v.id == $this._pid ? " selected" : "") + ">" + v.name + "</option>";
					});
				
				$(this._psc).html(bf);
				
				$("#hsPlaylistControl").val(this._apl == null || this._pid == 0 ? "Save" : "New").show();
				
				this.bindSortable();
			},
			
			/**
			 * New / Save button control
			 *
			 * @return false
			 */
			btControl: function() {
				if ((this._apl == null || this._pid == 0) && hsPlayer._user == null) { // not logged
					$("#HSplaylist").overlay().close();
					setTimeout(function(){
						$("#HSlogin").overlay().load();
					}, 500);
					
					return false;
				}
				
				// get a name for the list
				var name = prompt("Please name your playlist:");
				
				if ($.trim(name) == "") {
					alert("Invalid name.");
					return false;
				}
				
				this.handler(
					0,
					"new",
					name
				);
				
				return false;
			},
			
			/**
			 * Binds sortable and ajax callback
			 *
			 * This requires jQuery.ui.sortable, previously loaded by this.init();
			 * if the javascript is not ready yet we will delay the execution until
			 * it's ready.
			 *
			 */
			bindSortable: function(){
				var $this = this;
				
				if (typeof jQuery.ui == 'undefined' || typeof jQuery.ui.sortable == 'undefined') {
					setTimeout(function(){
						$this.bindSortable();
					}, 50);
					
					return false;
				}
				
				$(this._plc).sortable({
					opacity: 0.6,
					cursor: "move",
					items: "li.lst",
					placeholder: "HShighlight",
					update: function() { $this.handler(0, "order", "1&" + $(this).sortable("serialize")); }
				});
				
				return true;
			},
			
			/**
			 * Adds entry to currently selected playlist
			 * 
			 * @param id int file_id
			 *
			 * @return false
			 */
			add: function(id, flash) {
				if (typeof flash == 'undefined')
					flash = false;
				
				if (this._cpl == null)
					this._cpl = [];
				
				// check if this song is on the playlist already...
				var exists = false;
				for (var i in this._cpl) {
					if (typeof this._cpl[i].id != 'undefined' && this._cpl[i].id == id) {
						exists = true;
						break;
					}
				}
				
				
				if (exists) // doh, already exists on the playlist, show the window for that MF
					this.init();
				else // not added, do the ajax request
					this.handler(
						id,
						"add"
					);
				
				if ($("#addPlaylist_" + id).length > 0)
					$("#addPlaylist_" + id + ">a>span").html("Song added!"); // <a href='#' onClick='return hsPlayer.playlist.init();'>View</a>");

				if ($("#addPlaylistRel_" + id).length > 0)
					$("#addPlaylistRel_" + id).hide();

				return flash ? "1" : false;
			},
			
			/**
			 * Delete entry from the playlist
			 *
			 * @param id int entry id (on _cpl json array)
			 *
			 * @return false
			 *
			 */
			del: function(id, useHandler) {
				if (typeof useHandler == 'undefined')
					useHandler = true;
				
				if (useHandler)
					this.handler(id, "del");
				$("#hsPS_" + id).remove();
				
				// rebuild _cpl removing the entry
				var tmp = [];
				$.each(this._cpl, function(i, v) {
					if (v.id != id)
						tmp.push(v);
				});
				this._cpl = tmp;
				
				return false;
			},
			
			/**
			 * Delete current active playlist
			 *
			 * @return false
			 */
			delList: function(){
				if (confirm("Are you sure that you want to delete this playlist?"))
					this.handler(
						0,
						"delList"
					);
				
				return false;
			}
		}
	};

hsPlayer.init(); // self-init
