// Variables Globales

var strURL = document.domain;
strURL = strURL.toUpperCase();

var val_btn="PERSONAS";
var act="1";
var val_menu;
var val_submenu;
var carpeta;

OCULTO="none";
VISIBLE="block";


// Fin Variables Globales

//--------------------------------------------------------------------------
//--------------- Inicio Funciones Impresión Customizada -------------------
//--------------------------------------------------------------------------

	function getWindowSize() 
	{
	if( (typeof( window.innerWidth ) == 'number') || ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) ) {
	    //Non-IE
	    myWidth = document.body.clientWidth;
	    myHeight =document.body.clientHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 4 in 'standards compliant mode'
	    myWidth = document.documentElement.clientWidth;
	    myHeight = document.documentElement.clientHeight;
	  }
	  /*else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 6+ compatible
	    myWidth = document.body.clientWidth;
	    myHeight = document.body.clientHeight;
	  }
	  */
	}
	
	//---------------------------------------------------------------------------
	//detecta browsers
	//---------------------------------------------------------------------------
	var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

	};
	BrowserDetect.init();
	//---------------------------------------------------------------------------

	//---------------------------------------------------------------------------
	//Función impresión Sin Lateral Derecho
	//---------------------------------------------------------------------------
	function PrintWdHt() 
	{
		getWindowSize();
			                
		var totalHt=myHeight;
		var totalWt=myWidth;
		var height_original_div;
		var width_original_div;
		switch(BrowserDetect.browser){
			case "Explorer":
				//alert("IE")
				// OCULTAR DIVS 
		   		document.getElementById('div_principal').style.display=VISIBLE;
		   		document.getElementById('div_sup_pagina').style.display=OCULTO;
				document.getElementById('div_superior').style.display=OCULTO;
				document.getElementById('div_lat_izquierdo').style.display=OCULTO;
				document.getElementById('div_pie_pagina').style.display=OCULTO;
				// OBTENER TAMAÑO ORIGINAL
				height_original_div = document.getElementById('div_principal').style.height;
				width_original_div = document.getElementById('div_principal').style.width;
				// CAMBIAR TAMAÑO
				if(myHeight < 760) 
				{
					//alert("<855")
					document.getElementById('div_principal').style.height =document.documentElement.clientHeight;
				}
				else 
				{
					//alert(">855")
					document.getElementById('div_principal').style.height = document.documentElement.scrollHeight;
				}
				document.getElementById('div_principal').style.width =myWidth;
				//IMPRIMIR
				window.print();
				// VOLVER ORIGINAL
				document.getElementById('div_principal').style.height = height_original_div;
				document.getElementById('div_principal').style.width = width_original_div;
				//MOSTRAR DIVS
				document.getElementById('div_superior').style.display=VISIBLE;
				document.getElementById('div_principal').style.display=VISIBLE;
				document.getElementById('div_lat_izquierdo').style.display=VISIBLE;
				document.getElementById('div_pie_pagina').style.display=VISIBLE;
				document.getElementById('div_sup_pagina').style.display=VISIBLE;
				break;
			case "Firefox":
				//alert("Firefox");
				imprimir('div_principal');
				break;
			default: 
				//alert("Otro")
				// OCULTAR DIVS 
		   		document.getElementById('div_principal').style.display=VISIBLE;
		   		document.getElementById('div_sup_pagina').style.display=OCULTO;
				document.getElementById('div_superior').style.display=OCULTO;
				document.getElementById('div_lat_izquierdo').style.display=OCULTO;
				document.getElementById('div_pie_pagina').style.display=OCULTO;
				// OBTENER TAMAÑO ORIGINAL
				height_original_div = document.getElementById('div_principal').style.height;
				width_original_div = document.getElementById('div_principal').style.width;
				// CAMBIAR TAMAÑO
				document.getElementById('div_principal').style.height = document.documentElement.scrollHeight+"px";
				document.getElementById('div_principal').style.width = document.documentElement.scrollWidth+"px";
				//IMPRIMIR
				window.print();
				// VOLVER ORIGINAL
				document.getElementById('div_principal').style.height = height_original_div;
				document.getElementById('div_principal').style.width = width_original_div;
				//MOSTRAR DIVS
				document.getElementById('div_sup_pagina').style.display=VISIBLE;
				document.getElementById('div_superior').style.display=VISIBLE;
				document.getElementById('div_principal').style.display=VISIBLE;
				document.getElementById('div_lat_izquierdo').style.display=VISIBLE;
				document.getElementById('div_pie_pagina').style.display=VISIBLE;
		}
		return;
	}
	//---------------------------------------------------------------------------
	
	
	//---------------------------------------------------------------------------
	//funcion impresion firefox especial, abre popup, carga contenido del div, imprime y cierra
	//---------------------------------------------------------------------------
	function imprimir(que) {
		var ventana = window.open();
		ventana.document.write(document.getElementById(que).innerHTML);
		ventana.print();
		ventana.close();
	}
	//---------------------------------------------------------------------------


//--------------------------------------------------------------------------
//----------------- Fin Funciones Impresión Customizada --------------------
//--------------------------------------------------------------------------

	
function showTabla(obj,val_min_obj,val_max_obj)
{
		obj = parseInt(obj);
		val_max_obj = parseInt(val_max_obj);
		val_min_obj = parseInt(val_min_obj);

				
		//eval("document.getElementById("+obj+").style.display=''");	
		for (i=val_min_obj; i <= val_max_obj; i++ )
		{		
				if (i!=obj)
				{
					eval("document.getElementById("+i+").style.display='none'");
				}
		}
		if (obj <= val_max_obj)
			//if ( eval("document.getElementById("+obj+").style.display")=='' )
			//	eval("document.getElementById("+obj+").style.display='none'");	
			//else
				eval("document.getElementById("+obj+").style.display=''");		
}

function showAcceso()
{
		
		if ( document.getElementById("tbl_accesos").style.display =='' )
		{
			document.getElementById("tbl_accesos").style.display='none';
			document.getElementById("tbl_contacto").style.display='';
		}
		else
		{
			document.getElementById("tbl_accesos").style.display='';
			document.getElementById("tbl_contacto").style.display='none';
		}
}


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];}
}

function checkActive(boton,val_menu,val_submenu) 
{
	//alert(boton)
	switch (boton)
	{
		case 'btn_01':
			document.getElementById(boton).setAttribute("src", RUTA_PAG+"imagenes/naveg_sup/btn_personas_on.gif");
			break;
		case 'btn_02':
			document.getElementById(boton).setAttribute("src", RUTA_PAG+"imagenes/naveg_sup/btn_empresas_on.gif");
			break;
		case 'btn_03':
			document.getElementById(boton).setAttribute("src", RUTA_PAG+"imagenes/naveg_sup/btn_agentes_on.gif");
			break;
		case 'btn_04':
			document.getElementById(boton).setAttribute("src", RUTA_PAG+"imagenes/naveg_sup/btn_brokers_on.gif");
			break;
		case 'btn_05':
			document.getElementById(boton).setAttribute("src", RUTA_PAG+"imagenes/naveg_sup/btn_interRV_on.gif");
			break;
		case 'btn_06':
			document.getElementById(boton).setAttribute("src", RUTA_PAG+"imagenes/naveg_sup/btn_empleados_on.gif");
			break;
			
	}
	document.getElementById(val_menu).setAttribute("class", "link_niv1_active");
	document.getElementById(val_menu).setAttribute("className", "link_niv1_active");
	//alert(val_submenu)
	if ( (val_submenu!="") ) // ||(val_submenu != undefined)  ||(val_menu != "undefined") )
	{
	document.getElementById(val_submenu).setAttribute("class", "link_niv2_active");
	document.getElementById(val_submenu).setAttribute("className", "link_niv2_active");
	}
} 	


function abrir_ventana(myWindow,url,w,h)
{
	var ventana;
	//alert(url)
	opciones='toolbar=no,directories=no,location=no,status=no,menubar=no,scrollbars=yes,left=20,resizable=no,width=' +w + ', height=' + h;
	ventana = window.open(url,myWindow,opciones);
}
	