﻿function OpenZoom(mediaId, width, height) {
    var sUrl = "/" + mediaId + "/ufficio-stampa/popup";
    //alert(sUrl);
    var sParam = new String("width=" + width + ",height=" + height);
    myWindow = window.open(sUrl, "Locandina", sParam)
	
//	var frameString='<html><head><title>';
//		frameString= frameString + Label + '</title></head>';
//		frameString= frameString + '<body bgcolor="#4B5A6D" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"  style="margin:0px:padding:0px;" onload="self.focus();">';		
//		
//		frameString= frameString + immagine;
//		frameString= frameString + '</body></html>';
//		
//		myWindow.document.open();
//		myWindow.document.write(frameString);
//		myWindow.document.close();
//		myWindow.focus();
	
   // myWindow.document.bgColor = "#4B5A6D";
    return;
}

function generateTagVideo(titolo, video, videoEmbed) {
    var content = '';
    if (video && videoEmbed) {
        content = '<object width="600" height="338" id="HUY" name="HYETA">';
        content += '<param name="allowFullScreen" value="true" />';
        content += '<param name="allowScriptAccess" value="always" />';
        content += '<param name="wmode" value="transparent" />';
        content += '<param name="movie" value="' + video + '" />';
        content += '<embed src="' + videoEmbed + '" id="player" name="player" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" height="338" width="600" />';
        content += '</object>';
    } 
    else 
    {
        content = "<div class='homepageAlternativeVideo'>pDPD</div>";
    }
     
    return content;
}

function changeVideo(titolo, movieId, movieTypeId, indice, alternativeMovieUrl) {
    if (indice == null) indice = 1;
    var myTitle = $(titolo).prev().html();

    $('#blocco_sx_video').html('');
    $('#blocco_sx_title').html(myTitle);
    if (movieId && movieId != '' && movieTypeId && movieTypeId != '') {
        //Movie da preview network
        var myVideo = "http://www.player.filmtrailer.com/v3.4/player.swf?file=http://it.player-feed.previewnetworks.com/cinema/" + movieId + "/391100017-1/?clip_type[]=" + movieTypeId + "&amp;display_title=none&amp;menu=true&amp;default_quality=xxlarge&amp;controlbar=over&amp;autostart=false&amp;backcolor=241D16&amp;frontcolor=7F7F7F&amp;share=1&amp;repeat=always&amp;volume=80&amp;linktarget=_blank&amp;";
        var myVideoEmbed = "http://www.player.filmtrailer.com/v3.4/player.swf?file=http://it.player-feed.previewnetworks.com/cinema/" + movieId + "/391100017-1/?clip_type[]=" + movieTypeId + "&amp;display_title=none&amp;menu=true&amp;default_quality=xxlarge&amp;controlbar=over&amp;autostart=false&amp;backcolor=241D16&amp;frontcolor=7F7F7F&amp;share=1&amp;repeat=always&amp;displayclick=play&amp;volume=80&amp;linktarget=_blank&amp;";
        var myContent = generateTagVideo(myTitle, myVideo, myVideoEmbed);

        $('#blocco_sx_video').html(myContent);
    }
    else {
   
                                
        //Custom trailer
        var bloccoSxHtml = '<div id="blocco_sx_video_swfobject">';
        bloccoSxHtml += '  <div style="padding: 10px; margin-top: 90px;">';
        bloccoSxHtml += '    <a href="http://get.adobe.com/it/flashplayer/">';
        bloccoSxHtml += '      <img align="left" src="/images/flashplayer_100x100.jpg" style="padding:10px; align:left;" alt="Scarica flash player!"/>';
        bloccoSxHtml += '    </a>';
        bloccoSxHtml += '    <br/>';
        bloccoSxHtml += '    <br/>';
        bloccoSxHtml += '    <font style="font-size:12px; font-family: Lucida Grande, Arial, Myriad Pro; color: #ffffff; ">';
        bloccoSxHtml += '      Per vedere il video è necessario <br/> avere installato ';
        bloccoSxHtml += '      <a href="http://get.adobe.com/it/flashplayer/">';
        bloccoSxHtml += '      <strong>Flash Player</strong>';
        bloccoSxHtml += '      </a>.';
        bloccoSxHtml += '    </font>';
        bloccoSxHtml += '  </div>';
        bloccoSxHtml += '</div>';

        $('#blocco_sx_video').html(bloccoSxHtml);
        
        var flashvars = {
            videopercorso: alternativeMovieUrl//, 
            //autoplay: true
        };
        var params = {
         wmode: 'transparent'
        };
        swfobject.embedSWF("/f6/swf/F6VideoPlayer.swf", "blocco_sx_video_swfobject", "600", "338", "9.0.0", false, flashvars, params);
    }
    $("div[id^='linguetta']").hide();
    $("a[id^='btn_trailer']").attr('class', '');

    $('#linguetta' + indice).show();
    $('#btn_trailer' + indice).attr('class', 'actived');
}
window.onbeforeunload =  function() {
    $("object").remove();
}

function handleVotes(id, subid, value)
{
	//prima cosa spegniamo il link
	//$("a#vote_" + id).click(function() { return false; });
	//$("a#vote_" + id).attr("href", "javascript:void(0)");
	//$("a#vote_" + id).text("please wait...");
	var params = {
		nodeId: id,
		subNodeid: subid,
		vote: value
	};

	$.ajax({
		type: "GET",
		url: "/f6/Pages/AddVote.aspx",
		data: params,
		cache: false,
		success: function(result)
		{
			addMikadoCookie(id, subid);
			//$("a#vote_" + id).html("Voti " + result);
			alert("Voti " + result);
		},
		error: function(result)
		{
			//$("a#vote_" + id).html("Error");
			alert("error");
		}
	});
}

