function hide_fixed() {
	window.document.getElementById('cart').className = 'header_frame absolute';
	new Effect.Appear(document.getElementById('cart'), { duration: 1 } );	
}

function addtocart(form) {
	
	new Ajax.Updater('wkbox', '/cart/warenkorb_hinz', { asynchronous:true, evalScripts:true, parameters:Form.serialize(form)}); 
	
	if($('cart')) {
	
  	$('cart').hide();
  	window.document.getElementById('cart').className = 'header_frame fixed';
  	new Effect.Appear(document.getElementById('cart'), { duration: 1 } );	
	
  	new Effect.Appear(document.getElementById('addtocart'), { delay: 1 } );
  	new Effect.DropOut(document.getElementById('addtocart'), { delay: 8 } )
	
  	new Effect.SlideUp(document.getElementById('cart'), { delay: 9, afterFinish: hide_fixed } );	

  }
	
}

function varianten_laden(pid) {
  new Effect.BlindDown(document.getElementById('varianten-wrap_' + pid), { duration: 1.5 } );	
	new Ajax.Updater('varianten_' + pid , '/varianten/varianten_select?pid=' + pid);
	new $('direkt_button_' + pid).hide();
	new Effect.Appear(document.getElementById('close_button_' + pid), { duration: 1 });
}

function varianten_close(pid) {
  new Effect.BlindUp(document.getElementById('varianten-wrap_' + pid), { duration: 1 } );	
  new $('close_button_' + pid).hide();
	new Effect.Appear(document.getElementById('direkt_button_' + pid), { duration: 1 });
}

function change(script,element)
{
  new Ajax.Updater(element,script, {
  method: 'post'
  });
}

function unselect(tag)
{
  var elements = $$('body')[0].getElementsBySelector('[name="' + tag + '"]');
  for (var e=0;e<elements.length;e++) {
    if(elements[e].className != 'row deaktiv') elements[e].className = 'row';
  }   
}

function delete_wk(id) {
  
	var answer = confirm("Sind Sie sicher, dass Sie diesen Artikel aus dem Warenkorb entfernen möchten?");
	if (answer){
	  $('anzahl[' + id + ']').value = 0;
		$('cart_form').onsubmit();
	}
}

function getBestellscheinId(text, li) {
   		$("bestellschein").value = li.id;
   		$("buyid").value = li.id;
   		$('cart_form').onsubmit();
}

function bestellschein() { 
  new Ajax.Autocompleter("bestellschein", "BestellscheinChoices", "/products/suche", {afterUpdateElement : getBestellscheinId, parameters : 'bestellschein=1' });  
}
