
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 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;
	} 
}

