//includo il file js utilizzato per l'implementazione dei Flash e degli oggetti OpenLaszlo
document.write("<script language=\"JavaScript\" type=\"text/javascript\" src=\"/include/worinclude/library.js\"></script>");

function goToAnchor(v_strAnchorID){
	document.location.href = "#" + v_strAnchorID
}

function openCredits(v_intIdLanguage){
	window.open("Tools/credits/creditsPleiadi.asp?lng=" + v_intIdLanguage,"Credits","dependent=yes,Height=140,Width=320,location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=yes,toolbar=no");
}

function openCoomingSoon(){
	window.open("Tools/cooming.htm","CoomingSoon","dependent=yes,Height=180,Width=375,location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=yes,toolbar=no");
}

function loadInOpener(v_strUrl){
	window.opener.location = v_strUrl;
	window.focus()
}

function getObject(v_strIdImage){
	var strBrowserName = "";
	var vObj;
	
	strBrowserName = whatbrowser();
	
	switch(strBrowserName){
		case "NN6":{
			vObj = document.getElementById(v_strIdImage);
			break;
		}
		case "NN4":{
			vObj = document.getElementById(v_strIdImage);
			break;
		}
		case "ie4":
		case "ie6":
		case "ieMac":{
			vObj = document.all(v_strIdImage);
			break;
		}
		default:{
			vObj = document.all(v_strIdImage);
		}
	}
	
	return(vObj);
}


//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 blnIsIe5 = (strAppVersion.indexOf("MSIE 5") == -1) ? 0 : 1;
	var blnIsIe6 = (strAppVersion.indexOf("MSIE 6") == -1) ? 0 : 1;
	var blnIsMac = (strAppVersion.indexOf("Macintosh") == -1) ? 0 : 1;
	
	//interrogo l'oggetto document per capire quale broeser 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="ie";
         
         //alert(thisbrowser);
    }
    if(!document.all && document.getElementById){
         thisbrowser="NN6";
    }
    
    return(thisbrowser);
}

/*function printPage(){
	var strPage = "";
	var intStartIndex = 0;
	var intEndIndex = 0;
	
	strPage = document.location.href;
		
	intStartIndex = strPage.lastIndexOf("/") + 1;
	intEndIndex = strPage.indexOf("?", intStartIndex);
	
	strPage = strPage.substring(intStartIndex, intEndIndex);
	
	window.open("printSmatPage.aspx?page=" + strPage,"printPage","dependent=yes,Height=400,Width=440,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,titlebar=yes,toolbar=no");
}*/

function openPage(v_strPage, v_intWidth, v_intHeight){
	window.open(v_strPage,"popuppage","dependent=yes,Height=" + v_intHeight + ",Width=" + v_intWidth + ",location=no,menubar=no,resizable=no,scrollbars=yes,status=no,titlebar=yes,toolbar=no");
}

function OpenZoomWindow(strImg){

	//alert("tools/zoomWindow.aspx?img=" + strImg)

	window.open("tools/zoomWindow.aspx?img=" + strImg,"zoomWindow",'height=300,width=300,status=0,scrollbars=0');
}

function WriteSpace(v_intWidth){
	alert("v_intWidth: " + v_intWidth);
	
	var strSpace = "";
	
	strSpace = "<td width=\"" + v_intWidth + "\"><img src=\"img/shared/np.gif\" border=\"0\" width=\"" + v_intWidth + "\" height=\"1\"></td>";
	
	if(v_intWidth > 0){
		document.write(strSpace);
	}
}

//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 OpenPrintWindow(v_strURLPrint){
	var oWin = window.open(v_strURLPrint,'winPrint','status=0,scrollbars=1,width=590px,height=400px');
	oWin.focus();
}
function LoadDataToPrint(){
	var strId = 'tdPrint';
	var objSource = window.opener.document.getElementById(strId);
	var objDest = window.document.getElementById(strId);
	objDest.innerHTML = objSource.innerHTML;
}

function FastSearchTab_onclick(i_strTabID)
{
    //alert("FastSearchTab_onclick");
    
    var divID = "div" + i_strTabID;
    var objDivCantiere = document.getElementById("divCantiere");
    var objDivLunghezza = document.getElementById("divLunghezza");
    var objDivPrezzo = document.getElementById("divPrezzo");
    
    if ( ( objDivCantiere != null ) && ( objDivLunghezza != null ) && ( objDivPrezzo != null ) )
    {
        if ( divID == 'divCantiere' )
        {
            objDivCantiere.style.display = "block";
            objDivLunghezza.style.display = "none";
            objDivPrezzo.style.display = "none";
        }
        else if ( divID == 'divLunghezza' )
        {
            objDivCantiere.style.display = "none";
            objDivLunghezza.style.display = "block";
            objDivPrezzo.style.display = "none";    
        }
        else if ( divID == 'divPrezzo' )
        {
            objDivCantiere.style.display = "none";
            objDivLunghezza.style.display = "none";
            objDivPrezzo.style.display = "block";    
        }
    }    
}

function imgLeftBarca_onclick()
{
	//alert("imgLeftBarca_onclick");

	var objHidPosLeftImg = document.getElementById("scheda_hidPosLeftImg");
	if ( objHidPosLeftImg != null )
	{
		//alert("hidPosLeftImg found");
		
		var posLeft = parseInt( objHidPosLeftImg.value );
		
		if ( posLeft > 1 )
		{
			posLeft = posLeft - 1;
			
			SpostaImmagini( posLeft );
		}
	}
}

function imgRightBarca_onclick()
{
	//alert("imgRightBarca_onclick");
	
	var objHidPosLeftImg = document.getElementById("scheda_hidPosLeftImg");
	var objHidNumImg = document.getElementById("scheda_hidNumImg");
	if ( ( objHidPosLeftImg != null ) && ( objHidNumImg != null ) )
	{
		//alert("hidPosLeftImg found");
		//alert("hidNumImg found");
		
		var posLeft = parseInt( objHidPosLeftImg.value );
		var numImg = parseInt( objHidNumImg.value );
		
		if ( (posLeft + 2) < numImg )
		{
			posLeft = posLeft + 1;
			
			SpostaImmagini( posLeft );
		}
	}	
}

function SpostaImmagini(i_posLeft)
{
	//alert("SpostaImmagini\r\n\r\ni_posLeft: " + i_posLeft);
	
	var objHypLnkIntEst1 = document.getElementById("scheda_hypLnkIntEst1");
	var objHypLnkIntEst2 = document.getElementById("scheda_hypLnkIntEst2");
	var objHypLnkIntEst3 = document.getElementById("scheda_hypLnkIntEst3");
	var objImgIntEst1 = document.getElementById("scheda_imgIntEst1");
	var objImgIntEst2 = document.getElementById("scheda_imgIntEst2");
	var objImgIntEst3 = document.getElementById("scheda_imgIntEst3");
	
	if ( ( objHypLnkIntEst1 != null ) && ( objHypLnkIntEst2 != null ) && ( objHypLnkIntEst3 != null ) &&
		( objImgIntEst1 != null ) && ( objImgIntEst2 != null ) && ( objImgIntEst3 != null ) )
	{
		var objHidNavUrl = null;
		var objHidImgUrl = null;
		var pos1 = i_posLeft;
		var pos2 = i_posLeft + 1;
		var pos3 = i_posLeft + 2;

		objHidNavUrl = document.getElementById("scheda_hidNavUrl" + pos1);
		objHidImgUrl = document.getElementById("scheda_hidImgUrl" + pos1);
		if ( objHidNavUrl != null )
		{
			if ( objHidNavUrl.value != "")
				objHypLnkIntEst1.href = "javascript:window.open" + objHidNavUrl.value;
			else
				objHypLnkIntEst1.href = "#";
		}
		if ( objHidImgUrl != null )
			objImgIntEst1.src = objHidImgUrl.value;
		
		objHidNavUrl = document.getElementById("scheda_hidNavUrl" + pos2);
		objHidImgUrl = document.getElementById("scheda_hidImgUrl" + pos2);
		if ( objHidNavUrl != null )
		{
			if ( objHidNavUrl.value != "")
				objHypLnkIntEst2.href = "javascript:window.open" + objHidNavUrl.value;
			else
				objHypLnkIntEst2.href = "#";
		}
		if ( objHidImgUrl != null )
			objImgIntEst2.src = objHidImgUrl.value;
		
		objHidNavUrl = document.getElementById("scheda_hidNavUrl" + pos3);
		objHidImgUrl = document.getElementById("scheda_hidImgUrl" + pos3);
		if ( objHidNavUrl != null )
		{
			if ( objHidNavUrl.value != "")
				objHypLnkIntEst3.href = "javascript:window.open" + objHidNavUrl.value;
			else
				objHypLnkIntEst3.href = "#";
		}
		if ( objHidImgUrl != null )
			objImgIntEst3.src = objHidImgUrl.value;
		
		//Aggiorna posizione nel campo nascosto
		var objHidPosLeftImg = document.getElementById("scheda_hidPosLeftImg");
		if ( objHidPosLeftImg != null )
			objHidPosLeftImg.value = i_posLeft;	
	}
}


function openFreePage(v_strPage, v_intWidth, v_intHeight){
	window.open(v_strPage,"popuppage","dependent=yes,Height=" + v_intHeight + ",Width=" + v_intWidth + ",location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=yes,toolbar=no");
}
