function Popup(page, width, height) {
	   var l = Math.floor((screen.width-width)/2);
	   var t = Math.floor((screen.height-height)/2);
	      window.open(page,"page","width=" + width + ",height=" + height + ",top=" + t + ",left=" + l);
}

/*POPUP PLAYER WEBRADIO*/
function apriWebradio(stream, titolo){
	//alert(canale);
	window.open('popup.php?ch=?streamRadio='+stream+'&titoloRadio='+titolo,'webradio','width=930,height=270');
}

/* ------------------------------------------------------------------------
 * Downloads.js
 * Copyright (c) 2008-2010 Virgin Radio Italy , SPA. All rights reserved.
 * ------------------------------------------------------------------------ */
function downloadAudio(id, a, b) {
	//if(a == 0) {
	//	$('#btn-download-'+id).removeAttr('onclick');
	//	$('#btn-download-'+id).html('Per poter votare bisogna essere loggati &raquo;');
	//	$('#btn-download-'+id).attr({ href: 'http://www.virginradio.it/top/virgin_club?ru='+b});
	//} else {

		$.ajax({
			  url: '/services/downloads/audio/format/ajax',
			  data: "c="+id,
			  success: function(data) {			
				if(data == 0) {
					$('#btn-download-'+id).removeAttr('onclick');
					$('#btn-download-'+id).attr({ href: 'http://www.virginradio.it/top/virgin_club?ru='+b});
					$('#btn-download-'+id).html(data);
				} else if(data == 1) {
					$('#btn-download-'+id).removeAttr('onclick');
					$('#btn-download-'+id).html('Spiacenti ci risulta che hai gi&agrave; scaricato il seguente file');					
				} else {
					window.location = data;
					//$('#btn-download-'+id).html(data);
				}
			  }
			});
		//}	
}

/* ------------------------------------------------------------------------
 * all.js
 * Copyright (c) 2008-2009 Radio Monte Carlo , SRL. All rights reserved.
 * ------------------------------------------------------------------------ */
$(document).ready(function(){
	$('.boxgrid.caption').hover(function(){
		$(".cover", this).stop().animate({top:'130px'},{queue:false,duration:160});
	}, function() {
		$(".cover", this).stop().animate({top:'224px'},{queue:false,duration:160});
	});
	$('.boxgrid.slidedown').hover(function(){
		$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300});
	}, function() {
		$(".cover", this).stop().animate({top:'224px'},{queue:false,duration:300});
	});	
});


/* ------------------------------------------------------------------------
 * widget.js
 * Copyright (c) 2008-2009 Virgin Radio Italy , SPA. All rights reserved.
 * ------------------------------------------------------------------------ */
Widget = {
	
	gallery: {
		
		anteprima: {

			hover: function() {
				$(".photosAnteprimaWrapper .photoSmall li.photo").hover(function(){
					Widget.gallery.buildImage(this);
				});	
			},
		
			click: function() {
				$(".photosAnteprimaWrapper .photoSmall li.photo").click(function(){
					Widget.gallery.buildImage(this);
					return false;
				});	
			}
		
		},
		
		buildImage: function(element) {
			var imgAlt  = $(element).find('img').attr("alt");
			var imgSrc  = $(element).find('a').attr("ref");
			var imgTitle = $(element).find('.block h3').html();
			var desc = $(element).find('.block').html();
			
			$(".photosAnteprimaWrapper .boxgrid.caption .cover.boxcaption").html(desc);
			$(".photosAnteprimaWrapper .boxgrid.caption img").attr({ src: imgSrc , alt: imgAlt});
		}
		
	}

}

