// JavaScript Document

//Massimizza la finestra
function maximize(){
	var largh = screen.availWidth;
	var alt = screen.availHeight;
	if (window.innerWidth){
		largWin = window.innerWidth;
	} else if (document.body.scrollWidth) {
		largWin = document.body.scrollWidth;
	} else if (document.width) {
		largWin = document.width
	}
	if (window.innerHeight){
		altWin = window.innerHeight;
	} else if (document.body.scrollHeight) {
		altWin = document.body.scrollHeight;
	} else if (document.height) {
		altWin = document.height
	}
	if (largh != largWin) {
		window.moveTo(0,0);
		window.resizeTo(largh,alt);
	}
}
//Cambio colore di sfondo della cella in giallo
function cellHighlight(cellID) {
	var ie4 = document.all;
	var ns4 = document.layers;
	var ns6 = document.getElementById && !document.all; 
	if (ie4) {
		ie4(cellID).style.backgroundColor = "#FFCC00"
	} 
	if (ns4){
		ns4.getElementById(cellID).style.backgroundColor = '#FFCC00'
	}
	if (ns6){
		document.getElementById(cellID).style.backgroundColor = '#FFCC00'
	}
}
//Cambio colore di sfondo della cella in bianco
function cellNoHighlight(cellID) {
	var ie4 = document.all;
	var ns4 = document.layers;
	var ns6 = document.getElementById && !document.all; 
	if (ie4) {
		ie4(cellID).style.backgroundColor = "#FFFFFF"
	} 
	if (ns4){
		ns4.getElementById(cellID).style.backgroundColor = '#FFFFFF'
	}
	if (ns6){
		document.getElementById(cellID).style.backgroundColor = '#FFFFFF'
	}
}
//Variazione del canale alpha al 100%
function imgHighlight(imgID, imgNAME) {
	var ie4 = document.all;
	var ns4 = document.layers;
	var ns6 = document.getElementById && !document.all; 
	var isMac = navigator.appVersion.indexOf("Mac");
	if (ie4) {
		if (isMac != -1) {
			document.getElementById(imgID).src = imgNAME;
		} else {
			document.getElementById(imgID).src = imgNAME
		}
	} 
	if (ns4){
		ns4.getElementById(imgID).src = imgNAME;
	}
	if (ns6){
		document.getElementById(imgID).src = imgNAME;
	}
}
//Variazione del canale alpha a 50%
function imgNoHighlight(imgID, imgNAME) {
	var ie4 = document.all;
	var ns4 = document.layers;
	var ns6 = document.getElementById && !document.all; 
	var isMac = navigator.appVersion.indexOf("Mac");
	if (ie4) {
		if (isMac != -1) {
			document.getElementById(imgID).src = imgNAME;
		} else {
			document.getElementById(imgID).src = imgNAME
		}
	} 
	if (ns4){
		ns4.getElementById(imgID).src = imgNAME;
	}
	if (ns6){
		document.getElementById(imgID).src = imgNAME;
	}
}
//Utilizzata nella pagina principale PRODOTTI per aprire i diversi siti esterni.
function openSite(siteNAME){
	var newSite = window.open(siteNAME);
}
//Ulitizzata per aprire le schede aggiuntive dei vari prodotti, dimensione passata come parametro
function openScheda(pagNAME,altPAG,largPAG){
	var larg = parseInt(largPAG);
	var alt = parseInt(altPAG);
	var newScheda = window.open(pagNAME,'','status=no,toolbar=no, menubar=no, width=' + larg + ', height=' + alt);
}
//Utilizzata per l'apertura del popup di richiesta indirizzo email per le informazioni tecniche dei prodotti OM
function omRicTec(cod){
	var ricEmail = window.open(cod,'','status=no,toolbar=no, menubar=no, width=480, height=270');
}
//Utilizzata per far apparire/scomparire testo nella sezione difianco alla pulsantiera
function nav(id,pos){
	var ie4 = document.all;
	var ns4 = document.layers;
	var ns6 = document.getElementById && !document.all; 
	var isMac = navigator.appVersion.indexOf("Mac");
	if (ie4) {
		if (isMac == -1) {
			document.getElementById("nav").style.visibility = "visible";
			document.getElementById("navRow").innerHTML = id;			
			if (pos == null) {
				document.getElementById("navTbl").align = "left";
			} else {
				document.getElementById("navTbl").align = "center";
			}
		} else {
			ie4("nav").style.visibility = "visible";
			ie4("navRow").innerHTML = id;
			if (pos == null) {
				ie4("navTbl").align = "left";
			} else {
				ie4("navTbl").align = "center";
			}
		}
	} 
	if (ns4){
		ns4.getElementById("nav").style.visibility = "visible";
		ns4.getElementById("navRow").innerHTML = id;
		if (pos == null) {
			ns4.getElementById("navTbl").align = "left";
		} else {
			ns4.getElementById("navTbl").align = "center";
		}
	}
	if (ns6){
		document.getElementById("nav").style.visibility = "visible";
		document.getElementById("navRow").innerHTML = id;
		if (pos == null) {
			document.getElementById("navTbl").align = "left";
		} else {
			document.getElementById("navTbl").align = "center";
		}
	}	
}
function navOut(){
	var ie4 = document.all;
	var ns4 = document.layers;
	var ns6 = document.getElementById && !document.all; 
	var isMac = navigator.appVersion.indexOf("Mac");
	if (ie4) {
		if (isMac == -1) {
			document.getElementById("nav").style.visibility = "hidden";
		} else {
			ie4("nav").style.visibility = "hidden";
		}
	} 
	if (ns4){
		ns4.getElementById("nav").style.visibility = "hidden";
	}
	if (ns6){
		document.getElementById("nav").style.visibility = "hidden";
	}	
}
//Controllo del tipo di carrello richiesto nel NOLEGGIO
function checkTipo(form){
	for (var i = 0; i < form.trazione.length; i++) {
		if (form.trazione[i].checked) {
			var trazValue = form.trazione[i].value;
			break;
		}
	}
	for (var i = 0; i < form.tipo.length; i++) {
		if (form.tipo[i].checked) {
			var tipo = form.tipo[i].value;
			break;
		}
	}
	if (trazValue && tipo){
		if (trazValue == 'Diesel' && tipo != 'Frontale'){
			alert ('Il carrello con trazione DIESEL puņ essere solamente FRONTALE');
			form.tipo[0].checked = true;
		}
	}
}
//Cambio colore di sfondo della cella nella pagina PRODOTTI, cella OM. Colore passato come parametro
function chgColor(cellID,color) {
	var ie4 = document.all;
	var ns4 = document.layers;
	var ns6 = document.getElementById && !document.all; 
	if (ie4) {
		ie4(cellID).style.backgroundColor = color;
	} 
	if (ns4){
		ns4.getElementById(cellID).style.backgroundColor = color;
	}
	if (ns6){
		document.getElementById(cellID).style.backgroundColor = color;
	}
}
