add_produkt=function(seite,goUp,produktId,toKonfiguration,firstPic)
{
	var preis=document.getElementById('preis_'+produktId).innerHTML;
	var i=0;
	attribute = new Array();
	attributeUebergabeArray = new Array();
	
	attributeUebergabeArray[0]="&att_0="+produktId;
	attributeUebergabeArray[7]="&att_7="+preis;
	for (i=0;i<=6;i++)
	{
		if(document.getElementById('att'+i+'_'+produktId))
		{
		attribute[i]=get_att_value('att'+i+'_'+produktId);
		attributeUebergabeArray[i+1]='&att'+'_'+(i+1)+"="+encodeURIComponent(attribute[i]);
		}

	};
	if(toKonfiguration=='true')
	{
		var zufallA=zufallszahl();
		attribute[5]=zufallA;
		attributeUebergabeArray[6]="&att_6="+zufallA;
	}

	var attstring=attribute.join(",,");
	var attributeUebergabe=attributeUebergabeArray.join("");
	var produkt=document.getElementById('produkt_'+produktId).innerHTML;
	
	
	
	var anzahl=selectWert(document.getElementById('anzahl_'+produktId));
	var goTo=document.location+("?a=0"+(attributeUebergabe));
	new Ajax.Request(goUp+'../plugins/shop/add_produkt.php',
	  {
		method:'get',
		onSuccess: function(transport){
		  var response = transport.responseText || "Keine Verbindung möglich.";
		  
	  	  if(response=='Produkt wurde dem Warenkorb hinzugefuegt.' && toKonfiguration=='true')
	  	  {
			  var konfigurationsString="";
			  
			  document.location=goTo;
	  	  } else {
	  	  		alert(response);
  	  		}
		  
		  
  
		},
		parameters: {produkt_name: 'example', attribute:attstring, produkt:produkt, preis:preis,anzahl:anzahl,seite:seite,toKonfiguration:toKonfiguration,firstPic:firstPic,konfigLink:goTo},
		onFailure: function(){ alert('Keine Verbindung möglich.') }
	  });

}

function change_select(basis,att,produktId)
{
	var alterWert=parseFloat(document.getElementById(att+'_fake2_'+produktId).innerHTML);
	
	var neuerWert=document.getElementById(att+'_fake_'+produktId).options[document.getElementById(att+'_'+produktId).selectedIndex].value;

	if(neuerWert=='')
	{
		neuerWert=0;
	}
	
	
	neuerWert=parseFloat(neuerWert);
	
	var differenz=neuerWert-alterWert;
	
	var neuTotal=parseFloat(document.getElementById('preis_'+produktId).innerHTML) +differenz;
	document.getElementById('preis_'+produktId).innerHTML=neuTotal.toFixed(2);

	document.getElementById(att+'_fake2_'+produktId).innerHTML=neuerWert;
}

warenkorb_clear=function()
{
	new Ajax.Request('../plugins/shop/warenkorb_clear.php',
	  {
		method:'get',
		onSuccess: function(transport){
		location.reload();
		},
		onFailure: function(){ alert('Something went wrong...') }
	  });
	
	
}

delete_produkt=function(nummer,modul_titel)
{
	new Ajax.Request(modul_titel+'/delete/'+nummer+'.htm',
	  {
		onSuccess: function(transport){
			location.reload();
		},
		onFailure: function(){ alert('Something went wrong...') }
	  });
}

plus_produkt=function(nummer,modul_titel)
{
	new Ajax.Request(modul_titel+'/plus/'+nummer+'.htm',
	  {
		onSuccess: function(transport){
			location.reload();
		},
		onFailure: function(){ alert('Something went wrong...') }
	  });
}

minus_produkt=function(nummer,modul_titel)
{
	new Ajax.Request(modul_titel+'/minus/'+nummer+'.htm',
	  {
		onSuccess: function(transport){
			location.reload();
		},
		onFailure: function(){ alert('Something went wrong...') }
	  });
}

  function get_att_value(att)
  {
	var tagName=document.getElementById(att).tagName;
	if(tagName=='SELECT')
	{
		return selectWert(document.getElementById(att));
	} else if(tagName=='INPUT')
	{
		return document.getElementById(att).value;
	}
  }
  
  
  
  
  function selectWert(sObj) {
    with (sObj) return options[selectedIndex].value;
  }
  
  function radioWert(rObj) {
    for (var i=0; i<rObj.length; i++) if (rObj[i].checked) return rObj[i].value;
    return false;
  }
  
  function zufallszahl()  {
		var a = Math.random();
		a = 1000000000000*a;
		a = Math.round(a);
		return a;
		
  }
