function closeDiv(divname) {

	var elem = document.getElementById(divname);
	elem.style.display = 'none' ;
}

function toggleDisplay(fO){
	
	var ns4 = (document.layers);
	var ie4 = (document.all && !document.getElementById);
	var ie5 = (document.all && document.getElementById);
	var ns6 = (!document.all && document.getElementById);


	if(ie5 || ns6){
		if (document.getElementById(fO).style.display=="none") {
		document.getElementById(fO).style.display="inline";
		}else{
		document.getElementById(fO).style.display="none";
		}
	}

	if(ie4){
		if (document.all[fO].style.display=="none") {
		document.all[fO].style.display="inline";
		}else{
		document.all[fO].style.display="none";
		}
	}	
}


/*************************************************
*	BOTTONIERA TOP
**************************************************/

function setAllOut(ownerId) {

	var classe="" ;
	var alldiv = document.getElementsByTagName("td");
	var nu = alldiv.length;
	var curr = "" ;
	
	for (i=0; i < nu; i++) {
		
		if (alldiv[i].getAttribute('id') 
			&& alldiv[i].getAttribute('id')!= null 
			&& alldiv[i].getAttribute('id') != "null") {
			
				if (alldiv[i].getAttribute('id').substring(0,9) == "idBtnTop_") {
					
					if (alldiv[i].getAttribute('id') != "idBtnTop_"+ownerId) {
						
						if (alldiv[i].getAttribute('id') == 'idBtnTop_1' || alldiv[i].getAttribute('id') == 'idBtnTop_2' || alldiv[i].getAttribute('id') == 'idBtnTop_3') {
							classe = "_small" ;
						}
						else {
							classe = "" ;
						}
						
						curr = document.getElementById(alldiv[i].getAttribute('id')) ;
						curr.className = 'testomenu vocemenu'+classe ;
						
					}
					
				}
				
		}
	}
	
}

function showSottomenu(idx,idxSm,periodo) {

	var show = true ;
	if (document.formTop.lastParent.value != idx) {
		show = true ;
	}
	else {
		show = false ;
	}
	
	if (show) {
		
		document.formTop.lastParent.value = idx ;
		
		var sm  = document.getElementById('sottomenu') ;
		sm.innerHTML = '' ;
		
		var ajaxObj = new ClassAJAX();
		ajaxObj.setExecute(true) ;
		ajaxObj.setElement('sottomenu') ;
		ajaxObj.setReturn(false) ;
		ajaxObj.setLoading(false) ;
		ajaxObj.setLoadingSottomenu('barra_3',periodo) ;
		if (idxSm) {
			ajaxObj.runAJAX('./ajax/ajax.asp?action=showSottomenu&id_menu='+idx+'&id_sottomenu='+idxSm) ;
		}
		else {
			ajaxObj.runAJAX('./ajax/ajax.asp?action=showSottomenu&id_menu='+idx) ;
		}
		
		var barra_3 = document.getElementById("barra_3");
		barra_3.style.backgroundImage="url(img/"+periodo+"sottomenu_"+idx+".gif)";
	}	
}

function setLastFather(idx) {

}

function btnTopSwitchOut(obj, classe, nome) {
	
	var lastParent = document.formTop.lastParent.value ;
	if (nome != lastParent) {
		obj.className=classe ;		
	}
	
	
}

function setVariables(){
	if (navigator.appName == "Netscape") {
		if (parseInt(navigator.appVersion) >= 5){
			v=".top=";
			h=".left=";
			dS="document.getElementById(\"";sD="\").style";
			y="window.pageYOffset";
			x="window.pageXOffset";
		}
		else {
			v=".top=";
			h=".left=";
			dS="document.";
			sD="";
			y="window.pageYOffset";
			x="window.pageXOffset";
		}
	}
	else {
	//ENTRO QUI
		h=".pixelLeft=";
		v=".pixelTop=";
		dS="";
		sD=".style";
		y="document.body.scrollTop";
		x="document.body.scrollLeft";
	}
	checkLocationA()
}

movex=0,movey=0,xdiff=0,ydiff=0,ystart=0,xstart=0
var elFake ;


function checkLocation(){
	object="obj";
	yy=eval(y);
	xx=eval(x);
	ydiff=ystart-yy;
	xdiff=xstart-xx;
	
	if ((ydiff<(-1))||(ydiff>(1))) {
		movey=Math.round(ydiff/10) ;
		ystart-=movey ;
	}
	if ((xdiff<(-1))||(xdiff>(1))) {
		movex=Math.round(xdiff/10) ; 
		xstart-=movex ;
	}
	
	if (ystart>=10){
		
		var alldiv = document.body.getElementsByTagName("DIV");
		nu = alldiv.length ;
		var altro_div = null ;
	
		
		for(r=0;r<nu;r++){
			if("DivAnag" == alldiv[r].getAttribute('id')){
				altro_div = alldiv[r].getAttribute('id');		
			}
		}
		
		/*elFake = document.getElementById(altro_div).style ;
		var newY = ystart+10 ;
		eval("elFake"+".top="+newY) ;*/
		
	} 
	else {
		var alldiv = document.body.getElementsByTagName("DIV");
		nu = alldiv.length ;
		var altro_div = null ;
	
		
		for(r=0;r<nu;r++){
			if("DivAnag" == alldiv[r].getAttribute('id')){
				altro_div = alldiv[r].getAttribute('id');		
			}
		}
	}


	var alldiv = document.body.getElementsByTagName("DIV");
	nu = alldiv.length ;
	var altro_div = null ;

	
	for(r=0;r<nu;r++){
		if("DivAnag" == alldiv[r].getAttribute('id')){
			altro_div = alldiv[r].getAttribute('id');		
		}
	}
	
	/*elFake = document.getElementById(altro_div).style ;
	var newX = xstart ;
	//eval("elFake"+".left="+newX) ;*/
		
	setTimeout("checkLocation()",10);
}

function checkLocationA(){
	ystart=eval(y);
	xstart=eval(x);
}


function changeCalMonth(CalAction, currMonth, currYear) {
	
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.setLoading(false) ;
	ajaxObj.runAJAX('./ajax/ajax.asp?action=changeCalMonth&CalAction='+CalAction+'&currMonth='+currMonth+'&currYear='+currYear) ;
	
	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {
			
				window.clearInterval(myInterval);

				var ele = document.getElementById('calendario') ;
				ele.innerHTML = html ;
			}
		}
	}
	,1) ;	
}

