// Funzione che apre un div e chiude tutti gli altri //

function THISonTHAToff(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 = "";
            }
        }
    }
}

// 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 chiude il div

function closeDiv(arg)
{
	if (arg)
	{
		var divToClose=document.getElementById(arg);
		if (divToClose)
			divToClose.style.display='none';
	}
}
// Funzione che apre la popup //

function Popup(url, stile) {
	window.open(url, "", stile);
	}
	
// Cambia classe //

function showMenu() 
{
     document.getElementById("slider_cont").style.visibility = 'visible';
	 document.getElementById("menu_hor").style.visibility = 'visible';
}

//Funzione che cambia il caption degli elementi specificati
function changeCaption(arg, layer)
{
	if (arg && layer)
	{
		var layerToCheck=document.getElementById(layer);
		var padre;
		padre=(arg.parentElement!=null) ? arg.parentElement : arg.parentNode;	
		if (layerToCheck.style.display!="none")
		{
			padre.className="chiudi_elenco";
			arg.innerHTML=arg.innerHTML.replace("Espandi", "Chiudi");
		}
		else
		{
			padre.className="espandi_elenco";		
			arg.innerHTML=arg.innerHTML.replace("Chiudi", "Espandi");
		}
	}
}

function changeMedia(arg, layer, mediaType)
{
	layerToReplace=document.getElementById(layer);
	flashcontainerx=document.getElementById("flashcontainer");
	var elements=window.location.href.split("/");
	var fileToRedirect=elements[elements.length-1];
	if (layerToReplace)
	{
		if (mediaType==1)	//flash
		{
			location.href=fileToRedirect;
		}
		else if (mediaType==2)	//jpg
		{
			flashcontainerx.style.display='none';
			layerToReplace.innerHTML="<img src=\"./gfx/big_"+arg+"\" border=\"0\">";
		}
	}
}

//Menu Gallery
if (document.location.pathname.indexOf("superDryFoto.aspx") == -1 && document.location.pathname.indexOf("superDryVideo.aspx") == -1) 
	{
		$(document).ready(function(){
	
			$("#SD_fotovideo").hover(
				function() {
					$("#menu_SuperDry_FotoVideo").show();
				}, 
				function() {
					$("#menu_SuperDry_FotoVideo").hide();
				}
			);
			
			
			$(".SD_foto").hover(function() { $("#menu_SuperDry_FotoVideo").show(); }, function() {
				$("#menu_SuperDry_FotoVideo").hide();
			});	
			$(".SD_video").hover(function() {$("#menu_SuperDry_FotoVideo").show(); }, function() {
				$("#menu_SuperDry_FotoVideo").hide();
			});	
		
			$("#menu_SuperDry_FotoVideo").hide();
	});

		}
