//--EXPLICACIÓN:
//*********************************************************************************************
//Nombre archivo: ventanas.js
//Accion:
//						-	Funciones a raiz de apertura de ventanas, popups.
//						-  .js activado desde el archivo inc_abierto.php
//*********************************************************************************************

function PopUp(img){ 
foto1= new Image(); 
foto1.src=(img); 
Control(img); 
} 
function Control(img){ 
    if((foto1.width!=0)&&(foto1.height!=0)){ 
        verFoto(img); 
    }else{ 
        funcion="Control('"+img+"')"; 
        intervalo=setTimeout(funcion,20); 
        } 
    } 
function verFoto(img){ancho=foto1.width+20; 
    alto=foto1.height+20; 
    cadena="width="+ancho+",height="+alto; 
    ventana=window.open(img,"",cadena); 
} 


function ventana_ajustable(URL,w,h)
{
	winName = "Prueba"
	var windowprops ="top=0,left=0,toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable=no,width=" + w + ",height=auto";
	window.open(URL,winName,windowprops); 
}

function imagen_mod(k)
{	
	document.getElementById("imagen_sin").style.background="transparent";
	document.getElementById("imagen_con").style.background="transparent";
	if (k==1)	//Volver
	{	document.getElementById("imagen_con").style.display="inline";
		document.getElementById("imagen_sin").style.display="none";
		document.getElementById("imagen_volver").style.display="none";
		document.getElementById("imagen_nueva").value = "0";
	}
	if (k==2)	//Eliminar
	{	
		document.getElementById("imagen_con").style.display="none";
		document.getElementById("imagen_sin").style.display="inline";
		document.getElementById("imagen_volver").style.display="none";
		document.getElementById("imagen_nueva").value = "0";
		
 		}
	if (k==3)	//Modificar
	{	document.getElementById("imagen_con").style.display="none";
		document.getElementById("imagen_sin").style.display="inline";
		document.getElementById("imagen_volver").style.display="inline";
		document.getElementById("imagen_nueva").value = "1";
		
	}
	
}
function combox_fech_cal_redirect()
{  form = document.forms["fech_cal_form"]
	fecha = form.elements["ano_b"].value+form.elements["mes_b"].value+form.elements["dia_b"].value
	if (fecha.length == 6)
	{  form.action += "&fech_cal="+fecha;
		form.submit();
	}
	
	
}
function combox_type_cal_redirect(form)
{  option_seleccionado = form.option_type_cal.selectedIndex;
	option_id = form.option_type_cal.options[option_seleccionado].id
	
	name_cal = form.option_type_cal.options[option_seleccionado].text
	
	form.action += "&name_cal="+name_cal+"&type_cal="+option_id.substring(7);
	form.submit();
}

function combox_per_cal_redirect(form)
{  option_seleccionado = form.option_per_cal.selectedIndex;
	option_value = form.option_per_cal.options[option_seleccionado].value
	name_cal = form.option_per_cal.options[option_seleccionado].text
	form.action += "&name_cal="+name_cal+"&per_cal="+option_value;
	form.submit();
}
function combox_com_type_cal(form)
{
	if(form.option_per_cal.selectedIndex != 0)
	{    	form.option_des_cal.disabled=false;
 	}
  else
 {	form.option_des_cal.selectedIndex= 0;
 	form.option_des_cal.disabled=true;
 }
 
}
function comprobar_apartados()
{	form = document.getElementById("menus")
	if (form.option_men.selectedIndex==0)
	{	form.option_apa.disabled = true;
		form.option_apa.selectedIndex = 0;
	}
	else
	{	form.option_apa.disabled = false;
	}
	id_men = document.getElementById("men"+form.option_men.selectedIndex).value
	form.action += "&valor_menu="+id_men;
	act = form.act.value
	
	redireccion = form.action;
	if (act!="1_apa")
	{	var patron_ac = /actualizar/i
		var patron_in = /ingresar/i
		redireccion_ac = redireccion.search(patron_ac)
		redireccion_in = redireccion.search(patron_in)
			
		if (redireccion_ac == "-1")
		{	
			if (redireccion_in=="-1")
			{
			}
			else
			{		
				redireccion = redireccion.replace("inc/inc_ingresar","index_admin");
				texto_titulo = form.titulo.value
				texto_texto = form.texto.value
				
			}
		}
		else
		{	redireccion = redireccion.replace("inc/inc_actualizar","index_admin");
		}
		redireccion += "&act="+act;
		location.href= redireccion;
	}
	
	
}
function comprobar_proyectos()
{	
	form = document.getElementById("proyectos")
	
	if (form.option_pro.selectedIndex==0)
	{	form.option_apa.disabled = true;
		form.option_apa.selectedIndex = 0;
	}
	else
	{	form.option_apa.disabled = false;
	}
	id_pro = document.getElementById("pro"+form.option_pro.selectedIndex).value
	
	form.action += "&valor_pro="+id_pro;
	act = form.act.value
	redireccion = form.action;
	if (act!="1_apa")
	{	var patron_ac = /actualizar/i
		var patron_in = /ingresar/i
		redireccion_ac = redireccion.search(patron_ac)
		redireccion_in = redireccion.search(patron_in)

		if (redireccion_ac == "-1")
		{
			if (redireccion_in=="-1")
			{
			}
			else
			{
				redireccion = redireccion.replace("inc/inc_ingresar","index_admin");
				texto_titulo = form.titulo.value
				texto_texto = form.texto.value

			}
		}
		else
		{	redireccion = redireccion.replace("inc/inc_actualizar","index_admin");
		}
		redireccion += "&act="+act;
		location.href= redireccion;
	}


}
function comprobar_grupos()
{	form = document.getElementById("organizacion")
	
	if (form.option_cic.selectedIndex==0)
	{	form.option_gru.disabled = true;
		form.option_gru.selectedIndex = 0;
	}
	else
	{	form.option_gru.disabled = false;
	}
	id_cic = document.getElementById("cic"+form.option_cic.selectedIndex).value
	
	form.action += "&valor_cic="+id_cic;
	act = form.act.value
	
	
	
	redireccion = form.action;
	if (act!="1_gru")
	{	var patron_ac = /actualizar/i
		var patron_in = /ingresar/i
		redireccion_ac = redireccion.search(patron_ac)
		redireccion_in = redireccion.search(patron_in)
		if (redireccion_ac == "-1")
		{	
			if (redireccion_in=="-1")
			{
			}
			else
			{		
				redireccion = redireccion.replace("inc/inc_ingresar","index_admin");
				texto_titulo = form.titulo.value
				
			}
		}
		else
		{	redireccion = redireccion.replace("inc/inc_actualizar","index_admin");
		}
		redireccion += "&act="+act;
		
		location.href= redireccion;
	}
	
	
}
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));

}
