//**************************************************
//**                                              **
//**                Script by jure                **
//**           giorgiobeggiora@email.it           **
//**                                              **
//**************************************************

function openWindow(theURL, theName, theFeatures) { //v2.0
  window.open(theURL, theName, theFeatures);
}

function popupBanner(pagina, titolo) {
	window.href='#';
  window.open(pagina,titolo,'height=410, width=560');
}

function apriTri() {
	window.href='#';
  window.open('/allianzit/it/triennale/popup_triennale.html','Triennale','height=465, width=650');
}

function pop(){
	// created by webanana www.e-tree.com
	// pop ( href [,target] [,x] [,y] [,"fullscreen"] [,"center"] [,"scroll"|"noscroll"] )

	var x,y,o,_target="",_params=new Array(),center=false;

	if(arguments.length>0){
		_url=arguments[0];
		for(i=1;i<arguments.length;i++){
			if(isNaN(arguments[i])){
				switch(arguments[i]){
					case"center":
						center=true;
						if( x!=undefined && y!=undefined ){
							_params[_params.length]="left="+((screen.width-x)/2);
							_params[_params.length]="top="+((screen.height-y)/2);
						}
					break;
					case"scroll":
						_params[_params.length]="scrollbars=yes";
					break;
					case"noscroll":
						_params[_params.length]="scrollbars=no";
					break;
					case"fullscreen":
						_params[_params.length]="fullscreen=yes";
					break;
					default:
						_target=arguments[i];
					break;
				}
			}else{
				if(x==undefined){
					x=arguments[i];
					_params[_params.length]="width="+x;
				}else{
					y=arguments[i];
					_params[_params.length]="height="+y;
					if(center){
						_params[_params.length]="left="+((screen.width-x)/2);
						_params[_params.length]="top="+((screen.height-y)/2);
					}
				}
			}
		}

		//alert(url);
		o=window.open(_url,_target,_params.join(","));
		if(o==undefined)alert("L'apertura della finestra è stata bloccata");

	}
}



//Gestione Errore
var c=1;
function handleError(){
if(c>1) location.reload(true);
return true;
}
window.onerror=handleError;

//Dichiarazione Browser, Versione Browser e Sistema Operativo
var safeIEstring = navigator.appVersion;
var VER = parseInt(safeIEstring);
var OS;
var BW;
if(safeIEstring.indexOf("Macintosh") != -1) OS="Mac";
if(safeIEstring.indexOf("Windows") != -1) OS="Win";
if(document.all){
	if(!document.getElementById || (document.getElementById && safeIEstring.indexOf("Opera") == -1)){
		BW="IE";
}
}


/*

modifica ad HOC per i browser Internet Explorer versione >= 5

*/
var vOP = ((ind1 = navigator.userAgent.indexOf("Opera")) > -1) ? 1 : 0;
var vIE = ((ind2 = navigator.appVersion.indexOf("MSIE")) > -1 && !vOP) ? 1 : 0;
var vIE4 = (vIE && parseInt(navigator.appVersion.substr(ind2+5)) == 4) ? 1 : 0;
var vIE5 = (vIE && parseInt(navigator.appVersion.substr(ind2+5)) == 5) ? 1 : 0;
var vIE6 = (vIE && parseInt(navigator.appVersion.substr(ind2+5)) == 6) ? 1 : 0;

//Funzione per la stampa
function printMe(){

if((vIE4) && OS=="Win"){
	document.all.WebBrowser2.ExecWB(6, 1); //1=con 2=senza
	document.all.WebBrowser2.outerHTML = "";
}else{

if(window.print) {self.print();}
else alert("Il Browser non supporta la stampa via Javascript.\nStampare dal Menu del browser")
}
}

function printMappa(){

if(window.print) self.print();
}

if((vIE4) && OS=="Win") document.write("<object ID=WebBrowser2 WIDTH=0 HEIGHT=0 CLASSID=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2></object>");

function apriChiudi(div){
if (document.all) {
var doc="document.all.";
var style=".style";
var chiudi="";

} else {
var doc="document.getElementById('";
var style="').style";
var chiudi="')";
}

    visibilita=eval(doc+div+style).visibility;
    if(visibilita=="hidden"){visibilita="visible"}
    else if(visibilita=="visible"){visibilita="hidden"}
    var z = (visibilita=="hidden") ? false : true;
	    var vis =(z)? "visible" : "hidden";
	    var disp =(z)? "" : "none";
	    var img =(z)? "/allianzit/images/bullet/freccia_aperta.gif" : "/allianzit/images/bullet/freccia_chiusa.gif";
        eval(doc+'freccia_'+div+chiudi).src=img;
         lay = eval(doc+div+style);
    lay.visibility = vis;
    lay.display =disp ;
}


function show(cosa){
if (document.all) {
var doc="document.all.";
var style=".style";
var chiudi="";
} else {
var doc="document.getElementById('";
var style="').style";
var chiudi="')";
}
if(cosa=='commerciali'){var noncosa="istituzionali";
if(eval(doc+'formContatti'+chiudi)){
eval(doc+'formContatti'+style).visibility='visible';
eval(doc+'formContatti'+style).display='';}
} else {
if(eval(doc+'formContatti'+chiudi)){
eval(doc+'formContatti'+style).visibility='hidden';
eval(doc+'formContatti'+style).display='none';}

}
var noncosa = (cosa=='commerciali') ? 'istituzionali' : 'commerciali';
eval(doc+cosa+style).visibility='visible';
eval(doc+cosa+style).display='';
eval(doc+cosa+'_on'+style).visibility='visible';
eval(doc+cosa+'_on'+style).display='';

eval(doc+noncosa+style).visibility='hidden';
eval(doc+noncosa+style).display='none';
eval(doc+noncosa+'_on'+style).visibility='hidden';
eval(doc+noncosa+'_on'+style).display='none';
}

function uscitaSito(goToURL) {
        url = "/uscita-sito?goto=" + goToURL
        window.open(url , 'popupuscita' ,'toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,width=430,height=350,top=100,left=200');
}
/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */

function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}



function myGetCookie(name)
{
  if (document.cookie)
  {
    var cookies=document.cookie.split(";");
    for (var i=0; i<cookies.length; i++)
    {
      var varName=(cookies[i].split("=")[0]);
      var varValue=(cookies[i].split("=")[1]);

      while (varName.charAt(0)==" ")
        varName=varName.substr(1,varName.length);

      // the escape() function will url encode the value
      if (varName==name)
        return escape(varValue);
    }
  }
  return " ";
}



var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;


// Hook for Internet Explorer
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 &&
  navigator.userAgent.indexOf("Windows") != -1 &&
  navigator.userAgent.indexOf("Windows 3.1") == -1)
{
  document.write('<SCRIPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('Sub main_FSCommand(ByVal command, ByVal args)\n');
  document.write('  call main_DoFSCommand(command, args)\n');
  document.write('end sub\n');
  document.write('</SCRIPT\> \n');
}



// Handle all the the FSCommand messages in a Flash movie
function main_DoFSCommand(command, args) {
  var getCookieObj = InternetExplorer ? main : document.main ;

  // Place your code here...
  if (command=="getCookie")
  {
        // myGetCookie function is defined above
  	var cookieValue=myGetCookie(args);
  	if (cookieValue==" ")
        {
  	  		//alert("Cookie not found, please set cookie first");
        	//cookieValue="[not found]";
        	cookieValue="";
        	//alert("setto cookieValue a " + cookieValue);
        	getCookieObj.SetVariable("cookieValue", "");

        }
    else {
			getCookieObj.SetVariable("cookieValue", cookieValue);
	  }


  }
}

function mredirect(sel){
	lang = sel.options[sel.selectedIndex].value;
	if ( lang == 'it'){	
		window.location= 'http://'+location.hostname+'/home.htm';
	} else{
		window.location= 'http://'+location.hostname+'/'+lang +'/home.htm';
	}
}
