/*
//////////////////////////////////////////////////////////////////////////////////////////////////////////// Conlegno
Conlegno_URL = function(){
	///////////////////////////////
	var strURL = document.location + "#";
	var G = Conlegno_Chunk(strURL, "&g0=", "#"); 
	///////////////////////////////
	return G;
	///////////////////////////////
}
/////////////////////////////////////////////////////////////////////////////////////////////
Conlegno_Chunk = function( xStr, TagStart, TagEnd ){
	///////////////////////////////
	var nTagS = xStr.indexOf(TagStart, 0);
	if( nTagS==-1 )return '';
	///////////////////////////////
	var nTagE = xStr.indexOf(TagEnd, nTagS + TagStart.toString().length);
	nTagS += TagStart.toString().length;
	if( nTagE > nTagS ) return xStr.substring(nTagS, nTagE);
	///////////////////////////////
	return '';
	///////////////////////////////
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////// 
*/


/*
////////////////////////////////////////////////////////////////////////////////////////////////////////////  Conlegno_OverlaySplashInit
Conlegno_OverlaySplashInit = function( xTg, xSession ){
	//////////////////////////////////// 	
	var C = parseCookie();
	var curDiv = getDivStyle(xTg);
	
	if( C[xTg] == xSession ){
		curDiv.display = "none";
	} else {			
		curDiv.display = "";
	}
	//////////////////////////////////// 
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
Conlegno_OverlaySplashHide = function( xTg, xSession ){
	//////////////////////////////////// 
	var curDiv = document.getElementById(xTg);	
	curDiv.innerHTML = "";		
	//////////////////////////////////// 
	setCookie( xTg + '=' + xSession );
	//////////////////////////////////// 
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////// 
*/

/*
//////////////////////////////////////////////////////////////////////////////////////////////////////////// Menu a tendina
OffPos = function( xTg, xPos ){
	//////////////////////////////////// 
	if( !xTg ) return xPos;
	if( xTg.offsetParent!=null ){
		xPos[0] += xTg.offsetParent.offsetLeft; 
		xPos[1] += xTg.offsetParent.offsetTop;
		xPos = OffPos( xTg.offsetParent, xPos );
	}
	//////////////////////////////////// 
	return xPos;
	////////////////////////////////////  
}
*/


/////////////////////////////////////////////////////////////////////////////////////////////
var MMenu;
MMenu = function(){
	this.Items = new Array();
	this.ItemShow = '';
}
/////////////////////////////////////////////////////////////////////////////////////////////
MMenu.prototype.Add = function( ID, Title, Text, Link, Sel, Target ){
	if( !this.Items[ID] ){
		this.Items[ID] = new Array();
	}
	this.Items[ID].push({ID:ID, Title:Title, Text:Text, Link:Link,  Sel:Sel, Target:Target});
}
/////////////////////////////////////////////////////////////////////////////////////////////
MMenu.prototype.Update = function(){

	for( var key in this.Items ){		
		var tg = document.getElementById('tendina'+key.replace(",","-"));
		var tgS = getDivStyle('tendina'+key);
		var tgMenu = document.getElementById('ConlegnoMenu');
		//var Pos = OffPos(tgMenu, [0, tgMenu.offsetTop] );

		if( tg ){
			var HTML = tg.innerHTML;
			if( this.Items[key] ){
				for( i=0; i<this.Items[key].length; i++ ){
					var Obj = this.Items[key][i];

					HTML += '<div class="menu1_0_1item'+Obj.Sel+'" onmouseover="javascript:sMenu.TendinaOver(\''+Obj.ID.replace(",","-")+'\');" onmouseout="javascript:sMenu.TendinaOut(\''+Obj.ID.replace(",","-")+'\');">' + '\n';
					HTML += '	<a href="'+Obj.Link+'" class="menu1_0_1'+Obj.Sel+'" title="'+Obj.Title+'" '+Obj.Target+'>' + Obj.Text + '</a>' + '\n';
					HTML += '</div>' + '\n';

				}
				tg.innerHTML = HTML;
				/*tgS.top = Pos[1]+3+'px';*/
			}
		}				
	}
}
/////////////////////////////////////////////////////////////////////////////////////////////
MMenu.prototype.Show = function( key, show ){

	this.TimerEnd();

	if( show=='' ){
		this.Show( this.ItemShow, 'none' );
		this.ItemShow = key;  
	} else {
		this.ItemShow = '';  
	}

	var tg = document.getElementById('tendina'+key.replace(",","-"));
	var tgS = getDivStyle('tendina'+key);	
	if( tgS ){
		var Obj = this.Items[key];
		if( this.Items[key] ){
			tgS.display = show;
		}
	}

}
/////////////////////////////////////////////////////////////////////////////////////////////
MMenu.prototype.TendinaOver = function( key ){
	this.TimerEnd();
}
/////////////////////////////////////////////////////////////////////////////////////////////
MMenu.prototype.TendinaOut = function( key ){
	this.TimerEnd();
	this.TimerInit(key); 
}
/////////////////////////////////////////////////////////////////////////////////////////////
MMenu.prototype.TimerInit = function( key ){
	var Self = this;
	this.closeTimer = window.setTimeout(function(){ 
			Self.Show(key, 'none'); 
		}, 1000);
}
/////////////////////////////////////////////////////////////////////////////////////////////
MMenu.prototype.TimerEnd = function(){
	clearTimeout( this.closeTimer );
}
/////////////////////////////////////////////////////////////////////////////////////////////
