// JavaScript Document
var topplayerisplaying = false;

$(document).ready(function() {
	
	$(".smallbox:nth-child(3n)").css('marginRight', '0px');
	
	if ($("#index").length > 0) {
		var flashvars = {};
		flashvars.xml = "config.xml";
		flashvars.font = "font.swf";
		var attributes = {};
		attributes.wmode = "transparent";
		attributes.id = "slider";
		swfobject.embedSWF("cu3er.swf", "index", "940", "420", "9", "expressInstall.html", flashvars, attributes);
	}
	
	if ($("#sposi").length > 0) {
	  var flashvars = {};
	  var lang = $("#sposi").attr("ccc:lang");
	  flashvars.file = "beppe"+lang+".flv";
	  flashvars.autostart = "true";
	  var attributes = {};
	  swfobject.embedSWF("player.swf", "sposi", "940", "540", "9", "expressInstall.html", flashvars, attributes);
	}
	
	if ($(".tablesorter").length > 0) {
	  $(".tablesorter").tablesorter({widthFixed: true, widgets: ['zebra']}).tablesorterPager({container: $("#pager"), positionFixed:false}); 
	}
	
	$("#language a.newlang").click(function() {
		var newlang = $(this).attr("ccc:lang");
		$.post("cambia_lingua.php", {lang:newlang}, function(data){
			//alert(newlang);
			window.location.href = window.location.href;
		});
		return false;
	});
	
	$("#topplayercommands").click(function() {
		setup_topplayer();
	});
	if ($("#starttopplayer").length > 0) {
		setup_topplayer();
	}
	
	$(".onephoto a").lightBox();
	
	$(".playbutton").click(function() {
		var flashvars = {};
	    flashvars.file = $(this).attr("ccc:mp3");
	    flashvars.autostart = "true";
		swfobject.embedSWF("player.swf", "player", "280", "24", "9", "expressInstall.html", flashvars, attributes);
	});
	
	/*$(".playbutton").each(function() {
		$(this).before('<a href="download.php?nomefile='+$(this).attr("ccc:mp3")+'"><img src="media/download.png" style="float:left" alt="Download"/></a>');
	})*/
	
	$(".inviamail").click(function() {
		var from = $(this).attr("ccc:from");
		var name = $("#"+from+" #qname").val();
		var email = $("#"+from+" #qemail").val();
		var mobile = $("#"+from+" #qsubject").val();
		var message = $("#"+from+" #qmessage").val();
		var motivo = $('input[name=qmotivo]:checked').val();
		
		$.post("sendmail.php", {name:name, email:email, mobile:mobile, message:message, motivo:motivo}, function(data){alert("Messaggio inviato!")});
		return false;
	});
});



function setup_topplayer() {
	if (!topplayerisplaying) {
		var flashvars = {};
		var attributes = {};
		flashvars.file = "composizioni/09.mp3";
		flashvars.autostart = "true";
		flashvars.controlbar = "none";
		swfobject.embedSWF("player.swf", "topplayer", "1", "1", "9", "expressInstall.html", flashvars, attributes);
		topplayerisplaying = true;
		$("#topplayercommands img").attr("src", "images/topplayerplay.png");
	} else {
		topplayerisplaying = false;
		$("#topplayer").html("");
		$("#topplayercommands img").attr("src", "images/topplayerpause.png");
	}
}

