//whatbrowser()
//
//determina con quale browser l'utente è collegato e restituisce la sigla corrispondente
//
//argomenti:
//	nessuno
//
//valore di ritorno:
//	stringa	=	sigla corrispondente al browser con cui l'utente è collegato
//				NN4	=	netscape4
//				NN6	=	netscape6
//				ie	=	internet explorer
function whatbrowser(){
	var thisbrowser = "";	//sigla del browser utilizzato dall'utente
	var strAppVersion = navigator.appVersion;
	var blnIsIe4 = (strAppVersion.indexOf("MSIE 4") == -1) ? 0 : 1;
	var blnIsIe6 = (strAppVersion.indexOf("MSIE 6") == -1) ? 0 : 1;
	var blnIsMac = (strAppVersion.indexOf("Macintosh") == -1) ? 0 : 1;
	var blnIsIe5 = (strAppVersion.indexOf("MSIE 5") == -1) ? 0 : 1;
	
	//interrogo l'oggetto document per capire quale browser sta utilizzando l'utente
    if(document.layers){
        thisbrowser="NN4";
    }
    if(document.all){
         if(blnIsIe4 == 1 || blnIsIe5 == 1) thisbrowser="ie4";
         else if(blnIsIe6 == 1) thisbrowser="ie6";
         else if(blnIsMac == 1) thisbrowser="ieMac";
         else thisbrowser="ie4";
         
         //alert(thisbrowser);
    }
    if(!document.all && document.getElementById){
         thisbrowser="NN6";
    }
    
    return(thisbrowser);
}

//openPageUrl(v_strUrl, v_strPageName, v_strWidth, v_strHeight, v_blnBoxLink, v_strTarget)
//
//gestione dei link nelle voci del top menu.
//La gestione dei link che aprono delle nuove finestre, cambia a seconda del browser 
//utilizzato dall'utente:
//	ie, NN6,	accettano il link anche sulla cella del menu, per evitare che sia il 
//				link sulla cella che quello sulla scritta vengano aperti (lo fa quando 
//				uso la funzione window.open), non metto quello sulla scritta
//	NN4,	supporta il link solo sulla scritta, non metto quello sulla cella
//
//argomenti:
//	v_strUrl	=	pagina da aprire
//	v_strPageName	=	nome da dare alla pagina
//	v_strWidth	=	larghezza della finestra da aprire
//	v_strHeight	=	altezza della finestra da aprore
//	v_blnBoxLink	=	flag che indica se la funzione è chiamata per gestire un link sulla cella (=true) o sulla scritta (=false)
//	v_strTarget	=	target del link
//
//valore di ritorno:
//	nessuno
function openPageUrl(v_strUrl, v_strPageName, v_strWidth, v_strHeight, v_blnBoxLink, v_strTarget){
	var strBrowserName = "";
	var strAppVersion = "";
	var intScreenWidth = 0;
	var intScreenHeight = 0;
	
	strBrowserName = whatbrowser();
	
	if(strBrowserName.indexOf("ie") != -1){
		intScreenWidth = parseInt(document.body.clientWidth);
		intScreenHeight = parseInt(document.body.clientHeight) - 30;
	}else{
		intScreenWidth = parseInt(window.innerWidth) - 10;
		intScreenHeight = parseInt(window.innerHeight);
	}
	
	
	if(v_strWidth == null || v_strWidth == "") v_strWidth = intScreenWidth;
	if(v_strHeight == null || v_strHeight == "") v_strHeight = intScreenHeight;
	
	if(v_blnBoxLink == true){
		switch(strBrowserName){
			case "ie6":
			case "ie4":
			case "ieMac":
			case "NN6":{
				if(v_strTarget == "_blank"){
					window.open(v_strUrl, v_strPageName,"dependent=yes,Height=" + v_strHeight + ",Width=" + v_strWidth + ", top=0, left=0, location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes,linksbar=yes");
				}else{
					location.href = v_strUrl;
				}
				break;
			}
			default:{
			}
		}
	}else{
		switch(strBrowserName){
			//case "ie4":
			//case "ieMac":
			case "NN4":{
				if(v_strTarget == "_blank"){
					window.open(v_strUrl, v_strPageName,"dependent=yes,Height=" + v_strHeight + ",Width=" + v_strWidth + ", top=0, left=0,location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes,linksbar=yes");
				}else{
					location.href = v_strUrl;
				}
				break;
			}
			case "ieMac":{
				if(v_strTarget != "_blank"){
					location.href = v_strUrl;
				}
				break;
			}
			default:{
			}
		}
	}
}



//npwidthmax()
//
//calcola width della pagina, toglie larghezza menu sinistra e larghezza menu 
//destra return (la differenza)
function npwidthmax(){
	size = parseInt(window.innerWidth) - 161;
	return size;
}

function openPage(v_strPagePath, v_strTitolo, v_intWidth, v_intHeight, v_blnScroll){
	if(v_blnScroll == false){
		window.open(v_strPagePath, v_strTitolo,"dependent=yes,Height=" + v_intHeight + ",Width=" + v_intWidth + ",location=no,menubar=no,resizable=yes,scrollbars=no,status=no,titlebar=yes,toolbar=no");
	}else{
		window.open(v_strPagePath, v_strTitolo,"dependent=yes,Height=" + v_intHeight + ",Width=" + v_intWidth + ",location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=yes,toolbar=no");
	}
}

function openNormalPage(v_strPagePath, v_strTitolo, v_intWidth, v_intHeight){
	window.open(v_strPagePath, v_strTitolo,"dependent=yes,Height=" + v_intHeight + ",Width=" + v_intWidth + ", top=0, left=0,location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes");
}

function openPageTopMenu(v_strPagePath, v_strTitolo, v_intWidth, v_intHeight){
	
	if((whatbrowser() == "NN6") || (whatbrowser() == "ie6") || (whatbrowser() == "ie4") || (whatbrowser() == "ieMac")){
		window.open(v_strPagePath, v_strTitolo,"dependent=yes,Height=" + v_intHeight + ",Width=" + v_intWidth + ",location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes");
	}
}

function changeStyle(v_strIDTd, v_strTopStyle, v_strBottStyle){
	switch(whatbrowser()){
		case "NN6":{
			document.getElementById(v_strIDTd + "Bottom").className = v_strBottStyle;
			break;
		}
		case "ie4":
		case "ie6":
		case "ieMac":{
			document.all(v_strIDTd + "Bottom").className = v_strBottStyle;
			break;
		}
		default:{
			document.all(v_strIDTd + "Bottom").className = v_strBottStyle;
		}
	}
}
	
	
function whiteArrow(v_strImageName){
	switch(whatbrowser()){
		case "NN6":{
			document.getElementById(v_strImageName).src = "img/interface/whiteArrowLeftMenu.gif";
			break;
		}
		case "ie6":
		case "ie4":
		case "ieMac":{
			document.all(v_strImageName).src = "img/interface/whiteArrowLeftMenu.gif";
			break;
		}
		default:{
			document.all(v_strImageName).src = "img/interface/whiteArrowLeftMenu.gif";
		}
	}
}


	
function trasparentImg(v_strImageName){
	switch(whatbrowser()){
		case "NN6":{
			document.getElementById(v_strImageName).src = "img/shared/np.gif";
			break;
		}
		case "ie6":
		case "ie4":
		case "ieMac":{
			document.all(v_strImageName).src = "img/shared/np.gif";
			break;
		}
		default:{
			document.all(v_strImageName).src = "img/shared/np.gif";
		}
	}
}

//prodotti selection spertura pagina colori
function openColor(v_strLocalLng){
	var strLocalLng = "";
	strLocalLng = (v_strLocalLng != null && v_strLocalLng != "") ? v_strLocalLng : "en";
	
	if(strLocalLng == "it"){
		window.open('prodotti/selectionFlashColori/selectionFlash.asp','_blank','scrollbars=no,menubar=0,width=552,height=428');
	}else{
		window.open('prodotti/selectionFlashColoriUK/selectionFlash.asp','_blank','scrollbars=no,menubar=0,width=552,height=428');
	}
}

function openRaceLine(v_strIdLanguage){
	location.href='prod_mod.asp?area=race&id=1&lng=' + v_strIdLanguage + '&ipag=plrace&swbox=1';
}
	
function openExciteLineHomeZoom(v_strNomeAttrezzo, v_strIdDetail){
	window.open('prodotti/excite/lineHomePageDetails/zoomPage.asp?nomeAttrezzo=' + v_strNomeAttrezzo + '&idimg=' + v_strIdDetail,'Details','dependent=yes,Height=357,Width=447,top=10,left=10,location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=yes,toolbar=no,linksbar=no');
}
