isMacOs = (navigator.appVersion.indexOf('Mac')>=0)?true:false;
isScreenOk = ((screen.height > 600)&&(screen.width > 800))?true:false;
isSafari = (navigator.userAgent.indexOf("Safari")!=-1)?true:false;
isIe = (navigator.userAgent.indexOf("MSIE")!=-1)?true:false;
isGecko = (navigator.userAgent.indexOf("Gecko")!=-1)?true:false;


////////////////////////////////////////
function cssAdjust(){
  if (isIe && !isMacOs){
	document.write('<link rel="stylesheet" type="text/css" href="css/screen_msiePc.css?ver=4" />')
  } else if (!document.layers){
    document.write('<link rel="stylesheet" type="text/css" href="css/screen_others.css?ver=4" />')
  }
}
cssAdjust();
////////////////////////////////////////

function openPopup(file,name,pWidth,pHeight,scroll)
{
 var scrollbars = "";
 var h = ((screen.height)-(pHeight))/2;
 var w = ((screen.width)-(pWidth))/2;
 if ( scroll == true ) { scrollbars=",scrollbars" }
 //if (!isScreenOk) { alert("Attenzione!\nPer vedere correttamente questo sito è necessario avere un monitor con una risoluzione di 800x600 pixel"); }
 if (isMacOs) { pWidth = pWidth - 16; pHeight = pHeight - 16; }
 if ((isMacOs)&&(isSafari)) { pWidth = pWidth + 16; pHeight = pHeight + 16; }
 //name = window.open(file,name,'width='+ pWidth +',height='+ pHeight +',top='+h+',left='+w+''+scrollbars+'');
 eval (name +"= window.open(file,name,'width='+ pWidth +',height='+ pHeight +',top='+h+',left='+w+''+scrollbars+'');") 
}


function titolo(area,testo,largh,linkage){
	ver = 4
	str =  "<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"  codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\"  WIDTH=\""+largh+"\" HEIGHT=\"18\" id=\"img_fieralibro\" ALIGN=\"\">"
	str += "<PARAM NAME=movie VALUE=\"swf/titolo.swf?ver="+ver+"\">" 
	str += "<PARAM NAME=\"flashVars\" VALUE=\"selected="+area+"&text="+testo+"&link="+linkage+"\">"
	str += "<PARAM NAME=quality VALUE=high> "
	str += "<PARAM NAME=scale VALUE=noscale> "
	str += "<PARAM NAME=salign VALUE=L> "
	str += "<PARAM NAME=bgcolor VALUE=#FFFFFF> "
	str += "<EMBED src=\"swf/titolo.swf?ver="+ver+"\" SALIGN=\"LT\" flashVars=\"selected="+area+"&text="+testo+"&link="+linkage+"\" SCALE=\"noscale\" quality=high bgcolor=#FFFFFF  WIDTH=\""+largh+"\" HEIGHT=\"18\" NAME=\"img_fieralibro\" ALIGN=\"\"  TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED>"
	str += "</OBJECT>"
	document.write(str)
}


function writeSWF(url,width,height){
	ver = 4
	str =  "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\""+width+"\" height=\""+height+"\">";
  	str += "<param name=\"movie\" value=\""+url+"\">";
  	str += "<param name=\"quality\" value=\"high\">"
  	str += "<embed src=\""+url+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+width+"\" height=\""+height+"\"></embed>";
	str += "</object>";

	document.write(str)
}
/////////////////////////////////////
function swapImage(name,status){
	if(status){
	document.images[name].src = "images/"+name+"_1.gif"
	}else{
	document.images[name].src = "images/"+name+"_0.gif"
	}
}
/////////////////////////////////////

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_validateForm() { //v4.0
  var validEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1) || !validEmail.exec(val)) errors+='- '+nm+' deve contenere un indirizzo email.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' deve essere un numero.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+'deve essere un numero compreso tra '+min+' e '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' è obbligatorio.\n'; }
  } if (errors) alert('E\' occorso almeno un errore:\n'+errors);
  document.MM_returnValue = (errors == '');
}


function printDoc()
{
  if (isMacOs) 
    { 
	alert("Attenzione!\nPer stampare il documento con un MacIntosh è necessario schiacciare MELA+P"); 
	}
  else
    {
	 
	  self.print();
	  
  }
}


function openPlan(url,querystring){
 openPopup(url+"?"+querystring,"plan",770,450)
}
////////////////////////////////////////////////////////////////////////////////
//  ADD EVENTS
////////////////////////////////////////////////////////////////////////////////

function addEvent(obj, eventName, fn)
{
    var prev = obj[eventName];
    obj[eventName] = prev ? function() { fn() ; prev() } : fn;
}
 
//addEvent( window, "onunload", checkPlanExistence);
function writeVideo(titolo,path,src,size,durata){
str  = "<div class=\"videoBox\">"
str += "	<h3>"+titolo+"</h3>"
//str += "	<div class=\"videoShot\"><a href=\"javascript:void(0)\" onclick=\"openPopup('/fiera/popups/videowmv.html?"+path+"/"+src+"','_video',192,224)\"><img src=\"/fiera/img/video/screens/"+src+".jpg\" alt=\"\" border=\"0\" /></a></div>"
str += "	<div class=\"videoDesc\">"
str += "	<strong>Titolo:</strong> "+titolo+"<br />"
str += "	<strong>Dimensione:</strong> "+size+"<br />"
str += "	<strong>Durata:</strong> "+durata+"<br />"
str += "	<strong>Formato:</strong> VMW<br /><br />"
str += "	<a href=\"javascript:void(0)\" onclick=\"openPopup('/fiera/popups/videowmv.html?"+path+"/"+src+"','_video',192,224)\">PLAY »</a>"
str += "	</div><div class=\"dummy\"></div>"
str += "</div>"

document.write(str)
}