//TEST FUNZIONE PER LAYER VIDEO
function openVideo(layerName, flv, thumb)
{	
	var layer=(layerName=='') ? document.getElementById("clipLayer") : document.getElementById(layerName);
	if (layer)
	{
		if (layer.style.display=='block')
		{
			var child=document.getElementById("movieclipContainer");
			layer.style.display='none';
			layer.parentNode.removeChild(child); 
		}		
		else
		{
		    var parent = layer;
		    var movieclipContainer = document.createElement("div");
		    var movieClip = "<object width=\'435\' height=\'327\' id=\'flashp\'>"
						 + "<param name=\'movie\' value=\'videoTooltip.swf\'></param>"
						 + "<param name=\'enc_flv\' value=\'" + flv + "\'></param>"
						 + "<param name=\'enc_thumb\' value=\'" + thumb + "\'></param>"
					     + "<param name=\'enc_shareit\' value=\'ed480d0dd3aca3036a34b6f2543d2f70\'></param>"
						 + "<param name=\'enc_playagain\' value=\'9bcaba7e5cf7c2a91d292a055d487b8cc8268ec3e820739e1137cc15d79c3329\'></param>"
						 + "<embed src=\'videoTooltip.swf\' type=\'application/x-shockwave-flash\' allowscriptaccess=\'always\' allowfullscreen=\'true\' width=\'435\' height=\'327\' flashvars=\'enc_flv=" + flv + "&enc_playagain=9bcaba7e5cf7c2a91d292a055d487b8cc8268ec3e820739e1137cc15d79c3329&enc_thumb=" + thumb + "\'></embed></object>";
		    var htmlTable = "<a class='box_video_x' href=\"Javascript: closeVideo('" + layer.id + "');\"><!-- --></a><div class='box_video_header'>Videos of Costa Cruises</div><div class='box_video_container'>" + movieClip + "</div>";
		    movieclipContainer.id = "movieclipContainer";
		    movieclipContainer.className = "box_video";
		    movieclipContainer.innerHTML = htmlTable;
		    parent.parentNode.insertBefore(movieclipContainer, parent);
		    layer.style.display = 'block';	
		}		
	}
}

function closeVideo(layerToClose)
{
    var layer=document.getElementById(layerToClose);
    var child = document.getElementById("movieclipContainer");
	layer.style.display='none';
	layer.parentNode.removeChild(child);
}

function closeVideoDemo(layerToClose, containerName) 
{
	try
	{
		var layer = document.getElementById(layerToClose);
		var player = getFlashMovieObject(containerName);
		layer.style.display = 'none';	
		player.rewindVideo();		
	}
	catch(ex) {}
}

//Funzione che apre un div e chiude tutti gli altri
function onOff(code) 
{
    ff = document.getElementsByTagName("div");
    for (i = 0; i < ff.length; i++) {
        if (ff[i].id.substr(0,5)=="onOff") {
            ff[i].style.display = "none";
        }
    }   
    for (i = 0; i < ff.length; i++) {
        if (ff[i].id == code) {
            if (ff[i].style.display == "none") {
                ff[i].style.display = "";
            }
        }
    }
}

//Abilita-disabilita l'elemento
function enableElement(arg, state) 
{
    if (arg && state) {
        var element = document.getElementById(arg);
        if (element) {
            element.disabled = (state == 0) ? false : true;
        }
    }
}

//Apri/chiudi il layer del forgot password
function showLayer(arg)
{
    if (arg)
    {
        var fpl = document.getElementById(arg);
        if (fpl)
        {
            if (fpl.style.display=='block' || fpl.style.display==null)
                fpl.style.display='none';
            else
                fpl.style.display='block';
        }
    }
}

//Funzione che apre un div e chiude tutti gli altri (BIS)
function risposta(code) 
{
    ff = document.getElementsByTagName("div");
    for (i = 0; i < ff.length; i++) {
        if (ff[i].id.substr(0,8)=="risposta") {
            ff[i].style.display = "none";
        }
    }   
    for (i = 0; i < ff.length; i++) {
        if (ff[i].id == code) {
            if (ff[i].style.display == "none") {
                ff[i].style.display = "";
            }
        }
    }
}

//Funzione che mette highlight nelle FAQ
function highlight(ul, uloff, li) 
{
    tot = document.getElementById(ul).getElementsByTagName("li");
    for (n = 0; n < tot.length; n++) {
		tot[n].style.background = "url(gfx/bg_li_lightblue.gif)";
		tot[n].style.backgroundPosition = "5px 2px";
		tot[n].style.backgroundRepeat = "no-repeat";
	}
	if (uloff!="") {
		tot = document.getElementById(uloff).getElementsByTagName("li");
		for (n = 0; n < tot.length; n++) {
			tot[n].style.background = "url(gfx/bg_li_lightblue.gif)";
			tot[n].style.backgroundPosition = "5px 2px";
			tot[n].style.backgroundRepeat = "no-repeat";
		}
	}
	li.style.background = "#aecef4 url(gfx/bg_li_lightblue.gif)";
	li.style.backgroundPosition = "5px 2px";
	li.style.backgroundRepeat = "no-repeat";
	return true;
}

//Funzione che apre l'overlayer e nasconde lo scroll
function overlay(code) 
{
    ff = document.getElementById(code);
	hh = document.getElementsByTagName("html");
		if (ff.style.display == "") {
			ff.style.display = "none";
			hh[0].style.overflow = "";
		} else if (ff.style.display == "none") {
			ff.style.display = "";
			hh[0].style.overflow = "hidden";
		}
}

//Funzione che apre e chiude un div cliccando sul link
function THISonTHISoff(code) 
{
    ff = document.getElementById(code);
		if (ff.style.display == "") {
		    ff.style.display = "none";
		} else
		if (ff.style.display == "none") {
			ff.style.display = "";
		}
}

//Funzione che apre la popup
function Popup(url, stile) 
{
	window.open(url, "", stile);
}

//Funzione che rileva l'oggetto flash in base al browser (chiamate diverse)
function getFlashMovieObject(movieName) 
{
	if (window.document[movieName])
	{
		return window.document[movieName];
	}
	if (navigator.appName.indexOf("Microsoft Internet")==-1)
	{
		if (document.embeds && document.embeds[movieName])
			return document.embeds[movieName];
	}
	else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
	{
		return document.getElementById(movieName);
	}
}
