function BrowserCheck() {
	var b = navigator.appName
	var agente=(navigator.userAgent);
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.version = navigator.appVersion
	this.platf = navigator.platform.toUpperCase()
	this.v = parseInt(this.version)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ns6 = (this.b=="ns" && this.v==6)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (this.version.indexOf('MSIE 4')>0)
	this.ie5 = (this.version.indexOf('MSIE 5')>0)
	this.ie6 = (this.version.indexOf('MSIE 6')>0)
	this.linux = (this.platf.indexOf('LINUX')>0)
	this.win = (this.platf.indexOf('WIN')>0)
	this.mac = (this.platf.indexOf('MAC')>0)
	this.konqueror = (agente.indexOf('Konqueror')>0);
	this.firefox = (agente.indexOf('Firefox')>0);
	this.galeon = (agente.indexOf('Galeon')>0);
	this.min = (this.ns||this.ie)
	this.comp = (this.ns5||this.ns6||this.ie5||this.ie6||this.konqueror||this.firefox||this.galeon||this.mac)
}
is = new BrowserCheck()

function putintester(imagen,texto){
	document.getElementById("tester-img").src="../img/"+imagen;
	document.getElementById("tester-wallpapername").innerHTML=texto;
}

function closelayer(quina){
	document.getElementById(quina).style.display="none";
	return false;
}

function openlayer(quina){
	document.getElementById(quina).style.display="block";
}
function javascript_css(quin){
	document.write("<link rel= \"stylesheet\" type=\"text/css\" media=\"all\" href=\"css/javascript.css\" />");
}
function show(quina){
	for(i=0;i<arFieldgroups.length;i++){
		if(quina!=anteriorgroup){
			document.getElementById(arFieldgroups[quina]).style.display="block";
			if(quina!=0){
				document.getElementById("tab"+quina).className="on";
			}
			else{
				document.getElementById("tab"+quina).className="first on";
			}
			document.getElementById(arFieldgroups[anteriorgroup]).style.display="none";
			if(anteriorgroup!=0){
				document.getElementById("tab"+anteriorgroup).className="";
			}
			else{
				document.getElementById("tab"+anteriorgroup).className="first";
			}
			anteriorgroup=quina;
		}
	}
}
function show2(quina){
	for(i=0;i<arFieldgroups.length;i++){
		if(quina!=anteriorgroup){
			document.getElementById(arFieldgroups[quina]).style.display="block";
			if(anteriorgroup!=-1)  document.getElementById(arFieldgroups[anteriorgroup]).style.display="none";
			anteriorgroup=quina;
		}
	}
}

showblocs=["none","none"];
function show3(quina,el){
	if(quina=='registrafoto') estilodisplay=0;
	else estilodisplay=1;
	
	if(showblocs[estilodisplay]=="none"){
			document.getElementById(quina).style.display="block";
			document.getElementById(el).className="link-on";
			showblocs[estilodisplay]="block";
	}
	else{
		document.getElementById(quina).style.display="none";
		document.getElementById(el).className="link-off";
		showblocs[estilodisplay]="none";
	}
	
}
fieldanterior=["",""];
function togglefield(quin,cas){
	//alert(quin+","+cas);
	if(quin!=fieldanterior[cas]){
		document.getElementById(quin).style.display="block";
		if(fieldanterior[cas]!=""){
			labelobj=document.getElementById(fieldanterior[cas]);
			textareaar=labelobj.getElementsByTagName("textarea");
			if(textareaar.length > 0){
				//alert("hi ha textarea");
				textareaar[0].value="";
			}
			else{
				inputar=labelobj.getElementsByTagName("input");
				if(inputar.length > 0){
					inputar[0].value="";
				}
			}
			labelobj.style.display="none";
		}
		fieldanterior[cas]=quin;
	}
}

function findmodifyimg(){
 var listfotos=document.getElementById("lista-fotos");
 if(listfotos){
	 tata=listfotos.getElementsByTagName('a');
	 for(i=0;i<tata.length;i++){
	 	if(tata[i].getAttribute("rel")=="modify"){
	 		tata[i].onclick=function(){modifyimg(this);return false;};
		}
	 }
  }
  var cancelmodify=document.getElementById("cancel-modify");
  if(cancelmodify){
  	cancelmodify.onclick=function (){resetform();return false;};
  }
}

timehighlights=4000;
timehighlightsrestart=10000;
function highlights_gallery(){
	var homehighlights=document.getElementById("destacados-home");
	if(homehighlights){
		var objpaginacion=document.getElementById("paginacion");
		if(objpaginacion){
			tata=objpaginacion.getElementsByTagName("li");
			for(i=0;i<tata.length;i++){
				if(tata[i].className!="ultima"){
		 			tata[i].onclick=function(){showhighlight(this);return false;};
				}
				else{
					var incrementa=document.getElementById("increasehigh");
					if(incrementa){
						incrementa.onclick=function(){increasehighlight(1);return false;};
					}
					var decrementa=document.getElementById("decreasehigh");
					if(decrementa){
						decrementa.onclick=function(){increasehighlight(-1);return false;};
					}
				}
			}
			timerhigh=setTimeout("highlights_automatic(2)",timehighlights);
		}
		
	}
}
activehighlight=1;
var counth;
var timerhigh;
var timer2;
function highlights_automatic(quin){
	document.getElementById("contenido-destacado"+activehighlight).style.display="none";
	document.getElementById("destacado"+activehighlight).className="";
	document.getElementById("contenido-destacado"+quin).style.display="block";
	document.getElementById("destacado"+quin).className="seleccionada";
	activehighlight=quin;
	var activate=(quin==counth)?1:quin+1;
	timerhigh=setTimeout("highlights_automatic("+activate+")",timehighlights);
}

function showhighlight(quin){
	quinid=new String(quin.id);
	quinid=quinid.substring(quinid.length-1,quinid.length);
	clearTimeout(timerhigh);
	document.getElementById("contenido-destacado"+activehighlight).style.display="none";
	document.getElementById("destacado"+activehighlight).className="";
	document.getElementById("contenido-destacado"+quinid).style.display="block";
	document.getElementById("destacado"+quinid).className="seleccionada";
	activehighlight=quinid;
	clearTimeout(timer2);
	timer2=setTimeout("startagain("+activehighlight+")",timehighlightsrestart);
}

function increasehighlight(onoff){
	clearTimeout(timerhigh);
	goon=activehighlight+onoff;
	if(goon>=counth+1) goon=1;
	if(goon<=0) goon=counth;
	document.getElementById("contenido-destacado"+activehighlight).style.display="none";
	document.getElementById("destacado"+activehighlight).className="";
	document.getElementById("contenido-destacado"+goon).style.display="block";
	document.getElementById("destacado"+goon).className="seleccionada";
	activehighlight=goon;
	clearTimeout(timer2);
	timer2=setTimeout("startagain("+activehighlight+")",timehighlightsrestart);
}

function startagain(active){
	clearTimeout(timer2);
	clearTimeout(timerhigh);
	highlights_automatic(active);
}

function resetform(){
	var formmodifier=document.getElementById("modifyform");
	if(formmodifier){
		var deletefields=formmodifier.getElementsByTagName("input");
		if(deletefields){
			for(i=0;i<deletefields.length;i++){
				deletefields[i].value="";
			}
		}
		var deleteareas=formmodifier.getElementsByTagName("textarea");
		if(deleteareas){
			for(i=0;i<deleteareas.length;i++){
				deleteareas[i].value="";
			}
		}
		document.getElementById("modifyform").style.display="none";
	}
}
function modifyimg(){
	var formmodifier=document.getElementById("modifyform");
	if(formmodifier) formmodifier.style.display="block";
}
anteriorpos=0;
function galeria3(){
	var prevarrow=document.getElementById("prev-galeria3");
	var nextarrow=document.getElementById("next-galeria3");
	if(prevarrow){
		prevarrow.onclick=function (){zoomgaleria3("prev");return false;}
	}
	if(nextarrow){
		nextarrow.onclick=function (){zoomgaleria3("next");return false;}
	}
}

function zoomgaleria3(prevnext){
	nuevapos=(prevnext=="prev")?anteriorpos-1:anteriorpos+1;
	flechaprev=document.getElementById("prev-galeria3");
	flechanext=document.getElementById("next-galeria3");
	if(nuevapos<1){
		flechaprev.style.display="none";
	}
	else{
		flechaprev.style.display="block";
	}
	if(nuevapos>=countimg-1){
		flechanext.style.display="none";
	}
	else{
		flechanext.style.display="block";
	}
	
	document.getElementById("position"+anteriorpos).style.display="none";
	document.getElementById("info-position"+anteriorpos).style.display="none";
	
	document.getElementById("position"+nuevapos).style.display="block";
	document.getElementById("info-position"+nuevapos).style.display="block";
	
	anteriorpos=nuevapos;
}
function identificar(){
	alllinks=document.getElementsByTagName("a");
	if(alllinks){
		for(i=0;i<alllinks.length;i++){
			auxi=new String(alllinks[i].className);
			if(auxi.indexOf("enlace-registro")!=-1){
				alllinks[i].onclick=function (){showiniciosesion();}
			}
		}
	}
}
function getStyle(el, style) {
   if(!document.getElementById) return;
   
     var value = el.style[toCamelCase(style)];
   
    if(!value)
        if(document.defaultView)
            value = document.defaultView.
                 getComputedStyle(el, "").getPropertyValue(style);
       
        else if(el.currentStyle)
            value = el.currentStyle[toCamelCase(style)];
     
     return value;
}

function setStyle(objId, style, value) {
    document.getElementById(objId).style[style] = value;
}

function toCamelCase( sInput ) {
    var oStringList = sInput.split('-');
    if(oStringList.length == 1)   
        return oStringList[0];
    var ret = sInput.indexOf("-") == 0 ?
       oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) : oStringList[0];
    for(var i = 1, len = oStringList.length; i < len; i++){
        var s = oStringList[i];
        ret += s.charAt(0).toUpperCase() + s.substring(1)
    }
    return ret;
}

function showiniciosesion(){
    var theDiv = document.getElementById("init-session-layer");
    var currWidth = 980;
	var x;
	var y;
	if(is.ie){
		x=document.documentElement.clientWidth;
	}
	else{
		x = window.innerWidth;
	}
	if(!is.ie){
		theDiv.style.left=((x-currWidth)/2+62)+"px";
	}
	else{
		theDiv.style.left=((x-currWidth)/2+70)+"px";
	}
	theDiv.style.top="324px";
	theDiv.style.display="block";
	window.scrollTo(0,0);
}
showinit=0;
function attachscript(){
	findmodifyimg();
	galeria3();
	highlights_gallery();
	identificar();
	if(showinit==1) showiniciosesion();
}

window.onload = attachscript

sas_tmstp=Math.round(Math.random()*10000000000);sas_masterflag=1;
function SmartAdServer(sas_pageid,sas_formatid,sas_target) {
if (sas_masterflag==1) {sas_masterflag=0;sas_master='M';} else {sas_master='S';};
document.write('<scr'+'ipt SRC="http://www2.smartadserver.com/call/pubj/' + sas_pageid + '/' + sas_formatid + '/'+sas_master + '/' + sas_tmstp + '/' + escape(sas_target) + '?"></scr'+'ipt>');
}

function Alternar(Seccion){ 
	var Seccion = document.getElementById("messagegood");
    if (Seccion.style.display=="none"){Seccion.style.display=""}
    else{Seccion.style.display="none"} 
}
function cajaamigo(Seccion){ 
	var Seccion = document.getElementById("caja-enviar-amigo");
    if (Seccion.style.display=="none"){Seccion.style.display=""}
    else{Seccion.style.display="none"} 
}

function enviarsms(Seccion){ 
	var Seccion = document.getElementById("clave-sms");
    if (Seccion.style.display=="none"){Seccion.style.display="block"}
    else{Seccion.style.display="block"} 
}

function errorenviarsms(Seccion){ 
	var Seccion = document.getElementById("error-clave-sms");
    if (Seccion.style.display=="none"){Seccion.style.display="block"}
    else{Seccion.style.display="block"} 
}

function changelayer(layerhide,layershow){
	closelayer(layerhide);
	openlayer(layershow);
}
function openerror(quina){
	openlayer(quina);
	$.scrollTo("botones-video-grande");
	//window.scrollTo(100,500);
}