/*
* Main Script 1 - 4incentive(c) 2007 Ferra srl
*/
var isIE  = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
<!-- Ajax --->
function GetXmlHttpObject(handler)
{ 
 var objXmlHttp=null;
 if (navigator.userAgent.indexOf("Opera")>=0) return; 
 if (navigator.userAgent.indexOf("MSIE")>=0)
 { 
  var strName="Msxml2.XMLHTTP"
  if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
  {
  strName="Microsoft.XMLHTTP"
  } 
 try
 { 
  objXmlHttp=new ActiveXObject(strName);
  objXmlHttp.onreadystatechange=handler;
  return objXmlHttp;
 } 
 catch(e)
 { 
  alert("Error. Scripting for ActiveX might be disabled") 
  return 
 } 
}

 if (navigator.userAgent.indexOf("Mozilla")>=0)
 {
  objXmlHttp=new XMLHttpRequest(); objXmlHttp.onload=handler; objXmlHttp.onerror=handler; return objXmlHttp;
 }
}

<!-- Flash --->
function FlashWrite(movie,data,fwidth,fheight,bg) {
   var html = '';
   html += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
   html += 'codebase="'+location.protocol+'//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" ';
   html += 'width="'+fwidth+'" height="'+fheight+'" id="Ferra" align="middle">';
   html += '<param name="movie" value="'+movie+'">';
   html += '<param name="quality" value="high">';
   html += '<param name="bgcolor" value="'+bg+'">';
   if (isIE) {
      html += '<param name="FlashVars" value="'+unescape(data)+'">';
   }
   html += '<embed src="'+movie+'" ';
   html += 'quality="high" bgcolor="#ffffff" ';
   html += 'width="'+fwidth+'" height="'+fheight+'" align="middle" wmode="transparent"';
   html += 'type="application/x-shockwave-flash" ';
   html += 'pluginspage="http://www.macromedia.com/go/getflashplayer" ';
   if (!isIE) {
      html += 'FlashVars="'+unescape(data)+'" ';
   }
   html += '></object>';
   document.write(html);
	return html;	
}

function FlashWriteEx(movie,data,fwidth,fheight,bg,id,nowrite,fTrasp) {
	var html = '';
	if (!id) id="Ferra";
	html+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
	html+='codebase="'+location.protocol+'//fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
 	html+='width="'+fwidth+'" height="'+fheight+'"';
 	html+=' id="'+id+'" align="middle">';
 	html+='<param name="movie" value="'+movie+'">';
 	html+='<param name="quality" value="high">';
 	if (bg) html+='<param name="bgcolor" value="'+bg+'">';
	if (fTrasp) html+='<param name="wmode" value="transparent">';

 	if (isIE) {html += '<param name="FlashVars" value="'+data+'">';}
 	html+='<embed src="'+movie+'" ';
 	html+='quality="high" bgcolor="#ffffff" ';
 	html+='width="'+fwidth+'" height="'+fheight+'" name="'+id+'" align="middle" wmode="transparent" ';
	html+='type="application/x-shockwave-flash" ';
 	html+='pluginspage="http://www.macromedia.com/go/getflashplayer" ';
 	if (!isIE) {html += 'FlashVars="'+unescape(data)+'" ';}
 	html += '></object>';
	if (!nowrite) document.write(html);
	return html;	
}

<!-- Dhtml --->
function getSize() {
  var size= { size:cx=0, size:cy=0 };
  
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
	 size.cx =window.innerWidth;	
	 size.cy= window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    size.cx = document.documentElement.clientWidth;
    size.cy = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    size.cx = document.body.clientWidth;
    size.cy = document.body.clientHeight;
  }
	return size;
}

function getElmHeight(obj) {
if (typeof(obj)=='string') obj=document.getElementById(obj);
if (obj.clientHeight) return obj.clientHeight; 
if (obj.offsetHeight) return obj.offsetHeight;
if (obj.style.height) return obj.style.height;
return null;
}
function getElmWidth(obj) {
if (typeof(obj)=='string') obj=document.getElementById(obj);
if (obj.clientWidth) return obj.clientWidth; 
if (obj.offsetWidth) return obj.offsetWidth;
if (obj.style.width) return obj.style.width;
return null;
}

function setPosition(objMove,dove,objRif)
{
  var obj,w,h,ow,oh;
  var orif,p;
  if (!objRif)
  {
	obj=document.getElementById(objMove); if (!obj) return;
	w=parseInt(obj.style.width);	h=parseInt(obj.style.height);
	size=getSize(); 
	p=dove.substring(0,1);
	if (p=='l') obj.style.left="0px";
	if (p=='c') obj.style.left=((size.cx-w)/2)+"px";
	if (p=='r') obj.style.left=(size.cx-w)+"px";

	p=dove.substring(1,2);
	if (p=='t') obj.style.top="0px";
	if (p=='m') obj.style.top=((size.cy-h)/2)+"px";
	if (p=='b') obj.style.top=(size.cy-h)+"px";
  }
  else
  {
	if (typeof(objRif)=='string') orif=document.getElementById(objRif); else orif=objRif;
	if (!orif) return;
	obj=document.getElementById(objMove); if (!obj) return;
	w=parseInt(getElmWidth(obj));	h=parseInt(getElmHeight(obj)); 
	ow=parseInt(getElmWidth(orif)); oh=parseInt(getElmHeight(orif)); 
	p=dove.substring(0,1);
	if (p=='l') obj.style.left=orif.offsetLeft+"px";
	if (p=='c') obj.style.left=orif.offsetLeft+(ow>>1)-(w>>1)+"px";
	if (p=='r') obj.style.left=(orif.offsetLeft+ow-w)+"px";
	p=dove.substring(1,2);
	if (p=='t') obj.style.top=orif.offsetTop+"px";
	if (p=='m') obj.style.top=orif.offsetTop+(oh>>1)-(h>>1)+"px";
	if (p=='b') obj.style.top=(orif.offsetTop+oh-h)+"px";
	}
}
function setVisible(layName,swt)
{
 if     (swt == 1) {var option = 'visible';var disp='block';}
 else if(swt == 0) {var option = 'hidden';var disp='none';}
 else              var option = 'inherit'
 
 if(document.getElementById)
	{
	  if (typeof(layName)!='object') layName=document.getElementById(layName);
      layName.style.visibility=option;
      layName.style.display=disp;
}
 else if(document.layers)document.layers[layName].visibility=option;
 else if(document.all)document.all(layName).style.visibility=option;
}
function Tog(id)
{
	var div=document.getElementById(id); if (!div) return;
	var fVisible=(!div.style.visibility.length||div.style.visibility=='hidden')?0:1;
	fVisible^=1; setVisible(id,fVisible);
	return fVisible;
}

function setOnLoad(fun)
{
	if(typeof window.addEventListener != 'undefined') //.. gecko, safari, konqueror and standard
	{
		window.addEventListener('load', fun, false);
	}
	else if(typeof document.addEventListener != 'undefined') //.. opera 7
	{
		document.addEventListener('load', fun, false);
	}
	else if(typeof window.attachEvent != 'undefined') //.. win/ie
	{
		window.attachEvent('onload', fun);
	}
}
<!-- Cookie ---------------->
var expdate = new Date();
expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 
function getCookieVal(offset) 
{
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1) endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}
function getCookie(name) 
{
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) 
      {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg) return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break; 
      }
   return null;
}
function setCookie(name,value) 
{
   var argv = setCookie.arguments;
   var argc = setCookie.arguments.length;
   var expires = (2 < argc) ? argv[2] : null;
   var path = (3 < argc) ? argv[3] : null;
   var domain = (4 < argc) ? argv[4] : null;
   var secure = (5 < argc) ? argv[5] : false;
   if (expires=='never') /* 1000 giorni */
   {
    var today = new Date();
	expires = new Date( today.getTime() + 1000 * 1000 * 60 * 60 * 24);
   }
   document.cookie = name + "=" + escape (value) +
     ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
     ((path == null) ? "" : ("; path=" + path)) +
     ((domain == null) ? "" : ("; domain=" + domain)) +
     ((secure == true) ? "; secure" : "");
}

<!-- Utility ------------->
function isEmail(email)
{
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
return re.test(email);
}
function isNumber(obj){return (typeof(obj)=='number');}
function EuroFormat(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+'.'+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '' + num + ',' + cents);
}


function getValue(id) {var obj=getElementById(id); return obj.value;}
function Go(page) {document.location.href=page;}
