/*
  VARIABILI GLOBALI
*/
var tmr;
var t;
var objPop;


/*-----------------------------------------------------------------------
    Gestione popup div
-----------------------------------------------------------------------*/
function sFa(objName) {
  objPop= gObj(objName);
  sLft(window.document.body.clientWidth/2);
	shw(true);
	hideSelectBoxes();
	t = 0;
	sTmr();
}

function hFa() {
	t = -100;
	sTmr();
	showSelectBoxes();
	return false;
}

function sTmr() {
	tmr = setInterval("fd()",20);
}

function fd() {
	var amt = Math.abs(t+=10);
	if(amt == 0 || amt == 100) clearInterval(tmr);
	amt = (amt == 100)?99.999:amt;
  	
	objPop.style.filter = "alpha(opacity:"+amt+")";
	objPop.style.KHTMLOpacity = amt/100;
	objPop.style.MozOpacity = amt/100;
	objPop.style.opacity = amt/100;
	
	if(amt == 0) shw(false);
}

function sLft(theWidth) {
  // set this to 1/2 the width of the faw div defined in the style sheet
  // there's not a reliable way to retrieve an element's width via javascript!!
	var w = theWidth;
	var l = (document.body.innerWidth)? document.body.innerWidth / 2:document.body.offsetWidth / 2;
	objPop.style.left = (l - w) + "px";
}

function gObj(objName) {
	return document.getElementById(objName);
}


function shw(b) {
	(b)? objPop.className = 'show':objPop.className = '';	
}

/*-----------------------------------------------------------------------
    FINE Gestione popup div
-----------------------------------------------------------------------*/

function showSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

function hideSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}

/*
  Ridimensiona la popup per l'immagine del concorso
*/
function resizeOnUNLoad() {
  document.getElementById("xclose").onclick = hFa;

  //-- ridimensiona la popup
  var largh = "640"; //"560";
  objPop.style.width = largh+"px";
  var altezza = "480"; //"420";
  objPop.style.height = altezza+"px";

  sLft(largh);
	document.getElementById("addiv").className = "ad2";

  var objImgDiv = document.getElementById("imagead");
  objImgDiv.innerHTML = "<img src='./adpop/INDEX.gif' alt='PIANETA BORSA' onclick='redirectAdPage()' width='"+largh+"px' height='"+altezza+"'>";
  document.getElementById("topBarMsg").innerHTML = "PIANETA BORSA: scopri la promozione!";
}
