function displayBlock(div) {
	document.getElementById(div).style.display = "block";
}
function displayN(div) {
	document.getElementById(div).style.display = "none";
}
function displayBlock2(div, div2) {
	document.getElementById(div).style.display = "block";
	document.getElementById(div2).style.display = "block";
}
function displayN2(div, div2) {
	document.getElementById(div).style.display = "none";
	document.getElementById(div2).style.display = "none";
}
function muestraOculta3(div1, div2, div3) {
	var o1 = document.getElementById(div1);
	var o2 = document.getElementById(div2);
	var o3 = document.getElementById(div3);
	if (o1 != null) {
		if (o1.style.display == 'none') {
			o1.style.display = 'block';
			o2.style.display = 'block';
			o3.style.display = 'none';
		} else {
			o1.style.display = 'none';
			o2.style.display = 'none';
			o3.style.display = 'block';
		}
	}
}

function muestraOculta2(div1, div2) {
	var o1 = document.getElementById(div1);
	var o2 = document.getElementById(div2);
	if (o1.style.display == 'none') {
		o1.style.display = '';
		o2.style.display = 'none';
	} else {
		o1.style.display = 'none';
		o2.style.display = '';
	}
}
function goToURL() { //v3.0
	var i, args = goToURL.arguments;
	document.returnValue = false;
	for (i = 0; i < (args.length - 1); i += 2)
		eval(args[i] + ".location='" + args[i + 1] + "'");
}
function MM_openBrWindow(theURL, winName, features) { //v2.0
	window.open(theURL, winName, features);
}

function changeStyle(id) {
	var e = document.getElementsByTagName('label');
	for (i = 0; i < e.length; i++) {
		e[i].className = 'off';
	}
	document.getElementById(id).className = 'selected';
}
function muestraOculta(div1) {
	var o1 = document.getElementById(div1);
	if (o1 != null) {
		if (o1.style.display == 'none') {
			o1.style.display = 'block';
		} else {
			o1.style.display = 'none';
		}
	}
}

function showSelect() {
	var e = document.getElementsByTagName('select');
	for (i = 0; i < e.length; i++) {
		e[i].style.visibility = 'visible';
	}
}
function hideSelect() {
	var e = document.getElementsByTagName('select');
	for (i = 0; i < e.length; i++) {
		e[i].style.visibility = 'hidden';
	}
}

//-----------------Nueva Funcion para desplegar el div transparente al alto del contenido -----------------//
function modifDiv() {
	var obj = document.getElementById('transparentDiv').style;
	if (obj.display == 'none')
		showSelect();
	else
		obj.height = document.getElementById('divMain').offsetHeight + 10 + 'px';
}
function displayTransparentDiv(transparentDivId, loadingDivId) {
	var transparentDiv = document.getElementById(transparentDivId);
	transparentDiv.style.display = "block";
	modifDiv();
	
	if (loadingDivId) {
		var loadingDiv = document.getElementById(loadingDivId);
		loadingDiv.style.display = "block";
	}
}
function displayActionPopupDiv(actionPopupDivId) {
	var actionPopupDiv = document.getElementById(actionPopupDivId);
	centerElement(actionPopupDiv);
	actionPopupDiv.style.display = "block";	
}
function displayLoadingPopupDiv(actionPopupDivId, loadingPopupDivId) {
	var loadingPopup =  document.getElementById(loadingPopupDivId);
	var actionPopup = document.getElementById(actionPopupDivId);
	
	var height = (actionPopup.getHeight() - 4).toString();
	var width = (actionPopup.getWidth() - 7).toString();
	var marginLeft = (-(width / 2) + 2).toString();
	
	loadingPopup.style.height = height + 'px';
	loadingPopup.style.width = width + 'px';
	loadingPopup.style.marginLeft = marginLeft + 'px';
	loadingPopup.style.display = 'block';	
}
//-----------------Nueva Funcion para ubicar al div del popup al top de donde se cliquea -----------------//
function displayPop(div, div2) {
	displayTransparentDiv(div2);
	displayActionPopupDiv(div);
}
//--------------------------//
function displayblockp(name) {
	var e = document.getElementsByName(name);
	for (i = 0; i < e.length; i++) {
		e[i].style.display = 'block';
	}
}
function hideblockp(name) {
	var e = document.getElementsByName(name);
	for (i = 0; i < e.length; i++) {
		e[i].style.display = 'none';
	}
}
//---------------Para mostrar u ocultar los errores de los formularios----------//
function tooltip(id, help, error) {
	var e = document.getElementsByTagName('samp');
	var f = document.getElementsByTagName('code');
	for (i = 0; i < e.length; i++) {
		e[i].style.display = "none";
	}
	for (j = 0; j < f.length; j++) {
		f[j].style.display = "none";
	}
	if (document.getElementById(id).className == 'errorlabel') {
		document.getElementById(error).style.display = "inline";
	} else {//en caso de que el id que estemos validando no tenga samp la siguiente linea lo condiciona.
		if (document.getElementById(help) != null) {
			document.getElementById(help).style.display = "block";
		}
	}
}

//------- Funcion para mostrar/ocultar los filtros ----------------//
function collapseExpandFilters(elem, div) {
	if (elem.className == "") {
		elem.className="off";
		document.getElementById(div).style.display = "none";
	} else {
		elem.className="";
		document.getElementById(div).style.display = "block";
	}
}

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof (window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	} else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		} else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function centerElement(element) {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentElement = element;
			var contentHeight = contentElement.offsetHeight;
			contentElement.style.position = 'absolute';
			if (windowHeight - contentHeight > 0) {
				contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
			}
		}
	}
}
