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

function andreoli() {

	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':'pad'}).inject(tool)
	new Asset.image(href, {onload: transition})

	function transition() {
		var img = new Element('img', {'src': href, 'alt': ''}).set('opacity', 0).inject(imgBox)
		fx(img, 650, 'tween')
		img.tween('opacity', 0 , 1)
	}
	
	
	// 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 immagini thumb
	var thumb = $$('.thumb', '.thumbIco')
	var aThumb = $$('.thumb a', '.thumbIco a')
	fx(aThumb, 350, 'tween')
	thumb.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')
	})	
	aThumb.removeProperty('title')
	aThumb.set('opacity', 1)
	aThumb.addEvents({
		'mouseover': 	function(){ this.tween('opacity', 0.3) },
		'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') }
	})
	
	
	// Effetti menù prodotti
	var mnProd = $$('#cont .mnProd a')
	mnProd.removeProperty('title')
	mnProd.each(function(item, index){
		var i = index
		if (i==mnProdActive) {
			item.addClass('active')
			item.addEvent('click', $lambda(false))
		} else {
			fx(item, 250, 'morph')
			item.addEvents({
				'mouseover': 	function(){ this.morph('.lnkOver') },
				'mouseleave': 	function(){ this.morph('.lnkOut') }
			})
		}
	})
	
	
	// Trasparenza immagini PNG
	var png = $$('.thumbII img', '.thumbIII img', '.thGallery img')
	png.each(function(item, index){
		item.setStyle('behavior', 'url(iepngfix.htc)')
	})
	
	
	// Rollover pulsanti invio-cancella
	// Rollover loghi piede pagine
	var bt	= $$('#sendMail .bt', '#foot .loghi a')
	fx(bt, 300, 'tween')
	bt.set('opacity', 0.5)
	bt.addEvents({
		'mouseover': 	function(){ this.tween('opacity', 1) },
		'mouseleave': 	function(){ this.tween('opacity', 0.5) }
	})


    // Effetti rollover td
    var div = $$('.elProd tr')
    //var td  = $$('.elProd')
	fx(div, 280, 'morph')
	div.addEvents({
		'mouseover': function(){
			this.morph('.bgIn')
		},
		'mouseleave': function(){
			this.morph('.bgOut')
		},
		'click': function(){
			var tagA = this.getElement('a')
			var lnk = tagA.getProperty('href')
			//window.location=lnk
			window.open(lnk)
		}
	})

}

window.addEvent('domready', andreoli)
