var altoAmpliado = 0;
var altoTotal = 466;
var URL = "http://www.otazu.com/"
var ventanaMusica = "";
var previo = "";
var letra = "";


var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

if (navigator.appName.indexOf("Netscape") != -1) {var isNN = true;}
else{var isNN = false;}

if (navigator.appName.indexOf("Microsoft Internet Explorer") != -1) {var isIE = true;}
else{var isIE = false;}

function pngFix(imagen){
	if ((version >= 5.5) && (document.body.filters)) 
	{
	  var img = imagen;
	  var imgName = img.src.toUpperCase()
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
		 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 img.outerHTML = strNewHTML
	}
}

if(typeof(document.getElementsByClassName) != 'function') {
  	document.getElementsByClassName = function (cn) {
		var rx = new RegExp("\\b" + cn + "\\b"), allT = document.getElementsByTagName("*"), allCN = [], i = 0, a;
			while (a = allT[i++]) {
			  if (a.className && a.className.indexOf(cn) + 1) {
				if(a.className===cn){ allCN[allCN.length] = a; continue;   }
				rx.test(a.className) ? (allCN[allCN.length] = a) : 0;
			  }
			}
		return allCN;
	}
}



function setContenido(objeto,texto) {
	document.getElementById(objeto).innerHTML = texto
}
	
		
function seeMe(obj){
	obj.style.visibility="visible";
	pngFix(obj);

}
		

function amplia(img,carpeta,ID) {
	resto = altoTotal-altoAmpliado
	if(resto>5){
		altoAmpliado = altoAmpliado + resto/2
	}else{
		altoAmpliado = altoTotal
	}
	var capa= document.getElementById("ampliado");
	capa.style.height = altoAmpliado+"px";
	capa.style.top = '94px';
	if(altoAmpliado>=altoTotal){
//		contenido = '<img src="http://www.inspirate.es/clientes/otazu/img/fotoBig/'+img+'" class="imgAmpliada"/>';

		valor = '<div id="imgAmpliada">';
		valor+= '	<div style=width:971px;height:444px;"'+' id="imgAmpliadaIn">';
		valor+= '		<img src="http://www.otazu.com/'+carpeta+img+'" alt="" onload="fadeFoto()"/>';
		valor+= '		<div id="cerrarAmpliado" onclick="cierra('+ID+')">'
		valor+= '			<div id="cerrarAmpliadoInBkg" onclick="cierra('+ID+')">'
		valor+= '			</div>'
		valor+= '			<div id="cerrarAmpliadoIn" onclick="cierra('+ID+')">'
		valor+= '				'+CONSTANTES['CERRAR_TXT'];
		valor+= '			</div>'
		valor+= '			<div id="cerrarAmpliadoInSobre" onclick="cierra('+ID+')">'
		valor+= '			</div>'
		valor+= '			<div id="cerrarAmpliadoIn2" onclick="cierra('+ID+')">'
		valor+= '				<img src="'+URL+'img/cerrar.jpg"/>'
		valor+= '			</div>'
		valor+= '		</div>'
		valor+= '	</div>'
		valor+= '</div>'
		setContenido("ampliado",valor)

        var content = document.getElementById("imgAmpliadaIn");
		var property = content.filters ? 'filter' : 'opacity';
		content.style[property] = content.filters ? 'alpha(opacity=' + 0 + ')' : 0/100;


        var content = document.getElementById("imgAmpliada");
        appear(content);
		if(ID!=null){
			obj = document.getElementById("menuGestor");
			previo = obj.innerHTML;
			obj.innerHTML = '<a href="" onclick="edit('+"'"+'galeria'+"'"+','+ID+');return false;" id="editBtn"><img src="'+URL+'img/iconos/entrar.jpg" title="Editar registro"/></a> ' + obj.innerHTML
		}
	}else{
		setTimeout(function () {amplia(img,carpeta,ID)}, 50)
	}
}

function fadeFoto(){
   var content = document.getElementById("imgAmpliadaIn");
   appear(content);
}

function cierra(ID){
	setContenido("ampliado","")
	var capa= document.getElementById("ampliado");
	resto = 0 - altoAmpliado;
	if(resto<-2){
		altoAmpliado = altoAmpliado + resto/2
	}else{
		altoAmpliado = 0
		capa.style.top = '-30px';
	}
	capa.style.height = altoAmpliado+"px";
	if(altoAmpliado>0){
		setTimeout(function () {cierra(ID)}, 50)
	}else{
		if(ID!=null){
			obj = document.getElementById("menuGestor");
			obj.innerHTML = previo;
		}
	}
}


function initAudio(){
	ventanaMusica = window.open(URL+"musica.php", "ventanaMusica", "left=00,top=00,width=220,height=40,location=no,menubar=no,scrollbars=no,status=no");
	valor = '<a href="" onClick="paraAudio();return false;">MÚSICA[ ON ]</a>';
	setContenido("musica",valor)
}


function paraAudio(){
	ventanaMusica.close()
	valor = '<a href="" onClick="initAudio();return false;">MÚSICA[ OFF ]</a>';
	setContenido("musica",valor)
}


function appear(content, value) {
    var property = content.filters ? 'filter' : 'opacity';
    if (typeof value == 'undefined'){
		if(content.style[property]== 'undefined' || content.style[property]== ''){
			value = 0;
		}else{
			valor = parseInt(content.style[property]);  
			if (isNaN(valor)) {  
			   //no es entero 0  
				value = parseInt(content.style[property].slice(14,content.style[property].length-1));
			}else{  
			   //es un valor entero  
				value = content.style[property]*100;
			}  
		}
	}
    if (value == 100) {
        content.style[property] = 1;
    } else {
        content.style[property] = content.filters ? 'alpha(opacity=' + value + ')' : value/100;
        setTimeout(function () {appear(content, value + 20)}, 50);
    }
}

function disappear(content, value) {
    var property = content.filters ? 'filter' : 'opacity';
    if (typeof value == 'undefined'){
		if(content.style[property]== 'undefined' || content.style[property]== ''){
			value = 100;
		}else{
			valor = parseInt(content.style[property]);  
			if (isNaN(valor)) {  
			   //no es entero 0  
				value = parseInt(content.style[property].slice(14,content.style[property].length-1));
			}else{  
			   //es un valor entero  
				value = content.style[property]*100;
			}  
		}
	}
    content.style[property] = content.filters ? 'alpha(opacity=' + value + ')' : value/100;
    if (value > 0) {
	    if (content.direccion == 1) {
		    setTimeout(function () {disappear(content, value - 20)}, 50);
		}
    }
}


function facebookOver(){
	var obj = document.getElementById("fcbImg");
	obj.src = URL+'img/logoFcb2.jpg'
}

function facebookOut(){
	var obj = document.getElementById("fcbImg");
	obj.src = URL+'img/logoFcb1.jpg'
}

function tweeterOver(){
	var obj = document.getElementById("twtImg");
	obj.src = URL+'img/logoTwit2.jpg'
}

function tweeterOut(){
	var obj = document.getElementById("twtImg");
	obj.src = URL+'img/logoTwit1.jpg'
}


function youtubeOver(){
	var obj = document.getElementById("ytbImg");
	obj.src = URL+'img/logoYou2.jpg'
}

function youtubeOut(){
	var obj = document.getElementById("ytbImg");
	obj.src = URL+'img/logoYou1.jpg'
}




function overSec(num){
	var obj = document.getElementById("li"+num);
	obj.style.background = "#36261f"
	obj = document.getElementById("a"+num);
	obj.style.color = "#ffffff"
	obj = document.getElementById("sp"+num);
	if(obj!=null){
		obj.style.background = "#36261f"
	}
}

function outSec(num){
	var obj = document.getElementById("li"+num);
	obj.style.background = "#e4e4e4"
	obj = document.getElementById("a"+num);
	obj.style.color = "#000000"
	obj = document.getElementById("sp"+num);
	if(obj!=null){
		obj.style.background = "#e4e4e4"
	}
}

function overTer(num){
	var obj = document.getElementById("at"+num);
//	obj.style.fontWeight = "600"
	obj.style.color = "#000000"
	var marca = document.getElementById("marcadort"+num);
	marca.style.background = 'url('+URL+'img/marcadorOn.jpg)'
}

function outTer(num){
	var obj = document.getElementById("at"+num);
//	obj.style.fontWeight = "400"
	obj.style.color = "#4e4e4e"
	var marca = document.getElementById("marcadort"+num);
	marca.style.background = 'url('+URL+'img/marcadorOff.jpg)'
}

function overPdf(){
	var obj = document.getElementById("pdfLink");
	obj.style.color = "#000000"
	var obj = document.getElementById("pdfImage");
	obj.src = URL+'img/pdf2.jpg'
}

function outPdf(){
	var obj = document.getElementById("pdfLink");
	obj.style.color = "#484848"
	var obj = document.getElementById("pdfImage");
	obj.src = URL+'img/pdf.jpg'
}


function overLang(num){
	var obj = document.getElementById("lb"+num);
	if(num==1){num2=2}else{num2=1}
	obj.style.color = "#503228"
	obj.style.textDecoration = "underline";
	var content = document.getElementById("sobre"+num2);
	content.direccion = 1;
	disappear(content)
}

function outLang(num){
	var obj = document.getElementById("lb"+num);
	if(num==1){num2=2}else{num2=1}
	obj.style.color = "#2b2b2b"
	obj.style.textDecoration = "none";
	var content = document.getElementById("sobre"+num2);
	content.direccion = 0;
	appear(content)
}

function sobreIdioma(urlDestino){
//	alert(urlDestino)
	var obj = document.getElementById("langExtra");
	obj.posicion = 1;
	obj.urlDestino = urlDestino;
	setTimeout(function () {actuaIdioma()}, 50)
}

function outIdioma(){
	var obj = document.getElementById("langExtra");
	obj.posicion = 0;
	setTimeout(function () {actuaIdioma()}, 50)
}

function actuaIdioma(){
	var objeto = document.getElementById("langExtra");
	var pulsado = objeto.posicion;
	if(pulsado == 1){
		if(objeto.innerHTML==''){
			localizacion = location.pathname;
			trozos = localizacion.split("/")
			nuevaLocation = "";
			for(i=0;i<trozos.length-1;i++){
				nuevaLocation += trozos[i]+"/";
			}
			if(CONSTANTES['idioma']=="ES"){idioma = "en";idiomaMay = "EN"}else{idioma = "es";idiomaMay = "ES"}
			enlace = nuevaLocation + idioma;
			enlace = objeto.urlDestino + idioma;
			objeto.innerHTML = '<a href="'+enlace+'" onmouseover="sobreIdioma()" onmouseout="outIdioma()" onfocus="sobreIdioma()"  onblur="outIdioma()">['+idiomaMay+']</a>';
		}
//		appear(objeto,0)
	}else{
		objeto.innerHTML = "";
	}
}


function makeSubMenu(num){
	var obj = document.getElementById("submenu"+num);
	if(obj.innerHTML==''){
		var valor ='	<ul>'
		var rep=1;
		if(CONSTANTES['idioma']=="ES"){idioma = "es";}else{idioma = "en";}
		while(CONSTANTES['MENU'+num+'_'+rep]!="undefined" && CONSTANTES['MENU'+num+'_'+rep]!="" && CONSTANTES['MENU'+num+'_'+rep]!=null){
			if(rep!=1){
				valor +='	<li>|</li>';
			}
			if(num==3 || num==4 || (num==1 && rep==4)){subApartado = '/1'}else{subApartado = ''}
			valor+='		<li><a href="'+URL+CONSTANTES['MENU'+num+'LINK']+'/'+CONSTANTES['MENU'+num+'_'+rep+"_URL"]+subApartado+'/'+idioma+'" target="_self" title="'+CONSTANTES['MENU'+num+'_'+rep]+'" onfocus="rollOver('+"'"+'l'+num+''+"'"+')"  onblur="rollOut('+"'"+'l'+num+''+"'"+')">'+CONSTANTES['MENU'+num+'_'+rep]+'</a></li>';
			rep++;
		}
		valor +='	</ul>'
		obj.innerHTML=valor;
		appear(obj,0)
		var marca = document.getElementById("marcador"+num);
		marca.style.background = 'url('+URL+'img/marcadorOn.jpg)'
	}
}


function urlAmiga(texto){

	texto = str_replace("<br>","-",texto);
//	texto = str_replace("<br/>","-",texto);
	texto = str_replace("á","a",texto);
	texto = str_replace("é","e",texto);
	texto = str_replace("í","i",texto);
	texto = str_replace("ó","o",texto);
	texto = str_replace("ú","u",texto);
	texto = str_replace("ü","u",texto);
	texto = str_replace("Á","A",texto);
	texto = str_replace("É","E",texto);
	texto = str_replace("Í","I",texto);
	texto = str_replace("Ó","O",texto);
	texto = str_replace("Ú","U",texto);
	texto = str_replace("Ü","u",texto);
	texto = str_replace("Ñ","N",texto);
	texto = str_replace("ñ","n",texto);
//	texto = str_replace(",","-",texto);
//	texto = str_replace(";","-",texto);
//	texto = str_replace("?","-",texto);
//	texto = str_replace("¿","-",texto);
	texto = str_replace(" ","-",texto);
//	texto = str_replace("_","-",texto);
//	texto = str_replace(".","-",texto);
//	texto = str_replace('"',"-",texto);
//	texto = str_replace("'","-",texto);*/

	return texto.toLowerCase();
}

function str_replace(busca, repla, orig)
{
	str 	= new String(orig);

	rExp	= "/"+busca+"/g";
	rExp	= eval(rExp);
	newS	= String(repla);

	str = new String(str.replace(rExp, newS));

	return str;
}


function delSubMenu(num){
	var obj = document.getElementById("submenu"+num);
	var valor =''
	obj.innerHTML=valor;
	var marca = document.getElementById("marcador"+num);
	marca.style.background = 'url('+URL+'img/marcadorOff.jpg)'
}

function rollOver(obj){
	var objeto = document.getElementById(obj);
	objeto.posicion = 1;
	setTimeout(function () {actua()}, 50)
}

function rollOut(obj){
	var objeto = document.getElementById(obj);
	objeto.posicion = 0;
	setTimeout(function () {actua()}, 50)
}

function actua(){
	var objeto;
	var pulsado;
	for(i=1;i<=5;i++){
		strSeccion = "l"+i;
		objeto = document.getElementById(strSeccion);
		pulsado = objeto.posicion;
		if(pulsado == 1){
			if(seccion!=strSeccion){makeSubMenu(i);}
		}else{
			if(seccion!=strSeccion){delSubMenu(i);}
		}
	}
}

function InitFade(capa){
	switch (capa)
	{
	case "noticias":
		capa = "interior";
		var content = document.getElementById(capa);
		appear(content)
		break;
	case "vinos":
		capa = "img_vinos_cont";
		var content = document.getElementById(capa);
		appear(content)
		break;
	case "galeria":
		capa = "fotografias";
		for(i=0;i<=9;i++){
			var content = document.getElementById("capaFoto"+i);
			if(content!=null){
				var property = content.filters ? 'filter' : 'opacity';
				content.style[property] = content.filters ? 'alpha(opacity=' + 0 + ')' : 0/100;
			}else{
				break;
			}
		}
		var content = document.getElementById(capa);
		var property = content.filters ? 'filter' : 'opacity';
		content.style[property] = content.filters ? 'alpha(opacity=' + 100 + ')' : 100/100;
		inicioAppear(0);
		break;
	}
}

function inicioAppear(num){
	var content = document.getElementById("capaFoto"+num);
	if(content!=null){
		preHeight = content.offsetHeight
		preWidth = content.offsetWidth
//		content.style.height="1px"
//		content.style.width="1px"
//		creceFoto(content,preWidth,preHeight) 
		appear(content);
		nuevoNum = num+1;
		if(nuevoNum<=9){
			setTimeout(function () {inicioAppear(nuevoNum)}, 50-num*3);
		}
	}
}


function creceFoto(capa,finW,finH){
	repetir = false;
	if(capa.style.width=="" || capa.style.width=="udefined"){capa.style.width = capa.offsetWidth+"px";}
	if(capa.style.height=="" || capa.style.height=="udefined"){capa.style.height = capa.offsetHeight+"px";}

	if(capa.style.width.slice(0,capa.style.width.length-2)<finW-3){
		distancia = Math.round((finW - parseInt(capa.style.width.slice(0,capa.style.width.length-2))) / 2)
		capa.style.width = (parseInt(capa.style.width.slice(0,capa.style.width.length-2))+distancia)+"px";
		repetir = true;
	}else{
		capa.style.width = finW+"px";
	}
	if(capa.style.height.slice(0,capa.style.height.length-2)<finH-3){
		distancia = Math.round((finH - parseInt(capa.style.height.slice(0,capa.style.height.length-2))) / 2)
		capa.style.height = (parseInt(capa.style.height.slice(0,capa.style.height.length-2))+distancia)+"px";
		repetir = true;
	}else{
		capa.style.height = finH+"px";
	}

	if(repetir==true){
		setTimeout(function () {creceFoto(capa,finW,finH)}, 50);
	}else{
	}
}


function valida_enviar(){
	visita = document.getElementById("telefono");
	document.getElementById("formError").innerHTML = "";
	if (document.commentForm.comment.value.length==0){
		alert(CONSTANTES['ERROR1'])
		document.commentForm.comment.focus()
		document.getElementById("formError").innerHTML = CONSTANTES['ERROR1'];
	}else if(document.commentForm.nombre.value.length==0){
		alert(CONSTANTES['ERROR2'])
		document.commentForm.nombre.focus()
		document.getElementById("formError").innerHTML = CONSTANTES['ERROR2'];
	}else if(visita!=null && (document.commentForm.telefono.value.length!=9)){
		alert(CONSTANTES['ERROR5'])
		document.commentForm.telefono.focus()
		document.getElementById("formError").innerHTML = CONSTANTES['ERROR5'];
	}else if(visita==null && document.commentForm.correo.value.length==0){
		alert(CONSTANTES['ERROR3'])
		document.commentForm.correo.focus()
		document.getElementById("formError").innerHTML = CONSTANTES['ERROR3'];
	}else if(visita!=null && document.commentForm.correo2.value.length==0){
		alert(CONSTANTES['ERROR3'])
		document.commentForm.correo2.focus()
		document.getElementById("formError").innerHTML = CONSTANTES['ERROR3'];
	}else{
		if(visita==null){
			correo = document.commentForm.correo.value;
		}else{
			correo = document.commentForm.correo2.value;
		}
		if(correo.split("@").length!=2 || correo.split("@")[0]=="" || correo.split("@")[1]=="" || correo.split("@")[1].split(".").length!=2 || correo.split("@")[1].split(".")[0]=="" || correo.split("@")[1].split(".")[1]==""){
			alert(CONSTANTES['ERROR4'])
			document.commentForm.correo.focus()
			document.getElementById("formError").innerHTML = CONSTANTES['ERROR4'];
		}else{
			if(visita==null){
				enviaComment(false);
			}else{
				enviaComment(true);
			}
		}
	}
}


function enviaComment(visita){ 
	var oXMLHttpRequest = generaReqHome();
	oXMLHttpRequest.onreadystatechange = function(){
		if(oXMLHttpRequest.readyState == 4 && oXMLHttpRequest.status == 200)
		{
			var respuesta = oXMLHttpRequest.responseXML;
			var elementos = respuesta.getElementsByTagName("valor"); 
			var resultado = elementos[0].getElementsByTagName("enviado")[0].firstChild.data;
			if(resultado=="true"){
				alert(CONSTANTES['ENVIADO'])
				document.getElementById("formError").innerHTML = CONSTANTES['ENVIADO'];
				document.commentForm.comment.value="";
				document.commentForm.nombre.value="";
				if(visita==false){
					document.commentForm.correo.value="";
				}else{
					document.commentForm.correo2.value="";
					document.commentForm.telefono.value="";
				}
			}else{
				alert(CONSTANTES['ERROR_ENVIO'])
				document.getElementById("formError").innerHTML = CONSTANTES['ERROR_ENVIO'];
			}
			obj = document.commentForm;
			obj.submit.style.visibility="visible";
		}
	};
	obj = document.commentForm;
	obj.submit.style.visibility="hidden";
	document.getElementById("formError").innerHTML = "Enviando...";
	if(visita==false){
		oXMLHttpRequest.open( 'GET', URL+'inc/enviaCorreo_js.php?nombre='+document.commentForm.nombre.value+'&correo='+document.commentForm.correo.value+'&comment='+document.commentForm.comment.value, true );
	}else{
		oXMLHttpRequest.open( 'GET', URL+'inc/enviaCorreo_js.php?nombre='+document.commentForm.nombre.value+'&correo='+document.commentForm.correo2.value+'&comment='+document.commentForm.comment.value+'&telefono='+document.commentForm.telefono.value, true );
	}
	oXMLHttpRequest.send( null);
} 


function generaReqHome(){
	var oXMLHttpRequest; 
	if(window.XMLHttpRequest) { // no es IE 
		oXMLHttpRequest = new XMLHttpRequest(); 
	} else { // Es IE o no tiene el objeto 
		try { 
			oXMLHttpRequest = new ActiveXObject('Microsoft.XMLHTTP'); 
		} catch (e) { 
			alert('El navegador utilizado no está soportado'); 
		} 
	} 
	return oXMLHttpRequest;
}


function clickSec(destino){
	if(letra!=17){
		document.location = destino;
	}else{
		window.open(destino)
		letra = "";
	}
}


function abajo(e) {
  var keyCode=0 ;
  if (navigator.appName.indexOf("Microsoft Internet Explorer") != -1) {var isIE = true;}
  else{var isIE = false;}

  if (isIE){
    keyCode=event.keyCode
  }else{
    keyCode=e.which;
  }
  letra = keyCode;
}

function arriba(e) {
  letra = "";
}

document.onkeydown = abajo;
document.onkeyup = arriba;

vinasAll = false;

function actuaVinasAll(){
	if(vinasAll == false){
		vinasAll = true;
		document.getElementById("aVinas").innerHTML = CONSTANTES['DESACTIVAR'];
		num=1;
		while(document.getElementById("vinaMap"+num)!=null){
			if(isIE==false){
				$("#vinaMap"+num).stop(true);
				$("#vinaMap"+num).animate({ opacity: 100 }, {duration: 600,easing: 'easeInQuart'});
			}else{
				document.getElementById("vinaMap"+num).style.visibility = "";
			}
			num++;
		}
	}else{
		vinasAll = false;
		document.getElementById("aVinas").innerHTML = CONSTANTES['ACTIVAR'];
		num=1;
		while(document.getElementById("vinaMap"+num)!=null){
			if(isIE==false){
				$("#vinaMap"+num).stop(true);
				$("#vinaMap"+num).animate({ opacity: 0 }, {duration: 600,easing: 'easeOutQuart'});
			}else{
				document.getElementById("vinaMap"+num).style.visibility = "hidden";
			}
			num++;
		}
	}
}

function overVinas(num){
	if(vinasAll == false){
		obj = document.getElementById("vinaMap"+num)
		if(isIE==false){
			$("#vinaMap"+num).stop(true);
			$("#vinaMap"+num).animate({ opacity: 100 }, {duration: 600,easing: 'easeInQuart'});
		}else{
			obj.style.visibility = "";
		}
	}
	objeto = document.getElementById("txtVina")
	apareceTexto(objeto, CONSTANTES['VINA'+num])
}

function outVinas(num){
	if(vinasAll == false){
		obj = document.getElementById("vinaMap"+num)
		if(isIE==false){
			$("#vinaMap"+num).stop(true);
			$("#vinaMap"+num).animate({ opacity: 0 }, {duration: 600,easing: 'easeOutQuart'});
		}else{
			obj.style.visibility = "hidden";
		}
	}
	objeto = document.getElementById("txtVina")
	objeto.innerHTML = "";
	clearInterval(intervalID)
}

cuentaLetra = 0;

function apareceTexto(objeto, texto){
	cuentaLetra = 0;
	txt = texto.substring(6);
	trozos = txt.split("</span>");
	
	intervalID = setInterval("meteletra('"+objeto.id+"','"+trozos[0]+"','"+trozos[1]+"')",25);
}

function meteletra(obj, texto1, texto2){
	objeto = document.getElementById(obj)
	texto1 = str_split (texto1, 1)
	texto2 = str_split (texto2, 1)
	if(cuentaLetra<texto1.length){
		texto = "<span>";
		for(i=0;i<=cuentaLetra;i++){
			texto += texto1[i]; 
		}
		texto += "</span>";
		objeto.innerHTML = texto;
		cuentaLetra++;
	}else if(cuentaLetra<texto1.length+texto2.length){
		texto = "<span>";
		for(i=0;i<texto1.length;i++){
			texto += texto1[i]; 
		}
		texto += "</span>";
		limitador = cuentaLetra-texto1.length+1;
		for(i=0;i<limitador;i++){
			texto += texto2[i]; 
		}
		objeto.innerHTML = texto;
		cuentaLetra++;
	}else{
		clearInterval(intervalID)
	}

}



function str_split (string, split_length) {
    if (string === undefined || !string.toString || split_length < 1) {
        return false;
    }
    return string.toString().match(new RegExp('.{1,' + (split_length || '1') + '}', 'g'));
}
