
function openWindow(URL, ancho, alto) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, 'ventana', 'toolbar=no, scrollbars=no, location=no, statusbar=no, menubar=no, resizable=yes, width=" + ancho + ",height=" + alto + "');");
	eval("page" + id + ".focus();");
}

function getURLParameter( name )
{
 var regexS = "[\\?&]"+name+"=([^&#]*)";
 var regex = new RegExp( regexS );
 var tmpURL = window.location.href;
 var results = regex.exec( tmpURL );
 if( results == null )
 return "";
 else
 return results[1];
}


function show(id) {
	document.getElementById(id).style.display = 'block'
}
function hide(id) {
	document.getElementById(id).style.display = 'none'
}
function showHide(id) {
	if (document.getElementById(id).style.display == 'none')
		document.getElementById(id).style.display = 'block'
	else
		document.getElementById(id).style.display = 'none'
}
function swap(id1, id2) {
	if (document.getElementById(id1).style.display == 'none') {
		document.getElementById(id1).style.display = 'block'
		document.getElementById(id2).style.display = 'none'
	} else {
		document.getElementById(id1).style.display = 'none'
		document.getElementById(id2).style.display = 'block'
	}
}


function CheckAll()
{	count = document.Form1.elements.length;
 for (i=0; i < count; i++) 
	{	if(document.Form1.elements[i].checked == 1)
 {	document.Form1.elements[i].checked = 0; }
 else
		{	document.Form1.elements[i].checked = 1;	}
	}
}
function UncheckAll()
{	count = document.Form1.elements.length;
 for (i=0; i < count; i++) 
	{	if(document.Form1.elements[i].checked == 1)
 {	document.Form1.elements[i].checked = 0; }
 else
		{	document.Form1.elements[i].checked = 1;	}
	}
}


function resizeWindow(ancho, alto)
{
	ventana.resizeTo(ancho+12,alto+28);
	ventana.moveTo((screen.width-ancho)/2,(screen.height-alto)/2); //centra la ventana. Eliminar si no se quiere centrar el popup
}

function resizeImage(idImg) { 
	var maxwidth = 90; 
	var maxheight = 90; 
	var image = document.getElementById(idImg);
	//alert(image.id)
	if (image.width>maxwidth || image.height>maxheight) { 
		var scale = Math.min((maxwidth/image.width),(maxheight/image.height), 1); 
		var new_width = Math.floor(scale*image.width); 
		var new_height = Math.floor(scale*image.height); 
		image.width = new_width;
		image.height = new_height;
	} 
}


function removeNode(n){
 if(n.hasChildNodes())
 for(var i=0;i<n.childNodes.length;i++)
 n.parentNode.insertBefore(n.childNodes[i].cloneNode(true),n);
 n.parentNode.removeChild(n);
}
/**************************************************************************
 *                                                                        *
 * JAVASCRIPT MENU HIGHLIGHTER v.1.0 (051123)                             *
 * --------------------------------------------                           *
 * ©2005 Media Division (www.MediaDivision.com)                           *
 *                                                                        *
 * Written by Marius Smarandoiu & Armand Niculescu                        *
 *                                                                        *
 * You are free to use, modify and distribute this file, but please keep  *
 * this header and credits                                                *
 *                                                                        *
 * Usage:                                                                 *
 * - the script will apply the .current class to the <a> and its parent   *
 * <li>that is contained in the element with id="primarynav" and points   *
 * to the current URL                                                     *
 * - works in IE6, Firefox and Opera                                      *
 **************************************************************************/
function extractPageNameA(hrefString)
{	var arr = hrefString.split('.');
	arr = arr[arr.length-2].split('/');
	return arr[arr.length-2].toLowerCase();		
}
function extractPageNameB(hrefString)
{	var arr = hrefString.split('.');
	arr = arr[arr.length-2].split('/');
	return arr[arr.length-1].toLowerCase();		
}
function setActiveMenuA(arr, crtPage)
{	for(var i=0; i < arr.length; i++)
	{	if(extractPageNameA(arr[i].href) == crtPage)
		{	arr[i].className = "current";
			arr[i].parentNode.className = "current";
			//alert('/' + crtPage)
			//removeNode(arr[i]);
		}
	}
}
function setActiveMenuB(arr, crtPage)
{	for(var i=0; i < arr.length; i++)
	{	if(extractPageNameB(arr[i].href) == crtPage)
		{	arr[i].className = "current";
			arr[i].parentNode.className = "current";
			//alert(crtPage+'.html')
			//removeNode(arr[i]);
		}
	}
}
function hrefString()
{	if(document.location.href) 
		return document.location.href;
	else
		return document.location;
}
function setPageMenuNivel2A()
{	if (document.getElementById("navlist2")!=null)
		setActiveMenuA(document.getElementById("navlist2").getElementsByTagName("a"), extractPageNameA(hrefString()));
}
function setPageMenuNivel2B()
{	if (document.getElementById("navlist2")!=null)
		setActiveMenuB(document.getElementById("navlist2").getElementsByTagName("a"), extractPageNameB(hrefString()));
}
function setPageMenuNivel4A()
{	if (document.getElementById("navlist4")!=null) 
		setActiveMenuA(document.getElementById("navlist4").getElementsByTagName("a"), extractPageNameA(hrefString()));
}
function setPageMenuNivel4B()
{	if (document.getElementById("navlist4")!=null) 
		setActiveMenuB(document.getElementById("navlist4").getElementsByTagName("a"), extractPageNameB(hrefString()));
}
