Cufon.replace('h1')
Cufon.replace('h2')
Cufon.replace('h3')
Cufon.replace('.title')

window.addEvent('domready', function () {
  
  if($('featured')){
    var featured = new Featured('featuredContainer', { prev:'featuredPrev', next:'featuredNext', width:175, visible:5})    
  }

	$$('.item').addEvents({
		'mouseenter': function(e){
			this.getFirst('.itemAjaxLink').setStyle('display', 'block')
			this.getFirst('a').getFirst('strong').tween('color', '#000000')
		},
		'mouseleave': function(e){
			this.getFirst('.itemAjaxLink').setStyle('display', 'none')
			this.getFirst('a').getFirst('strong').tween('color', '#808080')
		}
	})

  SqueezeBox.assign($$('a[rel=boxed]'), {
  	size: {x: 460, y: 510},
		onUpdate: function(){
			Cufon.replace('h1')
			setTips()
		},
  	ajaxOptions: {
  		method: 'post'
  	},
		shadow: false
  });

	function setTips(){
		$$('.itemIcon').each(function(el){
			el.store('tip:title', el.getProperty('title')).store('tip:text', el.getNext())
		})
		new Tips('.itemIcon', {
			className: 'tip',
			onShow: function(tip, el){
				tip.setStyle('opacity', 0.8)
			}
		})
	}
	setTips()
  
	if(invoice = $('purchase_invoice')){
		function invoice_change(){
			$A(["purchase_invoice_company", "purchase_invoice_city", "purchase_invoice_address", "purchase_invoice_id", "purchase_invoice_vat_id", "purchase_invoice_name"]).each(function(id){
				if(input = $(id)){
					if(invoice.checked) input.removeClass('disabled'); else input.addClass('disabled');
					input.disabled = !invoice.checked
				} 
			})
			return true
		}
		invoice.addEvent('change', invoice_change)
		$('purchaseFormForm').addEvent('submit', invoice_change)
		invoice_change()
	}

})