
var myLink = null;

var PageToLink = new Array();
PageToLink["societa"] 		= "societa/societa00.htm";
PageToLink["servizi"] 		= "servizi/servizi00.htm";
PageToLink["clienti"] 		= "clienti/clienti0.htm";
PageToLink["realizzazioni"] 	= "realizz/realizz00.htm";
PageToLink["registrazione"] 	= "infocomm/registrazione.htm";
PageToLink["prodotti"] 		= "prodotti/prodotti1.htm";
PageToLink["prodotti_cnd"] 	= "../prodotti/prodotti1.htm";

function initPage() {
	if ( myLink != null )
		linkPage(myLink)
}

function linkPage(NomeSez) {
	location.href = (NomeSez != null && PageToLink[NomeSez] != null) ? PageToLink[NomeSez] : "index.html";
}

// ==========================================================================
// Lingua
// ==========================================================================

function Lingua(tipo) {
	var marker = "/simula_"
	var path = location.href;
	var p = path.indexOf(marker);
	if ( p >= 0 ) {
		var full_marker = marker + path.substr(p + marker.length, 2);
		var new_path = path.replace(full_marker, marker + tipo)
		location.href = new_path;
	}
}

// ==========================================================================

function linkToSimula() {
	if ( self.opener == null )
		document.write('<h4 align="center"><a href="http://www.simula.it" target="_blank">www.simula.it</a></h4><br />');
}

// ==========================================================================

var WinZoom=null;

function imgZoom(imgName, w, h, mScrollbars, mStatusbar) {
  if ( w == null ) w = 830;
  if ( h == null ) h = 640;  
  LinkPage = imgName + ".htm";
  WindOpen(LinkPage,w,h,null,mScrollbars, mStatusbar);
}

function OpenCliente(imgName,L,A,bm) {
 	LinkPage = "" + imgName + ".htm";
 	WindOpen(LinkPage,L,A,bm)
}

function WindOpen(pageName, L, A, bookmark, mScrollbars, mStatusbar) {
  LinkPage = (bookmark == null) ? pageName: pageName+"#"+bookmark
  var Opzioni;

	if ((WinZoom==null) || (WinZoom.closed)) 
	{
 		var DimX, DimY, X, Y;
  	if (screen.width <= 800){
  		DimX = screen.width;
      DimY = screen.height;
    } else {
      DimX = L;
      DimY = A;
    }
    X = (screen.width - DimX)/2;
    Y = (screen.height - DimY)/2;
    DimX = DimX -10;
    DimY = DimY -35;
 			
    // [2007/02/14] parametrizza la presenza delle scrollbars e della status bar
    // -------------------------------------------------------------------------------
    // Opzioni="scrollbars=yes,resizable=yes,width="+DimX+",height="+DimY+",dependent=yes";
    Opzioni  = (mScrollbars == null || mScrollbars == true ) ? "scrollbars=yes," : "scrollbars=no,"
    Opzioni += (mStatusbar == null || mStatusbar == true ) ? "statusbar=yes," : "statusbar=no,"
    Opzioni += "resizable=yes,width="+DimX+",height="+DimY+",dependent=yes";
						
    WinZoom = window.open(LinkPage, "imgZoom", Opzioni);
    WinZoom.moveTo(X,Y);
    
  } else {
		WinZoom.close();
    WindOpen(pageName,L,A);
  }
  
  WinZoom.focus();
}

/* ---------------------------------------------------------------- *\
	 [2007/02/14] APERTURA DELLE DEMO ON-LINE
\* ---------------------------------------------------------------- */

var WinDemo = null;

// Apre la finestra con la Demo
// ----------------------------------------------------------------
function OpenDemo(tipo, maximize)
{
	// window options
	var scrollbars = true;
	var statusbar = true;

  LinkPage = tipo + ".htm";  
 	// WindOpen(LinkPage, 800, 600, null, scrollbars, statusbar);	

  if ( WinDemo != null && !WinDemo.closed ) {
  	WinDemo.closeapp();
		WinDemo.close();
	}

  WinDemo = window.open(LinkPage);
	if ( maximize == null ) maximize = false;
	SizeWindow(WinDemo, maximize)
}


function TitoloPagina(sName) {
		var sTitle = "";
		switch(sName) {
		  case "cor"	: sTitle = "Principi Base di Corrosione"; break;
		  case "met"	: sTitle = "Corso Base di Metallurgia"; break;
		  case "ndtmt": sTitle = "Controllo con Particelle Magnetiche"; break;
		  case "ndtpt": sTitle = "Controllo con Liquidi Penetranti"; break;
		  case "ndtrt": sTitle = "Controllo Radiografico"; break;
		  case "ndtut": sTitle = "Controllo con Ultrasuoni"; break;
		  case "ndtvt": sTitle = "Controllo Visivo"; break;
		}	
		return sTitle;
}

// Massimizzare la finestra delle demo;
// maximize = true per massimizzare la finestra
// 					= false per centrare la finestra a 800x600
// ----------------------------------------------------------------
function SizeWindow(myWin, maximize) 
{
  var Xm = 800;
  var Ym = 600;
	var X0, Y0;
	var Xs, Ys;

	if ( maximize )	{
	 	X0 = 0;
		Y0 = 0;
		Xs = screen.availWidth;
		Ys = screen.availHeight;
	}	
	else { // center
		X0 = (screen.width - Xm) / 2;
		Y0 = (screen.height - Ym) / 2;
		Xs = Xm + 4;
		Ys = Ym + 23;
	}

	// dimensiona
	if (document.all || document.layers)	{
	  myWin.resizeTo(Xs+8,Ys+8)
	} 
	else if (myWin.screen) 	{
  	myWin.outerWidth = Xs+8;
	  myWin.outerHeight = Ys+8;
	}
	// posiziona
	myWin.moveTo(X0-4,Y0-4);
	// set focus
  myWin.focus();
}

/* ---------------------------------------------------------------- *\
	 LINK ESTERNI
\* ---------------------------------------------------------------- */

function FibreOttiche() {
	var LinkPage = "../../fibre/index.htm";
	var Opzioni;
	if (screen.width <= 800)
		Opzioni = "status=yes,scrollbars=yes,resizable=yes,width="+screen.width+",height="+screen.height+"";
	else
		Opzioni = "status=yes,scrollbars=yes,resizable=no,width=800,height=600";
	window.open(LinkPage,"Fibre", Opzioni);
}


