var _loc=document.location.href.substring(window.location.href.indexOf(document.document)+document.documentlength);
var locFlashVars = "_loc="+_loc;
locFlashVars += "&us=tvpopcorn";
locFlashVars += "&splashButton=swf/player/components/buttonPlay.swf";
locFlashVars += "&fullFunction=goFullLocandine";

var isFull = 0;
var idCanale = 0;
var carouselPiuvisti = null;


$(document).ready(function() {
	
	//Prossimamente
	$('#prossimamente ul').jcarousel({
		scroll: 3,
		visible: 3, 
		vertical: 'true',
		itemVisibleInCallback: {
            onBeforeAnimation: function(){$("#prossimamente ul .bollinoVietatoV").hide();},
            onAfterAnimation:  function(){$("#prossimamente ul .bollinoVietatoV").show();}
        }
	});
	
	//Preferiti
	$("#preferiti ul").jcarousel({scroll: 3, vertical: 'true',
		itemVisibleInCallback: {
            onBeforeAnimation: function(){$("#preferiti ul .bollinoVietatoV").hide();},
            onAfterAnimation:  function(){$("#preferiti ul .bollinoVietatoV").show();}
        }
	});
    
	$('#piuvisti ul').jcarousel({scroll: 3, vertical: 'true',
		itemVisibleInCallback: {
            onBeforeAnimation: function(){$("#piuvisti ul .bollinoVietatoV").hide();},
            onAfterAnimation:  function(){$("#piuvisti ul .bollinoVietatoV").show();}
        }
	});
});


function goFullTop()
{	
	if( myCarousel = $(".h_carousel ul").data('jcarousel') ) {
    	myCarousel.reset();
		myCarousel.remove();
		myCarousel.size(0);
	}
	
	if( myCarousel = $("#prossimamente ul").data('jcarousel') ) {
    	myCarousel.reset();
		myCarousel.remove();
		myCarousel.size(0);
	}
	
	if( myCarousel = $("#preferiti ul").data('jcarousel') ) {
    	myCarousel.reset();
		myCarousel.remove();
		myCarousel.size(0);
	}
	
	if( myCarousel = $("#piuvisti ul").data('jcarousel') ) {
    	myCarousel.reset();
		myCarousel.remove();
		myCarousel.size(0);
	}
	
	//$("body").css("background-image", "url('');");
	
	$("#advContainer").hide();
	$("#banner").hide();

	$("#leaderboard").css("width", "100%");
	$("#leaderboard").css("height", "100%");
	$("#leaderboard").css("margin-top", "0px");
	
	$("#containerPayerTop").css("width", "100%");
	$("#containerPayerTop").css("height", "100%");
	$("#containerPayerTop").css("background-color", "#000");
	$("#containerPayerTop").css("top", "0px");
	
	$("#apriTV").css("position", "absolute");
	$("#apriTV").css("top", "0px");
	$("#apriTV").css("width", "100%");
	$("#apriTV").css("height", "100%");
	
	$("#palyerTop").css("width", "100%");
	$("#palyerTop").css("height", "100%");
	
	$("#containerPlayerLocandine").hide();
	$("#header").hide();
	$("#container").hide();
	$("#footer").hide();
	$("#banner img").hide();
	
	swfobject.removeSWF("palyerHome");
	
}

function goFullLocandine()
{	
	isFull = 1;
	
	if( myCarousel = $(".h_carousel ul").data('jcarousel') ) {
    	myCarousel.reset();
		myCarousel.remove();
		myCarousel.size(0);
	}
	
	if( myCarousel = $("#prossimamente ul").data('jcarousel') ) {
    	myCarousel.reset();
		myCarousel.remove();
		myCarousel.size(0);
	}
	
	if( myCarousel = $("#preferiti ul").data('jcarousel') ) {
    	myCarousel.reset();
		myCarousel.remove();
		myCarousel.size(0);
	}
	
	if( myCarousel = $("#piuvisti ul").data('jcarousel') ) {
    	myCarousel.reset();
		myCarousel.remove();
		myCarousel.size(0);
	}
	 
	
	$("#leaderboard").hide();
	$("#container").hide();
	$("#footer").hide();
	
	
	swfobject.removeSWF("palyerTop");
	swfobject.removeSWF("palyerHome");
	
	$("#containerPlayerLocandine").css("background-color", "#000");
	$("#containerPlayerLocandine").css("width", "100%");
	$("#containerPlayerLocandine").css("height", "100%");
	$("#containerPlayerLocandine").css("top", "0");
	$("#containerPlayerLocandine").css("left", "0");
}

function callPublish(msg, name, hrefStr, description, img) {
	hrefStr = hrefStr + "&social=facebook&rnd=" + Math.round(Math.random()*10000000000);
	hrefStr = encodeURIComponent(hrefStr);
	hrefStr = hrefStr.replace("index.php","");
	desc = escape(description);
	window.open("http://www.facebook.com/sharer.php?u=" + hrefStr + "&t=" + name + "&d=" + desc, "Condividi", "width=600, height=400");
}
function callPublishTW(hrefStr, name) {
	hrefStr = escape(hrefStr);	
	window.open("http://twitter.com/home?status=" + name + "-" + hrefStr, "Condividi", "width=600, height=400");
}
function callPublishMS(msg, name, hrefStr, description, img) {
	hrefStr = escape(hrefStr);	
	window.open("http://www.myspace.com/Modules/PostTo/Pages/?u=" + hrefStr + "&t=" + name, "Condividi", "width=600, height=400");
}


function getFlashMovie(movieName) {
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  return (isIE) ? window[movieName] : document[movieName];
}

function setFile(video, category, tmpidCanale) 
{
	if(tmpidCanale > 0)
	{
		idCanale = tmpidCanale;
	}
	else
	{
		idCanale = 0;
		}
	getFlashMovie("palyerlocandine").setVideo(video, category, idCanale);
}


var dtit = "LA WEB TV ITALIANA MULTIPIATTAFORMA: NUOVA, GRATUITA, ON DEMAND, IN FULL SCREEN";
var ddsc = "PopCornTv.it &egrave; una web tv multipiattaforma on demand in streaming, legale e gratuita su cui si possono vedere film, video musicali, filmati sportivi e tanto di pi&ugrave;, contenuti nella Library costantemente ampliata. Non bisogna abbonarsi n&egrave; registrarsi.";
function fillText(tit, dsc) {
	if(tit == "") {
		document.getElementById("testo_lancio").innerHTML = "<h3>" + dtit + "</h3><p>" + ddsc + "</p>";
	} else {
		document.getElementById("testo_lancio").innerHTML = "<h3>" + tit + "</h3><p>" + dsc + "</p>";
	}
}
