// JavaScript Document
//**************************************//
/*scroll*/
function verifyCompatibleBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}
bw=new verifyCompatibleBrowser()
var speed=20
var loop, timer
function ConstructObject(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.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
	this.up=MoveAreaUp;this.down=MoveAreaDown;
	this.MoveArea=MoveArea; this.x; this.y;
	this.obj = obj + "Object"
	eval(this.obj + "=this")
	return this
}
function MoveArea(x,y){
	this.x=x;this.y=y
	this.css.left=this.x+((bw.dom)?'px':'');
	this.css.top=this.y+((bw.dom)?'px':'');
}
function MoveAreaDown(move){
	if(this.y>-this.scrollHeight+objContainer.clipHeight){
	this.MoveArea(0,this.y-move)
	if(loop) setTimeout(this.obj+".down("+move+")",speed)
	}
}
function MoveAreaUp(move){
	if(this.y<0){
	this.MoveArea(0,this.y-move)
	if(loop) setTimeout(this.obj+".up("+move+")",speed)
	}
}
function pScroll(speed){
	if(initialised){
		loop=true;
		if(speed>0) objScroller.down(speed)
		else objScroller.up(speed)
	}
}
function cScroll(){
	loop=false
	if(timer) clearTimeout(timer)
}
var initialised;
function isa(){
	objContainer=new ConstructObject('news')
	objScrollers=new ConstructObject('scrollers')
	objScroller=new ConstructObject('newsContent','news')
	objScroller.MoveArea(0,0)
	objContainer.css.visibility='visible'
	objContainer.css.overflow='hidden'
	objScrollers.css.visibility='visible'
	initialised=true;
}
//popup
function viewImg(img,titolo) {
		w = window.open('','','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,copyhistory=no,width=200,height=200');	
		w.document.write( "<html><head><title>"+titolo+"</title>" );
		w.document.write( "<script language='JavaScript'>\n");
		w.document.write( "function autoSize() {\n");
		w.document.write( "resizeTo(document.images[0].width+27,document.images[0].height+122)\n");
		w.document.write( "	self.focus()\n");
		w.document.write( "}\n</script>\n");
		w.document.write( "</head><body style='margin:0px:padding:0px;text-align:center;' onLoad='javascript:autoSize();'>" );
		w.document.write( "<div style='margin:0px;padding:0px;'>");
		w.document.write("<a href='javascript:top.window.close();'>");
		w.document.write(" <img src='"+img+"' border=0 alt='"+titolo+"' title='"+titolo+"' style='margin:0px:padding:2px;border:1px solid #ccc;'/></a>" );
		w.document.write("<p style='font:11px Verdana, sans-serif;color:#999;text-align:center;margin:0px;padding:2px 2px 0px;'>Tutti i diritti riservati a<br />Rossella Deiana</p></div></body></html>" );
		w.document.close();
}

function hidden(el){
	var arra = new Array("tit","col","bio","lav");
	
	for(var i=0; i<arra.length; i++) {		
		if(arra[i] == el){
			var ob = document.getElementById(arra[i]) 	
			ob.style.display = "block";
		}else{	
			var ob = document.getElementById(arra[i]) 	
			ob.style.display = "none";
		}
	}
}

function too(n){
	for(var i=0; i<MyHeight.length; i++) { 		
		if(i == n){
			MyHeight[i].toggle();	
		}
	}
}


window.onload = function () { 	
if (document.getElementById('news')) {
	isa(); 
	}
	
if (document.getElementById("bio")) {
	MyHeight = new Array();
	MyHeight[0] = new fx.Height('chi', {duration: 400});
	MyHeight[0].toggle();		
	MyHeight[1] = new fx.Height('tit', {duration: 400});
	MyHeight[1].toggle();	
	MyHeight[2] = new fx.Height('lav', {duration: 400});
	MyHeight[2].toggle();		
	MyHeight[3]= new fx.Height('col', {duration: 400});
	MyHeight[3].toggle();	
}
}
