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,"Makita","pi1056749374.php",null,"1001");
navigation[1] = new navElem(1,"Bohren/Schrauben/Stemmen","pi1143982815.php",0,"1001_1");
navigation[2] = new navElem(2,"Akkuschrauber  bis 9,6","pi-1989475532.php",1,"1001_1_1");
navigation[3] = new navElem(3,"Akkuschrauber 12-14,4","pi363874341.php",1,"1001_1_2");
navigation[4] = new navElem(4,"Akkuschrauber 18-24V","pi1091431554.php",1,"1001_1_3");
navigation[5] = new navElem(5,"Bohrhämmer","pi141516507.php",1,"1001_1_4");
navigation[6] = new navElem(6,"SDS+ und Akku","pi982281856.php",5,"1001_1_4_1");
navigation[7] = new navElem(7,"SDS-Max","pi-1779012479.php",5,"1001_1_4_2");
navigation[8] = new navElem(8,"Sonstige","pi487389358.php",5,"1001_1_4_3");
navigation[9] = new navElem(9,"Stemmen/Meisseln","pi137628311.php",1,"1001_1_5");
navigation[10] = new navElem(10,"Bohrmaschinen","pi627672716.php",1,"1001_1_6");
navigation[11] = new navElem(11,"Schlagbohrmaschinen","pi1231974045.php",1,"1001_1_7");
navigation[12] = new navElem(12,"Schlagschrauber","pi1980399514.php",1,"1001_1_8");
navigation[13] = new navElem(13,"Bau-/Magazinschrauber","pi-1828926957.php",1,"1001_1_9");
navigation[14] = new navElem(14,"Winkelbohren/Schrauben","pi1505531736.php",1,"1001_1_A");
navigation[15] = new navElem(15,"Diamantwerkzeuge","pi1411361401.php",0,"1001_2");
navigation[16] = new navElem(16,"Schleifen/Polieren/Trennen","pi1039772998.php",0,"1001_3");
navigation[17] = new navElem(17,"Winkelschleifer bis 150","pi-1441769137.php",16,"1001_3_1");
navigation[18] = new navElem(18,"Winkelschleifer ab 180","pi-1646482204.php",16,"1001_3_2");
navigation[19] = new navElem(19,"Schwing-/Exzenterschleifer","pi-937477099.php",16,"1001_3_3");
navigation[20] = new navElem(20,"Gerad-/Tellerschleifer","pi-1715966542.php",16,"1001_3_4");
navigation[21] = new navElem(21,"Bandschleifer","pi712586315.php",16,"1001_3_5");
navigation[22] = new navElem(22,"Scheren/Knabber","pi940151600.php",16,"1001_3_6");
navigation[23] = new navElem(23,"Sägen/Garten","pi1340866417.php",0,"1001_4");
navigation[24] = new navElem(24,"Kreissägen","pi2067492062.php",23,"1001_4_1");
navigation[25] = new navElem(25,"Stich-/Säbelsägen","pi1858180871.php",23,"1001_4_2");
navigation[26] = new navElem(26,"Kapp-/Gehrungssägen","pi1148704316.php",23,"1001_4_3");
navigation[27] = new navElem(27,"Kettensägen/Bandsägen","pi378179725.php",23,"1001_4_4");
navigation[28] = new navElem(28,"Hecken-/Astscheren","pi-1770383670.php",23,"1001_4_5");
navigation[29] = new navElem(29,"Hobeln","pi1685028227.php",0,"1001_5");
navigation[30] = new navElem(30,"Fräsen","pi-467877368.php",0,"1001_6");
navigation[31] = new navElem(31,"Saugen/Blasen","pi1231113065.php",0,"1001_7");
navigation[32] = new navElem(32,"Sonstige","pi-585459850.php",0,"1001_8");
navigation[33] = new navElem(33,"Ersatzteile","pi-784292929.php",0,"1001_E");
navigation[34] = new navElem(34,"Kohlebürsten","pi1346003604.php",33,"1001_E_K");
navigation[35] = new navElem(35,"Zubehör","pi1339313157.php",0,"1001_Z");
navigation[36] = new navElem(36,"Akkus","pi1826478818.php",35,"1001_Z_1");
navigation[37] = new navElem(37,"Ladegeräte","pi1143375291.php",35,"1001_Z_2");
navigation[38] = new navElem(38,"Lampen","pi-1632926752.php",35,"1001_Z_3");

// 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"));


