var xmlHttp;
function getProductGroups(str,str1){
	xmlHttp=GetXmlHttpObjectProductGroups();
	if (xmlHttp==null){
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	if(document.location.protocol=="https:") var url="https://msb-server02.de/ssl/thefightshop.de/get_product_groups.php";
	else var url=document.location.protocol+"//www.thefightshop.de/get_product_groups.php";
	url=url+"?q="+str+"&q1="+str1;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChangedProductGroups;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChangedProductGroups(){ 
	if (xmlHttp.readyState==4){
		document.suche.warengruppe.length=0;
		var product_groups=eval(xmlHttp.responseText);
		for(i=0;i<product_groups.length;i++){
			NeuerEintrag=eval(product_groups[i]);
			NeuerEintrag.text=NeuerEintrag.text.replace(/&Auml;/,"Ä");
			NeuerEintrag.text=NeuerEintrag.text.replace(/&auml;/,"ä");
			NeuerEintrag.text=NeuerEintrag.text.replace(/&Ouml;/,"Ö");
			NeuerEintrag.text=NeuerEintrag.text.replace(/&ouml;/,"ö");
			NeuerEintrag.text=NeuerEintrag.text.replace(/&Uuml;/,"Ü");
			NeuerEintrag.text=NeuerEintrag.text.replace(/&uuml;/,"ü");
			NeuerEintrag.text=NeuerEintrag.text.replace(/&szlig;/,"ß");
			NeuerEintrag.text=NeuerEintrag.text.replace(/&amp;/,"&");
			document.suche.warengruppe.options[document.suche.warengruppe.length] = NeuerEintrag;	
		}
	}
}

function GetXmlHttpObjectProductGroups(){
	var xmlHttp=null;
	try{
  		// Firefox, Opera 8.0+, Safari
  		xmlHttp=new XMLHttpRequest();
  	}
	catch (e){
  		// Internet Explorer
  		try{
    		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    	}
  		catch (e){
    		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
  	}
	return xmlHttp;
}

var xmlHttpProductSeries;
function getProductSeries(str,str1){ 
	xmlHttpProductSeries=GetXmlHttpObjectProductSeries();
	if (xmlHttpProductSeries==null){
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	if(document.location.protocol=="https:") var url="https://msb-server02.de/ssl/thefightshop.de/get_product_series.php";
	else var url=document.location.protocol+"//www.thefightshop.de/get_product_series.php";
	url=url+"?q="+str+"&q1="+str1;
	url=url+"&sid="+Math.random();
	xmlHttpProductSeries.onreadystatechange=stateChangedProductSeries;
	xmlHttpProductSeries.open("GET",url,true);
	xmlHttpProductSeries.send(null);
}

function stateChangedProductSeries(){ 
	if (xmlHttpProductSeries.readyState==4){
		document.suche.serie.length=0;
		var series=eval(xmlHttpProductSeries.responseText);
		for(i=0;i<series.length;i++){
			NeuerEintrag=eval(series[i]);
			NeuerEintrag.text=NeuerEintrag.text.replace(/&Auml;/,"Ä");
			NeuerEintrag.text=NeuerEintrag.text.replace(/&auml;/,"ä");
			NeuerEintrag.text=NeuerEintrag.text.replace(/&Ouml;/,"Ö");
			NeuerEintrag.text=NeuerEintrag.text.replace(/&ouml;/,"ö");
			NeuerEintrag.text=NeuerEintrag.text.replace(/&Uuml;/,"Ü");
			NeuerEintrag.text=NeuerEintrag.text.replace(/&uuml;/,"ü");
			NeuerEintrag.text=NeuerEintrag.text.replace(/&szlig;/,"ß");
			NeuerEintrag.text=NeuerEintrag.text.replace(/&amp;/,"&");
			document.suche.serie.options[document.suche.serie.length] = NeuerEintrag;	
		}
	}
}

function GetXmlHttpObjectProductSeries(){
	var xmlHttpProductSeries=null;
	try{
  		// Firefox, Opera 8.0+, Safari
  		xmlHttpProductSeries=new XMLHttpRequest();
  	}
	catch (e){
  		// Internet Explorer
  		try{
    		xmlHttpProductSeries=new ActiveXObject("Msxml2.XMLHTTP");
    	}
  		catch (e){
    		xmlHttpProductSeries=new ActiveXObject("Microsoft.XMLHTTP");
    	}
  	}
	return xmlHttpProductSeries;
}

var xmlHttpMainProductGroup;
function getMainProductGroup(str,str1){ 
	xmlHttpMainProductGroup=GetXmlHttpObjectMainProductGroup();
	if (xmlHttpMainProductGroup==null){
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	if(document.location.protocol=="https:") var url="https://msb-server02.de/ssl/thefightshop.de/get_main_product_group.php";
	else var url=document.location.protocol+"//www.thefightshop.de/get_main_product_group.php";
	url=url+"?q="+str+"&q1="+str1;
	url=url+"&sid="+Math.random();
	xmlHttpMainProductGroup.onreadystatechange=stateChangedMainProductGroup;
	xmlHttpMainProductGroup.open("GET",url,true);
	xmlHttpMainProductGroup.send(null);
}

function stateChangedMainProductGroup(){ 
	if (xmlHttpMainProductGroup.readyState==4 && xmlHttpMainProductGroup.responseText!=""){
		url_string_hauptkategorie=LTrim(xmlHttpMainProductGroup.responseText).replace(/\//,"%7C")+"/";
		if(document.suche.serie.options[document.suche.serie.options.selectedIndex].value!="" && document.suche.warengruppe.options[document.suche.warengruppe.options.selectedIndex].value!=""){
			url_string=url_string_hauptkategorie;
			url_string+=document.suche.serie.options[document.suche.serie.options.selectedIndex].text.replace(/\//,"%7C")+"/"+document.suche.warengruppe.options[document.suche.warengruppe.options.selectedIndex].text.replace(/\//,"%7C")+"/";
		}
		else if(document.suche.serie.options[document.suche.serie.options.selectedIndex].value!=""){
			url_string=url_string_hauptkategorie;
			url_string+=document.suche.serie.options[document.suche.serie.options.selectedIndex].text.replace(/\//,"%7C")+"/";
		}
		else if(document.suche.warengruppe.options[document.suche.warengruppe.options.selectedIndex].value!=""){
			url_string="Warengruppen/";
			url_string+=document.suche.warengruppe.options[document.suche.warengruppe.options.selectedIndex].text.replace(/\//,"%7C")+"/";
		}
		while(url_string.search(/&/)!=-1 || url_string.search(/\+/)!=-1){
			url_string=url_string.replace(/&/,"%7E");
      		url_string=url_string.replace(/\+/,"%2B");
   		}
		window.location.href="http://www.thefightshop.de/"+escape(url_string);
	}
}

function GetXmlHttpObjectMainProductGroup(){
	var xmlHttpMainProductGroup=null;
	try{
  		// Firefox, Opera 8.0+, Safari
  		xmlHttpMainProductGroup=new XMLHttpRequest();
  	}
	catch (e){
  		// Internet Explorer
  		try{
    		xmlHttpMainProductGroup=new ActiveXObject("Msxml2.XMLHTTP");
    	}
  		catch (e){
    		xmlHttpMainProductGroup=new ActiveXObject("Microsoft.XMLHTTP");
    	}
  	}
	return xmlHttpMainProductGroup;
}

function LTrim(str)
{
	// create a string that holds all possible white space values..
	var whitespace = new String(" \t\n\r");

	// create a String object from our value
	var s = new String(str);
	
	if (whitespace.indexOf(s.charAt(0)) != -1) {
		var j=0, i = s.length;
		
		while (j < i && whitespace.indexOf(s.charAt(j)) != -1) { j++; }
			
		s = s.substring(j, i);
		}
	
	return s;
}
