/*
 * Frigoveneta_JS.v.1.0 with mootools 1.2
 * By Mario Zambon (http://www.urbangap.com)
 * Copyright (c) 2008 cody urbangap
*/

function frigoveneta() {

	function fx(el, tmp, type) {el.set(type, {duration: tmp, transition: Fx.Transitions.linear})}	

	// Effetti tool bar
	var tool = $('tool')
	var imgBox = new Element('div', {'class':'bg'}).inject(tool)
	new Asset.image(imgTool, {onload: transition})
	

	function transition() {
		var img = new Element('img', {'src': imgTool, 'alt': ''}).set('opacity', 0).inject(imgBox)
		fx(img, 650, 'tween')
		img.tween('opacity', 0 , 1)
	}


	// Effetti menù lingue
	var mnLang = $$('#top a')
	
	if (mnLangActive=='it') {mnLangActive = 0} 
	else if (mnLangActive=='en') {mnLangActive = 1} 
	else {mnLangActive = null}
	
	mnLang.removeProperty('title')
	mnLang.each(function(item, index){
		var i = index
		if (i==mnLangActive) {
			item.addClass('active')
			item.addEvent('click', $lambda(false))
		} else {
			fx(item, 250, 'morph')
			item.addEvents({
				'mouseover': 	function(){ this.morph('#top .over') },
				'mouseleave': 	function(){ this.morph('#top .out') }
			})
		}
	})


	// Effetti menù principale
	var mn = $$('#mn a')
	mn.removeProperty('title')
	mn.each(function(item, index){
		var i = index
		if (i==mnActive) {
			item.addClass('active')
			item.addEvent('click', $lambda(false))
		} else {
			fx(item, 300, 'tween')
			item.addEvents({
				'mouseover': 	function(){ this.tween('opacity', 0.1) },
				'mouseleave': 	function(){ this.tween('opacity', 1) }
			})
		}
	})
	// Effetti menù principale [piede]
	var mnFoot = $$('.mnFoot a')
	mnFoot.removeProperty('title')
	mnFoot.each(function(item, index){
		var i = index
		if (i==mnActive) {
			item.addClass('active')
			item.addEvent('click', $lambda(false))
		} else {
			fx(item, 250, 'morph')
			item.addEvents({
				'mouseover': 	function(){ this.morph('#foot .over') },
				'mouseleave': 	function(){ this.morph('#foot .out') }
			})
		}
	})

	
	// Effetti "bottoni" home page
	var bt = $$('#btit li')
	var aBt = $$('#btit a')
	fx(aBt, 280, 'tween')
	bt.each(function(item, index){
		var img = item.getElement('img').getProperty('src')
		var str = img.replace('.jpg', 'Over.jpg')
		item.set('style', 'background: url('+str+') 0 0 no-repeat')
	})	
	aBt.removeProperty('title')
	aBt.set('opacity', 1)
	aBt.addEvents({
		'mouseover': 	function(){ this.tween('opacity', 0.3) },
		'mouseleave': 	function(){ this.tween('opacity', 1) }
	})



	// Effetti "bottoni" home page
	var bt = $$('#bten li')
	var aBt = $$('#bten a')
	fx(aBt, 280, 'tween')
	bt.each(function(item, index){
		var img = item.getElement('img').getProperty('src')
		var str = img.replace('En.jpg', 'OverEn.jpg')
		item.set('style', 'background: url('+str+') 0 0 no-repeat')
	})	
	aBt.removeProperty('title')
	aBt.set('opacity', 1)
	aBt.addEvents({
		'mouseover': 	function(){ this.tween('opacity', 0.3) },
		'mouseleave': 	function(){ this.tween('opacity', 1) }
	})



	// Effetti menù prodotti
	var subI = $$('.subI a')
	subI.removeProperty('title')
	subI.each(function(item, index){
		var i = index
		if (i==	mnIIActive) {
			item.addClass('active')
			item.addEvent('click', $lambda(false))
		} else {
			fx(item, 250, 'tween')
			item.addEvents({
				'mouseover': 	function(){ this.tween('opacity', 0.1) },
				'mouseleave': 	function(){ this.tween('opacity', 1) }
			})
		}
	})


	// Effetti rollover link testi
	var lnk = $$('#cont a.lnk', '#cont .din a')
	//lnk.removeProperty('title')
	fx(lnk, 250, 'morph')
	lnk.addEvents({
		'mouseover': 	function(){ this.morph('.lnkOver') },
		'mouseleave': 	function(){ this.morph('.lnkOut') }
	})
	
	
	// Trasparenza immagini PNG
	var png = $$('.imgNews img')
	png.each(function(item, index){
		item.setStyle('behavior', 'url(iepngfix.htc)')
	})
	
	
	// Loghi piede pagina
	var loghi	= $$('#sendMail .bt', '#foot .loghi a')
	fx(loghi, 300, 'tween')
	loghi.set('opacity', 0.5)
	loghi.addEvents({
		'mouseover': 	function(){ this.tween('opacity', 1) },
		'mouseleave': 	function(){ this.tween('opacity', 0.5) }
	})


}

window.addEvent('domready', frigoveneta)

