/*
	This script (c) 2000 Ivanopulo / DAMN -- http://www.damn.to
	You're free to use it, but please leave this message intact if you do it.
	
	Thanks alot to Marek for making this script NN6 compatible
	
	NN6 notice: It's *very* slow when it comes to timers, and it's an understatement!)
	
	Opera notice: Opera can identify itself as any browser, depending on value chosen
	in Preferences / Connections / Browser identification. This script assumes that it
	identifies itself as Opera. I dare not say it's a bold assumption, but it's default
	is MSIE 5. Go figure.
*/

var bNetscape4	 = (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1) == "4");
var bNetscape6	 = (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1) >= "5");
var bExplorer4plus = (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.substring(0,1) >= "4");
var bOpera5		= (navigator.appName == "Opera" && navigator.appVersion.substring(0,1) >= "5" );

var nn6DivMenu; // specially for NN6 to speed up things at least a little
var topoffset = 1;
var wheigth;


function CheckUIElements()
{
	var yMenuFrom, yMenuTo, yButtonFrom, yButtonTo, yOffset, timeoutNextCheck;
	
	if ( bNetscape4 ) {
		yMenuFrom   = document["divMenu"].top;
		yMenuTo	 = top.pageYOffset + topoffset;
		wheight = top.innerHeight;
	}
	else if ( bExplorer4plus ) {
		yMenuFrom   = parseInt (divMenu.style.top, 10);
		yMenuTo	 = document.body.scrollTop + topoffset;
		wheight = document.body.clientHeight;
	}
	else if ( bNetscape6 ) {
		yMenuFrom   = nn6DivMenu.style.top.replace(/px/,"");
		yMenuTo	 = top.pageYOffset + topoffset;
		wheight = top.innerHeight;
	}
	else if ( bOpera5 ) {
		yMenuFrom   = nn6DivMenu.style.top;
		yMenuTo	 = top.pageYOffset + topoffset;
		wheight = top.innerHeight;
	}
	
	
	timeoutNextCheck = 500;
	
	if ( yMenuFrom != yMenuTo && wheight >= 588 ) {
	
		if ( bNetscape6 )
			yOffset = Math.ceil( Math.abs( yMenuTo - yMenuFrom ) / 10 );
		else
			yOffset = Math.ceil( Math.abs( yMenuTo - yMenuFrom ) / 30 );
			
		if ( yMenuTo < yMenuFrom )
			yOffset = -yOffset;
		
		timeoutNextCheck = 10;

		if ( bNetscape4 )
			document["divMenu"].top += yOffset;
		else if ( bExplorer4plus )
			divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;
		else if ( bOpera5 )
			nn6DivMenu.style.top += yOffset;
		else if ( bNetscape6 ) {
			nn6DivMenu.style.top = eval(nn6DivMenu.style.top.replace(/px/,"")) + yOffset;
			timeoutNextCheck = 50;
		}

		timeoutNextCheck = 10;
	}

	setTimeout ("CheckUIElements()", timeoutNextCheck);
}

function ReadCookie (CookieName) {
  var CookieString = document.cookie;
  var CookieSet = CookieString.split (';');
  var SetSize = CookieSet.length;
  var CookiePieces
  var ReturnValue = "";
  var x = 0;

  for (x = 0; ((x < SetSize) && (ReturnValue == "")); x++) {

	CookiePieces = CookieSet[x].split ('=');

	if (CookiePieces[0].substring (0,1) == ' ') {
	  CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);
	}

	if (CookiePieces[0] == CookieName) {
	  ReturnValue = CookiePieces[1];
	}

  }

  return ReturnValue;

}


function OnLoad()
{
	if (ReadCookie('nofloat')=='"1"') return true;
	// we're not gonna be loaded in frames, no sir!
	if ( top.frames.length )
		top.location.href = self.location.href;
		
	// setting initial UI elements positions
	if ( bNetscape4 ) {
		document["divMenu"].top = top.pageYOffset + topoffset;
		document["divMenu"].visibility = "visible";
	}
	else if ( bExplorer4plus ) {
		divMenu.style.top = document.body.scrollTop + topoffset;
		divMenu.style.visibility = "visible";
	}
	else if ( bNetscape6 || bOpera5 ) {
		nn6DivMenu = document.getElementById('divMenu');
		nn6DivMenu.style.top = top.pageYOffset + topoffset;
		nn6DivMenu.style.visibility = "visible";
	}
	
	// initializing UI update timer
	CheckUIElements();
	return true;
}

function PreloadImages() {
	img_1=new Image();  img_1.src="navpics/div/pulsantimenu/cpul_On_1.jpg";
	img_2=new Image();  img_2.src="navpics/div/pulsantimenu/cpul_On_2.jpg";
	img_3=new Image();  img_3.src="navpics/div/pulsantimenu/cpul_On_3.jpg";
	img_4=new Image();  img_4.src="navpics/div/pulsantimenu/cpul_On_4.jpg";
	img_5=new Image();  img_5.src="navpics/div/pulsantimenu/cpul_On_5.jpg";
	img_6=new Image();  img_6.src="navpics/div/pulsantimenu/cpul_On_6.jpg";
	img_7=new Image();  img_7.src="navpics/div/pulsantimenu/cpul_On_7.jpg";
	img_8=new Image();  img_8.src="navpics/div/pulsantimenu/cpul_On_8.jpg";
	img_9=new Image();  img_9.src="navpics/div/pulsantimenu/cpul_On_9.jpg";
	img_10=new Image(); img_10.src="navpics/div/pulsantimenu/cpul_On_10.jpg";
	img_11=new Image(); img_11.src="navpics/div/pulsantimenu/cpul_On_11.jpg";
	img_12=new Image(); img_12.src="navpics/div/pulsantimenu/cpul_On_12.jpg";
	img_13=new Image(); img_13.src="navpics/div/pulsantimenu/cpul_On_13.jpg";
	img_14=new Image(); img_14.src="navpics/div/pulsantimenu/cpul_On_14.jpg";
	img_15=new Image(); img_15.src="navpics/div/pulsantimenu/cpul_On_15.jpg";
	img_16=new Image(); img_16.src="navpics/div/pulsantimenu/cpul_On_16.jpg";
	img_17=new Image(); img_17.src="navpics/div/pulsantimenu/cpul_On_17.jpg";
}

function bfmovepic(img_name,img_src) {
	if ( bNetscape4 ) {
		document.layers["divMenu"].document.images[img_name].src=img_src;
	} else {
		document[img_name].src=img_src;
	}
}

function bfprel(img_old_name, img_new_name) {
    document[img_old_name].oldsrc=document[img_old_name].src;
    document[img_old_name].src=img_new_name.src;
    img_new_name.src=document[img_old_name].oldsrc;
}


function openThumb(url) {
	self.name = "main";
	open(url, "popup", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=830,height=700');
}
function openLink(url) {
	self.name = "main";
	open(url, "Dettagli", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=500,height=210');
}

function openNewAdv(url,w,h) {
	self.name = "main";
	open(url, "popup", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+w+',height='+h);
}
function openPopup(url,w,h) {
	self.name = "main";
	open(url, "popup", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+w+',height='+h);
}

function openCover(url) {
	self.name = "main";
	open(url, "popup", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=1000,height=1400');
}

function openCD(url) {
	self.name = "main";
	open(url, "popup", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=700,height=500');
}

function openDVD(url) {
	self.name = "main";
	open(url, "popup", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=820,height=520');
}

function openNew(url) { self.name="main"; open(url); }


// Javascript code that fixes a bug in some versions of Netscape Navigator
function reloadPage(init)
{  //reloads the window if Nav4 resized
  if (init==true) with (navigator)
	{
	  if ((appName=="Netscape")&&(parseInt(appVersion)==4))
		{
	  document.pgW=innerWidth;
			document.pgH=innerHeight;
	  onresize=reloadPage;
		}
	}
  else if (innerWidth!=document.pgW || innerHeight!=document.pgH)
	location.reload();
}
reloadPage(true);

function barra_nav() {
if ( bNetscape4 ) {
	doc=document.layers["divMenu"].document;
} else {
	doc=document;
}
doc.write('');
}

function getexpirydate(nodays){
	var UTCstring;
	Today = new Date();
	nomilli=Date.parse(Today);
	Today.setTime(nomilli+nodays*24*60*60*1000);
	UTCstring = Today.toUTCString();
	return UTCstring;
}

function getCookie(name) { // use: getCookie("name");
	var bites = document.cookie.split("; "); // break cookie into array of bites
	for (var i=0; i < bites.length; i++) {
		nextbite = bites[i].split("="); // break into name and value
		if (nextbite[0] == name) // if name matches
			return unescape(nextbite[1]); // return value
	}
	return null;
}

function setCookie(name, value, days) { // use: setCookie("name", value);
	var today = new Date();
	var expiry = new Date(today.getTime() + days * 24 * 60 * 60 * 1000); // determiniamo la data di scadenza
	if (value != null && value != "")
		document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString();
	bites = document.cookie.split("; "); // update cookie bites
}


function hideLyr(lyr) {
	var curcss = get_lyr_css(lyr);
	if (curcss) {
		curcss.visibility = "hidden";
		curcss.zIndex = 1000;   // some browsers need z-index set
	}
}
// get reference
function get_lyr_css(id) {
	var lyr, lyrcss;
	lyr = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? getLyrRef(id,document): null;
	if (lyr) lyrcss = (lyr.style)? lyr.style: lyr;
	return lyrcss;
}

function showLyr(lyr) {
	var curcss = get_lyr_css(lyr);
	if (curcss) {
		curcss.visibility = "visible";
		curcss.zIndex = 1000;   // some browsers need z-index set
	}
}

// get reference to nested layer for ns4
// from old dhtmllib.js by Mike Hall of www.brainjar.com
function getLyrRef(lyr,doc) {
	if (document.layers) {
		var theLyr;
		for (var i=0; i<doc.layers.length; i++) {
		theLyr = doc.layers[i];
			if (theLyr.name == lyr) return theLyr;
			else if (theLyr.document.layers.length > 0)
			if ((theLyr = getLyrRef(lyr,theLyr.document)) != null)
					return theLyr;
	  }
		return null;
  }
}
