$(document).ready(function(){
zahlungsart=$("#zahlungsart").val();

	$(".basketInfo").click(function(e){		
		url="index.php?view=warenkorb";
		window.location.href=url;		
	});
	
	$("#subcategory").change(function(){
		
		hauptcat=this.name;
		filter=$("#subcategory").val();
		url="index.php?view=kategorie&id="+hauptcat+"&filter="+filter;
		window.location.href=url;		
	});

$(".produktlink").click(function(e){		
		jQuery("#inhalt_links").load("produkte.php?id="+this.id+"&name="+this.name);
  });
$(".anzahl").click(function(e){		
	jQuery("html").load("carthelper.php?adjust="+this.id+"&anz="+this.val());
	alert(this.val());
	//window.location('cart.php');
});

$("#zahlungsart").change(function(e){	
	
	zahlungsart=$("#zahlungsart").val();
	if(zahlungsart==2){
		//alert("Bitte geben Sie eine Telefonnummer an !");
	}else{
		//alert("notel");
	}
	
});

$("#bild1").click(function(e){		
    $("#inhalt_links").slideToggle("slow");
	});

check_tel = (function()
		{
		if(zahlungsart==2){
			telnummer=$("#telefon").val();
			if(telnummer==""){
			alert(unescape("Bei der Zahlungsart %22Abholung im Gesch%E4ft%22 wird Ihre Telefonnummer ben%F6tigt%21"));
			return false;
			}else{return true;}
		}
		})

show_details = (function( artno ) {
	jQuery("#inhalt_rechts").load("produkte.php?uid="+artno+"");
	show_untertitel(artno);
});

filter_article_list= (function() {
	 wert = $('#groesse').val();
	 jQuery("#preis").load("produkte.php?preis="+wert+"");
});

get_preis = (function() {
	 wert = $('#groesse').val();
	 jQuery("#preis").load("produkte.php?preis="+wert+"");
});

show_untertitel = (function(wert) {	 
	 jQuery("#untertitel").load("produkte.php?untertitel="+wert+"");
	 jQuery("#produktbeschreibung").load("produkte.php?beschreibung="+wert+""); 	 
});

adjust_anz = (function(id) {	 
	
	//alert(id);
	wert=$("#"+id).val();
	if(IsNumeric(wert)){
	//alert(wert);
	window.location="index.php?view=warenkorb&adjust="+id+"&anz="+wert;
	//jQuery("html").load("carthelper.php?adjust="+this.id+"&anz="+this.val());
	}else{
		alert("Bitte geben sie eine korrekte Menge ein!");
	    document.getElementById(id).value="1";
	}
	
});

});


function IsNumeric(strString)
//  check for valid numeric strings	
{
var strValidChars = "0123456789";
var strChar;
var blnResult = true;

if (strString.length == 0) return false;

//  test strString consists of valid characters listed above
for (i = 0; i < strString.length && blnResult == true; i++)
   {
   strChar = strString.charAt(i);
   if (strValidChars.indexOf(strChar) == -1)
      {
      blnResult = false;
      }
   }
return blnResult;
}

function check_anzahl()
{
	 if (document.getElementById("anzahl").length == 0) 
     {
     alert("Bitte geben sie eine Menge an!");
     document.getElementById("anzahl").value="1";
     } 
  else if (IsNumeric(document.getElementById("anzahl").value) == false) 
     {
     alert("Bitte geben sie eine Zahl bei Menge ein!");
     document.getElementById("anzahl").value="1";
     }
  else if (document.getElementById("anzahl").value == 0) 
  {
	  alert("Dieser Wert ist nicht erlaubt!");
	  document.getElementById("anzahl").value="1";
  }
	 
}



