/*
<a class="linkNormal" href="mailto:az@2010az.com&cc=zxcvxcv&bcc=zxcvzxcvxc;&subject=texto del Asunto&body=texto del Asunto"><b>enviar >><br></a>
*/
/////////////////////////////
function cambiarIdioma() {
var cad=window.location+"";
/*
var cad1='/allat/';
var cad2='/allat/en/';
if(cad.indexOf(cad2)>-1){
cad=strReplace(cad,cad2,cad1);
}else{
cad=strReplace(cad,cad1,cad2);
}
cad1='http://allatmedica.com/';
cad2='http://allatmedica.com/en/';
cad=strReplace(cad,'http://www.','http://');
if(cad.indexOf('/en/')>-1){
cad=strReplace(cad,cad2,cad1);
}else{
cad=strReplace(cad,cad1,cad2);
}
*/
cad=strReplace(cad,'allatmedica.com/','allatmedica.com/en/');
window.location=cad;
}	
/////////////////////////////
function centrarEnVentanaHorizontal(elBody) {
y01=document.getElementById(elBody).offsetHeight;
y11=tamaoVentana("y");
if(y01<y11)
	document.getElementById(elBody).style["marginTop"] =(y11-y01)/2 +'px';
else
	document.getElementById(elBody).style["marginTop"] ='2px';
}
////////////////////////////
function tamaoVentana(coordenada) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
if (coordenada=="x")
  return myWidth;
if (coordenada=="y")
  return myHeight;
}
//////////////////////////////////////////////
function abrirVentanaNuevaPopUp(url,targt,w,h){window.open(url,targt,"width=" + w +",height=" + h +", left="+((screen.availWidth-w)/2)+", top="+((screen.availHeight-h)/2)+", status=no, toolbar=no, menubar=no, scrollbars=yes,resizable=yes");}
/////////////////////////////
function citaValida(){
	document.frmCita.action='http://www.allatmedica.com/email1.asp';
	if(document.frmCita.MetodoContacto.selectedIndex==2){
		if(emailCheck(document.frmCita.contacto.value, '') && (trim(document.frmCita.Nombre.value).length>5))
			return true;
	}else{
		if((trim(document.frmCita.contacto.value).length>5) && (trim(document.frmCita.Nombre.value).length>5))
			return true;
	}
	//alert('Por favor, rellene correctamente los datos del formulario.');
	return false;
}
/////////////////////////////
function strReplace(fullS,oldS,newS) {
for (var i=0; i<fullS.length; i++){
      if (fullS.substring(i,i+oldS.length) == oldS) {
          fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length)      
}}   
return fullS;
}
/////////////////////////////
function divFaq(idFaq){
var cad=document.getElementById(idFaq).style.visibility;
if(idFaq!='faq01'){
document.getElementById('faq01').style.visibility='hidden';
document.getElementById('faq01').style.display='none';
document.getElementById('faq01P').className='linkFaq';
}
if(idFaq!='faq02'){
document.getElementById('faq02').style.visibility='hidden';
document.getElementById('faq02').style.display='none';
document.getElementById('faq02P').className='linkFaq';
}
if(idFaq!='faq03'){
document.getElementById('faq03').style.visibility='hidden';
document.getElementById('faq03').style.display='none';
document.getElementById('faq03P').className='linkFaq';
}
if(idFaq!='faq04'){
document.getElementById('faq04').style.visibility='hidden';
document.getElementById('faq04').style.display='none';
document.getElementById('faq04P').className='linkFaq';
}
if(idFaq!='faq05'){
document.getElementById('faq05').style.visibility='hidden';
document.getElementById('faq05').style.display='none';
document.getElementById('faq05P').className='linkFaq';
}
if(idFaq!='faq06'){
document.getElementById('faq06').style.visibility='hidden';
document.getElementById('faq06').style.display='none';
document.getElementById('faq06P').className='linkFaq';
}
if(idFaq!='faq07'){
document.getElementById('faq07').style.visibility='hidden';
document.getElementById('faq07').style.display='none';
document.getElementById('faq07P').className='linkFaq';
}
if(idFaq!='faq08'){
document.getElementById('faq08').style.visibility='hidden';
document.getElementById('faq08').style.display='none';
document.getElementById('faq08P').className='linkFaq';
}
if(idFaq!='faq09'){
document.getElementById('faq09').style.visibility='hidden';
document.getElementById('faq09').style.display='none';
document.getElementById('faq09P').className='linkFaq';
}
if(idFaq!='faq10'){
document.getElementById('faq10').style.visibility='hidden';
document.getElementById('faq10').style.display='none';
document.getElementById('faq10P').className='linkFaq';
}
if(idFaq!='faq11'){
document.getElementById('faq11').style.visibility='hidden';
document.getElementById('faq11').style.display='none';
document.getElementById('faq11P').className='linkFaq';
}
if(idFaq!='faq12'){
document.getElementById('faq12').style.visibility='hidden';
document.getElementById('faq12').style.display='none';
document.getElementById('faq12P').className='linkFaq';
}

if(cad=='visible'){
document.getElementById(idFaq).style.visibility='hidden';
document.getElementById(idFaq).style.display='none';
document.getElementById(idFaq+'P').className='linkFaq';
}else{
document.getElementById(idFaq).style.visibility='visible';
document.getElementById(idFaq).style.display='block';
}
}
 /////////////////////////////
function resizesFr(anchoIframe) {
alert(anchoIframe);	
}	
/////////////////////////////
function trim(cad){
if(cad.length < 1){
return"";
}
cad = rtrim(cad);
cad = ltrim(cad);
if(cad==""){
return "";
}
else{
return cad;
}
} //End Function

function rtrim(cad){
var w_space = String.fromCharCode(32);
var v_length = cad.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(cad.charAt(iTemp) == w_space){
}
else{
strTemp = cad.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function ltrim(cad){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = cad.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(cad.charAt(iTemp) == w_space){
}
else{
strTemp = cad.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function

 /////////////////////////////
function menuOverOut(thisaz,c1,c2,c3){
	if(c1!=thisaz.className){
		thisaz.className=c2; 
		var elizqui=document.getElementById('td0_'+thisaz.id.substring(3,99));
		if (elizqui!=null && elizqui.className==c3){
			elizqui.className = c2;
		}
		var eldere=document.getElementById('td_'+thisaz.id.substring(4,99));
		if (eldere!=null && eldere.className==c3)
			eldere.className = c2;
	}else{
	}
}
/////////////////////////////
function statusRelojSinMenu() {
temporizador = window.setTimeout("statusRelojSinMenu();", 1000);
var hoy = new Date();
var fecha= hoy.toLocaleString();
status=mensaje+' '+ fecha;
}
/////////////////////////////
function ocultarEnCarga() {
	if (document.getElementById) {
		document.getElementById('cuerpo').style.visibility = 'visible';
		document.getElementById('cuerpo').style.display= 'block';
		}else{
		if (document.layers){
			document.cuerpo.visibility = 'visible';
  		document.cuerpo.display= 'block';
		}else{
			document.all.cuerpo.style.visibility = 'visible';
			document.all.cuerpo.style.display= 'block';
		} 			
	}
statusRelojSinMenu()

if(document.getElementById('frBuscador')!=null){
	//alert(document.getElementById('frBuscador').style.height);
	//alert(document.getElementById('frBuscador').getElementById('elBody').offsetHeight);
	
	//document.getElementById('frBuscador').style.height=
	//document.getElementById('frBuscador').getElementById('elBody').offsetHeight;
}

}

//////////////////////////////////////////////////
function emailCheck (emailStr, cadError) {
/* Verificar si el email tiene el formato user@dominio. */
var emailPat=/^(.+)@(.+)$/ 
/* Verificar la existencia de caracteres. ( ) < > @ , ; : \ " . [ ] */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]" 
/* Verifica los caracteres que son válidos en una dirección de email */
var validChars="\[^\\s" + specialChars + "\]" 
var quotedUser="(\"[^\"]*\")" 
/* Verifica si la dirección de email está representada con una dirección IP Válida */ 
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* Verificar caracteres inválidos */ 
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
 cadError="Direccion de Email incorrecta"
 return false
}
var user=matchArray[1]
var domain=matchArray[2]
// Si el user "user" es valido 
if (user.match(userPat)==null) {
// Si no
 cadError="El nombre de usuario no es válido."
 return false
}
/* Si la dirección IP es válida */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
 cadError="IP de destino inválida"
 return false
}
}
return true
}
var domainArray=domain.match(domainPat)
if (domainArray==null) {
 cadError="El dominio parece no ser válido."
 return false
}
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
domArr[domArr.length-1].length>3) { 
 cadError="La dirección debe tener 3 letras si es .com o 2 si en de algún pais.";
 return false;
}
if (len<2) {
var errStr="La dirección de email parece no ser correcta.";
 cadError= errStr;

return false;
}
// La dirección de email ingresada es Válida
return true;
}
//////////////////////////////////////////////////
