Event.addBehavior({
"a:mousedown": function(){
$(this).addClassName('down');
},
"a:mouseup": function(){
$(this).removeClassName('down');
},
"input[type=text]:focus,input[type=password]:focus": function(){
$($(this).up(0)).addClassName('field-hover');
// if (this.parentNode.className.indexOf('field-hover') == -1) { this.parentNode.className += ' field-hover ';}
},
"input[type=text]:blur,input[type=password]:blur": function(){
$($(this).up(0)).removeClassName('field-hover');
// this.parentNode.className = this.parentNode.className.replace('field-hover', '');
},
"span.error input[type=text]:focus": function(){
$($(this).up(0)).removeClassName('error');
if ($(this).readAttribute('error') == this.value) {
    this.value = '';
}
$($(this).up(0)).addClassName('field-hover');
},
"span.error input[type=text]:blur": function(){
$($(this).up(0)).removeClassName('field-hover');
},
"ul.slist li:mouseover": function(){
$(this).addClassName('hover');
},
"ul.slist li:mouseout": function(){
$(this).removeClassName('hover');
},
"ul.list li:mouseover": function(){
$(this).addClassName('hover');
},
"ul.list li:mouseout": function(){
$(this).removeClassName('hover');
},
"ul.products li div.fotos:mouseover": function(){
$(this).addClassName('hover');
},
"ul.products li div.fotos:mouseout": function(){
$(this).removeClassName('hover');
},
"ul.products li:mouseover": function(){
$(this).addClassName('hover');
},
"ul.products li:mouseout": function(){
$(this).removeClassName('hover');
}
});

function updateProduct(code) {
	if ($(code) != null) {
	  $($($(code).up('.describe')).parentNode).addClassName('light');
	  $($($(code).up('.describe')).parentNode).stopObserving();
	  $($($(code).writeAttribute({'class': 'in','href': '/wish_lists'})).update('In My Wishlist')).show();
	}
}

function removeFromWL(prodId) {
  new Ajax.Request('/wish_lists/remove', {
    asynchronous:true, 
    evalScripts:true, 
    method:'post', 
    onLoading: function(request){
      $('wl'+prodId).update('<img src="/images/loading.gif" width="41" height="11" alt="" />');
    }, 
    parameters:'product_id='+prodId + '&authenticity_token=' + encodeURIComponent(window._auth_token)}
    ); 
  return false;	
}

function add_to_wish_list(store_id, product_code, shop_name, product_name, original_price, currency) {
  $('wish_list_shop_id').value = store_id;
	$('shop_id_name').value = shop_name;
  $('wish_list_product_code').value = product_code;
	$('product_code_name').value = product_name;
	$('wish_list_shop_id', 'wish_list_product_code').invoke('hide');
	$('shop_id_name', 'product_code_name').invoke('show');
  $('shop_id_name').activate();
  $('product_code_name').activate();
	$('product_currency').innerHTML = currency;
	$('original_price').innerHTML = original_price + " " + currency;
	$('original_price_container').show();
	var obj = $('wlist_initial') || $('wishlist-back') || $('wishlist-new');
	if (obj) {
		obj.addClassName("long");
		obj.up().setStyle({height: "234px"});
	}
	window.scrollTo(0, 0);
	$('wish_list_product_price').activate();  
}
