var loaded = new Array();
var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var popOldWidth = window.innerWidth;
nsResizeHandler = new Function('if (popOldWidth != window.innerWidth) location.reload()');
/**********************************************************************************/
function trimall(tira_trimeable){ 
 var tira = new String(tira_trimeable) 
 var iDinamic = tira.length  
 for (i=0; i <= iDinamic; i++){     
     car = tira.substring(0,1)     
     if (car == " "){
        tira = tira.substring(1,tira.length)                
     }
     else break;     
 }
 
 return tira
}
//**********************************************************************
function Invalid_Character(tira_parametro){
//Esta función retorna un valor booleano false si la cadena es válida y
//true si la cadena es invalida.
var valor = false
var tira = new String(tira_parametro)
 for (var i=0; i < tira.length; i++){  
   switch (tira.charCodeAt(i))
   {
    case 34:{valor = true
             break;} //doble comilla
    case 39:{valor = true
             break;} //comilla simple
    case 59:{valor = true
             break;} //punto y coma
    case 60:{valor = true
             break;} //signo menor
    case 62:{valor = true
             break;} //signo mayor
    case 92:{valor = true
             break;} //backslash
    case 124:{valor = true
             break;} //este es el caracter |
   }  
 } 
 if (valor){
    alert("Caracter inválido: '' < > ' | / ;") 
    return true 
 }
 else{
   return false
 }
}   
/**********************************************************************************/
function trim(tira_trimeable,Uppercase,InMiddle){
 var pos
 var tira = new String(tira_trimeable)
 var iDinamic = tira.length
 
 for(var i = 0; i < iDinamic; i++){  
  pos = tira.indexOf(" ")   
  if (pos == 0){   
   tira = tira.substring(pos + 1,tira.length)            
  }
  else{
    break;
  }
 } 
 iDinamic = tira.length
 long1 = iDinamic 
 for(var i = 0; i < long1; i++){  
  pos = tira.lastIndexOf(" ")
  if (pos == iDinamic - 1){   
   tira = tira.substring(0,tira.length - 1)
   iDinamic = tira.length    
  }
  else{break;}
 } 
 
 if (InMiddle == "SI"){
    iDinamic = tira.length
    long1 = iDinamic 
    for(var i = 0; i < long1; i++){  
       pos = tira.indexOf(" ")
       if (pos != 0 && pos != iDinamic - 1){   
		  tira = tira.substring(0,pos) + tira.substring(pos + 1,tira.length)          
          iDinamic = tira.length     
	   }     
    }
 }
 
 if (Uppercase == "SI"){
    tira = tira.toUpperCase();
    return tira
 } 
 else{return tira}
}
/**********************************************************************************/
function F_loadRollover(image,imageName) {  
	if (image && image.src &&
		(null == image.out || typeof(image.out) == typeof(void(0)))) {
		s = image.src;
		image.out = new Image();
		image.out.src = s;
		image.over = new Image();
		if (imageName.lastIndexOf('/') >= 0 || imageName.lastIndexOf('\\') >= 0) {
			s = imageName;
		} else {
			i = s.lastIndexOf('/');
			if (i<0) i = s.lastIndexOf('\\');
			if (i<0) { s = imageName; }
			else	 { s = s.substring(0,i+1) + imageName; }
		}
		image.over.src = s;
		loaded[image.name] = image;
	} 
}
/**********************************************************************************/
function F_roll(imageName,over) {   
	if (document.images) {
	if (over) { imageObject = "over"; }
	else	  { imageObject = "out"; }
	image = loaded[imageName];	
	if (image) {	
		ref = eval("image."+imageObject);
		if (ref) image.src = eval("image."+imageObject+".src");
	}
	if (window.event)
		window.event.cancelBubble = true;
	} 
}
/**********************************************************************************/
/*Función para centrat las nuevas ventanas*/
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=='center'){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);
}


/**********************************************************************************/
var ir_a
var parametro
Image1= new Image()
Image1.src = "images/financia.gif"
Image2 = new Image()
Image2.src = "images/edificio.gif"
Image3 = new Image()
Image3.src = "images/serv_qual.gif"
/**********************************************************************************/
function cambiar_imagen(){ 
var fuente  
 if (parametro == "1"){
    parametro = "2";
    document.sticken.src = Image1.src;    
    ir_a = "Cotice"
 }
 else{
    if (parametro == "2"){
       parametro = "3";    
       document.sticken.src  = Image2.src;
       ir_a = "Quienes Somos"  
    }
    else{
        parametro = "1";    
        document.sticken.src  = Image3.src;
        ir_a = "Servicios"
    }
 } 
 window.setTimeout("cambiar_imagen();",1000)
}
/**********************************************************************************/
function enlace_banner(){  
  switch (parametro){
  case "1": 
       {
       window.location = "servicios.html" 
       break;
       }
  case "2":
       {
       window.open('Financiamiento/FrmFinanciamiento.asp?txthiddenNu_Contr=10&txthiddenVieneDirecto=SI&txthiddenNb_Contr=SEGUROS QUALITAS C.A. (10)','nueva','top=10,left=80,width=600,height=500,status=yes,scrollbars=yes')       
       break;
       }  
  case "3":
       {
       window.location = "Organizacion.html"        
       break;
       }          
 }  
}
//********************************************************************

	
function emailCheck (emailStr) {

	/* The following variable tells the rest of the function whether or not
	to verify that the address ends in a two-letter country or well-known
	TLD.  1 means check it, 0 means don't. */

	var checkTLD=1;

	/* The following is the list of known TLDs that an e-mail address must end with. */

	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

	/* The following pattern is used to check if the entered e-mail address
	fits the user@domain format.  It also is used to separate the username
	from the domain. */

	var emailPat=/^(.+)@(.+)$/;

	/* The following string represents the pattern for matching all special
	characters.  We don't want to allow special characters in the address. 
	These characters include ( ) < > @ , ; : \ " . [ ] */

	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

	/* The following string represents the range of characters allowed in a 
	username or domainname.  It really states which chars aren't allowed.*/

	var validChars="\[^\\s" + specialChars + "\]";

	/* The following pattern applies if the "user" is a quoted string (in
	which case, there are no rules about which characters are allowed
	and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	is a legal e-mail address. */

	var quotedUser="(\"[^\"]*\")";

	/* The following pattern applies for domains that are IP addresses,
	rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	e-mail address. NOTE: The square brackets are required. */

	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

	/* The following string represents an atom (basically a series of non-special characters.) */

	var atom=validChars + '+';

	/* The following string represents one word in the typical username.
	For example, in john.doe@somewhere.com, john and doe are words.
	Basically, a word is either an atom or quoted string. */

	var word="(" + atom + "|" + quotedUser + ")";

	// The following pattern describes the structure of the user

	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

	/* The following pattern describes the structure of a normal symbolic
	domain, as opposed to ipDomainPat, shown above. */

	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	/* Finally, let's start trying to figure out if the supplied address is valid. */

	/* Begin with the coarse pattern to simply break up user@domain into
	different pieces that are easy to analyze. */

	var matchArray=emailStr.match(emailPat);

	if (matchArray==null) {

	/* Too many/few @'s or something; basically, this address doesn't
	even fit the general mould of a valid e-mail address. */

	alert("¡Dirección de correo electrónico incorrecta!");
	return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];

	// Start by checking that only basic ASCII characters are in the strings (0-127).

	for (i=0; i<user.length; i++) {
	if (user.charCodeAt(i)>127) {
	alert("¡Dirección de correo electrónico incorrecta!");
	return false;
	   }
	}
	for (i=0; i<domain.length; i++) {
	if (domain.charCodeAt(i)>127) {
	alert("¡Dirección de correo electrónico incorrecta!");
	return false;
	   }
	}

	// See if "user" is valid 

	if (user.match(userPat)==null) {

	// user is not valid

	alert("¡Dirección de correo electrónico incorrecta!");
	return false;
	}

	/* if the e-mail address is at an IP address (as opposed to a symbolic
	host name) make sure the IP address is valid. */

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {

	// this is an IP address

	for (var i=1;i<=4;i++) {
	if (IPArray[i]>255) {
	alert("¡Dirección de correo electrónico incorrecta!");
	return false;
	   }
	}
	return true;
	}

	// Domain is symbolic name.  Check if it's valid.
	 
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
	if (domArr[i].search(atomPat)==-1) {
	alert("¡Dirección de correo electrónico incorrecta!");
	return false;
	   }
	}

	/* domain name seems valid, but now make sure that it ends in a
	known top-level domain (like com, edu, gov) or a two-letter word,
	representing country (uk, nl), and that there's a hostname preceding 
	the domain or country. */

	if (checkTLD && domArr[domArr.length-1].length!=2 && 
	domArr[domArr.length-1].search(knownDomsPat)==-1) {
	alert("¡Dirección de correo electrónico incorrecta!");
	return false;
	}

	// Make sure there's a host name preceding the domain.

	if (len<2) {
	alert("¡Dirección de correo electrónico incorrecta!");
	return false;
	}

	// If we've gotten this far, everything's valid!
	return true;
}
/**********************************************************************************/
function validaentero(e) 
{
	var valid = "0123456789"
	var whichCode = (window.Event) ? e.which : e.keyCode;
	if (whichCode == 13) return true;  // Enter
	key = String.fromCharCode(whichCode);  // Get key value from key code
	if (valid.indexOf(key) == -1) return false; 
	
}
/**********************************************************************************/
function validanumero(obj) 
{
	reg = /[^0-9]/g;
	obj.value =  obj.value.replace(reg,"");

}
/**********************************************************************************/
function validatelefono(obj) 
{
	reg = /[^0-9.,-]/g;
	obj.value =  obj.value.replace(reg,"");
}
/**********************************************************************************/
function validamonto(obj) 
{
	reg = /[^0-9.]/g;
	obj.value =  obj.value.replace(reg,"");
}
/**********************************************************************************/
function compararfecha(fecha1,fecha2) 
{ 
   var str1  = fecha1;
   var str2  = fecha2;
   var dt1   = parseInt(str1.substring(0,2),10); 
   var mon1  = parseInt(str1.substring(3,5),10);
   var yr1   = parseInt(str1.substring(6,10),10); 
   var dt2   = parseInt(str2.substring(0,2),10); 
   var mon2  = parseInt(str2.substring(3,5),10); 
   var yr2   = parseInt(str2.substring(6,10),10); 
   var date1 = new Date(yr1, mon1, dt1); 
   var date2 = new Date(yr2, mon2, dt2); 

   if(date2 < date1)
   {
      return false; 
   } 
	return true;
} 

/**********************************************************************************/
function validacaracter(e) 
{
var strCheck = 'aábcdeéfghiíjklmnñoópqrstuúvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ-_0123456789 ';
var whichCode = (window.Event) ? e.which : e.keyCode;
if (whichCode == 13) return true;  // Enter
key = String.fromCharCode(whichCode);  // Get key value from key code
if (strCheck.indexOf(key) == -1) return false; 
}
/**********************************************************************************/
function validasolocaracter(e) 
{
var strCheck = 'aábcdeéfghiíjklmnñoópqrstuúvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ ';
var whichCode = (window.Event) ? e.which : e.keyCode;
if (whichCode == 13) return true;  // Enter
key = String.fromCharCode(whichCode);  // Get key value from key code
if (strCheck.indexOf(key) == -1) return false; 
}
/**********************************************************************************/
function validacaractersinespacio(e) 
{
var strCheck = 'aábcdeéfghiíjklmnñoópqrstuúvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ-0123456789';
var whichCode = (window.Event) ? e.which : e.keyCode;
if (whichCode == 13) return true;  // Enter
key = String.fromCharCode(whichCode);  // Get key value from key code
if (strCheck.indexOf(key) == -1) return false; 
}
/**********************************************************************************/
/*function validatelefono(e) 
{
var strCheck = '-0123456789,';
var whichCode = (window.Event) ? e.which : e.keyCode;
if (whichCode == 13) return true;  // Enter
key = String.fromCharCode(whichCode);  // Get key value from key code
if (strCheck.indexOf(key) == -1) return false; 
}*/
/**********************************************************************************/
function textCounter(field, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
	{
		field.value = field.value.substring(0, maxlimit);
	}
}



