var Ventana
//Para manejo de control fichas
function overOPC(obj)
{
	try 
	{
		if (obj.getAttribute("TD_Sel")=='False') obj.className='pesCO';
	}
	catch(exception)
	{
		alert('Error en funcion overOPC, avise al administrador.');
	}
}
//---------------------------------------------------------------------------------------------------------------------->
function outOPC(obj)
{
	try
	{
		if (obj.getAttribute("TD_Sel")=='False') obj.className='pesClose';
	}
	catch(exception)
	{
		alert('Error en funcion outOPC, avise al administrador.');
	}
}
//---------------------------------------------------------------------------------------------------------------------->
/*function manejaOPC(obj,items,Ruta)
{	
	try
	{
		if (obj.getAttribute("TD_Sel")=='False')			
			{
			for (var x=1;x<=items;x++)
				{
				document.getElementById(obj.id.substr(0,1)+x).setAttribute('TD_Sel','False');
				document.getElementById(obj.id.substr(0,1)+x).className='pesClose';
				}
			obj.setAttribute('TD_Sel','True');
			obj.className='pesOpen';
			document.getElementById('iFrameDetalleTab').src = Ruta;
			}
	}
	catch(exception) 
	{
		alert('Error en función manejaOPC, avise al administrador.');
	}
}*/
//---------------------------------------------------------------------------------------------------------------------->
function pintaMes(sMes)
{	
	try
	{
		document.getElementById('txtMes').value = sMes;
	}
	catch(exception) 
	{
		alert('Error en función pintaMes, avise al administrador.');
	}
}

//---------------------------------------------------------------------------------------------------------------------->
function SacarMes(items,idDepartamento,Anio,MesO,idDelegacion)
{	
	/*
	try
	{
	*/
		var Mes=0;
		var Ruta='';	
		
		//alert('Entra en la Funcion');
		//alert(month);
		
		Mes = document.getElementById('txtMes').value;
		//alert(Mes);
		
		/*
		for (var x=1;x<=items;x++)
		{
			if (document.getElementById('p'+ x).getAttribute("TD_Sel")=='1')			
			{
				Mes=x;
			}		
		}
		//alert(Mes);
		if(Mes==0)
		{
			//alert('entra');
			Mes=MesO
		}
		//alert(month);
		*/
		
		Ruta='ResultadosVistaPrevia.aspx?idDepartamento='+ idDepartamento +'&Mes='+ Mes +'&Anio='+ Anio +'&idDelegacion='+ idDelegacion +'';
		//alert(Ruta);
		nueva_ventana(Ruta, 800, 800, 1)
		
	/*}
	catch(exception) 
	{
		alert('Error en función SacarMes, avise al administrador.');
	}
	*/
}

//---------------------------------------------------------------------------------------------------------------------->
function SacarMesMaes(items,idDepartamento,Anio,MesO)
{	
	try
	{
		var Mes=0;
		var Ruta='';
		
		
		/*
		alert(items);
		alert(idDepartamento);
		
		alert(Anio);
alert(MesO);*/
		
		
		for (var x=1;x<=items;x++)
		{
			if (parent.document.getElementById('p'+ x).getAttribute("TD_Sel")=='1')			
			{
				Mes=x;
			}
		}
		if(Mes==0)
		{
			Mes=MesO;
		}
		
		
		Ruta='IndicadoresMaestroVistaPrevia.aspx?idDepartamento='+ idDepartamento +'&Mes='+ Mes +'&Anio='+ Anio +'';
		nueva_ventana(Ruta, 850, 800, 1);
		
	}
	catch(exception) 
	{
		alert('Error en función SacarMes, avise al administrador.');
	}
}	
//---------------------------------------------------------------------------------------------------------------------->
function manejaOPC_Resultados(obj,items,Ruta)
{	
	try
	{
		if (obj.getAttribute("TD_Sel")=='False')			
		{
			for (var x=1;x<=items;x++)
				{
				document.getElementById(obj.id.substr(0,1)+x).setAttribute('TD_Sel','False');
				document.getElementById(obj.id.substr(0,1)+x).className='pesClose';
				}
			obj.setAttribute('TD_Sel','True');
			obj.className='pesOpen';
			//Ruta para 'Resultados_ActPrincipales.aspx'
			document.getElementById('iFrameDetalleTab_ActPrincipales').src = 'Resultados_ActPrincipales.aspx' + Ruta;
			//Ruta para 'Resultados_NivEvolutivos.aspx'			
			document.getElementById('iFrameDetalleTab_NivEvolutivos').src = 'Resultados_NivEvolutivos.aspx' + Ruta;
		}
	}
	catch(exception) 
	{
		alert('Error en función manejaOPC, avise al administrador.');
	}
}	
//--------------------------------------------------------------------------------------------------------------------
var popUp; 

function OpenCalendar(idname, postBack)
{
	popUp = window.open('../Utiles/Calendar.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
		'popupcal', 
		'width=200,height=230,left=200,top=250');
}

//------------------------------------------------------------------------------------------------------------------------
var popUp; 

function OpenCalendar2(idname, postBack)
{
	popUp = window.open('../../Calendar.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
		'popupcal', 
		'width=200,height=230,left=200,top=250');
}

//--------------------------------------------------------------------------------------------------------------------
function cerrarVentana(){ 
//la referencia de la ventana es el objeto window del popup. Lo utilizo para acceder al método close 
Ventana.close() 
} 

function nueva_ventana(url, ancho, alto, barra) {
	izquierda = (screen.width) ? (screen.width-ancho)/2 : 100
	arriba = (screen.height) ? (screen.height-alto)/2 : 100
	opciones = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=' + barra + ',resizable=0,width=' + ancho + ',height=' + alto + ',left=' + izquierda + ',top=' + arriba + ''
	window.open(url, '', opciones)
}

function nueva_ventana_nuevapagina(url, ancho, alto, barra) {
	izquierda = (screen.width) ? (screen.width-ancho)/2 : 100
	arriba = (screen.height) ? (screen.height-alto)/2 : 100
	opciones = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=' + barra + ',resizable=0,width=' + ancho + ',height=' + alto + ',left=' + izquierda + ',top=' + arriba + ''
	//window.open(url, 'popUp', opciones)
//	window.open("Fclientes_buscador.aspx" ,"Nueva","toolbar=no,location=no,directories<=no,status=no,menubar=no,scrollbars=no,resizable=no,width=700,height=300");
	window.open(url ,'Nueva',opciones);
}

function nueva_ventana_sizable(url, ancho, alto, barra) {
	izquierda = (screen.width) ? (screen.width-ancho)/2 : 100
	arriba = (screen.height) ? (screen.height-alto)/2 : 100
	opciones = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=' + barra + ',resizable=1,width=' + ancho + ',height=' + alto + ',left=' + izquierda + ',top=' + arriba + ''
	window.open(url, 'popUp', opciones)
}

function nueva_ventana_dialogo(url, ancho, alto, barra) {//no funciona bien
	izquierda = (screen.width) ? (screen.width-ancho)/2 : 100
	arriba = (screen.height) ? (screen.height-alto)/2 : 100
	opciones = 'dependent=yes, toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=' + barra + ',resizable=0,width=' + ancho + ',height=' + alto + ',left=' + izquierda + ',top=' + arriba + ''
	window.open(url, '', opciones)
}


function fullwin()
{
   //settings='width='+screen.width+',height='+screen.height+',top=0,left=0,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
   
   //window.open('Principal.aspx?OpcMenu=1','',settings);
   
   agree = confirm('Desea Imprimir la pagina actual');
}

var popUp; 

function OpenCalendarAnio(idname,idnameAnio, postBack)
{
	popUp = window.open('../Calendar.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&id2=' + idnameAnio + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
		'popupcal', 
		'width=200,height=230,left=200,top=250');
}

//------------------------------------------------------------------------------------------------------------------------------
function printPage() {
if (window.print) {
agree = confirm('Desea Imprimir la pagina actual');
if (agree) window.print(); 
   }
}

//---------------------------------------------------------------------------------------------------------------------->
function alturaDIV()
{
	var altura = screen.height - 300;
	var _x = document.getElementById('divContenedor');			
	_x.style.height = '' + altura + 'px';
}
//---------------------------------------------------------------------------------------------------------------------->
function ocultarFrame()
{	
	try
	{
		window.parent.parent.frames[1].document.bgColor = 'red';
		window.parent.parent.frames[3].window.document.width = 0;		
		//window.parent.frames[3].window.document.setAttribute('width','0');
		//window.parent.frames[3].window.document.getElementById('ayuda').setAttribute('width','0');		
		alert(window.parent.parent.frames[3].window.width);
	}
	catch(exception) 
	{
		alert('Error en funcion ocultarFrame, avise al administrador.');
	}
}
//---------------------------------------------------------------------------------------------------------------------->
function pantallaCompleta(pagina) 
{
	window.open(pagina, '', 'fullscreen=yes, scrollbars=auto');
}
//---------------------------------------------------------------------------------------------------------------------->
function AbriDosPopup(url, ancho, alto, barra) 
{
		izquierda = (screen.width) ? (screen.width-ancho)/2 : 100
		arriba = (screen.height) ? (screen.height-alto)/2 : 100
		opciones = 'toolbar=0,location=0,directories=0,status=1,menub ar=0,scrollbars=' + barra + ',resizable=0,width=' + ancho + ',height=' + alto + ',left=' + izquierda + ',top=' + arriba + ',dependent'
		window.open(url, '', opciones)
}
//---------------------------------------------------------------------------------------------------------------------->
//FUNCIONES JAVA PARA OCULTAR Y MOSTRAR EL MENU
function mostrar(modulo,posicionx,posiciony)
{
	
	document.getElementById(modulo).style.display='block';
	document.getElementById(modulo).style.bottom=posicionx+'px';
	document.getElementById(modulo).style.right=posiciony+'px';
}

function ocultar(modulo)
{

	document.getElementById(modulo).style.display='none';
}
//FIM FUNCIONES JAVA PARA OCULTAR Y MOSTRAR EL MENU
//---------------------------------------------------------------------------------------------------------------------->


function CambiarIdioma(Idioma)
{
	var cabecera='';
	var cuerpoA='';
	var cuerpoB='';
	var cuerpo='';
	var Pie='';
	var menuIzquierdo='';
	var menuDerecho='';
	
	
	cabecera=document.location;
	cuerpoA=parent.document.frames['contenido'].document.frames['cuerpo'].document.frames['topFrame'].document.location;
	cuerpoB=parent.document.frames['contenido'].document.frames['cuerpo'].document.frames['mainFrame'].document.location;
	cuerpo=parent.document.frames['contenido'].document.frames['cuerpo'].document.location;
	Pie=parent.document.frames['pie'].document.location;
	menuIzquierdo=parent.document.frames['contenido'].document.frames['mnuizq'].document.location;
	menuDerecho=parent.document.frames['contenido'].document.frames['mnudch'].document.location;
	
	switch (Idioma)
			{
				case 'ESP': 
				{
					document.location=CambiarContenidoIdioma(cabecera,'ESP') 
					parent.document.frames['contenido'].document.frames['cuerpo'].document.frames['topFrame'].document.location=CambiarContenidoIdioma(cuerpoA,'ESP') 
					parent.document.frames['contenido'].document.frames['cuerpo'].document.frames['mainFrame'].document.location=CambiarContenidoIdioma(cuerpoB,'ESP') 
					parent.document.frames['contenido'].document.frames['cuerpo'].document.location=CambiarContenidoIdioma(cuerpo,'ESP') 
					parent.document.frames['pie'].document.location=CambiarContenidoIdioma(Pie,'ESP') 
					parent.document.frames['contenido'].document.frames['mnuizq'].document.location=CambiarContenidoIdioma(menuIzquierdo,'ESP') 
					parent.document.frames['contenido'].document.frames['mnudch'].document.location=CambiarContenidoIdioma(menuDerecho,'ESP') 
					
					document.getElementById('imagenIdioma').src='../imagenes/Fondos/IdiomasInglesFrances.gif'
					document.getElementById('map1').onclick ="CambiarIdioma('ING');"
					document.getElementById('map2').onclick ="CambiarIdioma('FRA');"
					
					break;
				}
				case 'ING': 
				{
					document.location=CambiarContenidoIdioma(cabecera,'ING') 
					parent.document.frames['contenido'].document.frames['cuerpo'].document.frames['topFrame'].document.location=CambiarContenidoIdioma(cuerpoA,'ING') 
					parent.document.frames['contenido'].document.frames['cuerpo'].document.frames['mainFrame'].document.location=CambiarContenidoIdioma(cuerpoB,'ING') 
					parent.document.frames['contenido'].document.frames['cuerpo'].document.location=CambiarContenidoIdioma(cuerpo,'ING') 
					parent.document.frames['pie'].document.location=CambiarContenidoIdioma(Pie,'ING') 
					parent.document.frames['contenido'].document.frames['mnuizq'].document.location=CambiarContenidoIdioma(menuIzquierdo,'ING') 
					parent.document.frames['contenido'].document.frames['mnudch'].document.location=CambiarContenidoIdioma(menuDerecho,'ING') 
					
					document.getElementById('imagenIdioma').src='../imagenes/Fondos/IdiomasEspanolFrances.gif'
					document.getElementById('map1').onclick ="CambiarIdioma('ESP');"
					document.getElementById('map2').onclick ="CambiarIdioma('FRA');"

					
					break;
				}
				case 'FRA': 
				{

					document.location=CambiarContenidoIdioma(cabecera,'FRA') 
					parent.document.frames['contenido'].document.frames['cuerpo'].document.frames['topFrame'].document.location=CambiarContenidoIdioma(cuerpoA,'FRA') 
					parent.document.frames['contenido'].document.frames['cuerpo'].document.frames['mainFrame'].document.location=CambiarContenidoIdioma(cuerpoB,'FRA') 
					parent.document.frames['contenido'].document.frames['cuerpo'].document.location=CambiarContenidoIdioma(cuerpo,'FRA') 
					parent.document.frames['pie'].document.location=CambiarContenidoIdioma(Pie,'FRA') 
					parent.document.frames['contenido'].document.frames['mnuizq'].document.location=CambiarContenidoIdioma(menuIzquierdo,'FRA') 
					parent.document.frames['contenido'].document.frames['mnudch'].document.location=CambiarContenidoIdioma(menuDerecho,'FRA') 
					
					document.getElementById('imagenIdioma').src='../imagenes/Fondos/IdiomasInglesEspanol.gif'
					document.getElementById('map1').onclick ="CambiarIdioma('ING');"
					document.getElementById('map2').onclick ="CambiarIdioma('ESP');"
					break;
				}
			}
}

function CambiarContenidoIdioma(sVar,sIdioma) 
{
	//Esta funcion me cambia el idioma de la pagina seleccionada
	
	var cadena="";
	cadena=String(sVar);
	
	
	
	switch (sIdioma)
	{
		case 'ESP':
		{
			if(cadena.indexOf('ING')!= '-1')
			{
				cadena=cadena.replace('ING','ESP')
			
			}
			else
			{
				cadena=cadena.replace('FRA','ESP')
			}
	
			break;
		}
		
		case 'ING':
		{
			if(cadena.indexOf('ESP')!='-1')
			{
				cadena=cadena.replace('ESP','ING')
			
			}
			else
			{
				cadena=cadena.replace('FRA','ING')
			}
	
			break;
		}
		
		case 'FRA':
		{
			if(cadena.indexOf('ESP')!= '-1')
			{
				cadena=cadena.replace('ESP','FRA')
			
			}
			else
			{
				cadena=cadena.replace('ING','FRA')
			}
	
			break;
		}
	
	}
	return cadena
}