	function refreshBanners () {
		/*$('#top-left-banner').load("/widget/banner-widget.html?panel=0");
		$('#top-right-banner').load("/widget/banner-widget.html?panel=1");
		$('#right-side-banner-11').load("/widget/banner-widget.html?panel=2");
		$('#right-side-banner-12').load("/widget/banner-widget.html?panel=3");
		$('#right-side-banner-13').load("/widget/banner-widget.html?panel=4");
		
		$('#right-side-banner-1').load("/widget/banner-widget.html?panel=2");
		$('#right-side-banner-2').load("/widget/banner-widget.html?panel=3");
		$('#right-side-banner-3').load("/widget/banner-widget.html?panel=4");
		
		$('#left-side-banner').load("/widget/banner-widget.html?panel=5");*/
	}

	var prevPlayer = null;
	var prevMixId = "";
	
	var boxy = null;	

	function showBoxy() {
		boxy.show();
	    return false;
	}
	
	function showCommentDlg(itemId, itemTypeId) {
		Boxy.load('/widget/comments.html?form[itemId]='+itemId+'&form[itemTypeId]='+itemTypeId + '&isFromBoxy=true&container=dummy', 
			{title: 'Post Comment', 
			 modal: true, 
			 show: true, 
			 unloadOnHide: true,
			 afterHide: function () {
				if (($('#newComment').html()).toLowerCase().indexOf('<div class="pending-message new-user">') >= 0) {
					window.location.href=window.location.href;
				}
		    }});
		
	}
	
	
	function showSignupDlg(itemId) {
		
		Boxy.load('/widget/event-signup.html?form[itemId]='+itemId + '&isFromBoxy=true&container=dummy', 
			{title: 'Signup for Event', 
			 modal: true, 
			 show: true, 
			 unloadOnHide: true,
			 afterHide: function () {
				if (($('#newComment').html()).toLowerCase().indexOf('<div class="pending-message new-user">') >= 0) {
					location.reload(true);
				}
		    }});
	}
	
	function signupBoxyEvent(form, container) {
		
		var params = $('#'+form.id).serializeArray();
	  	jQuery.post(
	  		"/event-signup.html",
	  		params,
	  		function (data) {
	  			if (data.success == "true") {
	  				$('#newComment').html('<div class="pending-message">You\'ve successfully signed up for event!<br/> Thank you!</div>');
		  		}
		  	},
	  		"json"	
		);
		
		return false;
	}

	function signupUnregBoxyEvent(form, container) {
		
		var frm = $('#'+form.id);
		frm.validate({
			   debug: true
		});
		if (frm.valid()) {
			var params = frm.serializeArray();
		  	jQuery.post(
		  		"/event-signup.html",
		  		params,
		  		function (data) {
		  			if (data.success == "true") {
		  				$('#newComment').html('<div class="pending-message new-user">You\'ve successfully signed up for event!<br/> Thank you!</div>');
			  		} else if (data.fail == "true") {
			  			$('#newComment').html('<div class="pending-message">User with such email already exists.<br/> Please <a href="/auth.html">sign in</a> to be able to signup for event.</div>');
			  		}
			  	},
		  		"json"	
			);
		}
		
		return false;
	}
	
	$(document).ready(function(){

		refreshBanners();

		boxy = new Boxy("<p class='login-p'>You have to be logged in to <b>rate</b> or <b>comment</b> a mix.<br/> " +
				"Please <a class='login-dlg' href='/auth.html'>LOGIN</a> or <a class='login-dlg'href='/registration.html'>REGISTER</a> to comment and rate mixes. " +
				"</p>", {title: 'Login or Register', modal: true, show: false});
		/*
		$('.non-reg-star').click(function() {
			showBoxy();
		});
		*/

		
		$('.window .close').click(function (e) {  
			//Cancel the link behavior  
			e.preventDefault();  
			$('#mask, .window').hide();  
		});       
		      
		//if mask is clicked  
		$('#mask').click(function () {  
			$(this).hide();  
			$('.window').hide();  
		});           

		$("#live_music").css("cursor","pointer"); 
		$("#live_music").click(function(){
			var params = "width=690,height=680,menubar=no,location=no,resizable=no,scrollbars=no,status=no";
			window.open("/live.php", "player", params);
			return false;
		});
		
		
		$(".mix-btn").css("cursor","pointer"); 
		$(".mix-btn").click(function(){
			if (prevPlayer != null) {
				prevPlayer.stop();
				
				$("#mixplayer"+prevMixId).fadeOut(100, 
						function() {
							var mixid = $(this).attr('id');
							mixid = mixid.replace('mixplayer','');
							$("#playmix" + mixid ).fadeIn(100);
							$('#download_link' + mixid).fadeIn(100, function () {;
								$(this).parent().css("padding-top","0");
								$(this).parent().css("width","107px");
							});
						});
				
			}
			prevMixId = $(this).attr('mixid');
			$('#download_link' + prevMixId).fadeOut(100, function () {;
				$(this).parent().css("padding-top","8px");
				$(this).parent().css("width","25px");
			});
			$("#playmix" + prevMixId).fadeOut(100, 
					function() {
						var mixid = $(this).attr('mixid');
						$("#mixplayer"+mixid).fadeIn(100, function () {
							var mixid = $(this).attr('id').replace('mixplayer','');
							var mixurl = $("#playmix" + mixid).attr('mixurl');
							prevPlayer = niftyplayer('niftyPlayer' + prevMixId);
							prevPlayer.loadAndPlay(mixurl);

							prevPlayer.registerEvent('onPlay', 'FlashHelper.getMovie("speaker'+mixid+'").SetVariable("msg","play")');
							prevPlayer.registerEvent('onStop', 'FlashHelper.getMovie("speaker'+mixid+'").SetVariable("msg","stop")');
							prevPlayer.registerEvent('onPause', 'FlashHelper.getMovie("speaker'+mixid+'").SetVariable("msg","stop")');
							prevPlayer.registerEvent('onSongOver', 'FlashHelper.getMovie("speaker'+mixid+'").SetVariable("msg","stop")');
						});
			});
			
			;
		});
	});
	$(window).unload( function () {

	});
	document.write('<style>.noscript { display: none; }</style>');

	var nifty =  null;
	
	function loadAndPlay(name, url) {

		if (nifty == null) {
			nifty = niftyplayer(name);
		}
		
		nifty.loadAndPlay(url);
	}
	
	function getRatingContainerId(itemId, itemType, itemSubType) {
		return "rate_" + itemType + "_" + itemSubType + "_" + itemId;
	}
	
	function getCommentContainerId(itemId, itemTypeId) {
		return "comment_mix_" + itemId;
	}
	
	function showLoginPopup() {
		//Get the screen height and width  
		var maskHeight = $(document).height();  
		var maskWidth = $(window).width();  
		       
		//Set height and width to mask to fill up the whole screen  
		$('#mask').css({'width':maskWidth,'height':maskHeight});  
		           
		//transition effect       
		$('#mask').fadeIn(1000);      
		$('#mask').fadeTo("slow",0.8);    
		       
		//Get the window height and width  
		var winH = $(window).height();  
		var winW = $(window).width();  
		                 
		//Set the popup window to center  
		$("#dialog").css('top',  winH/2-$("#dialog").height()/2);  
		$("#dialog").css('left', winW/2-$("#dialog").width()/2);
		
		$("#dialog").fadeIn(2000);
	}
	
	function refreshRating (itemId, itemType, itemSubType, ext) {
		var curTs = new Date().getTime();
		$('#' + getRatingContainerId(itemId, itemType, itemSubType)).load("/widget/vote.html?ts="+curTs+"&vote[itemId]=" 
					+ itemId + "&vote[itemType]=" 
					+ itemType + "&vote[itemSubType]=" 
					+ itemSubType + "&vote[itemExt]=" + ext );
	}
	
	function getFreshComment (itemId, itemTypeId, prefix) {
		$('#' + prefix + getCommentContainerId(itemId, itemTypeId)).load("/widget/fresh-comment.html?form[itemId]=" 
				+ itemId + "&form[itemTypeId]=" 
				+ itemTypeId);
	}
	
	function updateRating (id, itemId, itemType, itemSubType, vote, ext) {
		var curTs = new Date().getTime();
		$('#' + getRatingContainerId(itemId, itemType, itemSubType)).load(
			"/widget/vote.html?ts="+curTs+"&act=update&vote[id]="+id 
				+ "&vote[itemType]=" + itemType 
				+ "&vote[itemId]=" + itemId
				+ "&vote[itemSubType]=" + itemSubType
				+ "&vote[vote]=" + vote
				+ "&vote[itemExt]=" + ext);
	}
	
	function refreshRatingPrefix (itemId, itemType, itemSubType, ext, prefix) {
		var curTs = new Date().getTime();
		$('#' + prefix + getRatingContainerId(itemId, itemType, itemSubType)).load("/widget/vote.html?ts="+curTs+"&vote[itemId]=" 
					+ itemId + "&vote[itemType]=" 
					+ itemType + "&vote[itemSubType]=" 
					+ itemSubType + "&vote[itemExt]=" + ext 
					+ "&prefix=" + prefix);
	}
	
	function updateRatingPrefix (id, itemId, itemType, itemSubType, vote, ext, prefix) {
		var curTs = new Date().getTime();
		$('#' + prefix +  getRatingContainerId(itemId, itemType, itemSubType)).load(
			"/widget/vote.html?ts="+curTs+"&act=update&vote[id]="+id 
				+ "&vote[itemType]=" + itemType 
				+ "&vote[itemId]=" + itemId
				+ "&vote[itemSubType]=" + itemSubType
				+ "&vote[vote]=" + vote
				+ "&vote[itemExt]=" + ext
				+ "&prefix=" + prefix);
	}
	
	function showRateStar (div) {
		if (div.getAttribute('selected') == null 
				|| div.getAttribute('selected') == '') {
			div.innerHTML = '<img src="/resources/site/images/favorite-sel.png" />';
			div.setAttribute('selected','true');
		}
	}
	
	function hideRateStar (div) {
		if (div.getAttribute('selected') != null
				&& div.getAttribute('selected') == 'true') {
			div.innerHTML = '<img src="/resources/site/images/space.png" />';
			div.setAttribute('selected','');
		}
	}
