CSAg = window.navigator.userAgent;
CSBVers = parseInt(CSAg.charAt(CSAg.indexOf("/")+1),10);
function IsMacIE() {
	if (CSAg.indexOf("MSIE")!= -1 && CSAg.indexOf("Mac")!= -1) return true;
	return false;
}
function IsIE() { return CSAg.indexOf("MSIE") > 0;}
function IsIE6() {
	if (CSAg.indexOf("MSIE 6")!= -1) return true;
	else return false;
}
function IsIE50() {
	if (CSAg.indexOf("MSIE 5.0")!= -1) return true;
	else return false;
}
function IsIE7() {
	if (CSAg.indexOf("MSIE 7")!= -1) return true;
	return false;
}
function IsNE6() {
	if (CSAg.indexOf("Netscape6")!= -1) return true;
	return false;
}
function IsNE() {
	if (CSAg.indexOf("Netscape")!= -1) return true;
	return false;
}
function IsMozVer15() {
	var numVer = CSAg.substring(CSAg.indexOf("rv:")+3, CSAg.indexOf("rv:")+6);
	if (numVer < 1.5) return "min";
	if (numVer > 1.5) return "sup";
	if (numVer == 1.5) return "ugu";
	return null;
}

// FUNZIONE CHE MUOVE IL LAYER
var X = 0;
var Speed = 10;
var Step = 4;
var controllo=true;
var openLayer = false;
var movimento = false;
var nomeLayerGlobal;
var modelloGlobal;
var imgDettModelloFreccettina;
function OpenLayer(){
	openLayer = true;
	if (controllo) {
		X += Step;
		if(X >= 159)controllo = false;
	}
	document.getElementById(nomeLayerGlobal).style.left = X+"px";
	if(controllo) {
		setTimeout("OpenLayer()",Speed);
	}
	else {
		// Costruisco dinamicamente il contenuto di dettaglioModello:
		document.getElementById('dettModCel').innerHTML = '<img onclick="javascript:location.href=\''+linkFr[modelloGlobal]+'\'" style="cursor:hand" align="center" src="'+nomeImg[modelloGlobal]+'" hspace="0" vspace="5" width="137" height="74" border="0"><br>'+testo[modelloGlobal];
		document.getElementById('dettModCelPrezzo').innerHTML = '<img onclick="javascript:location.href=\''+linkFr[modelloGlobal]+'\'" style="cursor:hand" align="right" src="'+imgDettModelloFreccettina+'" hspace="0" vspace="0" width="14" height="10" border="0"><b>'+prezzo[modelloGlobal]+'</b>';
		document.getElementById('dettaglioModello').style.display = "block";
	}
	controllo = true;
}

function ChiudiLayer(){
	openLayer = false;
	if (controllo) {
		document.getElementById('dettaglioModello').style.display = "none";
		X -= Step;
		if(X <= 0)controllo = false;
	}
	document.getElementById(nomeLayerGlobal).style.left = X+"px";
	if(controllo) setTimeout("ChiudiLayer()",Speed);
	else{
		controllo = true;
		if(movimento) {
			movimento = false;
			OpenLayer();
		}
	}
	controllo = true;	
}

function MuoviLayer(nomeLayer, modello){
	if(modelloGlobal == modello){
		if(openLayer) ChiudiLayer();
		else OpenLayer();
		modelloGlobal == "";
	}	
	else{
		nomeLayerGlobal = nomeLayer;
		modelloGlobal = modello;
		if(openLayer){
			movimento = true;
			ChiudiLayer();
		}
		else {
			OpenLayer();
		}
	}
}

// FUNZIONE CHE SETTA IN BOLD E SFONDO BIANCO IL MODELLO SELEZIONATO
var idDesc = 0;

function setRedDesc(desc) {
	if (idDesc) {
		document.getElementById("descMod"+idDesc).style.backgroundColor = 'transparent';
		document.getElementById("descMod"+idDesc).className = 'textGreyBold';
	}
	document.getElementById("descMod"+desc).style.backgroundColor = '#FFFFFF';
	document.getElementById("descMod"+desc).className = 'modelDescRed';
	idDesc = desc;
}


// FUNZIONE PER LA GESTIONE DELLA SITE MAP
function moveSiteMap(obj){
	if(document.getElementById(obj).style.display == "none"){
		document.getElementById(obj).style.display = "block";
	}
	else{
		document.getElementById(obj).style.display = "none";
	}
	//setLayerProperty();
}

// FUNZIONE PER LA GESTIONE DEL SIZE LIMIT OVER 1024
var cc = false;
var flagmodelli = false;

function sizeLimit() {
	var content = document.getElementById('content');
	var res = (document.all) ? (window.document.body.clientWidth <= 1000) ? true : false : (window.innerWidth <= 1024) ? true : false;
	if (res) content.style.width = "100%";
	else content.style.width = "1000px";
	if (cc) {
		moveFlash();
		setBoxDxTop();
	}
	if (flagmodelli) resizeModelli();
	setBorderAlfa5Alfa6();
}

function resizeModelli() {
	var widthContAlfa6 = document.getElementById("contAlfa6").offsetWidth - 160;
	if (document.getElementById("modello1"))   document.getElementById("modello1").style.width = widthContAlfa6 + "px";
	if (document.getElementById("modello234")) document.getElementById("modello234").style.width = widthContAlfa6 + "px";
	if (document.getElementById("modello5"))   document.getElementById("modello5").style.width = widthContAlfa6 + "px";
	if (document.getElementById("modello6"))   document.getElementById("modello6").style.width = widthContAlfa6 + "px";
	if (document.getElementById("modello7"))   document.getElementById("modello7").style.width = widthContAlfa6 + "px";
	if (document.getElementById("modello8"))   document.getElementById("modello8").style.width = widthContAlfa6 + "px";
	if (document.getElementById("modello9"))   document.getElementById("modello9").style.width = widthContAlfa6 + "px";
	if (document.getElementById("modello10"))  document.getElementById("modello10").style.width = widthContAlfa6 + "px";
}

window.onload = sizeLimit;
window.onresize = sizeLimit;

function setBorderAlfa5Alfa6() {
	if (document.getElementById("alfa4") && document.getElementById("alfa5") && document.getElementById("alfa6")) {
		var a4 = document.getElementById("alfa4");
		var a5 = document.getElementById("alfa5");
		var a6 = document.getElementById("alfa6");
		if ((a5.offsetHeight - 138) <= a6.offsetHeight) {
			a5.style.borderLeft = "0";
			a4.style.borderRight = "1px solid #FFFFFF";
		} else {
			a6.style.borderRight = "0";
		}
	}
}


//Restituisce un riverimento ad un DIV (layer)
function getRefToDiv(divID) {
					if( document.layers ) { //Netscape layers
						return document.layers[divID]; }
					if( document.getElementById ) { //DOM; IE5, NS6, Mozilla, Opera
						return document.getElementById(divID); }
					if( document.all ) { //Proprietary DOM; IE4
						return document.all[divID]; }
					if( document[divID] ) { //Netscape alternative
						return document[divID]; }
					return false;
}

//Restituisce true se almeno una risposta è selezionata
function checkInstantPolling(radioArray){
					for(var i=0;i<radioArray.length;i++){
						if(radioArray[i].checked) return true;
					}
					return false;
}