var altoAmpliado = 0;
var altoTotal = 473;
var URL = "http://www.grupoarquitelia.com/"
var ventanaMusica = "";
var previo = "";
var fotos = "";
var cambio = "";
var alt = "";
var carpetaCabecera = "";
var numFoto = 0;
var interTime = 2000;
var puedeAmpliar = true;
var primeraPosCapa="";
var centroInicial = "";
var	versionNav = navigator.appVersion.substring(0,4);
var	nombreNav = navigator.appName;
var despAbierto = "";
var fotAbierto = "";

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
	}
}


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

}

function ampliaProyecto(img,carpeta,ID,pos) {
	if(img!=""){
		var capa= document.getElementById("ampliadoProyectos");
		var property = capa.filters ? 'filter' : 'opacity';
		capa.style[property] = capa.filters ? 'alpha(opacity=' + 0 + ')' : 0/100;
		tween(capa,"alpha",100,5)

		capa.style.top = "8px";
		capa.style.left = "8px";
		capa.style.width = "526px";
		capa.style.height = "324px";
		capa.style.zIndex = "50";


		capa.innerHTML += '<img id="ampliadoProyectosIMG" src=""/>'
		valor= '		<div id="cerrarAmpliado" onclick="cierraAmpliProy('+ID+')">'
		valor+= '			<div id="cerrarAmpliadoIn2" onclick="cierraAmpliProy('+ID+')">'
		valor+= '			</div>'
		valor+= '		</div>'
		capa.innerHTML += valor


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

		capaImg.onload = function(){
			tween(capaImg,"alpha",100,5)
		}
		capaImg.src = URL+carpeta+img;

	}

}

function cierraAmpliProy(ID){
	var capa= document.getElementById("ampliadoProyectos");
	tween(capa,"alpha",0,2,"acabaCerrarAmpliado")
}

function acabaCerrarAmpliado(){
	var capa= document.getElementById("ampliadoProyectos");
	capa.innerHTML = '';
	capa.style.top = "0px";
	capa.style.left = "0px";
	capa.style.width = "0px";
	capa.style.height = "0px";
	capa.style.zIndex = "-50";
}


function amplia(img,carpeta,ID,pos,enlace) {
	if(puedeAmpliar==true && img!=""){
		puedeAmpliar = false;
		var capa= document.getElementById("ampliado");
		capa.style.position = "absolute";
		if(primeraPosCapa==""){
			capa.style.top = capa.offsetTop;
			primeraPosCapa = capa.offsetTop;
		}else{
			capa.style.top = primeraPosCapa+"px";
		}
		if(pos!=null){
			capa.style.top = pos+"px";
		}
		capa.style.left = "0px";
		capa.style.width = "885px";
		capa.style.zIndex = "50";
		ampliando(img,carpeta,ID,enlace)
	}
}

function ampliando(img,carpeta,ID,enlace) {
	resto = altoTotal-altoAmpliado
	if(resto>5){
		altoAmpliado = altoAmpliado + resto/2
	}else{
		altoAmpliado = altoTotal
	}
	var capa= document.getElementById("ampliado");
	capa.style.height = altoAmpliado+"px";
	if(altoAmpliado>=altoTotal){
//		contenido = '<img src="http://www.inspirate.es/clientes/otazu/img/fotoBig/'+img+'" class="imgAmpliada"/>';
		valor = '<div id="imgAmpliada">';
		valor+= '	<div style='+'"'+'background:url('+URL+carpeta+img+")"+';width:869px;height:457px;"'+' id="imgAmpliadaIn">';
		valor+= '		<div id="cerrarAmpliado" onclick="cierra('+ID+')">'
		valor+= '			<div id="cerrarAmpliadoIn2" onclick="cierra('+ID+')">'
		valor+= '			</div>'
		valor+= '		</div>'

		if(enlace!=null && enlace!=""){
			valor+= '		<div id="cerrarAmpliado2">'
			valor+= '			<div id="cerrarAmpliadoInBkg2" onclick="abreVentana('+"'"+enlace+"'"+')">'
			valor+= '			</div>'
			valor+= '			<div id="cerrarAmpliadoIn22" onclick="abreVentana('+"'"+enlace+"'"+')">'
			valor+= '				VER PROYECTO'
			valor+= '			</div>'
			valor+= '			<div id="cerrarAmpliadoInSobre2" onclick="abreVentana('+"'"+enlace+"'"+')">'
			valor+= '			</div>'
			valor+= '		</div>'
		}

		valor+= '	</div>'
		valor+= '</div>'
		setContenido("ampliado",valor)
		var bg = document.getElementById("cerrarAmpliadoInBkg");
		var property = bg.filters ? 'filter' : 'opacity';
		bg.style[property] = bg.filters ? 'alpha(opacity=' + 60 + ')' : 60/100;
		var bg = document.getElementById("cerrarAmpliadoInBkg2");
		var property = bg.filters ? 'filter' : 'opacity';
		bg.style[property] = bg.filters ? 'alpha(opacity=' + 60 + ')' : 60/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 () {ampliando(img,carpeta,ID,enlace)}, 50)
	}

}

function abreVentana(uri){
	window.open(uri)
}

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 = '-300px';
	}
	capa.style.height = altoAmpliado+"px";
	if(altoAmpliado>0){
		setTimeout(function () {cierra(ID)}, 50)
	}else{
		puedeAmpliar = true;
		if(ID!=null){
			obj = document.getElementById("menuGestor");
			obj.innerHTML = previo;
		}
	}
}


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 overServicio(objetoStr){
	objeto = document.getElementById(objetoStr);
	objeto.posicion = 1;
	setTimeout(function () {actuaServicios(objetoStr)}, 50)
}

function outServicio(objetoStr){
	objeto = document.getElementById(objetoStr);
	objeto.posicion = 0;
	setTimeout(function () {actuaServicios(objetoStr)}, 50)
}

function actuaServicios(objetoStr){


	var objParent = document.getElementById(objetoStr);
	var pulsado = objParent.posicion;
	var num = objetoStr.slice(objetoStr.length-1,objetoStr.length)
	var objeto = document.getElementById("serviciosLiCenter"+num);


	if(pulsado == 1){
		if(objeto.estado != 1){
			objeto.estado = 1;
//			objeto.style.height = "51px";
//			tween(objeto,"height",51,3,"terminaAmpliar",objetoStr)
			tween(objeto,"height",51,1)
			terminaAmpliar(objetoStr)
		}
	}else{
		if(objeto.estado == 1){
			objeto.estado = 0;
			obj = document.getElementById("serviciosLiBottom"+num);
			obj.style.background = "#d9d9d9";
			obj = document.getElementById("serviciosLiUp"+num);
			obj.style.background = "#d9d9d9";
			obj = document.getElementById("serviciosLiCenter"+num);
			obj.style.background = "#d9d9d9";
			obj = document.getElementById("flechas"+num);
			obj.src =  URL+"img/flechas.png";
			pngFix(obj)
			obj = document.getElementById("top_left"+num);
			obj.style.background = "url("+URL+"img/esqtopleft.jpg)";
			obj = document.getElementById("top_right"+num);
			obj.style.background = "url("+URL+"img/esqtopright.jpg)";
			obj = document.getElementById("bottom_left"+num);
			obj.style.background = "url("+URL+"img/esqbotleft.jpg)";
			obj = document.getElementById("bottom_right"+num);
			obj.style.background = "url("+URL+"img/esqbotright.jpg)";
			obj = document.getElementById("top_center"+num);
			obj.style.background = "url("+URL+"img/topcenter.jpg)";
			objeto.innerHTML = "<!-- -->";
//			objeto.style.height = "0px";
			tween(objeto,"height",0,3)
			InitBar();
		}
	}
}

function terminaAmpliar(objetoStr){

	var objParent = document.getElementById(objetoStr);
	var num = objetoStr.slice(objetoStr.length-1,objetoStr.length)
	var objeto = document.getElementById("serviciosLiCenter"+num);
			objeto.innerHTML =  '<div id="servCenterIn">';
			objeto.innerHTML += '</div>';
			objeto = document.getElementById("servCenterIn");
			var property = objeto.filters ? 'filter' : 'opacity';
			objeto.style[property] = objeto.filters ? 'alpha(opacity=' + 0 + ')' : 0/100;
			objeto.innerHTML =  '	<div id="servLogo"><div id="servLogoImg"><img id="servLogoImgIn" src="'+URL+"img/"+CONSTANTES['LOGO_SERVICIOS_'+num]+'" alt="Logo '+num+'"></div></div>';
			objeto.innerHTML += '	<div id="servTxt"><div id="servTxtTexto"><div id="servTxtTextoTxt">'+CONSTANTES['TEXTO_SERVICIOS_'+num]+'</div></div></div>';

			obj = document.getElementById("servTxtTextoTxt");
			altura = obj.offsetHeight;
			posY = Math.ceil(95/2 - altura/2);
			obj.style.marginTop = posY+"px"; 
			tween(objeto,"alpha",100,5)



			obj = document.getElementById("serviciosLiBottom"+num);
			obj.style.background = "#ffffff";

			obj = document.getElementById("serviciosLiUp"+num);
			obj.style.background = "#ffffff";

			obj = document.getElementById("serviciosLiCenter"+num);
			obj.style.background = "#ffffff";


			obj = document.getElementById("flechas"+num);
			obj.src = URL+"img/flechas2.png";
			pngFix(obj)
			
			obj = document.getElementById("top_left"+num);
			obj.style.background = "url("+URL+"img/esqtopleft2.jpg)";
			obj = document.getElementById("top_right"+num);
			obj.style.background = "url("+URL+"img/esqtopright2.jpg)";
			obj = document.getElementById("bottom_left"+num);
			obj.style.background = "url("+URL+"img/esqbotleft2.jpg)";
			obj = document.getElementById("bottom_right"+num);
			obj.style.background = "url("+URL+"img/esqbotright2.jpg)";
			obj = document.getElementById("top_center"+num);
			obj.style.background = "url("+URL+"img/topcenter2.jpg)";
			InitBar();

}


function recogeDesplegados(clase){
	var capa = document.getElementById("servicios_desplegable_int_txt_1");
	if(capa!=null){
		i=1;
		while(document.getElementById("servicios_desplegable_int_txt_"+i)!=null){
			capa = document.getElementById("servicios_desplegable_int_txt_"+i);
			capa.texto = capa.innerHTML;
			capa.innerHTML = "<!-- -->";
			capa.style.marginTop = "0px";
			capa.style.paddingBottom = "0px";
			capa.style.height = "0px";
			i++;
		}

	}
}


function overDesplegable(objetoStr){
	var	objeto = document.getElementById(objetoStr);
	objeto.posicion = 1;
	setTimeout(function () {actuaDesplegables(objetoStr)}, 50)
}

function outDesplegable(objetoStr){
	var objeto = document.getElementById(objetoStr);
	objeto.posicion = 0;
	setTimeout(function () {actuaDesplegables(objetoStr)}, 50)
}

function clickDesplegable(objetoStr,clase){
	var objeto = document.getElementById(objetoStr);
	var pulsado = objeto.posicion;
	var num = objetoStr.slice(objetoStr.length-1,objetoStr.length)
	if(objeto.texto!=""){
		if(pulsado!=2){
			var property = objeto.filters ? 'filter' : 'opacity';
			objeto.style[property] = objeto.filters ? 'alpha(opacity=' + 0 + ')' : 0/100;
			objeto.style.marginTop = "15px";
			objeto.style.paddingBottom = "10px";
			objeto.style.height = "";
			objeto.style.overflow = "";
			objeto.innerHTML = objeto.texto;
			altoDest = objeto.offsetHeight;
			objeto.style.height = "0px";
			tween(objeto,"height",altoDest,2,"acabaDesplegar",objetoStr)
			objeto.posicion=2;
			var objetoFlecha = document.getElementById("flechaDesplegable_"+num);
			objetoFlecha.src = URL+'img/flechaCierra.jpg'
			if(clase=="clientes"){
				if(despAbierto!=""){
					if(despAbierto!=num){
						clickDesplegable("servicios_desplegable_int_txt_"+despAbierto)
					}else{
						despAbierto="";
					}
				}
//				cambiaFotos(num)
			}
			despAbierto = num;
		}else{
			objeto.posicion=1;
			tween(objeto,"alpha",0,2,"acabaDesplegable",objetoStr)
			var objetoFlecha = document.getElementById("flechaDesplegable_"+num);
			objetoFlecha.src = URL+'img/flechaAbre.jpg'
			if(clase=="clientes"){
				if(despAbierto!=""){
					if(despAbierto!=num){
	//					clickDesplegable("servicios_desplegable_int_txt_"+despAbierto)
					}else{
						despAbierto="";
					}
				}

			}
		}
	}
}

function cambiaFotos(num){
	if(num!=fotAbierto){
		var objeto = document.getElementById("clientes_content_inferior_left");
		tween(objeto,"alpha",0,3,"acabaCFotos1",num)
		fotAbierto = num;
	}
}

function acabaCFotos1(num){
	var objeto = document.getElementById("clientes_content_inferior_left");
	trozos = CONSTANTES['CLIENTES_'+num+'_IMG'].split(",")
	nombres = CONSTANTES['CLIENTES_'+num].split(",")
	var i=0;
	texto = "";
	clase = "right"
	while(trozos[i]!=null){
		if(trozos[i]!=null && trozos[i]!=""){
			if(clase!="left"){clase="left";}else{clase="right";}
			texto += '			<img class="'+clase+'" src="'+URL+'lib/clientes/'+trozos[i]+'" alt="Logotipo '+nombres[i]+'"/>';
		}
		i++;
	}
	objeto.innerHTML = texto;
	tween(objeto,"alpha",100,5)
//	alert(CONSTANTES['CLIENTES_'+num+'_IMG'])
}


function acabaDesplegar(objetoStr){
	var objeto = document.getElementById(objetoStr);
	tween(objeto,"alpha",100,3)
}


function acabaDesplegable(objetoStr){
	var objeto = document.getElementById(objetoStr);
//	objeto.innerHTML = "<!-- -->";
	objeto.style.marginTop = "0px";
	objeto.style.paddingBottom = "0px";
//	objeto.style.height = "0px";
	objeto.style.overflow = "hidden";
	tween(objeto,"height",8,2)
}

function actuaDesplegables(objetoStr){


	var objeto = document.getElementById(objetoStr);
	var pulsado = objeto.posicion;
	var num = objetoStr.slice(objetoStr.length-1,objetoStr.length)


	if(pulsado == 1){
		if(objeto.innerHTML=="<!-- -->" || objeto.innerHTML==""){
			var property = objeto.filters ? 'filter' : 'opacity';
			objeto.style[property] = objeto.filters ? 'alpha(opacity=' + 0 + ')' : 0/100;
			objeto.style.marginTop = "15px";
			objeto.style.paddingBottom = "10px";
			objeto.style.height = "";
			objeto.innerHTML = CONSTANTES['DESPLEGABLE_'+num+'_TXT_SERVICIOS_1']
			tween(objeto,"alpha",100,5)
			InitBar();
			objeto.estado = 1;
		}
 	}else{
		if(objeto.estado == 1){
			tween(objeto,"alpha",0,2,"acabaDesplegable",objetoStr)
			objeto.estado = 0;
		}
	}
}


function overDescarga(num){
	var obj = document.getElementById("desImg"+num);
	tween(obj,"alpha",100,3)
	var obj = document.getElementById("flecha"+num);
	tween(obj,"alpha",100,3)
	var obj = document.getElementById("tit"+num);
	obj.style.color = "#e6e6e6";
	var obj = document.getElementById("desc"+num);
	obj.style.color = "#b3b5b4";
}

function outDescarga(num){
	var obj = document.getElementById("desImg"+num);
	tween(obj,"alpha",50,3)
	var obj = document.getElementById("flecha"+num);
	tween(obj,"alpha",50,3)
	var obj = document.getElementById("tit"+num);
	obj.style.color = "#787879";
	var obj = document.getElementById("desc"+num);
	obj.style.color = "#5e6060";
//	pngFix(obj)
}



function overPdf(num){
	var obj = document.getElementById("pdfImage"+num);
	obj.src = URL+'img/pdf2.png'
//	pngFix(obj)
}

function outPdf(num){
	var obj = document.getElementById("pdfImage"+num);
	obj.src = URL+'img/pdf.png'
//	pngFix(obj)
}


function overMenuSubGaleria(num){
	obj = document.getElementById("flecha"+num);
	obj.src = URL+"img/flechas2.png";
	pngFix(obj)
	obj = document.getElementById("liMenuSubGal"+num);
	obj.style.background = "#ffffff";
	obj.style.color = "#000000";
}

function outMenuSubGaleria(num){
	obj = document.getElementById("flecha"+num);
	obj.src = URL+"img/flechas.png";
	pngFix(obj)
	obj = document.getElementById("liMenuSubGal"+num);
	obj.style.background = "#1d1e1f";
	obj.style.color = "#cacaca";

}



function clickSec(destino){
	document.location = destino;
}



function rollOver(obj){
	idioma = "es"
	var objeto = document.getElementById(obj);
	var archivoImg = "";
	numObjeto = objeto.id.slice(4,5)
	archivoImg = "b"+numObjeto+"b.jpg";
	objeto.src = URL+"img/menu/"+idioma+"/"+archivoImg;
}

function rollOut(obj){
	idioma = "es"
	var objeto = document.getElementById(obj);
	var archivoImg = "";
	numObjeto = objeto.id.slice(4,5)
	
	if(seccion=="home"){
		letra = "";
	}else{
		letra = "c";
	}


	archivoImg = "b"+numObjeto+letra+".jpg";
	objeto.src = URL+"img/menu/"+idioma+"/"+archivoImg;
}


function InitFade(capa){
	var content = document.getElementById(capa);
	appear(content)
//	tween(content,"alpha",100,3)
	InitBar();

}

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(){
	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(document.commentForm.correo.value.length==0){
		alert(CONSTANTES['ERROR3'])
		document.commentForm.correo.focus()
		document.getElementById("formError").innerHTML = CONSTANTES['ERROR3'];
	}else{
		correo = document.commentForm.correo.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{
			alert(CONSTANTES['ENVIADO'])
			document.commentForm.comment.value="";
			document.commentForm.nombre.value="";
			document.commentForm.correo.value="";
			document.getElementById("formError").innerHTML = CONSTANTES['ENVIADO'];
		}
	}
}


function compruebaEdad(tipo){
	var alerta = false; 
	var fecha=new Date();
	var annoActual=fecha.getFullYear();
	var diferencias = CONSTANTES['EDADES_ARRAY'].split(",");

	switch(tipo){
		case 1:   //ESPAÑOL
			if(document.getElementById("nacimiento_es").value==0){
				alerta=true;
				elError = "No se ha indicado la edad"
			}else{
				nacimiento = parseInt(document.getElementById("nacimiento_es").value);
				diferencia = diferencias[parseInt(document.getElementById("pais_es").value)];
				if(annoActual-nacimiento<diferencia){
					alerta=true;
					elError = "Aun no has cumplido la edad necesaria para acceder a este tipo de contenidos en tu pais";
				}
			}
			break;
		case 2:   //INGLES
			if(document.getElementById("year_birth").value==0){
				alerta=true;
				elError = "E - No se ha indicado la edad"
			}else{
				nacimiento = parseInt(document.getElementById("year_birth").value);
				diferencia = diferencias[parseInt(document.getElementById("country").value)];
				if(annoActual-nacimiento<diferencia){
					alerta=true;
					elError = "E - Aun no has cumplido la edad necesaria para acceder a este tipo de contenidos en tu pais";
				}
			}
			break;
	}

	formulario = document.forms["condiciones"];


	if(alerta == false){
		document.forms["condiciones"].submit();
	}else{
		document.getElementById("formError").innerHTML = elError;
		alert("ERROR: "+elError)
	}
}


function tween(capa,propiedad,destino,velocidad,funcion,objeto){
	if(eval("capa.idTO_" + propiedad)!=null){ 
		clearTimeout(eval("capa.idTO_" + propiedad))
	}
	doTween(capa,propiedad,destino,velocidad,funcion,objeto)
}


function doTween(capa,propiedad,destino,velocidad,funcion,objeto){
	repetir = false;
	switch (propiedad){
		case "top":
			if(capa.style.top=="" || capa.style.top=="udefined"){capa.style.top = capa.offsetTop+"px";}
			distancia = destino - parseInt(capa.style.top.slice(0,capa.style.top.length-2))
			if(distancia>1){
				distancia = distancia / velocidad ;
				capa.style.top = Math.ceil(parseInt(capa.style.top.slice(0,capa.style.top.length-2))+distancia)+"px";
				repetir = true;
			}else if(distancia<-1){
				distancia = distancia / velocidad ;
				capa.style.top = Math.floor(parseInt(capa.style.top.slice(0,capa.style.top.length-2))+distancia)+"px";
				repetir = true;
			}else{
				capa.style.top = destino+"px";
			}
			break;
		case "left":
			if(capa.style.left=="" || capa.style.left=="udefined"){capa.style.left = capa.offsetLeft+"px";}
			distancia = destino - parseInt(capa.style.left.slice(0,capa.style.left.length-2))
			if(distancia>1){
				distancia = distancia / velocidad ;
				capa.style.left = Math.ceil(parseInt(capa.style.left.slice(0,capa.style.left.length-2))+distancia)+"px";
				repetir = true;
			}else if(distancia<-1){
				distancia = distancia / velocidad ;
				capa.style.left = Math.floor(parseInt(capa.style.left.slice(0,capa.style.left.length-2))+distancia)+"px";
				repetir = true;
			}else{
				capa.style.left = destino+"px";
			}
			break;
		case "width":
			if(capa.style.width=="" || capa.style.width=="udefined"){capa.style.width = capa.offsetWidth+"px";}
			distancia = destino - parseInt(capa.style.width.slice(0,capa.style.width.length-2))
			if(distancia>1){
				distancia = distancia / velocidad ;
				capa.style.width = Math.ceil(parseInt(capa.style.width.slice(0,capa.style.width.length-2))+distancia)+"px";
				repetir = true;
			}else if(distancia<-1){
				distancia = distancia / velocidad ;
				capa.style.width = Math.floor(parseInt(capa.style.width.slice(0,capa.style.width.length-2))+distancia)+"px";
				repetir = true;
			}else{
				capa.style.width = destino+"px";
			}
			break;
		case "height":
			if(capa.style.height=="" || capa.style.height=="udefined"){capa.style.height = capa.offsetHeight+"px";}
			distancia = destino - parseInt(capa.style.height.slice(0,capa.style.height.length-2))
			if(distancia>1){
				distancia = distancia / velocidad ;
				capa.style.height = Math.ceil(parseInt(capa.style.height.slice(0,capa.style.height.length-2))+distancia)+"px";
				repetir = true;
			}else if(distancia<-1){
				distancia = distancia / velocidad ;
				capa.style.height = Math.floor(parseInt(capa.style.height.slice(0,capa.style.height.length-2))+distancia)+"px";
				repetir = true;
			}else{
				capa.style.height = destino+"px";
			}
			break;
		case "alpha":
			var property = capa.filters ? 'filter' : 'opacity';
			if(capa.style[property]== 'undefined' || capa.style[property]== ''){
				if(destino==0){value=100}else{value=0}
			}else{
				valor = parseInt(capa.style[property]);  
				if (isNaN(valor)) {  
				   //no es entero 0  
					value = parseInt(capa.style[property].slice(14,capa.style[property].length-1));
				}else{  
				   //es un valor entero  
					value = capa.style[property]*100;
				}  
			}
			distancia = destino - value;
			if(distancia>1){
				distancia = distancia / velocidad ;
				nuevoValor = Math.ceil(value + distancia);
				capa.style[property] = capa.filters ? 'alpha(opacity=' + nuevoValor + ')' : nuevoValor/100;
				repetir = true;
			}else if (distancia<-1){
				distancia = distancia / velocidad ;
				nuevoValor = Math.floor(value + distancia);
				capa.style[property] = capa.filters ? 'alpha(opacity=' + nuevoValor + ')' : nuevoValor/100;
				repetir = true;
			}else{
				capa.style[property] = capa.filters ? 'alpha(opacity=' + destino + ')' : destino/100;

			}
			break;
	}


	if(repetir==true){
		eval("capa.idTO_" + propiedad + " = setTimeout(function () {doTween(capa,propiedad,destino,velocidad,funcion,objeto)}, 50);");
//		idTimer = eval("capa.idTO_" + propiedad);
//		document.getElementById("trazador").innerHTML = document.getElementById("trazador").innerHTML+"<br/> Auto";
	}else{
//		eval("capa.idTO_" + propiedad +"=null");
		if(objeto==null){
			eval(funcion+"()")
		}else{
			eval(funcion+"('"+objeto+"')")
		}
	}
}


function cookieAdulto(){
	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'); 
		} 
	} 
	oXMLHttpRequest.open( 'GET', URL+'inc/cookieAdulto.php', true );
	oXMLHttpRequest.send( null );


}


function cambiaEstilo(){
	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'); 
		} 
	} 


	oXMLHttpRequest.onreadystatechange = function(){
		if(oXMLHttpRequest.readyState == 4 && oXMLHttpRequest.status == 200)
		{

			window.location =  location.pathname;
		}
	}



	oXMLHttpRequest.open( 'GET', URL+'inc/cambiaEstilo.php', true );
	oXMLHttpRequest.send( null );
}


function cambiaHome(){
	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'); 
		} 
	} 


	oXMLHttpRequest.onreadystatechange = function(){
		if(oXMLHttpRequest.readyState == 4 && oXMLHttpRequest.status == 200)
		{

			window.location =  location.pathname;
		}
	}



	oXMLHttpRequest.open( 'GET', URL+'inc/cambiaHome.php', true );
	oXMLHttpRequest.send( null );
}


function getWindowData(){
    var widthViewport,heightViewport,xScroll,yScroll,widthTotal,heightTotal;
    if (typeof window.innerWidth != 'undefined'){
        widthViewport= window.innerWidth-17;
        heightViewport= window.innerHeight-17;
    }else if(typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth !='undefined' && document.documentElement.clientWidth != 0){
        widthViewport=document.documentElement.clientWidth;
        heightViewport=document.documentElement.clientHeight;
    }else{
        widthViewport= document.getElementsByTagName('body')[0].clientWidth;
        heightViewport=document.getElementsByTagName('body')[0].clientHeight;
    }
    xScroll=self.pageXOffset || (document.documentElement.scrollLeft+document.body.scrollLeft);
    yScroll=self.pageYOffset || (document.documentElement.scrollTop+document.body.scrollTop);
//    widthTotal=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth,widthViewport);
    widthTotal=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth,widthViewport);
    heightTotal=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,heightViewport);
    return [widthViewport,heightViewport,xScroll,yScroll,widthTotal,heightTotal];
} 

function InitBar(tipo){
	var obj = document.getElementById("pie");
	obj.style.width = "990px";
	valores = getWindowData();
	var content = document.getElementById("centrado");
	if(centroInicial=="" || tipo=="resize"){  //Se coge el centro inicial xa saber donde estaba antes de que crezca la barra
		centroInicial = content.offsetLeft;
	}
//	alert("BAR "+valores[4]);
	var obj = document.getElementById("pie");
	anchoDestino = 940 + (( valores[4] - 990 ) / 2);
	obj.style.width = anchoDestino+"px";

	var content = document.getElementById("centrado");

// Para recentrarlo al hacer mas grande la barra para el IE

	if(content.offsetLeft!=centroInicial){
//		alert("modifico")
		content.style.position="absolute";
		content.style.left = (( valores[4] - 990 ) / 2)+"px";
	}
}

