/*
  (C) Upgrade Multimediale Srl
      viale dell'Industria 24/D
      37135 Verona - ITALY
      Tel:  +39 045 8903199
      Fax:  +39 045 8231203  
      @: info@upgrade4.it
      W: http://www.upgrade4.it
         
   Content:   Common variables setting, functions and generic routines called by other functions...
   Type:      Generic
*/                


  var browser = navigator.appName;
  var version = parseInt(navigator.appVersion); 
 
  var MOZILLA = (navigator.userAgent.indexOf("Gecko")!=-1);	 		// Mozilla 
  var OPERA   = (navigator.userAgent.indexOf("Opera")!=-1); 			// Opera
  var IE = (navigator.userAgent.indexOf("MSIE")!=-1);      			// IE
  var NS = (navigator.userAgent.indexOf("Mozilla")!=-1) && !MOZILLA && !IE;  	// NS 4.7 or older
 
  
  if (!NS && !MOZILLA) IE=true; // older functions compatibility
  //if (!MOZILLA) NS=true;
  
  var WIN = false;
  var MAC = false;
  var UNIX = false;                                                                                                                           
  
  // set platform type ...
                                                               
  if (navigator.platform)  
      if (navigator.platform.indexOf("Win")!=-1)  WIN = true; // windows
      else
      if (navigator.platform.indexOf("Mac")!=-1)  MAC = true; // Mac
      else
      if (navigator.platform.indexOf("Linux")!=-1 || navigator.platform.indexOf("Unix")!=-1)  UNIX = true; // unix o linux
      
  /*******************/
  function getArgs() { 
  /*******************/
    
    /* Estrae i parametri passati al "file.htm?p1=primo_par,p2=secondo_par" ecc. */
    
    var args = new Object();
    var query = location.search.substring(1);
    var params = query.split(",");
    for (var i=0; i<params.length; i++) {
      var pos=params[i].indexOf('=');
      if (pos==-1) continue;
           var argname=params[i].substring(0,pos);
           var value=params[i].substring(pos+1);
           args[argname]=unescape(value);
      }
    return args;
  }


/************** Gestione Finestre *******************/  
  
  function openInner(url, name, param, innerW, innerH) {
          if (NS) { 
             new_win=window.top.open(url, name, param+",innerHeight="+innerH+",innerWidth="+innerW);
             if (MAC) { new_win._mac_flag="opened"} // fix per comportamento anomalo con NS e MAC
          }
          else if (MOZILLA) {                              
            offH=offW=0;
            new_win=window.top.open(url, name, param+",width="+(innerW+offW)+",height="+(innerH+offH));
          }  
          else if (IE&&WIN) {                              
            offH=offW=0;
            new_win=window.top.open(url, name, param+",width="+(innerW+offW)+",height="+(innerH+offH));
          }  
          else if (IE&&MAC) {             
            //offW=-5;offH=28; ok per IE4 ma non IE5
            offW=0;
            offH=5;
            new_win=window.top.open(url, name, param+",width="+(innerW+offW)+",height="+(innerH+offH));
          }        
          return new_win;
  }
  
  function openNew(url, param) {
  	var win_name="win"+Math.round(Math.random()*9999999); 
  	window.open(url, win_name, param);
  }
  
  function zoom(img, w, h, titolo, code) {
  	var str, pos;
    if ((typeof titolo) == "undefined") titolo="[zoom]";
    if ((typeof code) == "undefined") code=Math.round(Math.random()*999999999);            
    var w_zoom=openInner("", "zoom"+(code), "resizable=yes,scrollbars=no,menubar=no,directories=no,location=no,status=yes,toolbar=no",w,h);
    if (w_zoom!=null) {  // controllo..
      w_zoom.document.writeln('<html><title>'+titolo+'</title><body marginwidth=0 marginheight=0 topmargin="0" rightmargin="0" leftmargin="0" bottommargin="0" bgcolor="#000000"><table width="'+w+'" height="'+h+'"><tr><td valign="middle" align="center"><font face="Arial, Helvetica, Sans-serif" color="#FFFFFF" size="1">loading...</font></td></tr></table><div id="zoom" style="position:absolute; width:1; height:1;  z-index:10; left: 0px;  top: 0px"><img src='+img+' width='+w+' height='+h+'></div></body></html>');
      w_zoom.document.close();
    }
    // CODICE AGGIUNTO PER TRACCIARE IL CLICK DEL BLOCCO FOTO
    // 04-07-2007  nicola
    pos = img.lastIndexOf('/');
    if ( pos > 0 )
    {
	    str = img.substr(0, pos);
	    str = str.replace(/\//g,"-");
	    track(str+'#',1);
  	}
  	// -------------------------------------------------------
    return w_zoom;
  }	

  
  function Rnd(n) { // return an integer between 0 and n-1
     return Math.ceil(Math.random()*n)-1
  }
  
/********* Gestion Bug NS onresize... ************/  
  
  var _innerW, _innerH;

  function fixNSresize(init) {  //reloads the window if Nav4 resized
   if (init==true) with (navigator) {
     if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
     _innerW=innerWidth; _innerH=innerHeight; onresize=fixNSresize; }
   }
   else if (MAC) {
      if ( (innerWidth!=_innerW || innerHeight!=_innerH) && (typeof window._mac_flag) == "undefined")  location.reload();
   }
   else if (innerWidth!=_innerW || innerHeight!=_innerH) location.reload();    
  }
  
  fixNSresize(true);        
  
/********* POP UPS ************/  

function requisiti() {
	openNew("requisiti.php","resizable=no,menubar=no,scrollbars=no,width=545,height=350");  
} 

function requirements() {
	openNew("requirements.php","resizable=no,menubar=no,scrollbars=no,width=545,height=350");  
} 

function privacy() {
	//open("privacy.php","privacy","menubar,toolbar,resizable,scrollbars,width=570,height=500");
	void(0);
}	

function mappa() {
	open("mappa.php","mappa","menubar,toolbar,resizable,scrollbars,width=571,height=500");
}	

function credits() {
	open("credits.php","credits","width=325,height=390");
}	

function newsletter() {
	openNew("newsletter.php","resizable,menubar=no,scrollbars,width=570,height=400");  
} 

function cadcam() {
	open("Soluzioni-software-CAD-CAM-per-Lasertube.html","cadcam","resizable,scrollbars,width=568,height=500");
}	

function homepopup() {
	open("pop-up_ITA.html","ITA","resizable,scrollbars,width=568,height=500");
}	

function homepopuping() {
	open("pop-up_ING.html","ITA","resizable,scrollbars,width=568,height=500");
}	

function vgp3d() {
	open("vgp3d.php","vgp3d","resizable,scrollbars,width=568,height=500");
}	

function openContact(type, code) {
	open("form.php?type="+type+"&sel="+code,"contatti","resizable,scrollbars,width=570,height=500");
}	

function openContactAz(type, code) {
	open("form_az.php?type="+type+"&sel="+code,"contatti","resizable,scrollbars,width=570,height=500");
}	

function stampa(id) {
	open("stampa_prod.php?id="+id,"stampaprod","menubar,toolbar,resizable,scrollbars,width=570,height=500");
}

function print(id) {
	open("print_product.php?id="+id,"stampaprod","menubar,toolbar,resizable,scrollbars,width=570,height=500");
}
function wopen(surl,swname)
{
 window.open(surl,swname,'scrollbars=yes,width=590,height=580,status=no,toolbar=no,menubar=no,location=no,top=60,left=100');
}
