if(idioma==""){var idioma="esp";}
if(idioma=="esp"){
	var logVal 	= "Validando ...";
	var logOK 	= "Iniciando ...";
	var logError= "Sus datos son incorrectos.";
	var Rdatos	= "Rellene los campos";
	var TXTCARGANDO = "Cargando...";
}
if(idioma=="eng"){
	var logVal 	= "Validating ...";
	var logOK 	= "Logging in ...";
	var logError= "Your login detail have an error.";
	var Rdatos	= "Fill the fields";
	var TXTCARGANDO = "Loading...";
}
if(idioma=="por"){
	var logVal 	= "Validando ...";
	var logOK 	= "Efetuando login ...";
	var logError= "Seus dados tem um erro.";
	var Rdatos	= "Preencha os campos";
	var TXTCARGANDO = "Cargando...";
}
function Brochure(area){
	if(idioma=="esp"){
		if(area=="Banking"){
			var PDFBrochure	= "ESP-TOPAZ-Banking.pdf";	
			}
		if(area=="Microfinance"){
			var PDFBrochure	= "ESP-TOPAZ-Microfinance.pdf";	
			}
		if(area=="Trace"){
			var PDFBrochure	= "ESP-TOPAZ-Trace.pdf";	
			}
	}
	if(idioma=="eng"){
		if(area=="Banking"){
			var PDFBrochure	= "ENG-TOPAZ-Banking.pdf";	
			}
		if(area=="Microfinance"){
			var PDFBrochure	= "ENG-TOPAZ-Microfinance.pdf";	
			}
		if(area=="Trace"){
			var PDFBrochure	= "ENG-TOPAZ-Trace.pdf";	
			}
	}
	if(idioma=="por"){
		if(area=="Banking"){
			var PDFBrochure	= "POR-TOPAZ-Banking.pdf";	
			}
		if(area=="Microfinance"){
			var PDFBrochure	= "POR-TOPAZ-Microfinance.pdf";	
			}
		if(area=="Trace"){
			var PDFBrochure	= "POR-TOPAZ-Trace.pdf";	
			}
	}
	//document.location=SITIO_Files+'archivos/'+PDFBrochure;
	URLBrochure=SITIO_Files+'archivos/'+PDFBrochure;
	window.open(URLBrochure, "_blank", "");
}
/******************************************************/

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 acceso(){
	if(IdUsuario==""){
		$.blockUI({
            message: $('#Conectar')
			, css: { top: '5%', left: '20%' }
			}
		);
	}else{
		document.location=Macceso;
		}
}

/**************************************************************************************************************/
/**************************************************************************************************************/
function LinkLogo(){
	document.location=GoHome;
}
/**************************************************************************************************************/
/**************************************************************************************************************/
function logout(){
	document.location=M10;
}
function FormularioContacto(){
	document.location=M5;
}
/**************************************************************************************************************/
/**************************************************************************************************************/
function menu(ID){
	if (ID==1){	SetCookieSite( 'MenuSelecto', 1 );		document.location=M1;	}
	if (ID==2){	SetCookieSite( 'MenuSelecto', 2 );		document.location=M2;	}
	if (ID==3){	SetCookieSite( 'MenuSelecto', 3 );		document.location=M3;	}
	if (ID==4){	SetCookieSite( 'MenuSelecto', 4 );		document.location=M4;	}
	if (ID==5){	SetCookieSite( 'MenuSelecto', 5 );		document.location=M5;	}
}
/**************************************************************************************************************/
/**************************************************************************************************************/
function Idioma(selecto){
	if(selecto=="1"){
		var rutaidioma = GoIdioma1;
		document.location=SITIO_Files+rutaidioma;
	}
	if(selecto=="2"){
		var rutaidioma = GoIdioma2;
		document.location=SITIO_Files+rutaidioma;
	}
}




/**************************************************************************************************************/
/**************************************************************************************************************/
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 conectar(){
	document.getElementById("Form_conectar").submit();
};
/**************************************************************************************************************/
/**************************************************************************************************************/
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();
}
/**************************************************************************************************************/

/**************************************************************************************************************/
/**************************************************************************************************************/
//----------------- JQuery 1.3 -----------------//

$(document).ready(function() { 
						   
  	$('#Msg').text(Rdatos);
    $('#IniSesion').click(function() { 
        $.blockUI({
            message: $('#Conectar'), 
            centerY: 0, 
            css: { top: '40px', left: '', right: '60%' } 
				  }
			)}
		); 	 
    $('#ConectarClose').click(function() { 
       $.unblockUI(); 
    }); 

/******************************************************/
	$("#login_form").submit(function()
	{
		//remove all the class add the messagebox classes and start fading
		$("#Msg").text(logVal).show();
		//check de usuario
		$.post(SITIO_Files+"check_login.php",{ usuario:$('#usuario').val(),pass:$('#pass').val(),rand:Math.random() } ,function(data)
        {
		  if(data=='yes') //if correct login detail
		  {
		  	$("#Msg").show()  //start fading the messagebox
			$("#Msg").html(logOK).show();
			document.location=Macceso;
		  }
		  else 
		  {
		  	$("#Msg").show();
			$("#Msg").html(logError).show();
          }
				
        });
 		return false; //not to post the  form physically
	});
	//now call the ajax also focus move from 
	$("#pass").blur(function()
	{
		$("#login_form").trigger('submit');
	});
	if(login=='login'){
	acceso();
	}
/***********************************************************/
});

/*************************************************************************************************************/
/*************************************************************************************************************/

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);
}