var basePath="/"
var cLang=getLang()
addReady(headerRun)

function headerRun() {
	buildLangs()
	if (headerData) {
		faderfoto('headfoto','/imgs/'+headerData.p,headerData.i)	
	}
}

function buildLangs() {
	var o=$o("langs")
	if (o) {
		var v=[]
		var l=[["ita","ita/"],["eng","eng/"],["fr","fr/"],["de","de/"]]
		var bPath=location.protocol+"//"+location.hostname+basePath
		var lPath=""
		if (cLang!="zita") {lPath=cLang+"/"}
		var np=location.href.replace(bPath+lPath,"")
		
		for(var i=0;i<l.length;i++) {
			if (cLang!=l[i][0]) {
				v.push('<a href="'+bPath+l[i][1]+np+'" class="'+l[i][0]+'"> </a>')	
			}
		}
		o.innerHTML=v.join("")
	}
}
function getLang() {
	var v=location.href.replace(location.protocol+"//"+location.hostname+basePath,"").split("/")
	if (v.length<2) {
		return "ita"
	} else {
		switch(v[0]) {
			case "eng":
			case "fr":
			case "de":
			case "ita":
				return v[0]
				break
			default:
				return "ita"
		}
	}
}
