// JavaScript Document file funhomepage.js
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_changeProp(objName,x,theProp,theValue) { //v3.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+theValue+"'");
}
function showcredits() {
	MM_changeProp('credits','','style.visibility','visible','DIV');
	MM_changeProp('credits','','visibility','show','DIV');
}
function hidecredits() {
	MM_changeProp('credits','','style.visibility','hidden','DIV');
	MM_changeProp('credits','','visibility','hide','DIV');
}
function visDiv(lingua) {
  switch (lingua) {
	case "ITA" :
	MM_changeProp('content_ita','','style.visibility','visible','DIV');
	MM_changeProp('content_ita','','visibility','show','DIV');
	MM_changeProp('content_eng','','style.visibility','hidden','DIV');
	MM_changeProp('content_eng','','visibility','hide','DIV');
	MM_changeProp('content_fra','','style.visibility','hidden','DIV');
	MM_changeProp('content_fra','','visibility','hide','DIV');
	MM_changeProp('content_ger','','style.visibility','hidden','DIV');
	MM_changeProp('content_ger','','visibility','hide','DIV');
	
	MM_changeProp('linkita','','style.visibility','visible','DIV');
	MM_changeProp('linkita','','visibility','show','DIV');
	MM_changeProp('linking','','style.visibility','hidden','DIV');
	MM_changeProp('linking','','visibility','hide','DIV');
	MM_changeProp('linkfra','','style.visibility','hidden','DIV');
	MM_changeProp('linkfra','','visibility','hide','DIV');
	MM_changeProp('linkger','','style.visibility','hidden','DIV');
	MM_changeProp('linkger','','visibility','hide','DIV');
	break;
	case "ENG" :
	MM_changeProp('content_eng','','style.visibility','visible','DIV');
	MM_changeProp('content_eng','','visibility','show','DIV');
	MM_changeProp('content_ita','','style.visibility','hidden','DIV');
	MM_changeProp('content_ita','','visibility','hide','DIV');
	MM_changeProp('content_fra','','style.visibility','hidden','DIV');
	MM_changeProp('content_fra','','visibility','hide','DIV');
	MM_changeProp('content_ger','','style.visibility','hidden','DIV');
	MM_changeProp('content_ger','','visibility','hide','DIV');

	MM_changeProp('linking','','style.visibility','visible','DIV');
	MM_changeProp('linking','','visibility','show','DIV');
	MM_changeProp('linkita','','style.visibility','hidden','DIV');
	MM_changeProp('linkita','','visibility','hide','DIV');
	MM_changeProp('linkfra','','style.visibility','hidden','DIV');
	MM_changeProp('linkfra','','visibility','hide','DIV');
	MM_changeProp('linkger','','style.visibility','hidden','DIV');
	MM_changeProp('linkger','','visibility','hide','DIV');
	break;
	case "FRA" :
	MM_changeProp('content_fra','','style.visibility','visible','DIV');
	MM_changeProp('content_fra','','visibility','show','DIV');
	MM_changeProp('content_ita','','style.visibility','hidden','DIV');
	MM_changeProp('content_ita','','visibility','hide','DIV');
	MM_changeProp('content_eng','','style.visibility','hidden','DIV');
	MM_changeProp('content_eng','','visibility','hide','DIV');
	MM_changeProp('content_ger','','style.visibility','hidden','DIV');
	MM_changeProp('content_ger','','visibility','hide','DIV');
 
 	MM_changeProp('linkfra','','style.visibility','visible','DIV');
	MM_changeProp('linkfra','','visibility','show','DIV');
	MM_changeProp('linking','','style.visibility','hidden','DIV');
	MM_changeProp('linking','','visibility','hide','DIV');
	MM_changeProp('linkita','','style.visibility','hidden','DIV');
	MM_changeProp('linkita','','visibility','hide','DIV');
	MM_changeProp('linkger','','style.visibility','hidden','DIV');
	MM_changeProp('linkger','','visibility','hide','DIV');
	break;
	case "GER" :
	MM_changeProp('content_ger','','style.visibility','visible','DIV');
	MM_changeProp('content_ger','','visibility','show','DIV');
	MM_changeProp('content_ita','','style.visibility','hidden','DIV');
	MM_changeProp('content_ita','','visibility','hide','DIV');
	MM_changeProp('content_eng','','style.visibility','hidden','DIV');
	MM_changeProp('content_eng','','visibility','hide','DIV');
	MM_changeProp('content_fra','','style.visibility','hidden','DIV');
	MM_changeProp('content_fra','','visibility','hide','DIV');

	MM_changeProp('linkger','','style.visibility','visible','DIV');
	MM_changeProp('linkger','','visibility','show','DIV');
	MM_changeProp('linking','','style.visibility','hidden','DIV');
	MM_changeProp('linking','','visibility','hide','DIV');
	MM_changeProp('linkfra','','style.visibility','hidden','DIV');
	MM_changeProp('linkfra','','visibility','hide','DIV');
	MM_changeProp('linkita','','style.visibility','hidden','DIV');
	MM_changeProp('linkita','','visibility','hide','DIV');
	break;
  }
}
// function x caricamento pop-up prenotazioni
function popup_prenot(theURL) { 
  var popprenot=0;
  // testo se esiste già l'applicazione aperta
  if (!popprenot) {
	  if (document.layers){ /* Netscape 4.x */
	    param="menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,width=700,height=500"
	  }
	  else if (document.all){ /* Explorer */
	    LeftPosition=(screen.width) ? (screen.width-700-30)/2 : 0;          
	    TopPosition=(screen.height) ? (screen.height-500+30)/2 : 0;
	    param="menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,width=700,height=500,top="+TopPosition+",left="+LeftPosition;
	  }
	  else if (document.getElementById){ /* Netscape 6 */
	    param="menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,width=700,height=500";
	  }
	  popprenot = window.open(theURL,'popprenot',param);
  }
}
// fine function x caricamento pop-up prenotazioni

/*
 * FlashObject embed
 * http://blog.deconcept.com/2004/10/14/web-standards-compliant-javascript-flash-detect-and-embed/
 * Usage:
 *
 *  myFlash = new FlashObject("path/to/swf.swf", "swfid", "width", "height", flashversion, "backgroundcolor");
 *  myFlash.altTxt = "Upgrade your Flash Player!";                // optional
 *  myFlash.addParam("wmode", "transparent");                     // optional
 *  myFlash.addVariable("varname1", "varvalue");                  // optional
 *  myFlash.addVariable("varname2", getQueryParamValue("myvar")); // optional
 *  myFlash.write();
 *
 */

FlashObject = function(swf, id, w, h, ver, c, al) {
    this.swf = swf;
    this.id = id;
    this.width = w;
    this.height = h;
    this.version = ver || 8; // default to 8
    this.align = al || "middle"; // default to middle
    this.redirect = "noflash.html";
    this.sq = document.location.search.split("?")[1] || "";
    this.altTxt = "Please <a href='http://www.macromedia.com/go/getflashplayer'>upgrade your Flash Player</a>.";
    this.bypassTxt = "<p>Already have Flash Player? <a href='?detectflash=false&"+ this.sq +"'>Click here if you have Flash Player "+ this.version +" installed</a>.</p>";
    this.params = new Object();
    this.variables = new Object();
    if (c) this.color = this.addParam('bgcolor', c);
    this.addParam('quality', 'high'); // default to high
    this.doDetect = getQueryParamValue('detectflash');
}

FlashObject.prototype.addParam = function(name, value) {
    this.params[name] = value;
}

FlashObject.prototype.getParams = function() {
    return this.params;
}

FlashObject.prototype.getParam = function(name) {
    return this.params[name];
}

FlashObject.prototype.addVariable = function(name, value) {
    this.variables[name] = value;
}

FlashObject.prototype.getVariable = function(name) {
    return this.variables[name];
}

FlashObject.prototype.getVariables = function() {
    return this.variables;
}

FlashObject.prototype.getParamTags = function() {
    var paramTags = "";
    for (var param in this.getParams()) {
        paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
    }
    if (paramTags == "") {
        paramTags = null;
    }
    return paramTags;
}

FlashObject.prototype.getHTML = function() {
    var flashHTML = "";
    if (window.ActiveXObject && navigator.userAgent.indexOf('Mac') == -1) { // PC IE
        flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '">';
        flashHTML += '<param name="movie" value="' + this.swf + '" />';
        if (this.getParamTags() != null) {
            flashHTML += this.getParamTags();
        }
        if (this.getVariablePairs() != null) {
            flashHTML += '<param name="flashVars" value="' + this.getVariablePairs() + '" />';
        }
        flashHTML += '</object>';
    }
    else { // Everyone else
        flashHTML += '<embed type="application/x-shockwave-flash" src="' + this.swf + '" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '"';
        for (var param in this.getParams()) {
            flashHTML += ' ' + param + '="' + this.getParam(param) + '"';
        }
        if (this.getVariablePairs() != null) {
            flashHTML += ' flashVars="' + this.getVariablePairs() + '"';
        }
        flashHTML += '></embed>';
    }
    return flashHTML;   
}


FlashObject.prototype.getVariablePairs = function() {
    var variablePairs = new Array();
    for (var name in this.getVariables()) {
        variablePairs.push(name + "=" + escape(this.getVariable(name)));
    }
    if (variablePairs.length > 0) {
        return variablePairs.join("&");
    }
    else {
        return null;
    }
}

FlashObject.prototype.write = function(elementId) {
    if(detectFlash(this.version) || this.doDetect=='false') {
        if (elementId) {
            document.getElementById(elementId).innerHTML = this.getHTML();
        } else {
            document.write(this.getHTML());
        }
    } else {
        if (this.redirect != "") {
            document.location.replace(this.redirect);
        } else {
            if (elementId) {
                document.getElementById(elementId).innerHTML = this.altTxt +""+ this.bypassTxt;
            } else {
                document.write(this.altTxt +""+ this.bypassTxt);
            }
        }
    }       
}

function getFlashVersion() {
    var flashversion = 0;
    if (navigator.plugins && navigator.plugins.length) {
        var x = navigator.plugins["Shockwave Flash"];
        if(x){
            if (x.description) {
                var y = x.description;
                //alert("fpstring:" + y);
				flashversion = y.charAt(y.indexOf('.')-1);
				if(flashversion < 5){
					flashversion=10 + flashversion;
				}
            }
        }
    } else {
        result = false;
        for(var i = 15; i >= 3 && result != true; i--){
            execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
            flashversion = i;
        }
    }
    return flashversion;
}

function detectFlash(ver) { 
	//alert("fver:" + getFlashVersion() );
    if (getFlashVersion() >= ver) {
        return true;
    } else {
        return false;
    }
}

// get value of querystring param
function getQueryParamValue(param) {
    var q = document.location.search;
    var detectIndex = q.indexOf(param);
    var endIndex = (q.indexOf("&", detectIndex) != -1) ? q.indexOf("&", detectIndex) : q.length;
    if(q.length > 1 && detectIndex != -1) {
        return q.substring(q.indexOf("=", detectIndex)+1, endIndex);
    } else {
        return true;
    }
}

var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

