
// browser detect
var ie4=(document.all)? true:false;	
var ns4=(document.layers)? true:false;

// pre-cache immagini per rollovers 
/*var chi_off = new Image(); chi_off.src="../../img/menu/chi_off.gif";
var chi_on = new Image(); chi_on.src="../../img/menu/chi_on.gif";*/


// image magic
function rolla(imgName,imgsrc){
	document.images[imgName].src=eval(imgName+imgsrc+".src");
}

// focus magic
function noBox() {
	for( x = 0; x < document.links.length; x++ ) document.links[ x ].onfocus = this.focus;
}

// popup engine
function popUp(target, myW, myH) {
	
	myleft = (screen.width - 700) / 2;
	mytop = (screen.height - 331) / 2;
	
	 window.open(target, 'eCard', 'width='+myW+',height='+myH+',scrollbars=0,resizable=0,menubar=0,toolbar=0,status=0,location=0,directories=0,left='+myleft+',top='+mytop);
}

function popUpPvt(target, myW, myH) {
	
	myleft = (screen.width - 760) / 2;
	mytop = (screen.height - 424) / 2;
	
	 window.open(target, 'pvt', 'width='+myW+',height='+myH+',scrollbars=1,resizable=0,menubar=0,toolbar=0,status=0,location=0,directories=0,left='+myleft+',top='+mytop);
}


//form magic
function formSender() {
	daForm = document.forms[0];
	daForm.submit();
}

//scroll magic
var mouseIsOver=false;
var scrollTextSpeed = 3;

function scrollDown() {
	if (ie4) {
		this.css = document.all.txtscr.style;
		this.elm = document.all.txtscr;
		this.y = this.elm.offsetTop;
		this.h = this.elm.offsetHeight;
		this.scrH = this.elm.scrollHeight;
		
		this.parcss = document.all.contTxt.style;
		this.parelm = document.all.contTxt;
		this.pary = this.parelm.offsetTop;
		this.parh = this.parelm.offsetHeight;
	} else {
		this.css = document.layers['contTxt'].document.layers['txtscr'];
		this.elm = this.css;
		this.y = this.elm.top;
		this.h = this.elm.clip.height;
		this.scrH = this.h;
		
		this.parcss =  document.layers['contTxt'];
		this.parelm =  this.parcss;
		this.pary = this.parelm.top;
		this.parh = this.parelm.clip.height;
	}
	if (this.y > -(this.scrH-this.parh)) {
		this.css.top = this.y-scrollTextSpeed;
	}
	(mouseIsOver) ? timerID =setTimeout('scrollDown()',1) : clearTimeout('timerID');
}

function scrollUp() {
	if (ie4) {
		this.css = document.all.txtscr.style;
		this.elm = document.all.txtscr;
		this.y = this.elm.offsetTop;
		this.h = this.elm.offsetHeight;
	} else {
		this.css =  document.layers['contTxt'].document.layers['txtscr'];
		this.elm =  this.css;
		this.y = this.elm.top;
		this.h = this.elm.clip.height;
	}
	if (this.y < 0) {
		this.css.top = this.y+scrollTextSpeed;
	}
	(mouseIsOver) ? timerID = setTimeout('scrollUp()',1) : clearTimeout('timerID');
}


	
// card title magic
function cardTitle() {
	myElms = document.forms['fc'].elements['attach'].length
	for (i=0; i<myElms ;i++ )
	{
		if (document.forms['fc'].elements['attach'][i].checked ==1)
		{
		//theVal = document.forms['fc'].elements['attach'][i].value;
		theVal = document.forms['frmNf'].elements['nomiFilm'][i].value;
		}
	}
	if (ie4)
	{
		document.all.card_tit.innerHTML = theVal;
	} else {
		document.layers.card_tit.innerHTML = theVal;
	}
	
}

// disclaimer checker
function radioCheck() {
	myForm = document.forms[0];
	//myVal = myForm.check[0].value;
	if (myForm.check[0].checked)
	{
		//alert("ok");
		//return true;
		//if (confirm("Confermi il trattamento dei tuoi dati personali?"))
		//{
			document.location.href = "registrati.asp"
		//}
	} else {
		alert("Per registrati é necessario acconsentire\nal trattamento dei dati personali.");
	}
}

// sets the right top frame and middle frame content
function linker(thePage) {
	myPage = thePage + "/top_menu.html"
	//alert(myPage);
	parent.frames[0].document.location.href = myPage;
	parent.frames[1].document.location.href = thePage + "/index.html";
}

// sets the right bottom frame
function frameChk() {
	pippo = top.document.src;
	alert(pippo);
}

// sets the bgcolor
function set_bgcolor(name, c) {
   var elm = (document.getElementById) ? document.getElementById(name) : (document.all) ? document.all[name] : null;

   if(elm==null) return;
   
   elm.style.backgroundColor = c; 
}
