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;
}
/* Functions that swaps images. */
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;
}

/* Functions that handle preload. */
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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function Minisitio(MSID){
	
	var leftPos = 0;
	var topPos = 0;
	var ancho = 535;
	var alto = 680;
	var Mancho = ancho / 2;
	var Malto = alto / 2;
	var defstatus='no';
	var defscrollbars='no';
	var scrollbars ='no';
	if (status!=''){
		defstatus = status;
	}
	if (scrollbars!=''){
		defscrollbars = scrollbars;
	}
	if (screen){
		leftPos = (screen.width / 2) - Mancho;
		topPos = (screen.height / 2) - Malto;
	}
	var ElementWindow = window.open(SITIO_Files+MSID,'Minisitio','status='+defstatus+',scrollbars='+defscrollbars+',width='+ancho+',height='+alto+',left='+leftPos+',top='+topPos);
	ElementWindow.focus();

}

function SliderNum(num){
		if(num==1){Slider_left=0;}
		if(num==2){Slider_left=-705;}
		if(num==3){Slider_left=-1410;}
		if(num==4){Slider_left=-2115;}
		if(num==5){Slider_left=-2820;}
		$("#Slider-boxes").animate({"left": Slider_left +"px"}, "slow");  
		$("#slider-nav a").removeClass('Selecto');
		$("#slider-nav a[id='a"+num+"']").addClass('Selecto');
		$("#Slider-Selecto").val(num);
	
	}
	function SliderDir(dir){

	var Sel = "a";
	Sele = $("#Slider-Selecto").val();
	Selecto = Sel+Sele;
	//alert(Selecto);
	var Slider_ele = "#Slider-boxes";
	var Slider_total = 5; 
	var Slider_ancho = 705;
	var SliderMax = -2820;
	var Slider_p = $(Slider_ele);
	var Slider_position = Slider_p.position();
	var Slider_left = Slider_position.left;
	
	$("#FlechaIZQ").hide();
	setTimeout('$("#FlechaIZQ").show();', 900);
	$("#FlechaDER").hide();	
	setTimeout('$("#FlechaDER").show();', 900);
	//
	
		if(dir==0){
		
			if (Slider_left != 0) {
				
			   $("#Slider-boxes").animate({"left": Slider_left+Slider_ancho +"px"}, "slow");
			   
			   	Select = eval($("#Slider-Selecto").val())-1;
			   	$("#slider-nav a").removeClass('Selecto');
				$("#slider-nav a[id='"+Select+"']").addClass('Selecto');
				
				$("#Slider-Selecto").val(Select);
				
			}  //end if
			
		}else{
		
			if (Slider_left > SliderMax) {
				
			   $("#Slider-boxes").animate({"left": Slider_left-Slider_ancho +"px"}, "slow");
			   
				Select = eval($("#Slider-Selecto").val())+1;
				$("#slider-nav a").removeClass('Selecto');
				$("#slider-nav a[id='"+Select+"']").addClass('Selecto');
				$("#Slider-Selecto").val(Select);
				
			} //end if

		} //end else
		
	} //end function
	

function GETUrl(url){
	document.location=url;
}
/**************************************************************************************************************/
/**************************************************************************************************************/

function validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(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+''+emailTXT;
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+''+numTXT;
          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+''+numMaxMinTXT+''+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+''+ReqTXT; }
    } if (errors) alert(ErrorTXT+''+errors);
    document.returnValue = (errors == '');
	}
}

/**************************************************************************************************************/
function SetCookieSite( name, value )
{
var expires = 30;
var path = '/';
var domain = '';
var secure = '';
//Set_Cookie( 'mycookie', 'visited 9 times', 30, '/', '', '' );.
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
/**************************************************************************************************************/
/**************************************************************************************************************/
function GetCookieSite( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

/**************************************************************************************************************/
/**************************************************************************************************************/
function LinkLogo(){
	document.location=GoHome;
}
/**************************************************************************************************************/
/**************************************************************************************************************/
function logout(){
	document.location=M10;
}
function FormularioContacto(){
	document.location=M5;
}

function formula(formula){
	document.getElementById(formula).submit();
}
/**************************************************************************************************************/
/**************************************************************************************************************/
function ejecutarBuscador(TXT_BUSCAR){
		var palabra = document.getElementById('palabra').value;
		if(palabra=="" || palabra==TXT_BUSCAR){
			$.blockUI({ message: "<h1 class='blockUIalerttext'>Por favor ingrese una palabra en el buscador.</h1>",timeout: 3000  }); 
		}else if(palabra.length<3){
			$.blockUI({ message: "<h1 class='blockUIalerttext'>La palabra clave debe poseer por lo menos<br />3 caractéres.</h1>",timeout: 3000  });
		}else{
			document.location=URLsearch+palabra;
		}
}
/**************************************************************************************************************/
/**************************************************************************************************************/
function ventana(laURL,ancho,alto,status,scrollbars) { //Creado por Martin Daguerre 
leftPos = 0;
topPos = 0;
Mancho = ancho / 2;
Malto = alto / 2;
defstatus='no';
defscrollbars='no';
if (status!=''){
defstatus = status;
}
if (scrollbars!=''){
defscrollbars = scrollbars;
}
if (screen){
leftPos = (screen.width / 2) - Mancho;
topPos = (screen.height / 2) - Malto;
}
ElementWindow = window.open(laURL,'visor','status='+defstatus+',scrollbars='+defscrollbars+',width='+ancho+',height='+alto+',left='+leftPos+',top='+topPos);
ElementWindow.focus();
}
/**************************************************************************************************************/
/**************************************************************************************************************/
function char_to_hexa(codigo)
{
  alto = Math.floor(codigo / 16);
  if (alto > 10) {
   if (alto == 10) alto = "A";
   if (alto == 11) alto = "B";
   if (alto == 12) alto = "C";
   if (alto == 13) alto = "D";
   if (alto == 14) alto = "E";
   if (alto == 15) alto = "F";
  }

  bajo = codigo % 16;
  if (bajo >= 10) {
   if (bajo == 10) bajo = "A";
   if (bajo == 11) bajo = "B";
   if (bajo == 12) bajo = "C";
   if (bajo == 13) bajo = "D";
   if (bajo == 14) bajo = "E";
   if (bajo == 15) bajo = "F";
  }
  return ("%" + alto + bajo);
}
/**************************************************************************************************************/
/**************************************************************************************************************/
function LIM_T_AREA(campo, contador, maxlimite) {
if (campo.value.length > maxlimite){
campo.value = campo.value.substring(0, maxlimite);
}else
contador.value = maxlimite - campo.value.length;
}
/**************************************************************************************************************/
/**************************************************************************************************************/
function impre(num) {
document.getElementById(num).className="ver";
print();
document.getElementById(num).className="nover";
}
/**************************************************************************************************************/
/**************************************************************************************************************/
function imprimir(nombre)
{
  var top = document.getElementById("top_print");
  var base = document.getElementById("base_print");
  var ficha = document.getElementById(nombre);
  var ventimpt = window.open(' ','popimpr', 'width=550,height=350,left=250,top=200,resizable=yes,scrollbars=yes');
  ventimpt.document.write(top.innerHTML);
  ventimpt.document.write( ficha.innerHTML);
  ventimpt.document.write(base.innerHTML);
  ventimpt.document.close();
  ventimpt.print();
  ventimpt.close();
}
/**************************************************************************************************************/
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 CargarNEWS(url){
var contenido, preloader, estado;
var contenido = document.getElementById('ListaDeNoticias');
			preloader = document.getElementById('preloader');
			ajax=NuevoAjax();
			ajax.open("GET", url,true);
			ajax.onreadystatechange=function(){
				if(ajax.readyState==1){
					
					contenido.innerHTML = "<img src='img/loading.gif' align='absmiddle' hspace='10' />"+TXTCARGANDO+"";
				}else if(ajax.readyState==4){
					if(ajax.status==200){
						
						
						contenido.innerHTML = ajax.responseText;
						
						
					}else if(ajax.status==404){
						contenido.innerHTML = "La p&aacute;gina no existe";
					}else{
						contenido.innerHTML = "Error:".ajax.status;
					}
				}
			}
			ajax.send(null);
}
