<!--
//detecto navegador
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);
var msie4 = (browserName == "Microsoft Internet Explorer" && browserVer >= 4);
if ((browserName == "Netscape" && browserVer >= 3) || msie4 || browserName=="Konqueror") {version = "n3";} else {version = "n2";}


function ampliar_informacion(campo){
	if (campo){
		ampliar_informacion();
		$('#caja_'+campo).slideUp(function (){
			$('#caja_'+campo+'_completo').slideDown('slow');
			$('#caja_'+campo+'_link').html("<a href=\"javascript:ampliar_informacion()\">[ - ] Reducir información </a>");
			location.href="#posCampo_"+campo;
		  });

	}else{
		
		for (t=1; t<900; t++){
			//document.write(t+"<br>");
			try {
				$('#caja_'+t).slideDown('slow');
					$('#caja_'+t+'_completo').hide();
					$('#caja_'+t+'_link').html("<a href=\"javascript:ampliar_informacion('"+t+"')\">[ + ] Ampliar información</a>");
				
			}
			catch (e) {
				break;
			}

		}
	}
	
}

function acomodo_layer_centro_x(nombre){

	tabla=eval(nombre+ ".style");
	var msie4 = (browserName == "Microsoft Internet Explorer" && browserVer >= 4);
	
	if (msie4)	{
		anchoPantalla=document.body.clientWidth;
		anchoTabla=parseInt(tabla.pixelWidth);		
//		alert(tabla.width);
	}else{
		anchoPantalla=window.innerWidth;
		anchoTabla=parseInt(tabla.width);		
	}	
 	posicionX=(anchoPantalla/2)-(anchoTabla/2);
	//alert(posicionX);
	tabla.left=posicionX;
}

function acomodo_layer_centro(nombre){

	tabla=eval(nombre+ ".style");
	tomo_scroll();
	var msie4 = (browserName == "Microsoft Internet Explorer" && browserVer >= 4);
	
	if (msie4)	{
		anchoPantalla=document.body.clientWidth;
		altoPantalla=document.body.clientHeight;
		anchoTabla=parseInt(tabla.pixelWidth);	
		altoTabla=parseInt(tabla.pixelHeight);			
//		alert(tabla.width);
	}else{
		anchoPantalla=window.innerWidth;
		altoPantalla=window.innerHeight;		
		anchoTabla=parseInt(tabla.width);		
		altoTabla=parseInt(tabla.height);				
	}	
 	posicionX=(anchoPantalla/2)-(anchoTabla/2);
 	posicionY=(altoPantalla/2)-(altoTabla/2);	
	//alert(posicionX);
	tabla.left=posicionX;
	tabla.top=posicionY+vertScroll;	
}

function acomodo_layer_full(nombre){

	tabla=eval(nombre+ ".style");
	var msie4 = (browserName == "Microsoft Internet Explorer" && browserVer >= 4);
	
	if (msie4)	{
		anchoPantalla=document.body.clientWidth;
		altoPantalla=document.body.clientHeight;
		altoDocumento=document.body.scrollHeight
	}else{
		anchoPantalla=window.innerWidth;
		altoPantalla=window.innerHeight;	
		altoDocumento=document.height;
	}	
	tabla.left=0;
	tabla.top=0;
	tabla.height=altoDocumento;
	tabla.width=anchoPantalla;
}

function acomodo_layer_centro_bottom(nombre){

	tabla=eval(nombre+ ".style");
	var msie4 = (browserName == "Microsoft Internet Explorer" && browserVer >= 4);


	if (msie4)	{
		altoDocumento=document.body.scrollHeight;	
	}else{
		altoDocumento=document.height;
		//alert(document.height);		
//		barrautil.innerHTML=window.statusbar.visible;		
	}


	if (msie4)	{
		altoTabla=parseInt(tabla.pixelHeight);		
//		alert(tabla.width);
	}else{
		altoTabla=parseInt(tabla.height);		
	}	
 	posicionY=altoDocumento-altoTabla;
	//alert(posicionY);
	tabla.top=posicionY;
	tabla.visibility="visible";
}  


function despliegaYCierraTerciario(nombreLink, nombreTablas, activada){
	despliegaYCierra(nombreTablas, activada);
	location.href=nombreLink;
}

function despliegaYCierra(nombreTablas, activada){
	MAXIMASTABLAS=20;
	try {
		tabla=eval(nombreTablas+activada + ".style");
		valorViejo=tabla.display;
	}
	catch(e)
	{	
		return 0;
	}
	
	for (t=0; t<MAXIMASTABLAS;t++){
		try {
			tabla=eval(nombreTablas + t + ".style");	
			tabla.display="none";
		}
        catch(e)
	     {
		 	break;
		 }
	}

	tabla=eval(nombreTablas+activada + ".style");
	if (valorViejo=="block") {
		tabla.display="none";
	}
	else{
		tabla.display="block";
	}
	location.href="#a"+nombreTablas+activada;
	
}


function verifico_checkeo(nombreCheck, estado){
	cajaoculta=eval('document.formulario.a_'+nombreCheck);
	if (estado)
		cajaoculta.value="si";
	else
		cajaoculta.value="no";
}

function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}

function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  if (cookieValue=="NaN" || cookieValue==""){cookieValue=0;}
  return cookieValue;
}

// Ejemplo
// writeCookie("Cookoliver", "imagen23.jpg", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}


function cambia_ima() { //Modificacion de MM_swapImage  : no se modifica con el swap
	 var i,j=0,x,a=cambia_ima.arguments; 
  for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){x.src=a[i+2];}
}  




function toHex(dec) {
	var hexCharacters = "0123456789ABCDEF"
	if (dec < 0)
		return "00"
	if (dec > 255)
		return "FF"
	var i = Math.floor(dec / 16)
	var j = dec % 16
	return hexCharacters.charAt(i) + hexCharacters.charAt(j)
}
// funcion que manda variables a otra pagina
// ej: 
// <a href="javascript:pasarVariables('destino.html', 'var1,var2','senti de,verdad')">aqu&iacute;</a>
function pasarVariables(pagina, nombres, valores, ancho, alto) {
       pagina +="?";
    nomVec = nombres.split(",");
    valores = valores.split(",");
	for (i=0; i<nomVec.length; i++)
      pagina += nomVec[i] + "=" + escape((valores[i]))+"&";
    pagina = pagina.substring(0,pagina.length-1);
//	alert (pagina);

	Ventana=window.open(pagina,'','scrollbars=yes,height='+alto+',left='+((screen.width/2)-(ancho/2))+',top='+((screen.height/2)-(alto/2))+',width='+ancho);
	Ventana.focus()
	
  }
  
 
function abre_pagina(ubicacion,nombre,parametros){
window.open(ubicacion,nombre,parametros);
}
contador_publi=0;
function abre_publicidad(ubicacion,ancho,alto){
	if (!alto) {alto=screen.height-90;}
	if (!ancho) {ancho=650;}
	contador_publi++;
	recursos=window.open(ubicacion,'recursos'+contador_publi,'scrollbars=yes,status=yes,height='+alto+',left='+((screen.width/2)-(ancho/2))+',top='+(((screen.height-20)-alto)/2-20)+',width='+ancho);
	recursos.focus();

	
}

function pongo_fecha(){  //funcion tomada del home de la DPIN
   mesarray=new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio","Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
   diaarray=new Array( "Domingo","Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado");
   hoy = new Date();
   dias = hoy.getDate();
   dia = hoy.getDay();
   mes = hoy.getMonth();
   mes=mesarray[mes];
   dia =diaarray[dia];
   anno = hoy.getYear();
   document.write(dia+" "+dias+" "+" de "+mes+" de "+anno);
}

function escribo_subtitulo(texto){
	if (parent.tituloSec!=null){
		parent.tituloSec.innerHTML=texto;
	}
}


contfoto=0;
function abre_foto(archivo,descripcion, fotografo){
	jQuery.slimbox(archivo, descripcion);
}



function abre_video(archivo,titulo, descripcion){
	if (descripcion){
		pasarVariables('vis_video.htm','archivo,titulo,descripcion', archivo+','+titulo+','+descripcion, 600, 600);
	}
	else{
		pasarVariables('vis_video.htm', 'archivo', archivo);
	}
	//encabezado.innerHTML='<img src="imagenes/encabezado_imagen.jpg" width="770" height="200">';
	//location.href='reproduciendo_video.htm'
}

function va_contacto(){
	opener.location.href='contacto.php';
	close();
}

function despliega(nombre){
	tabla=eval(nombre + ".style");
	if (tabla.display=="block") {
		tabla.display="none";
	}
	else{
		tabla.display="block";
	}
}




vie_scroll=1;
vie_heigth=1;
incre=2;



function tomo_scroll(){
//	if (msie4) vertScroll=document.body.scrollTop;
//	else vertScroll=self.pageYOffset;
	if (msie4)	{
		altoPantalla=document.body.clientHeight;
		anchoPantalla=document.body.clientWidth;
		vertScroll=document.body.scrollTop;
		altoDocumento=document.body.scrollHeight;
//		alert(altoDocumento);
	}else{
		altoPantalla=window.innerHeight;
		anchoPantalla=window.innerWidth;
		vertScroll=	self.pageYOffset;
		altoDocumento=window.dialogHeight;		
	}
}
//alert (vertScroll);
function acomoda_datos(){
	tomo_scroll();
	limiteArriba=220;
	limiteAbajo=70;
	delay=10;
	if (vertScroll!=vie_scroll || altoPantalla!=vie_heigth || Math.abs(incre)>0.2){
		ayu=barrautil.style;
		if (msie4)	{	
			incre=(ayu.pixelTop-30-vertScroll)/delay;
			//ayu.left=(anchoPantalla-778)/2+778-ayu.pixelWidth;
			ayu.left=(anchoPantalla-778)/2+10;//+ayu.pixelWidth;
			ayu.top=ayu.pixelTop-incre;
			if (ayu.pixelTop < (limiteArriba)) ayu.top=(limiteArriba);			
			if (ayu.pixelTop > altoDocumento - ayu.pixelHeight - limiteAbajo) 
				ayu.top = altoDocumento - ayu.pixelHeight - limiteAbajo;			
			if (Math.abs(incre)<1) {incre=0;}
			vie_scroll = vertScroll;
			vie_heigth = altoPantalla;
			//barrautil.innerHTML=altoPantalla;
		}else{
			incre=(parseInt(ayu.top)-30-vertScroll)/delay;
			//ayu.left=(anchoPantalla-778)/2+770-parseInt(ayu.width);
			ayu.left=(anchoPantalla-778)/2+2;//+parseInt(ayu.width);
			ayu.top=parseInt(ayu.top)-incre;
			if (parseInt(ayu.top) < (limiteArriba)) ayu.top=(limiteArriba);			
			if (parseInt(ayu.top) > altoDocumento - parseInt(ayu.height) - limiteAbajo) 
				ayu.top = altoDocumento - parseInt(ayu.height) - limiteAbajo;			
			if (Math.abs(incre)<1) {incre=0;}
			vie_scroll = vertScroll;
			vie_heigth = altoPantalla;
		}
	}
	setTimeout("acomoda_datos()",40);	
}

//contador dpara dar acceso
contadorAcceso=0;

function lanza(pagina){
	contadorAcceso++;
	if (contadorAcceso==3) {
		parent.location.href=pagina;
	}
}



// Funciones traducidas
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

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_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe contener una dirección de email.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' debe contener un número.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' debe contener un número entre '+min+' y '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es requerido.\n'; }
  } 
	if (errors) {
  		alert('Los siguientes errores han ocurrido:\n'+errors);
	}else{
		ocultoBotonesForm();
	}  
  document.MM_returnValue = (errors == '');	
}

function ocultoBotonesForm(){
	if ($("#botonesForm").length>0){
		$("#botonesForm").slideUp(function (){
				t='<div style="padding:20px; border:1px solid #006600; background:#EBFFCC; width:400px; margin:20px;">';
				t+='Se esta procesando su envio.<br>Por favor espere... </div>';
//				$("#botonesForm").hide();
				$("#botonesForm").html(t)
				$("#botonesForm").slideDown('slow');
//				$("#botonesForm").slideUp('slow');
			}
		);
	}
}

 
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 MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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 utf8_decode ( str_data ) {
    // Converts a UTF-8 encoded string to ISO-8859-1  
    // 
    // version: 810.1317
    // discuss at: http://phpjs.org/functions/utf8_decode
    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // +      input by: Aman Gupta
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Norman "zEh" Fuchs
    // +   bugfixed by: hitwork
    // +   bugfixed by: Onno Marsman
    // *     example 1: utf8_decode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'
    var tmp_arr = [], i = ac = c1 = c2 = c3 = 0;

    str_data += '';

    while ( i < str_data.length ) {
        c1 = str_data.charCodeAt(i);
        if (c1 < 128) {
            tmp_arr[ac++] = String.fromCharCode(c1);
            i++;
        } else if ((c1 > 191) && (c1 < 224)) {
            c2 = str_data.charCodeAt(i+1);
            tmp_arr[ac++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));
            i += 2;
        } else {
            c2 = str_data.charCodeAt(i+1);
            c3 = str_data.charCodeAt(i+2);
            tmp_arr[ac++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
            i += 3;
        }
    }

    return tmp_arr.join('');
}
	
// This function decodes the any string
// that's been encoded using URL encoding technique
function URLDecode(psEncodeString)
{
  // Create a regular expression to search all +s in the string
  var lsRegExp = /\+/g;
  // Return the decoded string
  return unescape(String(psEncodeString).replace(lsRegExp, " "));
}


// standart string replace functionality
function str_replace(haystack, needle, replacement) {
	var temp = haystack.split(needle);
	return temp.join(replacement);
}
 
// needle may be a regular expression
function str_replace_reg(haystack, needle, replacement) {
	var r = new RegExp(needle, 'g');
	return haystack.replace(r, replacement);
}	

function reemplazoCorchetes(texto){

	texto=str_replace(texto,"[","<");
	texto=str_replace(texto,"]",">");
	texto=str_replace(texto,"\n","<br>");
	return texto;
}
function number_format(number, decimals, dec_point, thousands_sep) {
    // http://kevin.vanzonneveld.net
    // *     example 2: number_format(1234.56, 2, ',', '');
    // *     returns 2: '1234,56'
    number = (number+'').replace(',', '').replace(' ', '');
    var n = !isFinite(+number) ? 0 : +number, 
        prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
        sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
        dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
        s = '',
        toFixedFix = function (n, prec) {
            var k = Math.pow(10, prec);
            return '' + Math.round(n * k) / k;
        };
    // Fix for IE parseFloat(0.55).toFixed(0) = 0;
    s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
    if (s[0].length > 3) {
        s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
    }
    if ((s[1] || '').length < prec) {
        s[1] = s[1] || '';
        s[1] += new Array(prec - s[1].length + 1).join('0');
    }
    return s.join(dec);
}

//redondeado_dos_decimal (1.28819); //da 1.28
function redondear_dos_decimal(valor) {
   float_redondeado=Math.round(valor * 100) / 100;
   float_redondeado=number_format( float_redondeado,2,"",".");
   decimalSubindice= '<font size=\"-2\"><sup>'+float_redondeado.substr(float_redondeado.length-2,2)+'</sup></font>';
   float_redondeado=float_redondeado.substr(0,float_redondeado.length-2)+decimalSubindice;
   return float_redondeado;
} 

//redondeado (1.28819,3); //da 1.289
function redondeado (numero, decimales) {
   factor = Math.pow(10, decimales);
   float_redondeado=Math.round(numero*factor)/factor;
   float_redondeado=number_format( float_redondeado,decimales,"",".");
   decimalSubindice= '<font size=\"-2\"><sup>'+float_redondeado.substr(float_redondeado.length-decimales,decimales)+'</sup></font>';   
   float_redondeado=float_redondeado.substr(0,float_redondeado.length-decimales)+decimalSubindice;
   return float_redondeado; 
} 


jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
}

jQuery.fn.fullScreenLayer = function () {
    //this.css("position","absolute");
    this.css("top",  "0px");
    this.css("left",  "0px");
    this.css("width",   $(window).width() + "px");
    this.css("height",  $(window).height() + "px");	
    return this;
}

function cierra_video(){
	$('#fade').hide();
	$('#light').hide();
	$('#contVideo').html("");
}

function cambio_video(id, titulo, descripcion){


	archivoVideo=rutaVideos+id+'.flv';
	archivoImagen=rutaFotos+'ch/tn_'+id+".jpg";
	
	/*muestro caja*/
	$('#contVideo').html('<div id="cajaVideo"></div>');
	$('#fade').show();
	$('#light').show();
	$('#fade').fullScreenLayer();
	$('#light').center();


	
	jwplayer("cajaVideo").setup({
		flashplayer: "videos/player.swf",
		width: "100%",
		height: "350",
		image: archivoImagen,
		file: archivoVideo,
		autostart: true,
		bufferlength: 5,
		skin: "videos/modieus/modieus.swf"
	});	
			

}

function despliega(nombre){
	$('#'+nombre).toggle('show');
}

function mando_mail(cuenta, site, ext){
	location.href='mailto:'+ cuenta + '@' + site + '.' + ext;
	
}
