/**** Made by Frank Hoffmann for StockholmBarcelona, www.stockholmbarcelona.com ****/
function Products(imgName, smallBottles_x, smallBottles_y, smallBottles_w, bigBottle_x, bigBottle_y, text_x){
	this.imgName = imgName
	this.sbX = smallBottles_x
	this.sbY = smallBottles_y
	this.sbW = smallBottles_w
	this.bbX = bigBottle_x
	this.bbY = bigBottle_y
	this.textX = text_x
	this.products = new Array()
	this.HTML = ""
	this.activeText = -1
	this.ready = false
	this.fichaIsShown = false
	// OLIKA OLIKA SPRÅK!!!! 
	// TA BORT HEAD-BILDEN????????????
	if(location.href.indexOf("castellano") != -1){
		this.fichaText = new Array("Ficha T&eacute;cnica","Densidad","Grado alcoh&oacute;lico","Acidez total","Acidez vol&aacute;til","Anh&iacute;drido sulfuroso libre","Anh&iacute;drido sulfuroso total","Az&uacute;cares reductores","Presi&oacute;n a 20&ordm;")
		this.textHeads = new Array("Aspecto","Aroma","Gusto","Ficha T&eacute;cnica")
	}
	else if(location.href.indexOf("english") != -1){
		this.fichaText = new Array("Analytical results","Density","Alcoholic strength","Total acidity","Volatile acidity","Free sulphur oxide","Sulphur oxide","Reducing sugars","Pressure at 20&ordm;C")
		this.textHeads = new Array("Apperance","Aroma","Taste","Analytical results")
	}
	else if(location.href.indexOf("deutsch") != -1){
		this.fichaText = new Array("Chemische weinanalyse","Dichte","Alkohol-Gehalt","Gesamt-Säure","Flüchtige Säure, ausgedrückt in Essigsäure","Freies Schwefeloxid","Gesamt-Schwefeloxid","Reduzierender Zucker","Druck bei 20&ordm;C")
		this.textHeads = new Array("Visueller eindruck","Geruch","Geschmack","Chemische weinanalyse")
	}
	else if(location.href.indexOf("catala") != -1){
		this.fichaText = new Array("Fitxa Tècnica","Densitat","Grau alcohòlic","Acidesa total","Acidesa volàtil","Anhídrid sulfurós lliure","Anhídric sulfurós","Sucres reductors","Pressió a 20º")
		this.textHeads = new Array("Aspecte","Aroma","Gust","Fitxa Tècnica")
	}
	///
	this.fichaUnits = new Array("","","%vol.","gr/l","gr/l","mg/l","mg/l","gr/l","atm")
	this.addProduct = addProductMethod
	this.addIntro = addIntroMethod
	this.generate = generateMethod
	this.showProd = showProdMethod
	this.blend = blendProductMethod
	this.init = initProductMethod
	this.closeFicha = closeFichaMethod
	this.openFicha = openFichaMethod
	this.printPage = printPageMethod
}function addProductMethod(name, imgBottleBig, imgBottleSmall, imgHead, text, aspecto, aroma, gusto, fichaTecnica){
	var index = this.products.length
	this.products[index] = new Product(index, name, imgBottleBig, imgBottleSmall, imgHead, text, aspecto, aroma, gusto, fichaTecnica)
}function addIntroMethod(head, text){
	this.introHead = head
	this.introText = text
}function generateMethod(){
	this.dotLine = new pLayer("divDotLine", 261, 17, 1, 388, "contentDiv", "", 1, 1)
		this.dotLine.setCont("<img src='../images/prod_dot_line.gif' width='1' height='388' border='0' alt=''>")
	this.dotLine2 = new pLayer("divDotLine2", 14, 65, 232, 1, "contentDiv", "", 1, 1)
		this.dotLine2.setCont("<img src='../images/prod_dot_line2.gif' width='244' height='1' border='0' alt=''>")
	this.dotLine3 = new pLayer("divDotLine3", 14, (87+this.products.length*16), 232, 1, "contentDiv", "", 1, 0)
		this.dotLine3.setCont("<img src='../images/prod_dot_line2.gif' width='244' height='1' border='0' alt=''>")
	this.prodTitle = new pLayer("divProdTitle", 15, 27, 500, 30, "contentDiv", "", 1, 0)
		this.prodTitle.setCont("<img src='" + this.imgName + "' border='0' alt=''>")
	this.bigBottle = new pLayer("divBigBottle", this.bbX, this.bbY, 200, 400, "contentDiv", "", 2, 1)
		this.bigBottle.setCont("<img id='bigBottleImg' name='bigBottleImg' src='../images/trans.gif' border='0' alt=''>")
	this.prodBackground = new pLayer("divProdBackground", 505, 3, 264, 249, "contentDiv", "", 1, 0)
		this.prodBackground.setCont("<img src='../images/prod_background.gif' width='264' height='249' border='0' alt=''>")
	this.fichaBackground = new pLayer("divFichaBackground", 420, 57, 364, 196, "contentDiv", "", 21, 0)
		this.fichaBackground.setCont("<img src='../images/prod_ficha_bg.gif' width='346' height='196' border='0' alt='' usemap='#mapficha'><MAP NAME='mapficha'><AREA SHAPE=RECT COORDS='11,11,29,28' HREF='javascript:void(0)' onclick='prod.closeFicha(); return false' onfocus='blur()'></MAP>")
	this.printIcon = new pLayer("divPrintIcon", 651, 11, 104, 18, "contentDiv", "", 35, 0)
		this.printIcon.setCont("<a href='javascript:void(0)' onclick='prod.printPage(); return false' onfocus='blur()'><img src='images/prod_imprimir.gif' width='104' height='18' border='0' alt=''></a>")
	this.introLayer = new pLayer("divIntroLayer", 274, 28, 465, 400, "contentDiv", "", 10, 0)
		this.introLayer.setCont("<span class='headRed'>"+this.introHead+"</span><br><img src='../images/trans.gif' width='10' height='10' border='0' alt=''><br><span class='textDarkRed3'>"+this.introText+"</span>")
	this.HTML = this.dotLine.HTML+this.prodTitle.HTML+this.bigBottle.HTML+this.prodBackground.HTML+this.dotLine2.HTML+this.dotLine3.HTML+this.fichaBackground.HTML+this.printIcon.HTML+this.introLayer.HTML
	var tmp=""
	for(var i=0; i<this.products.length; i++){
		this.HTML += this.products[i].textLayer.HTML
		this.HTML += this.products[i].smallBottle.HTML
		this.HTML += this.products[i].leftMenu.HTML
		this.HTML += this.products[i].leftMenuIn.HTML
		if(this.products[i].ficha != "nada") this.HTML += this.products[i].fichaTecnica.HTML
	}
	this.HTML += "<form id='printForm' name='printForm' action='../includes/printPage.asp' method='post' target='_blank'><input type='hidden' name='bigImg' id='bigImg' value='balle'></input><input type='hidden' name='text1' id='text1'></input><input type='hidden' name='ficha' id='ficha'></input></form>"
}function showProdMethod(index){
	if(this.ready && index != this.activeText){
		this.ready = false
		this.printIcon.setVis(0)
		if(this.fichaIsShown) this.closeFicha()
		if(this.activeText != -1){
			this.products[this.activeText].textLayer.setVis(0)
			this.products[this.activeText].leftMenu.setVis(1)
			if(!is.IE || is.Mac) this.products[this.activeText].smallBottle.setVis(1)
		}
		else(this.introLayer.setVis(0))	
		if(this.products.length>1) this.blend(index, this.activeText, 90)
		else this.printIcon.setVis(1)
		if(is.Moz) document.getElementById("bigBottleImg").src = this.products[index].imgBottleBig
		else if(is.Nav) this.bigBottle.writeHTML("<img src='"+ this.products[index].imgBottleBig +"' border='0' alt=''>")
		else document.all.bigBottleImg.src = this.products[index].imgBottleBig
		this.products[index].textLayer.setVis(1)
		this.products[index].leftMenu.setVis(0)
		this.activeText = index
	}
}function blendProductMethod(index, index2, num){
	if(is.IE && !is.Mac){
		this.products[index].smallBottle.opacity(num)
		if(index2 != -1) this.products[index2].smallBottle.opacity(100-num)
		num-=10
		if(num>0) setTimeout("prod.blend("+index+","+index2+","+num+")",50)
		else{
			this.ready = true
			if(index2 != -1) this.products[index2].smallBottle.opacity(100)
			this.printIcon.setVis(1)
		}
	}
	else{
		this.products[index].smallBottle.setVis(0)
		this.ready = true
		if(!is.Moz) this.printIcon.setVis(1)
	}
}function initProductMethod(){
	this.ready = true
	this.prodTitle.setVis(1)
	this.prodBackground.setVis(1)
	if(this.products.length>1){
		this.dotLine3.setVis(1)
		for(var i=0; i<this.products.length; i++){	
			this.products[i].smallBottle.setVis(1)
			this.products[i].leftMenu.setVis(1)
			this.products[i].leftMenuIn.setVis(1)
		}
		this.introLayer.setVis(1)
	}
	else{
		this.showProd(0)
		this.products[0].smallBottle.setVis(1)
	}
}function closeFichaMethod(){
	this.fichaBackground.setVis(0)
	this.products[this.activeText].fichaTecnica.setVis(0)
	this.fichaIsShown = false
}function openFichaMethod(){
	if(this.fichaIsShown) this.closeFicha()
	else{
		this.fichaBackground.setVis(1)
		this.products[this.activeText].fichaTecnica.setVis(1)
		this.fichaIsShown = true
	}
}function printPageMethod(){
	if(is.Nav) this.formRef = eval(document.layers.contentDiv.document.forms["printForm"])
	else if(is.Moz) this.formRef = eval(document.getElementById("printForm"))
	else this.formRef = eval(document.all.printForm)
	
	
	
	this.formRef.bigImg.value = this.products[this.activeText].imgBottleBig
	
	//alert(this.formRef.bigImg.value)
	
	this.formRef.text1.value = this.products[this.activeText].textLayer.cont
	if(this.products[this.activeText].ficha != "nada") this.formRef.ficha.value = this.products[this.activeText].fichaTecnica.cont
	else document.all.printForm.ficha.value = ""
	this.formRef.submit()
}

function Product(index, name, imgBottleBig, imgBottleSmall, imgHead, text, aspecto, aroma, gusto, fichaTecnica){
	this.index = index
	this.name = name
	this.imgBottleBig = imgBottleBig
	this.imgBottleSmall = imgBottleSmall
	this.imgHead = imgHead
	this.text1 = text
	this.aspecto = aspecto
	this.aroma = aroma
	this.gusto = gusto
	if(fichaTecnica != "nada") this.ficha = fichaTecnica.split(":")
	else this.ficha = "nada"
		
	this.textLayer = new pLayer("divTextLayer"+index, prod.textX, 31, (746-prod.textX), 300, "contentDiv", "", 10, 0)
		var tmp = "<span class='headRed'>"+this.name+"</span><br><span class='textRed'>"+((this.text1 != "") ? "<br>"+this.text1+"<br>" : "") + "</span>"
		tmp += (this.aspecto != "nada") ? "<span class='head1Red'><br>"+prod.textHeads[0]+"<br></span><span class='textDarkRed'>"+this.aspecto+"<br></span><span class='head1Red'><br>"+prod.textHeads[1]+"<br></span><span class='textDarkRed'>"+this.aroma+"<br></span><span class='head1Red'><br>"+prod.textHeads[2]+"<br></span><span class='textDarkRed'>"+this.gusto+"<br></span>" : ""
		tmp += (this.ficha != "nada") ? "<span class='head1Red'><br><a class='head1Red' href='javascript:void()' onclick='prod.openFicha(); return false' onfocus='blur()'>"+prod.textHeads[3]+"&nbsp;<img src='../images/prod_arrow.gif' width='12' height='7' border='0' alt=''></a><br></span>" : ""
		this.textLayer.setCont(tmp)
	
	if(prod.sbW != 0){
		this.smallBottle = new pLayer("divSmallBottle"+index, (prod.sbX+index*prod.sbW),prod.sbY, prod.sbW, 250, "contentDiv", "", 2, 0)
			this.smallBottle.setCont("<a href='javascript:void(0)' onclick='prod.showProd("+index+"); return false' onfocus='blur()'><img src='"+this.imgBottleSmall+"' border='0'></a>")
	}
	else{
		this.smallBottle = new pLayer("divSmallBottle"+index, prod.sbX,prod.sbY, 200, 250, "contentDiv", "", 2, 0)
			this.smallBottle.setCont("<img src='"+this.imgBottleSmall+"' border='0'>")
	}	
	this.leftMenu = new pLayer("divLeftMenu"+index, 15, (77+index*16), 300, 16, "contentDiv", "", 7, 0)
		this.leftMenu.setCont("<img src='../images/trans.gif' width='12' height='7' border='0' alt=''><a class='prodInactive' href='javascript:void(0)' onclick='prod.showProd("+index+"); return false' onfocus='blur()'>"+this.name+"</a>")
	this.leftMenuIn = new pLayer("divLeftMenuIn"+index, 15, (77+index*16), 300, 16, "contentDiv", "", 6, 0)
		this.leftMenuIn.setCont("<img src='../images/prod_arrow.gif' width='12' height='7' border='0' alt=''><a class='prodActive' href='javascript:void(0)' onclick='prod.showProd("+index+"); return false' onfocus='blur()'>"+this.name+"</a>")
	if(this.ficha != "nada"){
		var tmp = "<table border='0' cellspacing='3' cellpadding='0' width='320'><tr><td colspan='2' align='left' class='head1Red'>"+prod.fichaText[0]+"</td></tr>"
		for(var i=0; i<this.ficha.length; i++){
			if(this.ficha[i] != -1) tmp += "<tr><td width='240' class='textDarkRed' align='left'>" + prod.fichaText[i+1] + "</td><td class='textDarkRed' align='left'>" + this.ficha[i] + "&nbsp;" + prod.fichaUnits[i+1] + "</td></tr>"
		}
		tmp += "</table>"
		this.fichaTecnica = new pLayer("divFichaTecnica"+index, 440, 90, 320, 150, "contentDiv", "", 23, 0)
			this.fichaTecnica.setCont(tmp)
	}
}	
function abrirNueva(url,name,w,h,posX,posY){
	posX=(posX==null)?(screen.width/2)-(w/2):posX;
	posY=(posY==null)?(screen.height/2)-(h/2):posY;
	eval(name+"=window.open(url,name,'toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width="+w+",height="+h+",top="+posY+",left="+posX+"')");
	eval(name).focus()
}