
/*****************************************/
/* FUNCIONES PARA MUESTRA U OCULTA CAPAS */
/*****************************************/

var ns6=document.getElementById&&!document.all?1:0

function muestra_permiso(muestra){
	//Ocultamos todas las capas de permisos
	activa=document.getElementById("perm1").style;
	activa.display="none";
	activa=document.getElementById("perm2").style;
	activa.display="none";
	activa=document.getElementById("perm3").style;
	activa.display="none";
	//folder=ns6?curobj.nextSibling.nextSibling.style:document.all[curobj.sourceIndex].style
	if(ns6==1)	{
		activa=document.getElementById("perm"+muestra+"").style;
	}else{
		activa=eval("perm"+muestra+".style");
	}
	activa.display=""
}

function muestra_oculta(capa){
	if(ns6==1)	{
		activa=document.getElementById(capa).style;
	}else{
		activa=eval(""+capa+".style");
	}
	if(activa.display==""){
		activa.display="none";
	}else{
		activa.display="";
	}
}
/*********************************************/
/* FIN FUNCIONES PARA MUESTRA U OCULTA CAPAS */
/*********************************************/


/*****************************************/
/* FUNCIONES DE VALIDACIÓN DE FORMULARIO */
/*****************************************/

function valida_login(){
	texto=""
	if(document.form1.login.value==""){
		texto+="- Debe insertar su nombre de usuario.\n";
	}
	if(document.form1.pass.value==""){
		texto+="- Debe insertar su contraseña.\n";
	}
	if(texto==""){
		document.form1.submit();
	}else{
		alert(texto);
	}
}

function valida_rec_email(){
	texto=""
	if(document.form1.email.value==""){
		texto+="- Debe insertar su dirección de correo electrónico.\n";
	}
	if(texto==""){
		document.form1.submit();
	}else{
		alert(texto);
	}
}

function valida_rec_pass(){
	texto=""
	if(document.form1.pass.value=="" || document.form1.repass.value==""){
		texto+="- Debe insertar la contraseña en las dos casillas.\n";
	}
	if(document.form1.pass.value!=document.form1.repass.value){
		texto+="- El valor insertado en las dos casillas de contraseña deben ser iguales.\n";
	}
	if(texto==""){
		document.form1.submit();
	}else{
		alert(texto);
	}
}

function valida_rec_pass(){
	texto=""
	if(document.form1.pass.value=="" || document.form1.repass.value==""){
		texto+="- Debe insertar la contraseña en las dos casillas.\n";
	}
	if(document.form1.pass.value!=document.form1.repass.value){
		texto+="- El valor insertado en las dos casillas de contraseña deben ser iguales.\n";
	}
	if(texto==""){
		document.form1.submit();
	}else{
		alert(texto);
	}
}

function valida_usuario(){
	texto=""
	if(document.form1.usu_nombre.value==""){
		texto+="- Debe insertar el nombre del usuario.\n";
	}
	if(texto==""){
		document.form1.submit();
	}else{
		alert(texto);
	}
}

function valida_socio_demografico(){
	texto=""
	if(document.form1.sd_nombre.value==""){
		texto+="- Debe insertar la descripcion.\n";
	}
	if(texto==""){
		document.form1.submit();
	}else{
		alert(texto);
	}
}

function valida_grupo(){
	texto=""
	if(document.form1.grupo_nombre.value==""){
		texto+="- Debe insertar el nombre del grupo.\n";
	}
	if(texto==""){
		document.form1.submit();
	}else{
		alert(texto);
	}
}

function valida_area_analisis(){
	texto=""
	if(document.form1.ana_nombre.value==""){
		texto+="- Debe insertar el nombre del grupo.\n";
	}
	if(texto==""){
		document.form1.submit();
	}else{
		alert(texto);
	}
}

function valida_cuestionario(){
	texto=""
	if(document.form1.cue_nombre.value==""){
		texto+="- Debe insertar el nombre del cuestionario.\n";
	}
	if(texto==""){
		document.form1.submit();
	}else{
		alert(texto);
	}
}

function valida_perfil(){
	texto=""
	if(document.form1.per_nombre.value==""){
		texto+="- Debe insertar el nombre del perfil.\n";
	}
	if(texto==""){
		document.form1.submit();
	}else{
		alert(texto);
	}
}

function valida_valoracion(){
	texto=""
	if(document.form1.vran_nombre.value==""){
		texto+="- Debe insertar el nombre de la valoracion del grupo o cuestionario.\n";
	}
	if(texto==""){
		document.form1.submit();
	}else{
		alert(texto);
	}
}

function Comparar_Fecha(Obj1,Obj2)
{
String1 = Obj1;
String2 = Obj2;
// Si los dias y los meses llegan con un valor menor que 10
// Se concatena un 0 a cada valor dentro del string
if (String1.substring(1,2)=="/") {
String1="0"+String1
}
if (String1.substring(4,5)=="/"){
String1=String1.substring(0,3)+"0"+String1.substring(3,9)
}

if (String2.substring(1,2)=="/") {
String2="0"+String2
}
if (String2.substring(4,5)=="/"){
String2=String2.substring(0,3)+"0"+String2.substring(3,9)
}

dia1=String1.substring(0,2);
mes1=String1.substring(3,5);
anyo1=String1.substring(6,10);
dia2=String2.substring(0,2);
mes2=String2.substring(3,5);
anyo2=String2.substring(6,10);


if (dia1 == "08") // parseInt("08") == 10 base octogonal
dia1 = "8";
if (dia1 == '09') // parseInt("09") == 11 base octogonal
dia1 = "9";
if (mes1 == "08") // parseInt("08") == 10 base octogonal
mes1 = "8";
if (mes1 == "09") // parseInt("09") == 11 base octogonal
mes1 = "9";
if (dia2 == "08") // parseInt("08") == 10 base octogonal
dia2 = "8";
if (dia2 == '09') // parseInt("09") == 11 base octogonal
dia2 = "9";
if (mes2 == "08") // parseInt("08") == 10 base octogonal
mes2 = "8";
if (mes2 == "09") // parseInt("09") == 11 base octogonal
mes2 = "9";

dia1=parseInt(dia1);
dia2=parseInt(dia2);
mes1=parseInt(mes1);
mes2=parseInt(mes2);
anyo1=parseInt(anyo1);
anyo2=parseInt(anyo2);

if (anyo1>anyo2)
{
return false;
}

if ((anyo1==anyo2) && (mes1>mes2))
{
return false;
}
if ((anyo1==anyo2) && (mes1==mes2) && (dia1>dia2))
{
return false;
}

return true;
}


/*********************************************/
/* FIN FUNCIONES DE VALIDACIÓN DE FORMULARIO */
/*********************************************/


/*****************************************************/
/* FUNCIONES DE SUSTITUCIÓN DE IAMGEN DE DREAMWEAVER */
/*****************************************************/

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/*********************************************************/
/* FIN FUNCIONES DE SUSTITUCIÓN DE IAMGEN DE DREAMWEAVER */
/*********************************************************/



/***************************/
/* FUNCIONES PARA EL RELOJ */
/***************************/

var RelojRefresco = null
var RelojActivo = false 

function IniciarReloj() {
	PararReloj();
	MostrarHora(); 
}

function PararReloj(){
	if (RelojActivo);
	clearTimeout(RelojRefresco);
	RelojActivo = false
}

function MostrarHora() {
	var ahora = new Date();
	var horas = ahora.getHours();
	var minutos = ahora.getMinutes();
	var segundos = ahora.getSeconds();
	var ampm =" ";
	
	if (horas < 10) { Hora = "0" + horas } else { Hora = "" + horas }
	if (minutos < 10) { Hora += ":0" + minutos } else { Hora += ":" + minutos }
	if (segundos < 10) { Hora += ":0" + segundos } else { Hora += ":" + segundos }
	
	window.status = "Gestor de proyectos";
	
	document.getElementById('digitos').value=Hora;
	
	RelojRefresco = setTimeout("MostrarHora()",1000)
	RelojActivo=true
} 

/*******************************/
/* FIN FUNCIONES PARA EL RELOJ */
/*******************************/

/******************************************************/
/* FUNCIONES PARA INTERCAMBIO DE VALORES ENTRE COMBOS */
/******************************************************/

function move(fbox, tbox) {
var arrFbox = new Array();
var arrTbox = new Array();
var arrLookup = new Array();
var i;
for (i = 0; i < tbox.options.length; i++) {
arrLookup[tbox.options[i].text] = tbox.options[i].value;
arrTbox[i] = tbox.options[i].text;
}
var fLength = 0;
var tLength = arrTbox.length;
for(i = 0; i < fbox.options.length; i++) {
arrLookup[fbox.options[i].text] = fbox.options[i].value;
if (fbox.options[i].selected && fbox.options[i].value != "") {
arrTbox[tLength] = fbox.options[i].text;
tLength++;
}
else {
arrFbox[fLength] = fbox.options[i].text;
fLength++;
   }
}
arrFbox.sort();
arrTbox.sort();
fbox.length = 0;
tbox.length = 0;
var c;
for(c = 0; c < arrFbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrFbox[c]];
no.text = arrFbox[c];
fbox[c] = no;
}
for(c = 0; c < arrTbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrTbox[c]];
no.text = arrTbox[c];
tbox[c] = no;
   }
}

/**********************************************************/
/* FIN FUNCIONES PARA INTERCAMBIO DE VALORES ENTRE COMBOS */
/**********************************************************/


var nav4 = window.Event ? true : false;
function acceptNum(evt){
// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57
var key = nav4 ? evt.which : evt.keyCode;
return (key <= 13 || (key >= 48 && key <= 57) || key==46);
}


/******************/
/* FUNCIONES AJAX */
/******************/

function nuevoAjax(){
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function cargarContenido(url_redir, nombre_div){
	var contenedor;
	var ajax;
	contenedor = document.getElementById(nombre_div);
	ajax=nuevoAjax();
	ajax.open("GET", url_redir, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1) {
			document.getElementById("preload").style.display='';
        	//contenedor.innerHTML="<table width='100%' height='300' border='0' cellspacing='0' cellpadding='0'><tr><td><center><img src='../img/preload.gif'> Cargando...</center></td></tr></table>";
        }else if (ajax.readyState==4) {
			document.getElementById("preload").style.display='none';
			contenedor.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)
}

function cargarContenidoPost(url_redir, nombre_div, vars){
	var contenedor;
	var ajax;
	contenedor = document.getElementById(nombre_div);
	ajax=nuevoAjax();
	ajax.open("POST", url_redir, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1) {
			document.getElementById("preload").style.display='';
        	//contenedor.innerHTML="<table width='100%' height='300' border='0' cellspacing='0' cellpadding='0'><tr><td><center><img src='../img/preload.gif'> Cargando...</center></td></tr></table>";
        }else if (ajax.readyState==4) {
			document.getElementById("preload").style.display='none';
			contenedor.innerHTML = ajax.responseText
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send(vars)
}

/**********************/
/* FIN FUNCIONES AJAX */
/**********************/


/***********************************************
* Drop Down/ Overlapping Content- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function getposOffset(overlay, offsettype){
var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function overlay(curobj, subobjstr, opt_position){
if (document.getElementById){
var subobj=document.getElementById(subobjstr)
subobj.style.display=(subobj.style.display!="block")? "block" : "none"
var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
subobj.style.left=xpos+"px"
subobj.style.top=ypos+"px"
return false
}
else
return true
}

function overlayclose(subobj){
document.getElementById(subobj).style.display="none"
}