// JavaScript Document
//sub_hei=new Array("68", "136", "192", "24", "68");
var sub_hei = [];

function add_sub_hei(new_value){
	sub_hei.push(new_value);
}

function open_menu(num){
	var obj=document.getElementById("sub"+num);
	var obj2=document.getElementById("menu_cont"+num);
	if(obj.style.display=="block"){
		movement(num, false, sub_hei[num], sub_hei[num], 20);
	} else {
		obj.style.display="block";
		obj2.style.backgroundPosition="bottom left";
		obj.style.height="1px";
		movement(num, true, 1, sub_hei[num], 20);
		for(i=0; i<sub_hei.length-1; i++){
			if(i!=num){
				movement(i, false, sub_hei[i], sub_hei[i], 40);
			}
		}
	}
}

function movement(num, ope, start, finish, vel){
	var obj=document.getElementById("sub"+num);
	var obj2=document.getElementById("menu_cont"+num);
	if(!ope){
		if(start>1){
			start-=vel;
			if(start<1){
				start=1;
			}
			obj.style.height=start+"px";
			setTimeout(function () { movement(num, ope, start, finish, vel);}, 1);
		} else {
			obj.style.display="none";
			obj2.style.backgroundPosition="center left";
		}
	} else {
		if(start<finish){
			if(obj.style.height!=""){
				start+=vel;
				if(start>finish){
					start=finish;
				}
				obj.style.height=start+"px";
				setTimeout(function () { movement(num, ope, start, finish, vel);}, 1);
			}
		}
	}
}

function appari (e, tes, w, h){
	openPDA();
/*	var posy = 0;
	var posx = 0;
	
	if (!e) var e = window.event||window.Event;
	
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		sc_t=document.body.scrollTop;
		sc_l=document.body.scrollLeft;
	} else {
		sc_t=window.pageYOffset;
		sc_l=window.pageXOffset;
	}
	
	//document.body.style.overflow="hidden";
	//document.getElementsByTagName("html")[0].style.overflow = "hidden";
	document.getElementById("pop").style.visibility="visible";
	document.getElementById("pop").style.display="block";
	
	var myWidth = 0, myHeight = 0;
	if( typeof( document.height ) == 'number' ) {
		myWidth = window.innerWidth-25;
		myHeight = document.height;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		myWidth = document.body.clientWidth-10;
		myHeight = document.body.scrollHeight;
	}
	//window.alert( 'Width = ' + myWidth + ' and height = ' + myHeight + ' he: ' + document.body.scrollHeight );
	
	document.getElementById("pop").style.width=myWidth+"px";
	document.getElementById("pop").style.height=myHeight+"px";
	
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		//posy = (document.body.offsetHeight/2)-(h/2) + sc_t; 
		posx = (document.body.offsetWidth/2)-(w/2) + sc_l;
	} else {
		//posy = (window.innerHeight/2)-(h/2) + sc_t; 
		posx = (window.innerWidth/2)-(w/2) + sc_l;
		parent.scroll(1,sc_t)
	}
	//alert("t: "+document.body.clientHeight )
	
	document.getElementById("pop2").style.visibility="visible";
	document.getElementById("pop2").style.display="block";
	document.getElementById("pop2").style.width=w+"px";
	document.getElementById("pop2").style.height=h+"px";
		
	document.getElementById("pop2").style.top="100px";
	document.getElementById("pop2").style.left=posx+"px";*/
	//document.getElementById("pop2").innerHTML=tes;
}

function closed(e){
	if (!e) var e = window.event||window.Event;
	
	document.getElementById("pop2").style.visibility="hidden";
	document.getElementById("pop2").style.display="none";
	//document.body.style.overflow="auto";
	//document.getElementsByTagName("html")[0].style.overflow = "auto";
	document.getElementById("pop").style.visibility="hidden";
	document.getElementById("pop").style.display="none";
}

function open_win (pagina, scrol, nomefinestra, width, height ) {
	larghezza = screen.width;
	altezza = screen.height;
	spazio_oriz = (larghezza-width) / 2;
	spazio_vert = (altezza-height) / 2;
	parametri = "resizable=no,scrollbars="+scrol+",width="+width+",height="+height+",left="+spazio_oriz+",top="+spazio_vert;
	window.open (pagina, nomefinestra, parametri);
}
