pos=navigator.appVersion.search(" ");
appVer=navigator.appVersion.substr(0,pos);

//######################### INIZIO SCROLLING ORIZZONTALE ############################################
// By Ernst Straka (ernst.straka@central-europe.basf.org http://www.rs-systems.at/straka)
// Courtesy of SimplytheBest.net (http://simplythebest.net/info/dhtml_scripts.html)
/*var l1 =   35; // left of ticker in pixel, or 0 to position relative
var t1 = 320; // top of ticker in pixel, or 0 to position relative
//var w1 = 725; // width of ticker in pixel
var w1 = 1350; // width of ticker in pixel
var ie = document.all ? true : false;
var first = true;
var l2 = l1 + w1;
var l3 = l1 - l2;
var l = l2;
function tickinit() {
    if (ie) {
        if (l1 == 0 && t1 == 0) {
            pos = document.all['tickpos'];
            l1 = getLeft(pos);
            t1 = getTop(pos);
        }
        ticktext.style.posTop = t1;
    } else {
        if (l1 == 0 && t1 == 0) {
            pos = document.anchors['tickpos'];
            l1 = pos.x;
            t1 = pos.y;
        }
        
        if (Browser=="NS") {
            document.getElementById("ticktext").pageY = t1;
        } else {
            document.ticktext.pageY = t1;
        }
    }
    l2 = l1 + w1;
    l3 = l1 - l2;
    l = l2;
    setInterval('tick()',100);
}

function getLeft(ll) {
    if (ll.offsetParent)
        return (ll.offsetLeft + getLeft(ll.offsetParent));
    else 
        return (ll.offsetLeft);
}

function getTop(ll) {
    if (ll.offsetParent)
        return (ll.offsetTop + getTop(ll.offsetParent));
    else
        return (ll.offsetTop);
}

function tick() {
    l = l - 8;
    if (l < l3) l = l2;
    cl = l1 - l;
    cr = l2 - l;
    if (ie) {
        ticktext.style.posLeft = l;
        ticktext.style.posTop = t1;
        ticktext.style.clip = "rect(auto "+cr+"px auto "+cl+"px)";
        if (first) ticktext.style.visibility = "visible";
    } else {
        if (Browser=="NS") {
            
        } else {
            document.ticktext.pageX = l;
            document.ticktext.clip.left = cl;
            document.ticktext.clip.right = cr;
            if (first) document.ticktext.visibility = "show";
        }
    }
    first = false;
}*/
//######################### FINE SCROLLING ORIZZONTALE ############################################

//######################### INIZIO SCROLLING VERTICALE ############################################
/* Adesso si sposta anche orizzontalmente -> thanx to Marco Di Mitro*/
function lib_bwcheck(){ //Browsercheck (needed)
	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.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}

var bw=new lib_bwcheck()
/*****************
You set the width and height of the divs inside the style tag, you only have to
change the divScrollTextCont, Remember to set the clip the same as the width and height.
You can remove the divUp and divDown layers if you want. 
This script should also work if you make the divScrollTextCont position:relative.
Then you should be able to place this inside a table or something. Just remember
that Netscape crash very easily with relative positioned divs and tables.
Updated with a fix for error if moving over layer before pageload.
****************/

//If you want it to move faster you can set this lower, it's the timeout:
var speed = 30

//Sets variables to keep track of what's happening
var loop, timer

//Object constructor
function makeObj(obj,nest){
    nest=(!nest) ? "":'document.'+nest+'.';
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
  	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
	this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
    this.scrollWidth=bw.ns4?this.css.document.width:this.el.offsetWidth
	this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
    this.clipWidth=bw.ns4?this.css.clip.width:this.el.offsetWidth
	this.up=goUp;
    this.down=goDown;
    this.right=goRight;
    this.left=goLeft;
	this.moveIt=moveIt; this.x=0; this.y=0;
    this.obj = obj + "Object"
    eval(this.obj + "=this")
    return this
}

// A unit of measure that will be added when setting the position of a layer.
var px = bw.ns4||window.opera?"":"px";

function moveIt(x,y){
	this.x = x
	this.y = y
	this.css.left = this.x+px
	this.css.top = this.y+px
}

//Makes the object go up
function goDown(move,N){
    eval("var clipH=oCont" + N +".clipHeight");
    if (this.y>-this.scrollHeight+clipH){
		this.moveIt(0,this.y-move)
			if (loop) setTimeout(this.obj+".down("+move+",'"+N+"')",speed)
	}
}

//Makes the object go down
function goUp(move,N){
    if (this.y<0){
		this.moveIt(0,this.y-move)
		if (loop) setTimeout(this.obj+".up("+move+",'"+N+"')",speed)
	}
}

//Makes the object go up
function goRight(move,N){
    eval("var clipW=oCont" + N +".clipWidth");
    if (this.x>-this.scrollWidth+clipW){
        this.moveIt(this.x-move,0)
		if (loop) setTimeout(this.obj+".right("+move+",'"+N+"')",speed)
	}
}

//Makes the object go down
function goLeft(move,N){
    if (this.x<0){
		this.moveIt(this.x-move,0)
	    if (loop) setTimeout(this.obj+".left("+move+",'"+N+"')",speed)
	}
}

//Stops the scrolling (called on mouseout)
function noScroll(){
	loop = false
	if (timer) clearTimeout(timer)
}

//Makes the object
var scrolltextLoaded = false
function scrolltextInit(N) {
    eval("oCont" + N + " = new makeObj('divScrollTextCont" + N + "')");
	eval("oScroll" + N + " = new makeObj('divText" + N + "','divScrollTextCont" + N + "')");
	eval("oScroll" + N + ".moveIt(0,0)");
}

//Calls the scrolling functions. Also checks whether the page is loaded or not.
function scroll(speed,N){
    if (scrolltextLoaded){
        loop = true;
		if (speed>0) eval("oScroll" + N + ".down(speed,N)");
		else eval("oScroll" + N + ".up(speed,N)");
	}
}

//Calls the scrolling functions. Also checks whether the page is loaded or not.
function scrollO(speed,N){
    if (scrolltextLoaded){
        loop = true;
		if (speed>0) eval("oScroll" + N + ".right(speed,N)");
		else eval("oScroll" + N + ".left(speed,N)");
	}
}
//######################### FINE SCROLLING VERTICALE ############################################


function SwapImage(LayerName, ImgName, Path) {
    //Marco Di Mitro
    //Carica l'immagine situata percorso Path al posto dell'immagine Name.
    //Se l'immagine fa parte di un layer occorre specificarne il nome in LayerName, altrimenti
    //passare come primo parametro una stringa vuota.     
    if (LayerName=="") {
        document.images[ImgName].src=Path;
    } else {
        if (navigator.appName=="Netscape") {
            if (appVer < 5.0) {
                document.layers[LayerName].document.images[ImgName].src=Path;
            } else {
                document.images[ImgName].src=Path;
            }
        } else {
            document.images[ImgName].src=Path;
        }
    }
}

//visualizza i layer dello spettacolo di codice segnalato
function ViewThisShow (N) {
    if (CodLayer!="") {
        ViewLayer("divText1_" + CodLayer, false);
        ViewLayer("divScrollTextCont1_" + CodLayer, false);
        ViewLayer("divText3_" + CodLayer, false);
        ViewLayer("divScrollTextCont3_" + CodLayer, false);
        ViewLayer("image" + CodLayer, false);
        ViewLayer("titolo" + CodLayer, false);
    }
    
    ViewLayer("divText1_" + N, true);
    ViewLayer("divScrollTextCont1_" + N, true);
    ViewLayer("divText3_" + N, true);
    ViewLayer("divScrollTextCont3_" + N, true);
    ViewLayer("image" + N, true);
    ViewLayer("titolo" + N, true);
        
    if (CodLayer=="") {
        ViewLayer("divUp1",true);
        ViewLayer("divUp2",true);
        ViewLayer("divUp3",true);
        ViewLayer("divDown1",true);
        ViewLayer("divDown2",true);
        ViewLayer("divDown3",true);
    }
    CodLayer=N;
}

function CmdMenu(CmdName) {
    window.parent.frames["testata"].Menu(CmdName);
}
