var miniCartAvail = "X";
//
function miniCart(){
var prdCount = 0, prdString = "", subTotal = (xmlConfig.cartSubTotal > 0)?xmlConfig.cartSubTotal:0;
	if(xmlOHeader.childNodes.length==0) subTotal = 0;
	for(var i=0;i<xmlOHeader.childNodes.length;i++){
		prdCount = prdCount+(parseInt(xmlOHeader.childNodes[i].QuantityAmount));
		};
    prdString += "Warenkorb:&nbsp;<strong>" + prdCount + "&nbsp;";
    if(prdCount==1){
        prdString += "Produkt";
    }
    else{
        prdString += "Produkte";
    };
    prdString += "</strong>,&nbsp;Summe:&nbsp;<strong>" + TFormatCurrency(subTotal, objPriCurrency) + "</strong>";
	return(prdString);
	};
//
var TNavDropDownIndent = "..";
//
function NavLinkedDropDownList(){
	return(TNavDropDownList(true));
	};
//
function NavDropDownList(){
	return(TNavDropDownList(false));
	};
//
function storeSearchParameters(optionValueArray){
var xmlSearchEngine = xmlConfig.getFirstItem("SearchEngine");
	if(optionValueArray[0]!="null"&&optionValueArray[0]!="nada"){
		xmlSearchEngine.categoryIndex = optionValueArray[0];
		xmlSearchEngine.categoryId = optionValueArray[2];
		xmlSearchEngine.ByCategory = "1";
		}
	else{
		xmlSearchEngine.categoryIndex = "null";
		xmlSearchEngine.categoryId = "null";
		xmlSearchEngine.ByCategory = "0";
		};
	};
//
function TNavDropDownList(asLink){
var rString = "";
var myNavIndex = "";
	if(asLink) myNavIndex = xmlConfig.navIndex;
	else myNavIndex = xmlConfig.getFirstItem("SearchEngine").categoryIndex;
	if(!(myNavIndex=="null"||myNavIndex=="")){ navigation[parseInt(myNavIndex)].active = true; };
	if(asLink) rString += "<select name=\"navselect\" onChange=\"changeLoc(this[this.selectedIndex].value.split(';;')[0],this[this.selectedIndex].value.split(';;')[1])\">"
	else rString += "<select name=\"navselect\" onChange=\"storeSearchParameters(this[this.selectedIndex].value.split(';;'))\">";
	rString += "<option value=\"nada;;start.htm;;null\">Katalog</option>";
	for(var i=0; i<navigation.length; i++){
		if(navigation[i].parentId==null){
			rString += TNavDropDownItem(navigation[i], "");
			};
		};
	rString += "</select>";
	return(rString);
	};
//
function TNavDropDownItem(navItem, cptPreFix){
var rString = "";
	rString += "<option value=\"" + navItem.id + ";;" + navItem.linkUrl + ";;" + navItem.categoryId + "\"";
	if(navItem.active) rString += " selected";
	rString += ">" + cptPreFix + navItem.caption + "</option>";
	for(var i=0; i<navigation.length;i++) if(navigation[i].parentId==navItem.id) rString += TNavDropDownItem(navigation[i], cptPreFix + TNavDropDownIndent);
	return(rString);	
	};
//
	function openItem(itemId){
	var objActiveItem = null;
		if(itemId!=null){
			objActiveItem = navigation[itemId];
			if(objActiveItem!=null){
				objActiveItem.open = true;
				openItem(objActiveItem.parentId);
				};
			};
		};
		
	function activateItem(itemId){
	var objActiveItem = null;
		if(itemId!=null){
			objActiveItem = navigation[itemId];
			if(objActiveItem!=null){
				objActiveItem.active = true;
				openItem(objActiveItem.parentId);
				};
			};
		};
		
	function itemHasSubelems(itemId){
		for(var i=0; i<navigation.length;i++) if(navigation[i].parentId==itemId) return(true);
		return(false);
		};
	
	function TNavLinkList(){
	var strHTML = "";
		for(var i=0; i<navigation.length; i++) if(navigation[i].parentId==null) strHTML += printItem(navigation[i], 0);
		return(strHTML);
		};	
		
	function printItem(navItem, depth){
	var strHTML = "";
	var elemWidth = 1;
		strHTML += '<table width="100%" class="CATLINKS1STPARENT" border="0" cellpadding="1" cellspacing="1" >';
		strHTML += "<tr>"
		for(var i=0; i<depth; i++){
			strHTML += "<td";
			if(navItem.active) strHTML += " class=\"ACTIVECATEGORY\""
			else strHTML += " class=\"CATLINKS1STBULLET\"";
			strHTML += ' width="1%"><img src="assets/images/spacer.gif" width="9" height="1" height="1" alt="" border="0"></td>';
			};
		if(navItem.active) strHTML += '<td width="1%" class="ACTIVECATEGORY"><img src="assets/images/bulletact.gif" width="9" height="9" alt="BulletCatAct.gif" border="0" align="bottom" hspace="0" vspace="0" class="catnav"></td>'
		else if(navItem.open&&itemHasSubelems(navItem.id)) strHTML += '<td width="1%" class="CATLINKS1STBULLET"><img src="assets/images/bulletwgr.gif" width="9" height="9" alt="BulletCat1stCls.gif" border="0" align="bottom" hspace="0" vspace="0" class="catnav"></td>'
		else strHTML += '<td width=\"1%\"><img src="assets/images/bulletnor.gif" width="9" height="9" alt="BulletCat1st.gif" border="0" align="bottom" hspace="0" vspace="0" class="catnav"></td>'
		strHTML += "<td";
		if(navItem.active) strHTML += " class=\"ACTIVECATEGORY\""
		else strHTML += " class=\"CATLINKS1STBULLET\"";
		strHTML += "width=\"" + ( 100 - ( depth + 1 ) ) + "%\">"
			+ "<a href=\"" + navItem.linkUrl + "?categoryId=" + escape(navItem.id) + "\" class=\"WAGRUNAV\">"
			+ navItem.caption
			+ "</a>"
			+ "</td>";
		strHTML += "</tr>"
		strHTML += "</table>"
		depth++;
		if(navItem.active||navItem.open){
			for(var i=0; i<navigation.length;i++) if(navigation[i].parentId==navItem.id) strHTML += printItem(navigation[i], depth);
			};
		return(strHTML);
		};


//

// navElem
	function navElem(id,caption,linkUrl,parentId,categoryId){
		this.id = id;
		this.caption = caption;
		this.linkUrl = linkUrl;
		this.parentId = parentId;
		this.active = false;
		this.open = true;
		this.categoryId = categoryId;
		};
// navigation
var navigation = new Array();
//
navigation[0] = new navElem(0,"Metabo (Elektra-Beckum)","pi1081278406.php",null,"1018");
navigation[1] = new navElem(1,"Bohren/Schrauben/Stemmen","pi1148825192.php",0,"1018_1");
navigation[2] = new navElem(2,"Akkuschrauber","pi-300607415.php",1,"1018_1_1");
navigation[3] = new navElem(3,"Bohren/Stemmen","pi851892950.php",1,"1018_1_2");
navigation[4] = new navElem(4,"Bohrmaschinen","pi-1659847777.php",1,"1018_1_3");
navigation[5] = new navElem(5,"Schlagbohrmaschinen","pi-1321085708.php",1,"1018_1_4");
navigation[6] = new navElem(6,"Schrauber","pi-958028059.php",1,"1018_1_5");
navigation[7] = new navElem(7,"Zubehör","pi1250956354.php",1,"1018_1_Z");
navigation[8] = new navElem(8,"Diamantwerkzeuge","pi-737748069.php",0,"1018_2");
navigation[9] = new navElem(9,"Schleifen/Polieren","pi-1908286400.php",0,"1018_3");
navigation[10] = new navElem(10,"Schwing-/Exzenterschleifer","pi-42649791.php",9,"1018_3_1");
navigation[11] = new navElem(11,"Winkelschleifer","pi679418990.php",9,"1018_3_2");
navigation[12] = new navElem(12,"Band/-Doppelschleifer","pi-949824681.php",9,"1018_3_3");
navigation[13] = new navElem(13,"Geradschleifer","pi956256332.php",9,"1018_3_5");
navigation[14] = new navElem(14,"Zubehör","pi-33200803.php",9,"1018_3_Z");
navigation[15] = new navElem(15,"Sägen","pi-968597670.php",0,"1018_4");
navigation[16] = new navElem(16,"Stich/Säbelsägen","pi-600858925.php",15,"1018_4_1");
navigation[17] = new navElem(17,"Handkreissägen","pi1389395224.php",15,"1018_4_2");
navigation[18] = new navElem(18,"Bandsägen","pi-1391882951.php",15,"1018_4_3");
navigation[19] = new navElem(19,"Bau/Tisch/Kappsägen","pi-254867194.php",15,"1018_4_4");
navigation[20] = new navElem(20,"Anbauteile","pi-100664817.php",19,"1018_4_4_Z");
navigation[21] = new navElem(21,"Zubehör","pi1701342884.php",15,"1018_4_Z");
navigation[22] = new navElem(22,"Hobeln/Fräsen","pi465750741.php",0,"1018_5");
navigation[23] = new navElem(23,"Zubehör","pi800654706.php",22,"1018_5_Z");
navigation[24] = new navElem(24,"Scheren/Knabber","pi1089102091.php",0,"1018_6");
navigation[25] = new navElem(25,"Zubehör","pi1210249456.php",24,"1018_6_Z");
navigation[26] = new navElem(26,"Saugen/Blasen","pi-1633945039.php",0,"1018_7");
navigation[27] = new navElem(27,"Zubehör","pi1534263454.php",26,"1018_7_Z");
navigation[28] = new navElem(28,"Pumpen/HWW","pi-146468921.php",0,"1018_8");
navigation[29] = new navElem(29,"Zubehör","pi-770666500.php",28,"1018_8_Z");
navigation[30] = new navElem(30,"Schweissen","pi-515524787.php",0,"1018_9");
navigation[31] = new navElem(31,"Zubehör","pi1311794826.php",30,"1018_9_Z");
navigation[32] = new navElem(32,"Kompressoren","pi-1423834557.php",0,"1018_A");
navigation[33] = new navElem(33,"Handwerker/Hobby","pi616732616.php",32,"1018_A_1");
navigation[34] = new navElem(34,"Industrie/Stationär","pi1418878505.php",32,"1018_A_2");
navigation[35] = new navElem(35,"Druckluftwerkzeuge","pi-611097802.php",32,"1018_A_3");
navigation[36] = new navElem(36,"Zubehör","pi1133180031.php",32,"1018_A_Z");
navigation[37] = new navElem(37,"Kleben/Spalten/Tackern","pi-1680403372.php",0,"1018_B");
navigation[38] = new navElem(38,"Heckenscheren","pi303172293.php",0,"1018_C");
navigation[39] = new navElem(39,"Kombimaschinen","pi-82255198.php",0,"1018_D");
navigation[40] = new navElem(40,"Zubehör","pi2105369211.php",0,"1018_Z");
navigation[41] = new navElem(41,"Akku-Zubehör","pi759484832.php",40,"1018_Z_A");

// getNavElementByCatID
function getNavElementByCatID(categoryId){
	for(var i=0; i<navigation.length; i++){
		if(navigation[i].categoryId==categoryId){
			return(navigation[i]);
			break;
			};
		};
		return(null);
	};
// changeLoc
function changeLoc(id,linkUrl){
	if(id!="nada"){
		xmlConfig.navIndex = id.toString();
		if(xmlConfig.getFirstItem("SearchEngine").ByCategory == "1"){
			if(id=="null") xmlConfig.getFirstItem("SearchEngine").categoryId = "null"
			else xmlConfig.getFirstItem("SearchEngine").categoryId = navigation[id].categoryId;
			xmlConfig.getFirstItem("SearchEngine").categoryIndex = id;
			}
		else{
			xmlConfig.getFirstItem("SearchEngine").categoryId = "null";
			xmlConfig.getFirstItem("SearchEngine").categoryIndex = "null";
			};
		safeData();
		location.href = linkUrl + "?categoryId=" + id.toString();
		};
	};
// searchOnEnterNavi
function searchOnEnterNavi(){
	if(window.event.keyCode==13){
		xmlConfig.getFirstItem('SearchEngine').term=document.searchEngine.searchTerm.value;
		location.href = "search.php";
		};
	};
// activates entries for categories
activateItem(getParameterFromURL("categoryId"));


