// JavaScript Document
// Global variables
var isCSS, isW3C, isIE4, isNN4, isIE6CSS;
// Initialize upon load to let all browsers establish content objects
function initDHTMLAPI() {
    if (document.images) {
        isCSS = (document.body && document.body.style) ? true : false;
        isW3C = (isCSS && document.getElementById) ? true : false;
        isIE4 = (isCSS && document.all) ? true : false;
        isNN4 = (document.layers) ? true : false;
        isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
    }
}
// Set event handler to initialize API

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

// Return the available content width space in browser window
function getInsideWindowWidth() {
    if (window.innerWidth) {
        return window.innerWidth;
    } else if (isIE6CSS) {
        // measure the html element's clientWidth
        return document.body.parentElement.clientWidth
    } else if (document.body && document.body.clientWidth) {
        return document.body.clientWidth;
    }
    return 0;
}

// Return the available content height space in browser window
function getInsideWindowHeight() {
    if (window.innerHeight) {
        return window.innerHeight;
    } else if (isIE6CSS) {
        // measure the html element's clientHeight
        return document.body.parentElement.clientHeight
    } else if (document.body && document.body.clientHeight) {
        return document.body.clientHeight;
    }
    return 0;
}
function ajustarDivCentral(div) {
	w = 0;
	h = 0;
	NS4 = (document.layers) ? 1 : 0;
	if (parseInt(navigator.appVersion) >= 5) { NS5 = 1; } else { NS5 = 0;}
	if (document.compatMode && document.compatMode != "BackCompat") {
	   IE4=0; IE6=1; } else {IE4=1; IE6=0;}
	if (NS5) {
	   w = document.documentElement.clientWidth;
	   h  = document.documentElement.clientHeight;
	} else if (NS4) {
	   w = window.innerWidth;
	   h  = window.innerHeight;
	} else if (IE4) {
		 w = document.body.clientWidth;
		 h = document.body.clientHeight;
	} else if (IE6) {
	   w = document.documentElement.clientWidth;
	   h = document.documentElement.clientHeight;
   	}	
	h = parseInt(h);
	w = parseInt(w);
	var central = document.getElementById(div);
	central.style.width = (w-220) + "px";
}

function ajustarBordes(top,right,bottom,left) {
	initDHTMLAPI();
	var divright = document.getElementById(right);
	var divbottom = document.getElementById(bottom);
	var divleft = document.getElementById(left);
	divleft.style.height = getInsideWindowHeight() + "px";
	divright.style.height = getInsideWindowHeight() + "px";
}
function abrirPopup(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function posResultados(vent, parent) {
	var ventana = document.getElementById(vent);
	var scrollpos = document.documentElement.scrollTop;
	
	ventana.style.top = (scrollpos + 20)+ "px";
	ventana.style.left = "250px";
}

function hideDetalle(divis) {
	var divVentana = document.getElementById(divis);
	divVentana.style.zIndex = "3";
	divVentana.style.display = "none";
	divVentana.style.visibility = "visible";
}

function resetDivContenido(divis) {
	var div2reset = document.getElementById(divis);
	var cargando = '<img src="../slices/ajax-loader.gif" alt="cargando..." />&nbsp;&nbsp;Cargando...';
	div2reset.innerHTML = cargando;
	if (divis == 'contenidoCentral') {
		div2reset.style.height = "550px";
	}
}

function redimDivCentral(divcontenido) {
	var src = document.getElementById(divcontenido);
	var dst1 = document.getElementById('contenidoCentral');
	var dst2 = document.getElementById('divcentral');
	var dst3 = document.getElementById('columnaIzq');
	if (src.scrollHeight > 300) {
		dst1.style.height = (src.scrollHeight + 20) + "px";
		dst2.style.height = (src.scrollHeight + 20) + "px";
		dst3.style.height = (src.scrollHeight + 30) + "px";
	}
}
function confirmDel(user) {
	msg = "Esta seguro que desea borrar : "+user+" ?";
	if(confirm(msg)) {
		return true;
	} else {
		return false;
	}
}

function submitForm(theform) {
	var formu = document.getElementById(theform);
	formu.submit();
}

function showResultados(resultdiv) {
	var divmenu = document.getElementById(resultdiv);
	divmenu.style.zIndex = "99";
	
	divmenu.style.visibility = "visible";
	divmenu.style.display = "block";
}


