var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

// Calcolo la dimensione dello schermo client
var frameWidth = 0;
var frameHeight = 0;

if (self.innerWidth)
{
	frameWidth = self.innerWidth;
	frameHeight = self.innerHeight;
}
else if (document.documentElement && document.documentElement.clientWidth)
{
	frameWidth = document.documentElement.clientWidth;
	frameHeight = document.documentElement.clientHeight;
}
else if (document.body)
{
	frameWidth = document.body.clientWidth;
	frameHeight = document.body.clientHeight;
}


// Calcolo il posizionamento del mouse
// Set Netscape up to run the "captureMousePosition" function whenever
// the mouse is moved. For Internet Explorer and Netscape 6, you can capture
// the movement a little easier.
if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}
// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function captureMousePosition(e) {
    if (document.layers) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
        // When the page scrolls in IE, the event's mouse position
        // reflects the position from the top/left of the screen the
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no
        // matter if the user has scrolled or not.
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {
        // Netscape 6 behaves the same as Netscape 4 in this regard
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
}



//------------------------------------------------------------------------------
function gotoPage(time, url) { 
   page = url; 
   timer = setTimeout('redirect()', time); 
} 
//------------------------------------------------------------------------------
function redirect() { 
   window.location = page;    
}
//------------------------------------------------------------------------------
function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
//------------------------------------------------------------------------------
function preview_foto(app, idfoto, larghezza, altezza){
	//altezza=altezza+80;
	//larghezza=larghezza+40;
	window.open('preview_foto.php?app='+app+'&idfoto='+idfoto, 'preview'+idfoto, "height="+altezza+",width="+larghezza+",toolbar=no,scrollbars=no,resizable=yes,status=no", "replace=false");
}
//------------------------------------------------------------------------------
function preview_foto2(app, larghezza, altezza, url, Scrollb)
{
	if(!Scrollb){
		Scrollb='no'
	}
	//altezza=altezza+80;
	//larghezza=larghezza+40;
	window.open('preview_foto.php?app='+app+'&url='+url, 'preview', "height="+altezza+",width="+larghezza+",toolbar=no,scrollbars="+Scrollb+",resizable=yes,status=no", "replace=false");
	
	
}
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
function apri_finestra(URL, name, larghezza, altezza, scroll){
	// Semplice funzione che apre una finestra
	if(!scroll){
		scroll=1;
	}
	window.open(URL, name,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+scroll+",resizable=1,width="+larghezza+",height="+ altezza +"");
	

}
//------------------------------------------------------------------------------

var navName = navigator.appName;
var navVer = navigator.appVersion;
IE4 = (navName == "Microsoft Internet Explorer" && navVer >="4");
N4 = (navName == "Netscape" && navVer >= "3");
var loaded = "0";


function loadImages(){
	if (IE4 || N4){
		
		menu1=new Image();
		menu01=new Image();
		menu2=new Image();
		menu02=new Image();
		menu3=new Image();
		menu03=new Image();
		menu4=new Image();
		menu04=new Image();
		menu5=new Image();
		menu05=new Image();
		menu6=new Image();
		menu06=new Image();
		menu7=new Image();
		menu07=new Image();
		menu8=new Image();
		menu08=new Image();
		menu9=new Image();
		menu09=new Image();
		menu10=new Image();
		menu010=new Image();
		
		menu11=new Image();
		menu011=new Image();
		menu12=new Image();
		menu012=new Image();
		menu13=new Image();
		menu013=new Image();
		menu14=new Image();
		menu014=new Image();
		menu15=new Image();
		menu015=new Image();
		menu16=new Image();
		menu016=new Image();
		menu17=new Image();
		menu017=new Image();
		menu18=new Image();
		menu018=new Image();
		menu19=new Image();
		menu019=new Image();
		menu20=new Image();
		menu020=new Image();
		
			
        menu1.src="/visitors/images/square-phgallery-a2.jpg";	
		menu01.src="/visitors/images/square-phgallery-a.gif";
		menu2.src="/visitors/images/square-modelli-a2.jpg";	
		menu02.src="/visitors/images/square-modelli-a.gif";		
		menu3.src="/visitors/images/square-filmgallery-a2.jpg";	
		menu03.src="/visitors/images/square-filmgallery-a.gif";		
		menu4.src="/visitors/images/square-contatti-a2.jpg";	
		menu04.src="/visitors/images/square-contatti-a.gif";		
		menu5.src="/visitors/images/square-dealers-a2.jpg";	
		menu05.src="/visitors/images/square-dealers-a.gif";		
		menu6.src="/visitors/images/square-riva-a2.jpg";	
		menu06.src="/visitors/images/square-riva-a.gif";		
		menu7.src="/visitors/images/square-news-a2.jpg";	
		menu07.src="/visitors/images/square-news-a.gif";		
		menu8.src="/visitors/images/square-shop-a2.jpg";	
		menu08.src="/visitors/images/square-shop-a.gif";		
		menu9.src="/visitors/images/square-eventi-a2.jpg";	
		menu09.src="/visitors/images/square-eventi-a.gif";		
		menu10.src="/visitors/images/square-usato-b.gif";	
		menu010.src="/visitors/images/square-usato-a.gif";								
		
		menu11.src="/visitors/images/square-phgallery-a2.jpg";	
		menu011.src="/en/visitors/images/square-phgallery-a-en.gif";
		menu12.src="/visitors/images/square-modelli-a2.jpg";	
		menu012.src="/en/visitors/images/square-modelli-a-en.gif";		
		menu13.src="/visitors/images/square-filmgallery-a2.jpg";	
		menu013.src="/en/visitors/images/square-filmgallery-a-en.gif";		
		menu14.src="/visitors/images/square-contatti-a2.jpg";	
		menu014.src="/en/visitors/images/square-contatti-a-en.gif";		
		menu15.src="/visitors/images/square-dealers-a2.jpg";	
		menu015.src="/en/visitors/images/square-dealers-a-en.gif";		
		menu16.src="/visitors/images/square-riva-a2.jpg";	
		menu016.src="/en/visitors/images/square-riva-a-en.gif";		
		menu17.src="/visitors/images/square-news-a2.jpg";	
		menu017.src="/en/visitors/images/square-news-a-en.gif";		
		menu18.src="/visitors/images/square-shop-a2.jpg";	
		menu018.src="/en/visitors/images/square-shop-a-en.gif";		
		menu19.src="/visitors/images/square-eventi-a2.jpg";	
		menu019.src="/en/visitors/images/square-eventi-a-en.gif";		
		menu20.src="/visitors/images/square-usato-b.gif";	
		menu020.src="/en/visitors/images/square-usato-a-en.gif";				
						
		loaded = 1;
			}
		}
		
//------------------------------------------------------------------------------
function show(nome, num){
//alert(nome + num);
	if (loaded == "1"){
		if (IE4 || N4){
			document [nome].src = eval("menu" + num + ".src")
		}
	}
}

var winW = 630, winH = 460;
if (parseInt(navigator.appVersion)>3) {
	if (navigator.appName=="Netscape") {
		winW = window.innerWidth;
		winH = window.innerHeight;
	}
	/*if (navigator.appName.indexOf("Microsoft")!=-1) {
 		winW = document.body.offsetWidth;
		winH = document.body.offsetHeight;
	}*/
}
var nshack = ((winW - 770) /2);
//alert(winW);

//------------------------------------------------------------------------------





