/**
 * @author fabio
 */

jQuery(function() {
	jQuery('.voteVideo').bind('click', function(){
		if (jQuery(this).hasClass('notisloggedin')){
			alert("Per votare devi effettuare il login");
			return false;
		}
		if (jQuery(this).hasClass('alreadyVoted')){
			alert("Hai gia' votato");
			return false;
		}
				
		var videoUid = jQuery(this).attr('id').split('_');
			$.ajax( {
				type : "GET",
				url : "/",
				data : "eID=videochartExtraFunctions&responseType=AJAX&service=RATING&vote="+1+ "&videoUid=" + videoUid[1],
				async:false,
				success : function(msg) {
					alert('Grazie per aver votato');
					location.reload();
				}
			});
	});
	
	jQuery('#playHomeVideo').bind('click', function(){
		
var html = 'var fo_0bb6968ae61b6619853f2d9d90b945dc = new SWFObject("http://yetirap-http.weebo.it/swf/player.swf", "player", "100%", "100%", "10", "#ffffff",false,"high"); '+
		' fo_0bb6968ae61b6619853f2d9d90b945dc.useExpressInstall("/fileadmin/templates/scripts/expressinstall.swf"); fo_0bb6968ae61b6619853f2d9d90b945dc.addParam("allowScriptAccess", "always"); fo_0bb6968ae61b6619853f2d9d90b945dc.addParam("scaleMode", "noScale"); '+
	 	' fo_0bb6968ae61b6619853f2d9d90b945dc.addParam("allowFullScreen", "true"); ' +
		' fo_0bb6968ae61b6619853f2d9d90b945dc.addParam("menu", "false"); ' +
		' fo_0bb6968ae61b6619853f2d9d90b945dc.addVariable("plContext","http://yetirap-http.weebo.it/smil/defskoda.xml"); ' +
		' fo_0bb6968ae61b6619853f2d9d90b945dc.addVariable("serverDownloadProgressivo","http://yetirap-http.weebo.it//vodservice/"); ' +
		' fo_0bb6968ae61b6619853f2d9d90b945dc.addVariable("autoPlay","true"); ' +
		' fo_0bb6968ae61b6619853f2d9d90b945dc.addVariable("urlSkin","http://yetirap-http.weebo.it/swf/skin.swf"); ' +
		' fo_0bb6968ae61b6619853f2d9d90b945dc.addVariable("cartellaConfig","http://yetirap-http.weebo.it/config/"); ' +
		' fo_0bb6968ae61b6619853f2d9d90b945dc.addVariable("cartellaLingua","http://yetirap-http.weebo.it/config/"); ' +
		
		'fo_0bb6968ae61b6619853f2d9d90b945dc.write("homeVideo"); ';
		eval(html);
	});
	
	jQuery('#tx_videochart_formSendVideo').bind('click', function(){
		if(!$('#tx_videochart_videoTerms').attr('checked')){
			alert('Devi accettare le condizioni di caricamento');
			return false;
		}else{
			if($.trim($('#tx_videochart_videoTitle').val()) =='' || $.trim($('#tx_videochart_videoVideo').val()) ==''){
				alert('Devi compilare tutti i campi');
				return false;
			}
		}
		
	});
	
	jQuery('.tx_videochart_videoDelete').bind('click',function(){
		return false;
		
		var videoUid = jQuery(this).attr('id').split('_');
		if(confirm("Sei sicuro di eliminare il video?")){
			$.ajax( {
				type : "GET",
				url : "/",
				data : "eID=videochartExtraFunctions&responseType=AJAX&service=DELETEVIDEO&videoUid=" + videoUid[1],
				async:false,
				success : function(msg) {
					alert("Il video e' stato eliminato correttamente");
					location.reload();
				}
			});
		}
		
	});
});
