function toggleLayer( whichLayer ) {
	var elem, vis;
	if( document.getElementById ) // this is the way the standards work
		elem = document.getElementById( whichLayer );
	else if( document.all ) // this is the way old msie versions work
		elem = document.all[whichLayer];
	else if( document.layers ) // this is the way nn4 works
		elem = document.layers[whichLayer];
	vis = elem.style;

	// if the style.display value is blank we try to figure it out here
	if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
		vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
	vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function getHost() {
	var url = window.location.href;
	var nohttp = url.split('//')[1];
	var hostPort = nohttp.split('/')[0];
	var urlnoparams=url.split("?")[0];
}

var toggledElementSize;

// http://solutoire.com/2007/01/16/mootools-playing-with-height-transitions/

function toggleElement(element) {
	var elem;
	if( document.getElementById ) // this is the way the standards work
		elem = document.getElementById( element );
	else if( document.all ) // this is the way old msie versions work
		elem = document.all[element];
	else if( document.layers ) // this is the way nn4 works
		elem = document.layers[element];

	var toggle = new Fx.Style(elem, 'height',{duration: 250});

	//get the scrollSize of the contentElements
	toggledElementSize = elem.getSize().scrollSize.y;

	if(elem.getStyle('height').toInt() > 0){
		//hide
		toggle.start(0);
	}else{
		//show
		toggle.start(toggledElementSize);
	}
}


function f_setfocus( element )
{

	var elem;
	if( document.getElementById ) // this is the way the standards work
		elem = document.getElementById( element );
	else if( document.all ) // this is the way old msie versions work
		elem = document.all[element];
	else if( document.layers ) // this is the way nn4 works
		elem = document.layers[element];

	if( elem.elements[0]!=null) {
		var i;
		var max = elem.length;
		for( i = 0; i < max; i++ ) {
			if( elem.elements[ i ].type != "hidden" &&
				!elem.elements[ i ].disabled &&
				!elem.elements[ i ].readOnly ) {
				elem.elements[ i ].focus();
				break;
			}
		}
	}
}

function openWin(popup_url,name,width,height)
{
	var size = ',width=' + width + ',height=' + height;
	var posicion = ",left="+Math.round(screen.availWidth/3)+",top="+Math.round(screen.availHeight/3);
	var popUp=window.open(popup_url,name,',scrollbars=yes,resizable=yes,menubar=no,location=no,toolbar=no,status=no,directories=no,'+size+posicion);
	popUp.opener=self;
}

function pagina()
{
	var paginaSeleccionada = document.getElementById("paginaSel").value;
	irA(paginaSeleccionada);
}

function irA(pagina)
{
	pagina--;
	
	var location = window.location.href;
	
	if (location.charAt(location.length - 1) == '#')
	{
		location = location.substring(0, location.length - 1);
	}
	
	var idxBeginPagina = location.indexOf("pagina=") + 7;
	
	if (idxBeginPagina < 7)
	{		
		location = location + (location.indexOf("?") > 0 ? "&" : "?") + "pagina=" + pagina;
	}
	else
	{
		var idxEndPagina = location.indexOf("&", idxBeginPagina);
		if (idxEndPagina < 1)
		{
			idxEndPagina = location.length;
		}
		
		location = location.substring(0, idxBeginPagina) + pagina + location.substring(idxEndPagina, location.length);
	}
	
	window.location = location;	
}

