function esTeclaEnter(){
var keyCode = document.layers ? evt.which : document.all ? event.keyCode : document.getElementById ? evt.keyCode : 0; 
if(keyCode==13)return (true); else return(false);
}
function validaCobInfoVN() {
cRes='Corregir los siguientes errores:\n';
bRes=true;
if (document.frm1.nombre1.value==''){
cRes=cRes+'\n'+'Nombre';bRes=bRes && false;
}
if(!emailValido(document.frm1.email1.value) && document.frm1.email1.value!=''){
cRes=cRes+'\n'+'Email debe ser una dirección de válida';bRes=bRes && false;
}
if(document.frm1.telefono.value=='' && document.frm1.email1.value==''){
cRes=cRes+'\n'+'Teléfono o Email deben estar rellenos';bRes=bRes && false;
}
if (! bRes){alert(cRes);}
return bRes;
}
//////////////////////////
function validaDiaFrmLoOlvide() {
cRes='Corregir los siguientes errores:\n';
bRes=true;
if(!emailValido(document.frm1.email1.value) && document.frm1.email1.value!=''){
cRes=cRes+'\n'+'Email debe ser una dirección de válida';bRes=bRes && false;
}
if (! bRes){alert(cRes);}
return bRes;
}
//////////////////////////
function validaCobCitaTalleres() {
cRes='Corregir los siguientes errores:\n';
bRes=true;
if (document.frm1.nombre1.value==''){
cRes=cRes+'\n'+'Nombre';bRes=bRes && false;
}
if(!emailValido(document.frm1.email1.value) && document.frm1.email1.value!=''){
cRes=cRes+'\n'+'Email debe ser una dirección de válida';bRes=bRes && false;
}
if(document.frm1.telefono.value=='' && document.frm1.email1.value==''){
cRes=cRes+'\n'+'Teléfono o Email deben estar rellenos';bRes=bRes && false;
}
if(document.frm1.matricula.value==''){
cRes=cRes+'\n'+'Matrícula';bRes=bRes && false;
}
if (! bRes){alert(cRes);}
return bRes;
}
//////////////////////////
function validaCobPeticionRecambios() {
cRes='Corregir los siguientes errores:\n';
bRes=true;
if (document.frm1.nombre1.value==''){
cRes=cRes+'\n'+'Nombre';bRes=bRes && false;
}
if(!emailValido(document.frm1.email1.value) && document.frm1.email1.value!=''){
cRes=cRes+'\n'+'Email debe ser una dirección de válida';bRes=bRes && false;
}
if(document.frm1.telefono.value=='' && document.frm1.email1.value==''){
cRes=cRes+'\n'+'Teléfono o Email deben estar rellenos';bRes=bRes && false;
}
if(document.frm1.matricula.value==''){
cRes=cRes+'\n'+'Matrícula';bRes=bRes && false;
}
if(document.frm1.bastidor.value==''){
cRes=cRes+'\n'+'Bastidor';bRes=bRes && false;
}
if(document.frm1.cantidad1.value=='' || document.frm1.ref1.value=='' ||document.frm1.pieza1.value==''){
cRes=cRes+'\n'+'Se debe solicitar alguna pieza';bRes=bRes && false;
}
if (! bRes){alert(cRes);}
return bRes;
}
////////////////////////////
function emailValido(str) {
var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // no valido
var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valido
if (!reg1.test(str) && reg2.test(str))return true;
return false;
}
////////////////////////////
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 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 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 cambiaEstilo2(id,propiedad,valor){
	if (propiedad == 'fontSize') { document.getElementById(id).style.fontSize = valor; }
	if (propiedad == 'textAlign') { document.getElementById(id).style.textAlign = valor; }
} 
////////////////////////////////
function cambiaEstilo(accion){
	var allDIVs = document.getElementById('elBody').getElementsByTagName('*');
	if (accion == '0'){base=parseInt(base);}
	if (accion == '1'){base=parseInt(base)-1;}
	if (accion == '2'){base=11;}
	if (accion == '3'){base=parseInt(base)+1;}
	for(i=0;i<allDIVs.length;i++){
		if(allDIVs.item(i).id!=''){
			var actual=document.getElementById(allDIVs.item(i).id).id;	
			//alert(actual+'\n'+document.getElementById(actual).className+'\n'+document.getElementById(actual).innerHTML);
			if(document.getElementById(actual).className!=''){
				//alert(document.getElementById(actual).className);
				var correccion1=0;
				if (document.getElementById(actual).className=='TDMolde121')
					correccion1=9;
				if (accion == '0' || accion == '1' ||accion == '2' ||accion == '3'){
					cambiaEstilo2(actual,'fontSize',(base+correccion1)+'px');
					DeleteCookie('letraBase');
					SetCookie ('letraBase', base) ;
				}

				if (document.getElementById(actual).className=='class02'
				 || document.getElementById(actual).className=='class03'
				 || document.getElementById(actual).className=='class08L'
				 || document.getElementById(actual).className=='classCab'
				 || document.getElementById(actual).className=='class08L'
				 || document.getElementById(actual).className=='TDMolde122'
				 ){
					if (accion == 'l') {cambiaEstilo2(actual,'textAlign','left');SetCookie ('textAlign', 'l'); }
					if (accion == 'j') {cambiaEstilo2(actual,'textAlign','justify');SetCookie ('textAlign', 'j'); } 
				}
			}	
		}			
	}
//alert(base);
//alert(amt());
}
////////////////////////////////
function tipoFaq(contenedor,abierto){
	var allDIVs = document.getElementById(contenedor).getElementsByTagName('td');
	for(i=0;i<allDIVs.length;i++){
//alert(document.getElementById(allDIVs.item(i).id).id);
	var actual=document.getElementById(allDIVs.item(i).id).id;	
//alert(abierto+'\n'+actual);
		if (actual.indexOf('_t1')>-1){
			if (actual.indexOf(abierto)>-1){
				document.getElementById(actual).style.display = 'block';
				document.getElementById(actual).style.visibility= 'visible';
			}else{
				document.getElementById(actual).style.display = 'none';
				document.getElementById(actual).style.visibility= 'hidden';
			}	
		}
		if (actual.indexOf('_t0')>-1){
			if (actual.indexOf(abierto)>-1){
				document.getElementById(actual).className= 'class07S';
			}else{
				document.getElementById(actual).className= 'class07L';
			}	
		}
//alert(document.getElementById(allDIVs.item(i).id+'_'));
		//	document.getElementById(d2+'_m0').className=aSel[1]+"S2";
		//	document.getElementById(d2+'_m1').className=aSel[1]+"S";
		//allDIVs.item(i).style.display='block';
	}
}
//////////////////////////////////////////////
function getInnerWidth(win) {
  var winWidth;
  if (win.innerWidth) {
    winWidth = win.innerWidth;
  }
  else if (win.document.documentElement && win.document.documentElement.clientWidth) {
    winWidth = win.document.documentElement.clientWidth;
  }
  else if (document.body) {
    winWidth = win.document.body.clientWidth;
  }
  return winWidth;
}
//////////////////////////////////////////////
function getInnerHeight(win) {
  var winHeight;
  if (win.innerHeight) {
    winHeight = win.innerHeight;
  }
  else if (win.document.documentElement && win.document.documentElement.clientHeight) {
    winHeight = win.document.documentElement.clientHeight;
  }
  else if (win.document.body) {
    winHeight = win.document.body.clientHeight;
  }
  return winHeight;
}
//////////////////////////////////////////////
function getScrollTop(win) {
   var scrollTop = 0;
   if (win.pageYOffset) {
      scrollTop = win.pageYOffset;
   }
   else if (win.document.documentElement && win.document.documentElement.scrollTop) {
      scrollTop = win.document.body.scrollTop;
   }
   else if (win.document.body) {
      scrollTop = win.document.body.scrollTop;
   }
   return scrollTop;
}
//////////////////////////////////////////////
function getScrollLeft(win) {
   var scrollLeft = 0;
   if (win.pageXOffset) {
      scrollLeft = win.pageXOffset;
   }
   else if (win.document.documentElement && win.document.documentElement.scrollLeft) {
      scrollLeft = win.document.body.scrollLeft;
   }
   else if (win.document.body) {
      scrollLeft = win.document.body.scrollLeft;
   }
   return scrollLeft;
}
//////////////////////////////////////////////
function getBrowserName(){return navigator.appName;}
function getBrowserVersion(){return navigator.appVersion;}
function getBrowserCodeName(){return navigator.appCodeName;}
function getBrowserUserAgent(){return navigator.userAgent;}
function getBrowserVersion(){return navigator.appVersion;}
//////////////////////////////////////////////
function centrarVentana(img,titulo,xImg,yImg) {
if (document.images) {
	var foto1= new Image();
	foto1.src=img;
}
//setTimeout('void(0);',2000);
var largo=0;
var ancho=0;

//var xMax = screen.width;var yMax = screen.height;
var xMax = screen.availWidth-8;
var yMax = screen.availHeight-28;

var xOffset = 0;
var yOffset = 0;

largo=xImg;ancho=yImg;

var url="0az_verImagen.html?&xImg="+xImg+"&yImg="+yImg+"&f="+img+"&titulo="+titulo+"";
var c2="fullscreen=no, status=no, title=no, toolbar=no, menubar=no, scrollbars=no,resizable=yes, top=0, left=0, width="+(xMax-4)+",height="+(yMax-6)+" ";
mainwindow=window.open(url,'_blank',c2);
if(mainwindow != null){mainwindow.focus() ;}else{}
largo=0;ancho=0; 
return;
}
////////////////////////////////
function suena(elDiv, laCancion){
var text='<embed  width=0 height=0 src="' + laCancion+'" hidden="true" loop="false" autostart="true"></embed>';
document.getElementById(elDiv).innerHTML=text;
}
////////////////////////////////
function suena2(elDiv, laCancion,x,y){
var text='<embed width='+x+' height='+y+' src="' + laCancion+'" hidden="false" loop="false" autostart="true">';
document.getElementById(elDiv).innerHTML=text;
}
////////////////////////////////
function suena3(elDiv, laCancion){
var text='<embed src="' + laCancion+'" hidden="false" loop="false" autostart="true">';
document.getElementById(elDiv).innerHTML=text;
}
////////////////////////////////
function menuTeclado(e){
	var x='';
  if (document.all){
    var evnt = window.event;
    x=evnt.keyCode;
  }else{
    x=e.keyCode;
  }
  matrizTeclas(x);
  if (!document.all){
       window.captureEvents(Event.KEYPRESS);
       window.onkeypress=menuTeclado;
  }else{
       document.onkeypress = menuTeclado;
  }
}
////////////////////////////////
function pausa(delay){
date = new Date();
var curDate = null;

do { var curDate = new Date(); } 
while(curDate-date < delay);
//setTimeout('void(0);',delay);
}
////////////////////////////////
function PageQuery(q) {
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) {
	for(var j=0; j < this.keyValuePairs.length; j++) {
		if(this.keyValuePairs[j].split("=")[0] == s)
		return this.keyValuePairs[j].split("=")[1];
	}
	return false;
	}
	this.getParameters = function() {
	var a = new Array(this.getLength());
	for(var j=0; j < this.keyValuePairs.length; j++) {
		a[j] = this.keyValuePairs[j].split("=")[0];
		alert(a[j]);
	}
	return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; } 
}
/////////////////////////////
function queryString(key){
	var page = new PageQuery(window.location.search); 
	return unescape(page.getValue(key)); 
}
/////////////////////////////
function statusRelojSinMenu() {
temporizador = window.setTimeout("statusRelojSinMenu();", 1000);
var hoy = new Date();
var fecha= hoy.toLocaleString();
status=mensaje+fecha;
  var h = 0;
  if(document.getElementById('frCentral')!=null){ /*Descomentar para el mismo dominio*/
   if(document.all) {
 	h = document.frames('frCentral').document.body.scrollHeight;
	document.all.frCentral.style.height = h + 20 + 'px';
   }else if (document.getElementById) {
    h = document.getElementById('frCentral').contentDocument.height;
	document.getElementById('frCentral').style.height = h + 60 + 'px';
   }  
  }
}
////////////////////////////////
function abrirVentanaNuevaPopUpCentrada(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 strVeces(fullS,oldS) {
var veces=0;
for (var i=0; i<fullS.length; i++){
      if (fullS.substring(i,i+oldS.length) == oldS) {
          veces++;      
}}   
return veces;
}
////////////////////////////////////
function imprimir() {
if (window.print)
  window.print()
else
  alert("Disculpe, su navegador no soporta esta opción.");
}
////////////////////////////////
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 GetCookie (name){  
var arg = name + "=";  
var alen = arg.length;  
var clen = document.cookie.length;  
var i = 0;  
while (i < clen) {
var j = i + alen;    
if (document.cookie.substring(i, j) == arg)      
return getCookieVal (j);    
i = document.cookie.indexOf(" ", i) + 1;    
if (i == 0) break;   
}  
return null;
}
function SetCookie (name, value) {  
var argv = SetCookie.arguments;  
var argc = SetCookie.arguments.length;  
var expires = (argc > 2) ? argv[2] : null;  
var path = (argc > 3) ? argv[3] : null;  
var domain = (argc > 4) ? argv[4] : null;  
var secure = (argc > 5) ? argv[5] : false;  
document.cookie = name + "=" + escape (value) + 
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
((path == null) ? "" : ("; path=" + path)) +  
((domain == null) ? "" : ("; domain=" + domain)) +    
((secure == true) ? "; secure" : "");
}
////////////////////////////////
function DeleteCookie (name) {  
var exp = new Date();  
exp.setTime (exp.getTime() - 1);   
var cval = GetCookie (name);  
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var expDays = 30;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
////////////////////////////////
function amt(){
var count = GetCookie('letraBase')
if(count == null) {
SetCookie('letraBase','11')
return 11;
}else {
return count;
}
}
////////////////////////////////
function amt2(){
var count = GetCookie('textAlign')
if(count == null) {
SetCookie('textAlign','l')
return 'l';
}
else {
DeleteCookie('textAlign')
SetCookie('textAlign',count,exp)
return count
   }
}
////////////////////////////////
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
////////////////////////////////
//  cargando ini
////////////////////////////////
var t_id = setInterval(animate,20);
var pos=0;
var dir=2;
var len=0;
function animate(){
	var elem = document.getElementById('progress');
	if(elem != null) {
		if (pos==0) len += dir;
		if (len>110 || pos>79) pos += dir;
		if (pos>79) len -= dir;
		if (pos>79 && len==0) pos=0;
		//elem.style.left = pos;
		elem.style.width = len;
	}
}
function remove_loading(como) {
	if(document.getElementById('loader_container')!=null){ 
		this.clearInterval(t_id);
		var targelem = document.getElementById('loader_container');
		var cuerpo0 = document.getElementById('cuerpo0');
		targelem.style.display='none';
		targelem.style.visibility='hidden';
	}
	document.getElementById('cuerpo0').style.display='block';
	document.getElementById('cuerpo0').style.visibility='visible';
	if(como!='no')
	  centrarEnVentanaHorizontal('cuerpo0');
	document.getElementById('cuerpo0').style.display='block';
	statusRelojSinMenu();
}
////////////////////////////////
//  cargando fin
////////////////////////////////
