function getWindowHeight() {var windowHeight = 0; if (typeof(window.innerHeight) == 'number') {windowHeight = window.innerHeight;} else {if (document.documentElement && document.documentElement.clientHeight) {windowHeight = document.documentElement.clientHeight;} else {if (document.body && document.body.clientHeight) {windowHeight = document.body.clientHeight;}}} return windowHeight;}
function setContent() {if (document.getElementById) {var windowHeight = getWindowHeight(); if (windowHeight > 0) {var contentElement = document.getElementById('content'); var contentHeight = contentElement.offsetHeight; if (windowHeight - contentHeight > 0) {contentElement.style.position = 'relative'; contentElement.style.top = ((windowHeight/2)-(contentHeight/2)-dlt) + 'px';contentElement.style.visibility='visible'} else {contentElement.style.position = 'static';}}}}
window.onload = function() {setContent();}
window.onresize = function() {setContent();}

function checkBros() {
	this.ver=navigator.appVersion;
	this.agent=navigator.userAgent;
	this.dom=document.getElementById?1:0;
	this.opera5=this.agent.indexOf("Opera 5")>-1;
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie7=(this.ver.indexOf("MSIE 7")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6||this.ie7;
	this.mac=this.agent.indexOf("Mac")>-1;
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom && !this.ns6)?1:0;
	return this;
}
var bros=new checkBros()
function getObj(obj) {
	this.css = bros.dom?document.getElementById(obj).style:bros.ie4?document.all[obj].style:bros.ns4?document.layers[obj]:0;
   	this.obj = bros.dom?document.getElementById(obj):bros.ie4?document.all[obj]:bros.ns4?document.layers[obj].document:0;
}
function show(fil)	{
	w = 500;
	h = 500;
	pop = window.open("show.php?fil="+fil, "Visualizza", "top="+((screen.height-h)/2)+", left="+((screen.width-w)/2)+", width="+w+", height="+h+", resizable=no, scrollbars=no, menubar=no");
	pop.focus();
}
function go_prod(urls) {
	document.location.href = urls+'&ofsO='+scrollO_txt_div.css.left.replace('px','')+'&ofsV='+scrl_0.scrl.css.top.replace('px','');
}
function go_sub(urls) {
	document.location.href = urls+'&ofsV='+scrl_0.scrl.css.top.replace('px','');
}
var intID;
var step = 5;
var ltw = 355;
function scrollO_move(){
	lt = parseInt(scrollO_txt_div.css.left.replace('px',''));
	if ((lt<=0)&&(lt>=-scrollO_txt_div.obj.offsetWidth+ltw+21)) scrollO_txt_div.css.left = (lt+step)+'px';
	else {
		letsgoO = false;
		clearInterval(intID);
		if (lt>0) scrollO_txt_div.css.left = '0px';
		else if(lt<-scrollO_txt_div.obj.offsetWidth+ltw) scrollO_txt_div.css.left = (-scrollO_txt_div.obj.offsetWidth+ltw-5)+'px';
	}	
}
letsgoO = false;
function scrollO_start(stp) {
	if (stp==0) {
		letsgoO=false;
		clearInterval(intID);
	} else if (!letsgoO) {
		lt = parseInt(scrollO_txt_div.css.left.replace('px',''));
		if ((lt<=10)&&(lt>=-scrollO_txt_div.obj.offsetWidth+ltw+18-stp)) {
			if (!((lt>=0)&&(stp>0))) {
				step = stp;
				scrollO_txt_div.css.left = (lt+step)+'px';
				intID = setInterval(scrollO_move, 50);
				letsgoO = true;
			}
		}
	}
}
function scrollO_init() {
	scrollO_div = new getObj('scroll');
	scrollO_txt_div = new getObj('scroll_txt');
	scrollO_txt_div.css.left = lt;
}
function scrollV_move(scrl){
	var tp = parseInt(scrl.css.top.replace('px',''));
	if ((tp<=0)&&(tp>=-scrl.obj.offsetHeight+scrl.outh)) {
		scrl.css.top = (tp+scrl.step)+'px';
		if ((scrl.step>0)&&(scrl.step<5)) scrl.step+=0.3;
		else if ((scrl.step<0)&&(scrl.step>-5)) scrl.step-=0.3;
	} else {
		scrl.on=false;
		clearInterval(scrl.intID);
		if (tp>0) scrl.css.top = '0px';
		else if(tp<-scrl.obj.offsetHeight+scrl.outh) scrl.css.top = (-scrl.obj.offsetHeight+scrl.outh)+'px';
	}	
}
function scrollV_ctrl(stp) {
	if (stp==0) {
		this.scrl.on=false;
		clearInterval(this.scrl.intID);
	} else if (!this.on) {
		var tp = parseInt(this.scrl.css.top.replace('px',''));
		if ((tp<=10)&&(tp>=-this.scrl.obj.offsetHeight+this.scrl.outh-stp)) {
			if (!((tp>=0)&&(stp>0))) {
				this.scrl.step = stp;
				this.scrl.css.top = (tp+stp)+'px';
				this.scrl.intID = setInterval("scrollV_move(scrl_"+this.ID+".scrl)", 50);
				this.scrl.on = true;
			}
		}
	}
}
function scrollObj(ID, outh, tp) {
	this.ctrl = scrollV_ctrl;
	this.scrl = new getObj('smcrltxt'+ID);
	this.scrl.css.top = tp+'px';
	this.ID = ID;
	this.scrl.on = false;
	this.scrl.outh = outh;
	this.scrl.step = 1;
}
