function rollOn(obj){file=obj.src;obj.src=file.replace('_Off','_On');}

function rollOff(obj){file=obj.src;obj.src=file.replace('_On','_Off');}

var Key='';
function keyhandler(e) {
   	if ((Key >=48 && Key <=57) || (Key >=96 && Key <=105) || Key==46 || Key==8 || Key==9 || (Key >=37 && Key <=40)){return true}else{return false};
}

function validarEmail(valor) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
		return (true);
	} else {
		return (false);
	}
}

function changeImg(idImg, pstrImg,texto){
	document.getElementById(idImg).src = pstrImg;
}

function changeHomeImg(idImg, pstrImg, texto, id, total){
	document.getElementById(idImg).src = pstrImg;
	if(texto!='false'){
		document.getElementById('textosobreimagen').innerHTML = texto;
		if(texto==''){
			document.getElementById('textosobreimagen').style.display = 'none';
		}else{
			document.getElementById('textosobreimagen').style.display = 'block';
		}
	}
	for(k=1;k<total;k++){
		document.getElementById('item'+k).className='iPaginadorSlide';
	}
	document.getElementById('item'+id).className='iPaginadorSlideOn';
}

function ShowHideCategories(pstrOption, pIdCategory){
	if(document.getElementById(pstrOption+'subcategoria'+pIdCategory).style.display == "none" || document.getElementById(pstrOption+'subcategoria'+pIdCategory).style.display == ""){
		document.getElementById(pstrOption+'categoria'+pIdCategory).style.background = "#305397";
		document.getElementById(pstrOption+'subcategoria'+pIdCategory).style.display = "block";
		document.getElementById(pstrOption+'imgMM'+pIdCategory).src = "../sitefiles/img/imMenos.gif";
	}
	else{
		document.getElementById(pstrOption+'categoria'+pIdCategory).style.background = "#505050";
		document.getElementById(pstrOption+'subcategoria'+pIdCategory).style.display = "none";
		document.getElementById(pstrOption+'imgMM'+pIdCategory).src = "../sitefiles/img/imMas.gif";
	}
}

var autotime;
function changeImgAuto(){
	counter++;
	if(counter>=imgauto.length){counter=1;}
	changeHomeImg('imgCentral',imgauto[counter],textoauto[counter],counter,imgauto.length);
	autotime=setTimeout("changeImgAuto();",3000);
}

function stopImgAuto(){
	clearTimeout(autotime);
}


var solapa1activada=true;
var solapa2activada=true;

function muestraContenidosSolapas(SolapasId,Solapa1,Solapa2){
	if(Solapa1){
		document.getElementById('ContenidoSolapa1').style.display='none';
		imagen=document.getElementById('boton1');
		imagen.src=imagen.src.replace('_On','_Off');
	}
	if(Solapa2){
		document.getElementById('ContenidoSolapa2').style.display='none';
		imagen=document.getElementById('boton2');
		imagen.src=imagen.src.replace('_On','_Off');
	}
	
	document.getElementById('ContenidoSolapa'+SolapasId).style.display='block';
		
	imagen=document.getElementById('boton'+SolapasId);
	imagen.src=imagen.src.replace('_Off','_On');
	
	if(Solapa1 && solapa1activada && document.getElementById('ContenidoSolapa1').style.display=='block'){
		solapa1activada=false;
	}
	
	if(Solapa2 && solapa2activada && document.getElementById('ContenidoSolapa2').style.display=='block'){
		solapa2activada=false;
	}

}

function cambiaRollOver(obj){
	ok=true;
	
	if(obj.className.indexOf('Off')>=1 && ok){obj.className=obj.className.replace('Off','On');ok=false;}
	if(obj.className.indexOf('On')>=1 && ok){obj.className=obj.className.replace('On','Off');ok=false;}
}

function muestraContenidosSolapasFicha(SolapaId,totalsolapas){
	for(i=1;i<=totalsolapas;i++){
		document.getElementById('ContenidoSolapa'+i).style.display='none';
		imagen=document.getElementById('boton'+i);
		imagen.src=imagen.src.replace('_On','_Off');
	}
	
	document.getElementById('ContenidoSolapa'+SolapaId).style.display='block';
		
	imagen=document.getElementById('boton'+SolapaId);
	imagen.src=imagen.src.replace('_Off','_On');
}

function cambiaColorSolapasOn(id){
	foto=document.getElementById('imagenSolapa'+id);
	descripcion=document.getElementById('descripcionSolapa'+id);
	titulos=document.getElementById('titulosTxtSolapa'+id);
	precio=document.getElementById('precioSolapa'+id);
	imagenCierre=document.getElementById('imagenCierreSolapa'+id);
	
	foto.className=foto.className.replace('Off','On');
	descripcion.className=descripcion.className.replace('Off','On');
	titulos.className=titulos.className.replace('Off','On');
	precio.className=precio.className.replace('Off','On');
	imagenCierre.src=imagenCierre.src.replace('Off','On');
}

function cambiaColorSolapasOff(id){
	foto=document.getElementById('imagenSolapa'+id);
	descripcion=document.getElementById('descripcionSolapa'+id);
	titulos=document.getElementById('titulosTxtSolapa'+id);
	precio=document.getElementById('precioSolapa'+id);
	imagenCierre=document.getElementById('imagenCierreSolapa'+id);
	
	foto.className=foto.className.replace('On','Off');
	descripcion.className=descripcion.className.replace('On','Off');
	titulos.className=titulos.className.replace('On','Off');
	precio.className=precio.className.replace('On','Off');
	imagenCierre.src=imagenCierre.src.replace('On','Off');
}
