/* ************************************************************
 * CVS Header: This header is generated automatically.
 *             Do not remove
 * ************************************************************
 * $Header: /cvsprojekte/baershop/jshop/resources/jserver.js,v 1.53.2.5 2007/01/12 07:57:56 schofield Exp $
 *
 * $Name: orbis-3_1_0 $ 
 *
 ************************************************************ */
 
// This file contains (almost) all javascript code used by the shop 

// ------------------------------------------------------------------------------------
// Here you can control error behaviour
// ------------------------------------------------------------------------------------

//window.onerror = tellerror;
window.onerror = stopError;


function stopError() {
  return true;
}


function tellerror(msg, url, linenumber)
{
	if (linenumber > 23)
	{
		alert('Error message= '+msg+'\nURL= '+url+'\nLine Number= '+linenumber);
	}
	return true;
}

// ------------------------------------------------------------------------------------

/*
 * Since template variables cannot be evaluated in a jscript file, we
 * have to use this workaround if we want to access the information.
 *
 * The function "setClientVars" is called in "templates/includes/head.html"
 * directly after this file is referenced.
 */
 
var _shopBaseDir;
var _imagePath;

function setClientVars(shopBaseDir, imagePath) {
	_shopBaseDir = shopBaseDir;
	_imagePath = imagePath;
}

// ------------------------------------------------------------------------------------

			function recalcPrice(productID) 
			{
				eval("thisPrice = baseprice"+productID+";");
				eval("thisPriceExTax = basepriceExTax"+productID+";");
				eval("thisPriceIncTax = basepriceIncTax"+productID+";");
				eval("thisPriceTax = basepriceTax"+productID+";");
				eval("thisOOPrice = oobaseprice"+productID+";");
				eval("thisOOPriceExTax = oobasepriceExTax"+productID+";");
				eval("thisOOPriceIncTax = oobasepriceIncTax"+productID+";");
				eval("thisOOPriceTax = oobasepriceTax"+productID+";");
				currentValues = new Array(efcount);
				eval ("qtybox = document.productForm"+productID+".qty"+productID+";");
				qty = 1;
				if (typeof qtybox != "undefined") 
				{
					eval("qtyboxtype = qtybox.type");
					if (qtyboxtype == "select-one") 
					{
						qty = qtybox.options[qtybox.selectedIndex].text;
					}//if
					if (qtyboxtype == "text") 
					{
						qty = qtybox.value;
					}//if
				}//if
				

				
				for (f = 0; f < efcount; f++) 
				{
					currentValues[extrafields[f]] = "";
					eval("result = document.productForm"+productID+"."+extrafields[f]+";");
					if (extrafieldstype[f] == "CHECKBOXES") 
					{
						eval("result = document.productForm"+productID+"."+extrafields[f]+"1;");
					}//if
					if (extrafieldstype[f] == "RADIOBUTTONS") 
					{
						if (eval("document.productForm"+productID+"."+extrafields[f]+";")) 
						{
							eval("result = document.productForm"+productID+"."+extrafields[f]+".length;");
							if (result > 0) 
							{
								result = "radio";
							}//if
						}//if
					}//if
						
					if (typeof result != "undefined" || result=="radio") 
					{
						if (result != "radio") 
						{
							eval("fieldtype = result.type;");
						}//if
						else 
						{
							fieldtype = "radio";
						}//else
						if (fieldtype=="select-one") 
						{
							content = result.options[result.selectedIndex].value;
							currentValues[extrafields[f]] = content;
						}//if
						if (fieldtype=="checkbox") 
						{
							content = "";
							thisOne = 1;
							while (typeof result != "undefined") 
							{
								if (result.checked == true) 
								{
									if (content != "") 
									{
										content = content+";";
									}//if
									content = content + result.value;
								}//if
								thisOne = thisOne + 1;
								eval("result = document.productForm"+productID+"."+extrafields[f]+thisOne+";");
							}//while
							currentValues[extrafields[f]] = content;
						}
						if (fieldtype=="radio") 
						{
							eval("radlength = document.productForm"+productID+"."+extrafields[f]+".length;");
							for (g = 0; g < radlength; g++) 
							{
								eval("thisoption = document.productForm"+productID+"."+extrafields[f]+"["+g+"].checked;");
								if (thisoption == true) 
								{
									eval("thisvalue = document.productForm"+productID+"."+extrafields[f]+"["+g+"].value;");
									currentValues[extrafields[f]] = thisvalue;
								}//if
							}//for
						}//if
					}//if
				}//for


	
				eval ("arraylength = parray"+productID+".length;");
				eval ("advArray = parray"+productID+";");
				for (f = 0; f <  arraylength; f++) 
				{		
					applicable = false;
					if (parseInt(advArray[f]["qtyfrom"]) != -1 && parseInt(advArray[f]["qtyto"]) != -1 && parseInt(advArray[f]["qtyto"]) != 0) 
					{
						//quantity is applicable here
						if (parseInt(qty) >= parseInt(advArray[f]["qtyfrom"]) && parseInt(qty) <= parseInt(advArray[f]["qtyto"])) 
						{
							applicable = true;
						}//if
					} 
					else 
					{
						applicable = true;
					}//else
					thisapplic = true;
					foundMatches = 0;
					for (g = 0; g < efcount; g++) 
					{
						if (advArray[f][extrafields[g]] != "" && advArray[f][extrafields[g]] != "0") 
						{
							splitCheck = advArray[f][extrafields[g]].split(";");
							splitapplic = false;
							for (k = 0; k < splitCheck.length; k++) 
							{
								splitValues = currentValues[extrafields[g]].split(";");
								for (l = 0; l < splitValues.length; l++) 
								{
									if ((splitCheck[k] == splitValues[l] && splitCheck[k] != "" && splitValues[l] != "")) 
									{
										splitapplic = true;
										if (extrafieldstype[g] == "CHECKBOXES") 
										{
											foundMatches = foundMatches + 1;
										}//if
									}//if
								}//for
							}//for
							if (splitapplic == true && thisapplic == true) 
							{
								thisapplic = true;
							}//if
							else 
							{
								thisapplic = false;
							}//else
						}//if
					}//for
					if (thisapplic == true && applicable == true) 
					{
						applicable = true;
					}//if
					else 
					{
						applicable = false;
					}//else
					if (applicable == true) 
					{
						//new base price
						if (foundMatches == 0) 
						{ 
							foundMatches =1; 
						}//if
						if (parseInt(advArray[f]["priceType"]) == 0) 
						{
							if (parseFloat(advArray[f]["percentage"]) > 0) 
							{
								thisPrice = thisPrice + (thisPrice  * (1+(eval(advArray[f]["percentage"])/100)));
								thisPriceExTax = thisPriceExTax + (thisPriceExTax  * (1+(eval(advArray[f]["percentage"])/100)));
								thisPriceIncTax = thisPriceIncTax + (thisPriceIncTax  * (1+(eval(advArray[f]["percentage"])/100)));
								thisPriceTax = thisPriceTax + (thisPriceTax  * (1+(eval(advArray[f]["percentage"])/100)));
							}//if
							if (parseFloat(advArray[f]["percentage"]) < 0) 
							{
								thisPrice = thisPrice - (thisPrice  * (Math.abs(eval(advArray[f]["percentage"]))/100));
								thisPriceExTax = thisPriceExTax - (thisPriceExTax  * (Math.abs(eval(advArray[f]["percentage"]))/100));
								thisPriceIncTax = thisPriceIncTax - (thisPriceIncTax  * (Math.abs(eval(advArray[f]["percentage"]))/100));
								thisPriceTax = thisPriceTax - (thisPriceTax  * (Math.abs(eval(advArray[f]["percentage"]))/100));
							}//if
							if (parseFloat(advArray[f]["percentage"]) == 0) 
							{
								thisPrice = eval(advArray[f]["price"]);
								thisPriceExTax = eval(advArray[f]["priceExTax"]);
								thisPriceIncTax = eval(advArray[f]["priceIncTax"]);
								thisPriceTax = eval(advArray[f]["priceTax"]);
							}//if
						}//if
						if (parseInt(advArray[f]["priceType"]) == 1) 
						{
							if (parseFloat(advArray[f]["percentage"]) > 0) 
							{
								for (m = 1; m <= foundMatches; m++) 
								{
									thisPrice = thisPrice + (thisPrice  * ((eval(advArray[f]["percentage"])/100)));
									thisPriceExTax = thisPriceExTax + (thisPriceExTax  * ((eval(advArray[f]["percentage"])/100)));
									thisPriceIncTax = thisPriceIncTax + (thisPriceIncTax  * ((eval(advArray[f]["percentage"])/100)));
									thisPriceTax = thisPriceTax + (thisPriceTax  * ((eval(advArray[f]["percentage"])/100)));
								}
							}
							if (parseFloat(advArray[f]["percentage"]) < 0) 
							{
								for (m = 1; m <= foundMatches; m++) 
								{
									thisPrice = thisPrice - (thisPrice  * (Math.abs(eval(advArray[f]["percentage"]))/100));
									thisPriceExTax = thisPriceExTax - (thisPriceExTax  * (Math.abs(eval(advArray[f]["percentage"]))/100));
									thisPriceIncTax = thisPriceIncTax - (thisPriceIncTax  * (Math.abs(eval(advArray[f]["percentage"]))/100));
									thisPriceTax = thisPriceTax - (thisPriceTax  * (Math.abs(eval(advArray[f]["percentage"]))/100));
								}
							}
							if (parseFloat(advArray[f]["percentage"]) == 0) 
							{
								for (m = 1; m <= foundMatches; m++) 
								{
									thisPrice = thisPrice + eval(advArray[f]["price"]);
									thisPriceExTax = thisPriceExTax + eval(advArray[f]["priceExTax"]);
									thisPriceIncTax = thisPriceIncTax + eval(advArray[f]["priceIncTax"]);
									thisPriceTax = thisPriceTax + eval(advArray[f]["priceTax"]);
								}
							}
						}	
						if (parseInt(advArray[f]["priceType"]) == 2) 
						{
							if (parseFloat(advArray[f]["percentage"]) > 0) 
							{
								for (m = 1; m <= foundMatches; m++) 
								{
									thisPrice = thisPrice - (thisPrice * (eval(advArray[f]["percentage"])/100));
									thisPriceExTax = thisPriceExTax - (thisPriceExTax * (eval(advArray[f]["percentage"])/100));
									thisPriceIncTax = thisPriceIncTax - (thisPriceIncTax * (eval(advArray[f]["percentage"])/100));
									thisPriceTax = thisPriceTax - (thisPriceTax * (eval(advArray[f]["percentage"])/100));
								}
							}
							if (parseFloat(advArray[f]["percentage"]) < 0) 
							{
								for (m = 1; m <= foundMatches; m++) 
								{
									thisPrice = thisPrice - (thisPrice * (Math.abs(eval(advArray[f]["percentage"]))/100));
									thisPriceExTax = thisPriceExTax - (thisPriceExTax * (Math.abs(eval(advArray[f]["percentage"]))/100));
									thisPriceIncTax = thisPriceIncTax - (thisPriceIncTax * (Math.abs(eval(advArray[f]["percentage"]))/100));
									thisPriceTax = thisPriceTax - (thisPriceTax * (Math.abs(eval(advArray[f]["percentage"]))/100));
								}
							}
							if (parseFloat(advArray[f]["percentage"]) == 0) 
							{
								for (m = 1; m <= foundMatches; m++) 
								{
									thisPrice = thisPrice - eval(advArray[f]["price"]);
									thisPriceExTax = thisPriceExTax - eval(advArray[f]["priceExTax"]);
									thisPriceIncTax = thisPriceIncTax - eval(advArray[f]["priceIncTax"]);
									thisPriceTax = thisPriceTax - eval(advArray[f]["priceTax"]);
								}
							}
						}	
						if (parseInt(advArray[f]["priceType"]) == 4) 
						{
							if (parseFloat(advArray[f]["percentage"]) > 0) 
							{
								for (m = 1; m <= foundMatches; m++) 
								{
									thisOOPrice = thisOOPrice - (thisOOPrice * (eval(advArray[f]["percentage"])/100));
									thisOOPriceExTax = thisOOPriceExTax - (thisOOPriceExTax * (eval(advArray[f]["percentage"])/100));
									thisOOPriceIncTax = thisOOPriceIncTax - (thisOOPriceIncTax * (eval(advArray[f]["percentage"])/100));
									thisOOPriceTax = thisOOPriceTax - (thisOOPriceTax * (eval(advArray[f]["percentage"])/100));
								}
							}
							if (parseFloat(advArray[f]["percentage"]) < 0) 
							{
								for (m = 1; m <= foundMatches; m++) 
								{
									thisOOPrice = thisOOPrice - (thisPrice * (Math.abs(eval(advArray[f]["percentage"]))/100));
									thisOOPriceExTax = thisOOPriceExTax - (thisOOPriceExTax * (Math.abs(eval(advArray[f]["percentage"]))/100));
									thisOOPriceIncTax = thisOOPriceIncTax - (thisOOPriceIncTax * (Math.abs(eval(advArray[f]["percentage"]))/100));
									thisOOPriceTax = thisOOPriceTax - (thisOOPriceTax * (Math.abs(eval(advArray[f]["percentage"]))/100));
								}
							}
							if (parseFloat(advArray[f]["percentage"]) == 0) 
							{
								for (m = 1; m <= foundMatches; m++) 
								{
									thisOOPrice = eval(advArray[f]["price"]);
									thisOOPriceExTax = eval(advArray[f]["priceExTax"]);
									thisOOPriceIncTax = eval(advArray[f]["priceIncTax"]);
									thisOOPriceTax = eval(advArray[f]["priceTax"]);
								}
							}
						}												
					}							
				}
				displayPrice = presentValue(thisPrice,cDP,cPreT,cMidT,cPostT);
				changeContent("priceSpan"+productID,"priceLayer"+productID,displayPrice);
				displayPrice = presentValue(thisPriceExTax,cDP,cPreT,cMidT,cPostT);
				changeContent("priceExTaxSpan"+productID,"priceExTaxLayer"+productID,displayPrice);
				displayPrice = presentValue(thisPriceIncTax,cDP,cPreT,cMidT,cPostT);
				changeContent("priceIncTaxSpan"+productID,"priceIncTaxLayer"+productID,displayPrice);
				displayPrice = presentValue(thisPriceTax,cDP,cPreT,cMidT,cPostT);
				changeContent("priceTaxSpan"+productID,"priceTaxLayer"+productID,displayPrice);
				
				displayPrice = presentValue(thisOOPrice,cDP,cPreT,cMidT,cPostT);
				changeContent("oopriceSpan"+productID,"oopriceLayer"+productID,displayPrice);
				displayPrice = presentValue(thisOOPriceExTax,cDP,cPreT,cMidT,cPostT);
				changeContent("oopriceExTaxSpan"+productID,"oopriceExTaxLayer"+productID,displayPrice);
				displayPrice = presentValue(thisOOPriceIncTax,cDP,cPreT,cMidT,cPostT);
				changeContent("oopriceIncTaxSpan"+productID,"oopriceIncTaxLayer"+productID,displayPrice);
				displayPrice = presentValue(thisOOPriceTax,cDP,cPreT,cMidT,cPostT);
				changeContent("oopriceTaxSpan"+productID,"oopriceTaxLayer"+productID,displayPrice);

			}
			
isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;
			
function changeContent(theDiv,theLayer,newText) {
	if (isNS4){
	   elm = document.layers[theLayer];
	   elm.document.open();
       elm.document.write(newText);
       elm.document.close();

	}
	else if (isIE4) {
	   elm = document.all[theDiv];
	   elm.innerText = newText;
	}
	else if (isIE5) {
	   elm = document.getElementById(theDiv);
		if (elm) {
	   		elm.innerText = newText;
	   	}
	}
	else if (isNS6) {
		var elmw = document.getElementById(theDiv);
    	if (elmw) {
    		elmw.childNodes[0].nodeValue = newText;
    	}	
	}
}			

    function presentValue(value,dp,pt,mt,at) {
        if(value<=0.9999) {
            newPounds='0';
        } else {
            newPounds=parseInt(value);
        }
        dec='1';
        for (var i=1; i<=dp;i++) {
            dec=dec+'0';
        }
        if (value>0) {
            newPence=Math.round((eval(value)+.000008 - newPounds)*(eval(dec)));
        } else {
            newPence=0;
        }
        compstring='9';
        for (var i=1; i <=dp-1;i++) {
            if (eval(newPence) <= eval(compstring)) newPence='0'+newPence;
            compstring=compstring+'9';
        }
        // ###################################################################
        // ##																##
        // ## Money values should be displayed with thousand´s separator.	##
        // ## See comment on function "number_format_cit" in "general.php"  ##
        // ## for details.													##
        // ##																##
        // ###################################################################
        if (dp>0) {
            if (newPence==eval(dec)) { newPounds++; newPence='00'; }
            //ORIGINAL
            //newString=pt+newPounds+mt+newPence+at;
            newString=pt+setThousandsSep(newPounds)+mt+newPence+at;
        } else {
        	//ORIGINAL
            //newString=pt+newPounds+at;
            newString=pt+setThousandsSep(newPounds)+at;
        }
        return (newString);
    }

// ###################################################################
// ##																##
// ## Formats a given money value by setting the thousand´s			##
// ## separator. The separator corresponding to the current locale  ##
// ## (thousandsSep) has to be specified in the including page,		##
// ## PRIOR to the first call of "recalcPrice"!						##
// ##																##
// ###################################################################
function setThousandsSep(numValue) {
	var strValue = numValue.toString();
	var numSeps = Math.floor((strValue.length - 1) / 3);
	var pos = 3;
	
	for( var i = 1; i <= numSeps; i++ ) {
		strValue = strValue.slice(0, strValue.length - pos) + thousandsSep + strValue.slice(strValue.length - pos);
		pos += 4;
	}
	
	return strValue;
}

// The following code was added from includes/head.html
function activate( element )
{
		
	try
	{
    	header = element+'Header';
    	menuX = element+'Menu';
    	listingArea = "listingArea"+element;
    		
    	document.getElementById(header).className += "Inaktiv";
    	document.getElementById(menuX).className = "darkRedNew";
    	document.getElementById(listingArea).style.backgroundColor="#D9D9D9";
    }
    catch( e )
    {
    }
    
    try
    {
    	var jsMenuElement = document.getElementById( "pn" + element );
    	jsMenuElement.firstChild.style.color = "#d90000";
    }
    catch( e )
    {
	}
}

function deactivate( element )
{
	try
	{
    	x = document.getElementById(element);
    	header = document.getElementById(element+'Header');
    	listingArea = "listingArea"+element;
    		
    	s = header.className ;
    	s = s.substring (0, (s.length-7));
    		
    	header.className = s;
    		
    	document.getElementById(listingArea).style.backgroundColor="#ECECEC";
    		
    	menuX = element+'Menu';
    	document.getElementById(menuX).className = "rootSection";
    }
    catch( e )
    {
    }
    
    try
    {
    	var jsMenuElement = document.getElementById( "pn" + element );
    	jsMenuElement.firstChild.style.color = "";
    }
    catch( e )
    {
    }
}

function openPopup(url,titel,w,h,scroll)
{
	// Übergebene Prameter prüfen
	if (!url) return ;
	if (!titel) titel = "Baer_Online";
	if (!w) w = 375;
	if (!h) h = 530;
	if (!scroll) scroll = 0;
	
	// Mitte des Bildschrims ermitteln	
	var left = (screen.width)?(screen.width-w)/2:100;
	var top = (screen.height)?(screen.height-h)/2:100;
	var options = "";
	
	// Übergroße Popups auf die maximale Bildschirmgröße setzen und Schrollbars einblenden
	if (left<1)
	{
		left = 0 ;
		w = (screen.width)?(screen.width):w;
		scroll = 1 ;
	}
	if (top<1)
	{
		top = 0 ;
		h = (screen.height)?(screen.height-56):h; // -56 für Taskleiste
		scroll = 1 ;
	}
	
	// Optionen zusammenbauen
	options = "width="+w+",height="+h ;
	options += ",top="+top+",left="+left ;
	options += ",scrollbars="+scroll ;
	options += ",location=0,menubar=0,personalbar=0,resizable=1,toolbar=0,status=0" ;
	
	// Anzeigen
	popup = window.open(url,titel,options);
	popup.focus();
}

function getElemById(id){
    if(id==null){
        return false;
    }
    else if(document.getElementById){
        return document.getElementById(id);
    }
    else if(document.all){
        return document.all[id];
    }
    else if(document.layers){
        return document.layers[id];
    }
    else return false;
}

function toggleDiv(thisDiv, extra) {
	
	daDiv = getElemById(thisDiv);

	x = getElemById(thisDiv+'3');
	
	headline = getElemById(thisDiv+'2');
	
	header = getElemById(thisDiv+'Header');
	
	subSectionServiceHeadline = getElemById(thisDiv+'Headline');
	
	
	if (daDiv.style.display != "none") {
		//daDiv.className='';
		daDiv.style.display = "none";
		
		//if (x!= null)
		//x.className+='2';
		
		if (headline != null)
			headline.className =(headline.className).substring(0, (headline.className).indexOf('Open'));
		
		
		if (header != null)
			header.className = (header.className).substring(0, (header.className).indexOf('Active'));
		
		if (subSectionServiceHeadline != null)
			subSectionServiceHeadline.className = (subSectionServiceHeadline.className).substring(0, (subSectionServiceHeadline.className).indexOf('Active'));
		
	} else {
		daDiv.style.display = "";
		//daDiv.className='';
		
		//if (x!= null)
		//	x.className= (x.className).substring(0, (x.className.length-1));
		
		if (headline != null)
			headline.className+='Open';
		
		
		if (header != null)
			header.className+='Active';
		
		if (subSectionServiceHeadline != null)
			subSectionServiceHeadline.className+='Active';
		
		self.location.href='#'+thisDiv+"Anchor";
		
		//If the DirectOrder-Box is opened, the input field should gain the focus.
		if( thisDiv == "divDirectOrderBox" ) {
			try {
				document.getElementById("_directOrderProductCode").focus();
			} catch( e ) {}
		}
	}
	
	if( thisDiv == "divLoginBox" && extra == "loginBox" ) {
		try {
			if( daDiv.style.display != "none" ) {
				x.style.borderBottomWidth = "1px";
			} else {
				x.style.borderBottomWidth = "0px";
			}
		} catch( e ) {}
	}
}	

function toggleTabDiv(thisDiv) {
	try {
		daDiv = getElemById(thisDiv);
		daDivImg = getElemById(thisDiv+"Img");
		if (daDiv.style.display != "none") {
			daDiv.style.display = "none";
			//daDivImg.src = "{shop.baseDir}images{labels.baerMisc.i18n-imgpath}webbilder/anmelden/an_kreis_g_re.gif";
			daDivImg.src = /*_shopBaseDir + */"./images" + _imagePath + "webbilder/anmelden/an_kreis_g_re.gif";
		} else {
			daDiv.style.display = "";
			//daDivImg.src = "{shop.baseDir}images{labels.baerMisc.i18n-imgpath}webbilder/anmelden/an_kreis_r_un.gif";
			daDivImg.src = /*_shopBaseDir + */"./images" + _imagePath + "webbilder/anmelden/an_kreis_r_un.gif";
			self.location.href='#'+thisDiv+"Anchor";
			
		}
	}
	catch (e) {}
}	


function showTrolley() {
	//document.getElementById('trolley').style.visibility = "";
	//document.getElementById('pic5').className="leftbordered";
	numberOfFields = 6;
	
}

function menuSetVisible(thisDiv) {
	daDiv = document.getElementById(thisDiv);
	daDivToggle = document.getElementById(thisDiv+"Toggle");
	if (daDiv.style.display != "none") {
		daDiv.style.display = "none";
		//daDivToggle.innerHTML = '<img border="0" src="{shop.baseDir}images{labels.baerMisc.i18n-imgpath}webbilder/navi_links/nl_dreieck_s_re.gif" />';
		daDivToggle.innerHTML = '<img border="0" src="' + _shopBaseDir + 'images' + _imagePath + 'webbilder/navi_links/nl_dreieck_s_re.gif" />';
	} else {
		daDiv.style.display = "block";
		//daDivToggle.innerHTML = '<img border="0" src="{shop.baseDir}images{labels.baerMisc.i18n-imgpath}webbilder/navi_links/nl_dreieck_r_un.gif" />';
		daDivToggle.innerHTML = '<img border="0" src="' + _shopBaseDir + 'images' + _imagePath + 'webbilder/navi_links/nl_dreieck_r_un.gif" />';
		self.location.href='#'+thisDiv+"Anchor";
		
		//SR: what is that? does nothing else than throw exceptions...
		backTimes--;
	}
}	

// the following code was added from top.html

function showit(which){
	try {
		clear_delayhide();
	
		if (which!=-1)
			drawLines (which);
		else
			hideLines ();
	
		thecontent=(which==-1)? "" : submenu[which];
		if (document.getElementById||document.all)
			menuobj.innerHTML=thecontent
		else if (document.layers){
			menuobj.document.write(thecontent)
			menuobj.document.close()
		}
	} catch(e) {}
}

function drawLines(id) {
	for (i = 0; i <numberOfFields; i++)
	{
		var x = document.getElementById("pic"+i);
		var y = document.getElementById("top"+i);
			
		//try {
		//	y.style.backgroundColor = "#FFFFFF";
		//} catch( e ) {}
			
		try {
			/* the borders of the top menu*/
			if (i < id) {
				y.className = "rightbordered";
			} else if (i > id) {
				y.className = "leftbordered";
			}
			
			/* the borders of the dividing line*/
			if(i == (id-1))
			{
				x.className = "bottomrightbordered";
			}
			else if (i == id)
			{
				x.className = y.className = "notbordered";
			}
			else if (i == (id+1))
			{
				x.className = "bottomleftbordered";
			}
			else
			{
				x.className = "bottombordered";
			}
		} catch( e ) {}
	}
	
	//try {
	//	document.getElementById("top" + id).style.backgroundColor = "#D9D9D9";
	//} catch( e ) {}
}

function hideLines(id) {
	for (i = 0; i <numberOfFields ; i++)
	{
		var x = document.getElementById("pic"+i);
		
		//try {
		//	document.getElementById("top" + i).style.backgroundColor = "#FFFFFF";
		//} catch( e ) {}
		
		try {
			x.className="";
		} catch( e ) {}
	}
}

function resetit(e){
	try {
		if (document.all&&!menuobj.contains(e.toElement))
			delayhide=setTimeout("showit(-1)",delay_hide)
		else if (document.getElementById&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
			delayhide=setTimeout("showit(-1)",delay_hide)
	} catch(e) {}
}

function clear_delayhide(){
	try {
	
		if (window.delayhide)
			clearTimeout(delayhide)
	} catch(e) {}
}

function contains_ns6(a, b) {
	try {
		while (b.parentNode)
			if ((b = b.parentNode) == a)
				return true;
		return false;
	} catch(e) {}
}

// The following code was added from includes/left.html
function getBoxStatus(thisBox)
{
	thisBox = getElemById(thisBox);
	if(thisBox.style.display=='none')
	{
		visibility = 1;
	}
	else
	{
		visibility = 0;
	}
	return visibility;
}

function getCookieVal(offset)
{
	var endstr = document.cookie.indexOf (";", offset); 
	if (endstr == -1) 
	endstr = document.cookie.length; 
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie(name)
{
	var arg = name + "="; 
	var alen = arg.length; 
	var clen = document.cookie.length; 
	var i = 0; 
	while (i < clen)
	{
		var j = i + alen; 
		if (document.cookie.substring(i, j) == arg) 
		return getCookieVal (j); 
		i = document.cookie.indexOf(" ", i) + 1; 
		if (i == 0) break; 
	} 
return null;
}

function alrt()
{
	alert(getCookieVal('box_signup_stat'));
}

function SetCookie(name, value)
{
	var argv = SetCookie.arguments; 
	var argc = SetCookie.arguments.length; 
	var expires = (argc > 2) ? argv[2] : null; 
	var path = (argc > 3) ? argv[3] : null; 
	var domain = (argc > 4) ? argv[4] : null; 
	var secure = (argc > 5) ? argv[5] : false; 
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) + 
	((domain == null) ? "" : ("; domain=" + domain)) + 
	((secure == true) ? "; secure" : "");
}

function DeleteCookie (name)
{
	var exp = new Date(); 
	exp.setTime (exp.getTime() - 1); 
	var cval = GetCookie (name); 
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

// The following code was added from includes/boxen/searchfind.html
	function moveIt(DiD)
	{
		Obj_DIV_container = document.getElementById("container");
		Obj_DIV_menu = document.getElementById("menu_" + DiD);
		Obj_DIV_scroller = document.getElementById("scroller");
		Obj_DIV_product = document.getElementById("product_" + DiD);
			
		Obj_DIV_menu_ofst = Obj_DIV_menu.offsetTop;
		Obj_DIV_menu_stop = Obj_DIV_menu.style.top;
		Obj_DIV_scroller_ofst = Obj_DIV_scroller.offsetTop;
		Obj_DIV_scroller_stop = Obj_DIV_scroller.style.top;
		Obj_DIV_product_ofst = Obj_DIV_product.offsetTop + Obj_DIV_container.offsetTop;
		Obj_DIV_product_stop = Obj_DIV_product_ofst + 'px';
				
		negObj_DIV_scroller_ofst = 0 - Obj_DIV_scroller_ofst;				
				
		movePix = Obj_DIV_product_ofst - Obj_DIV_menu_ofst;
		movePix -= negObj_DIV_scroller_ofst;
		movePos = Obj_DIV_scroller_ofst - movePix;
				
		Obj_DIV_scroller.style.top =  movePos + 'px';
	}
	
	function stopIt(DiD)
	{
		//Obj_DIV_scroller = document.getElementById("scroller");
		//Obj_DIV_scroller.style.top =  '0px';
	}

	function smoothscroll(moveto)
	{
		movement = moveto;
		//moveON is true los gehts
		moveON = 1;
		scrollGo(movement);
	}
	
	function scrollGo()
	{
		//objekt holen und eigenschaften auslesen
		Obj_DIV_scroller = document.getElementById("scroller");
		Obj_DIV_scroller_ofst = Obj_DIV_scroller.offsetTop;
		
		Obj_DIV_product1 = document.getElementById("product_1");
		Obj_DIV_product2 = document.getElementById("product_2");
		
		//wenn moveON noch true ist
		if (moveON == 1)
		{	
			if (movement == 'down')
			{
				if (Obj_DIV_scroller_ofst < 0)
				{
					Obj_DIV_scroller_ofst += 9;
				}
				else
				{
					window.status = 'down scroll finished';
					return;
				}
			}
			else
			{
				ObjHeight = Obj_DIV_product2.offsetTop - Obj_DIV_product1.offsetTop;
				stoppoint = ObjHeight * nproducts;
				stoppoint -= screen.availHeight - 88 - 97;
				stoppoint = 0 - stoppoint;
				if (stoppoint < Obj_DIV_scroller_ofst)
				{
						Obj_DIV_scroller_ofst -= 9;
				}
				else
				{
					window.status = 'up scroll finished';
					return;
				}				
			}
			//position setzen
			Obj_DIV_scroller.style.top = (Obj_DIV_scroller_ofst) + 'px';
			//erneut aufrufen uns somit smooth scrollen
			window.setTimeout('scrollGo()', 68);
		} 
		else 
		{ 
			//moveON = false dann abbrechen
			return;
		}
	}
	
	function scrollStop()
	{
		//moveON is jetzt false
		window.status = '';
		moveON = 0;
	}
	
// the following code was added from include/address_fields.html

    function addFirstDeliveryAddr(){
        //try {
            getElemById("delAddressCnt").value = 1;
            getElemById("deliveryAddrToggleLink").href = "javascript:addFirstDeliveryAddr();";
            toggleTabDiv('deliveryAddress');
        //} catch(e){
        //}
        /////var baershopAction = document.{customer.details.form.name}.action + '&addFirstDeliveryAddr=1#deliveryAddressAnchor';
        /////document.{customer.details.form.name}.action = baershopAction;
        /////document.{customer.details.form.name}.submit();
    }

// The following code was added from includes/checkoutstep2content.html
    function step2CheckSubmit(labelSelectBillingAddress, labelSelectDeliveryAddress){
    	
    	if( labelSelectBillingAddress == null ) {
    		labelSelectBillingAddress = "Bitte wählen Sie eine Rechnungsadresse aus!";
    	}
    	if( labelSelectDeliveryAddress == null ) {
    		labelSelectDeliveryAddress = "Bitte wählen Sie eine Lieferadresse aus!";
    	}
    	
    	if(document.orderForm.billingSel.value == 0) {
    		alert (labelSelectBillingAddress);
    		return;
    	} 
    	
    	if(document.orderForm.deliverySel.value == 0) {
    		alert(labelSelectDeliveryAddress);
    		return;
    	}

    	document.orderForm.submit();
    }
    
    function billingselected(e) {
    	//Billing and delivery address selection was moved to the checkout page
    	//document.orderForm.billingSel.value = 1;
    	//document.orderForm.whichBill.value = e;
    	document.checkoutForm.billingSel.value = 1;
    	document.checkoutForm.whichBill.value = e;
    }
    
    function deliveryselected(e) {
    	//Billing and delivery address selection was moved to the checkout page
    	//document.orderForm.deliverySel.value = 1;
    	//document.orderForm.whichDel.value = e;
    	document.checkoutForm.deliverySel.value = 1;
    	document.checkoutForm.whichDel.value = e;
    }

    // the following code was added from contactKatalog.html
	function resetForm(which) {
		
		if(which == 'register')
		{
			//reset inputs
			var inputs = new Array();
			inputs = document.getElementsByTagName('input');
			var obj = null;
			for (i = 0; i < inputs.length; i++)
			{
				try {
					obj = inputs[i];
					if(obj.type == "text")
						obj.value = "";
				} catch(e) {}
			}
			
			//reset selects
			var selects = new Array();
			selects = document.getElementsByTagName('select');
			var obj = null;
			for (i = 0; i < selects.length; i++)
			{
				try {
					obj = selects[i];
					obj.selectedIndex = 0;
				} catch(e) {}
			}
			
		}
		else 
		{
			//reset all textfields!
			i = 1;
			while (true)
			{
				x = getElemById(which+'FormElement'+i);
				if(x == null) break;
				
				x.value="";
				
				i++;
			}
			
			//reset the selects
			i = 1;
			while (true)
			{
				x = getElemById(which+'FormElementSelect'+i);
				if(x == null) break;
				
				x.selected = true;
				
				i++;
			}
		}
		
		
	}

    // the following code was added from section.html
	function MM_checkPlugin(plgIn, theURL, altURL, autoGo) { //v4.0
		var ok = false;
		
		alert("hi");
		
	  	with( navigator ) 
  		if( appName.indexOf('Microsoft') == -1 || (plugins && plugins.length) ) {
    		ok = (plugins && plugins[plgIn]);
  		} else if( appVersion.indexOf('3.1') == -1 ) { //not Netscape or Win3.1
    		if( plgIn.indexOf("Flash") != -1 && window.MM_flash != null ) 
    			ok = window.MM_flash;
    		else if( plgIn.indexOf("Director") != -1 && window.MM_dir != null ) 
    			ok = window.MM_dir;
    		else 
    			ok = autoGo;
    	}
    	
    	return ok;
	}


// the following code was added from product.html	
    	function toggleDesc()
    	{
        	if (getElemById('shortDesc').style.display =='none')
        	{
            		getElemById('shortDesc').style.display = '';
            		getElemById('longDesc').style.display = 'none';
        	}
        	else	
        	{
            		getElemById('shortDesc').style.display ='none';
        		getElemById('longDesc').style.display = '';
        	}
    	}
    	
	
	//Funktionsbeschreibung:
	//	Enter Taste in Formular abfangen...
	//
	function CheckEnter(evt)
	{
		alert("hi");
		//try
		//{
			//Keycode holen		
			var keyCode = document.layers?evt.which:evt.keyCode;
			//wenn keycode nicht 13 ist ok...
	    		if (keyCode != 13)
	    		{
				return true;
	    		}
	    		else
	    		{
	    			return false;
			}
		//}
		//catch(e)
		//{
			//change later to return true to prevent errors
		//	return false;
		//}
	}



// the following code was added from checkoutstep4.html	
           function toggleLink()
           {
           	var x = document.getElementById("link");
           	var y = document.getElementById("linkImg");
           	
           	if (x.disabled == true)
           	{
           		enableLink(x,y);
           		return false;
           	}
           	
           	disableLink(x,y);
           }	
           

           function enableLink(x,y)
           {
       		x.disabled = false;
       		
       		//To make sure that the user can press the "Send Order" button only once,
       		//we disable it after the first click. The function "sendOrder" disables 
       		//the button and then submits the order form.
       		//x.href = "javascript:document.{ordering.form.name}.submit();";
       		x.href = "javascript:sendOrder();";
       		
       		y.src = (y.src).replace('grau','rot');
       		
       		
       		box = getElemById('confirm_checkbox');
       		box.checked = true;
       			
       		
           }
           
           function init() {
           	document.getElementById("link").disabled=true;
           }
           


//function for checkoutstep2:
	function disableRadio(radio) {

	     // If there are multiple items
	     if (radio !== undefined) {
	     	if (radio.length !== undefined && radio.length > 0) 
	     	{
	          var i;
	          for (i = 0; i < radio.length; i++) 
	          {
	          	radio[i].disabled = true;	
	          }
	        }
	      }
         }
         
       	function setSelectedRadios () {
		//set radios
		var x = window.opener.document.orderForm.whichBill;
		var y = window.opener.document.orderForm.whichDel;
		
		if (x.value == 1)
			document.getElementById("tst1").checked = true;
		else if (x.value == 2)
			document.getElementById("tst2").checked = true;
			
		if (y.value == 0)
			document.getElementById("xAid0").checked = true;
		else if (y.value != -1)
			document.getElementById("xAid"+y.value).checked = true;
			
		disableRadio(document.orderForm.xAid);
		disableRadio(document.orderForm.billingAddrNum);
		
		document.getElementById("orderCommentsField").disabled = true;
	}
	

///new functions	
	function makeRed(element) {
		document.getElementById(element).style.color = "#D70000";
	}
	
	function makeGrey(element) {
		document.getElementById(element).style.color = "#9D9D9D";
	}
           
// new wrappers to avoid some js errors in ie5           
	function moveSection_(x)
	{
	 if (typeof moveSection != "undefined") moveSection(x);
	}
	
	function unmoveSection_(x)
	{
	 if (typeof unmoveSection != "undefined") unmoveSection(x);
	}
	
	function moveSection(x)
	{
		activate(x);
	} 
	           
	function unmoveSection(x)
	{
		deactivate(x);
	} 

	function orderProgressDisplayOrderPic( step )
    {
    	if( step < 1 || step > 5 )
    	{
    		return;
    	}
    		
    	var element = document.getElementById( "stepSpacer" + step );
	    var offset  = orderProgressGetOffset( element );
	    var left 	= offset[0];
	    var top     = offset[1];
	    	
	    orderProgressShowOrderPic
	    (
	    	left - 14,
	    	top - 12,
	    	document.getElementById( "orderPic" + step )
	    );
    }
    
    
    function orderProgressDisplayOrderPicDone( step )
    {
    	if( step < 1 || step > 5 )
    	{
    		return;
    	}
    		
    	var element = document.getElementById( "orderStep" + step );
	   	var offset  = orderProgressGetOffset( element );
	   	var left 	= offset[0];
	   	var top     = offset[1];
    
	   	orderProgressShowOrderPic
	   	(
	   		left + element.offsetWidth + 3, 
	   		top - 2, 
	   		document.getElementById( "orderPicDone" + step )
	   	);
	}
    	
    function orderProgressGetOffset( element )
    {
    	var left 	   	   = 0;
	   	var top        	   = 0;
	   	var lastOffsetLeft = 0;
	   	var lastOffsetTop  = 0;

    	do {
    		left 	       += element.offsetLeft;
	   		top		       += element.offsetTop;
	   		lastOffsetLeft = element.offsetLeft;
	   		lastOffsetTop  = element.offsetTop;
	   		element    	   = element.offsetParent;
	   	} while( element != null && ( element.tagName != "BODY" && element.tagName != "HTML" ) );

	   	left -= lastOffsetLeft;
	   	top  -= lastOffsetTop;
	    	
	   	return new Array( left, top );
    }
    	
    function orderProgressShowOrderPic( left, top, element )
    {
    	element.style.left    = left + "px";
	   	element.style.top     = top + "px";
	   	element.style.display = "";
    }
    
    function openHelpPopup( url )
    {
    	var helpPopup = window.open( url, "BaerHelpPopup", "width=600,height=300,left=0,top=0,toolbar=no,status=no,menubar=no,resizable=yes,location=no" );
    	helpPopup.focus();
    }
    
    function showFlashScroller( width, height, scrolltext, bgcolor )
    {
    	if( !bgcolor )
    	{
    		bgcolor = "#ffffff";
    	}
    	
    	document.writeln( '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' );
    	document.writeln( '		codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"' );
    	document.writeln( '		width="' + width + '"' );
    	document.writeln( '		height="' + height + '"' );
    	document.writeln( '		align="middle"' );
    	document.writeln( '		style="margin: 0px 0px 0px 10px; padding: 0px;">' );
		document.writeln( '	<param name="allowScriptAccess" value="always" />' );
		document.writeln( '	<param name="movie" value="flash/scroller.swf?text=' + scrolltext + '" />' );
		document.writeln( '	<param name="quality" value="high" />' );
		document.writeln( '	<param name="bgcolor" value="' + bgcolor + '" />' );
		document.writeln( '	<embed src="flash/scroller.swf?text=' + scrolltext + '"' );
		document.writeln( '		   quality="high"' );
		document.writeln( '		   bgcolor="' + bgcolor + '"' );
		document.writeln( '		   width="' + width + '"' );
		document.writeln( '		   height="' + height + '"' );
		document.writeln( '		   align="middle"' );
		document.writeln( '		   allowScriptAccess="always"' );
		document.writeln( '		   type="application/x-shockwave-flash"' );
		document.writeln( '		   pluginspage="https://www.macromedia.com/go/getflashplayer" />' );
		document.writeln( '</object>' );
    }
   
// 
// Function to display, move and hide tooltips when the user moves the mouse over
// an article in the accessory list
//

/**
 * Contains a reference to the current tooltip element while the mouse pointer
 * is located over an article.
 */
var currentTooltip = null;

/**
 * Displays the tooltip matching the given productId and stores a reference
 * to it in the global variable "currentTooltip".
 */
function showAccessoryTooltip( productId )
{
	var element = document.getElementById( "accessoryInfoPopup" + productId );

	if( element )
	{
		currentTooltip 				 = element;
		currentTooltip.style.left    = "-1000px";
		currentTooltip.style.top	 = "-1000px";
		currentTooltip.style.display = "block";
	}
	else
	{
		currentTooltip = null;
	}
	
	try
	{
		document.getElementById( "accessoryCode" + productId ).style.color = "#D70000";
		document.getElementById( "accessoryName" + productId ).style.color = "#D70000";
	}
	catch( e )
	{
	}
}

/**
 * Displays the tooltip matching the given productId and stores a reference
 * to it in the global variable "currentTooltip".
 */
function showProductTooltip( productId )
{
	var element = document.getElementById( "productInfoPopup" + productId );

	if( element )
	{
		currentTooltip 				 = element;
		currentTooltip.style.left    = "-1000px";
		currentTooltip.style.top	 = "-1000px";
		currentTooltip.style.display = "block";
	}
	else
	{
		currentTooltip = null;
	}
	
	try
	{
		document.getElementById( "productCode" + productId ).style.color = "#D70000";
		document.getElementById( "productName" + productId ).style.color = "#D70000";
	}
	catch( e )
	{
	}
}

/**
 * Hides the current tooltip and sets the global variable "currentTooltip" to
 * null.
 */
function hideAccessoryTooltip( productId )
{
	if( currentTooltip != null )
	{
		currentTooltip.style.display = "none";
		currentTooltip 				 = null;
	}
	
	try
	{
		document.getElementById( "accessoryCode" + productId ).style.color = "#000000";
		document.getElementById( "accessoryName" + productId ).style.color = "#000000";
	}
	catch( e )
	{
	}
}

/**
 * Hides the current tooltip and sets the global variable "currentTooltip" to
 * null.
 */
function hideProductTooltip( productId )
{
	if( currentTooltip != null )
	{
		currentTooltip.style.display = "none";
		currentTooltip 				 = null;
	}
	
	try
	{
		document.getElementById( "productCode" + productId ).style.color = "#000000";
		document.getElementById( "productName" + productId ).style.color = "#000000";
	}
	catch( e )
	{
	}
}

/**
 * Updates the position of the current tooltip if the user moves the mouse.
 */
function updateProductTooltip( e )
{
	if( currentTooltip != null )
	{
		var scrollLeft = 0; // the amount in pixels, the content in the window is scrolled to the right.
		var scrollTop  = 0; // the amount in pixels, the content in the window is scrolled downwards.
		
		if( document.documentElement && document.documentElement.scrollTop )
		{
			// IE 6 in strict mode
			scrollLeft = document.documentElement.scrollLeft;
			scrollTop  = document.documentElement.scrollTop;
		}
		else if( document.body )
		{
			// IE 6 in non strict mode and all other IE's
			scrollLeft = document.body.scrollLeft;
			scrollTop  = document.body.scrollTop;
		}
		
		var x = ( document.all ) ? window.event.x + scrollLeft : e.pageX;
		var y = ( document.all ) ? window.event.y + scrollTop : e.pageY;
		
		x -= 220;
		y -= 70;
		
		currentTooltip.style.left = ( x + 20 ) + "px";
		currentTooltip.style.top  = y + "px";

		alignProductTooltip( x, y, scrollLeft, scrollTop );
		
		var tooltipLeft = parseInt( currentTooltip.style.left );
		var tooltipTop  = parseInt( currentTooltip.style.top );
		
		if( tooltipTop < 0 )
		{
			currentTooltip.style.width = ( currentTooltip.clientWidth + 100 ) + "px";
			alignProductTooltip( x, y, scrollLeft, scrollTop );
		}
	}
}

function alignProductTooltip( x, y, scrollLeft, scrollTop )
{
	if( currentTooltip != null )
	{
		var tooltipLeft		 = parseInt( currentTooltip.style.left ) + 220;
		var tooltipRight     = tooltipLeft + currentTooltip.offsetWidth;
		var viewWidth		 = ( document.body.scrollWidth > document.body.offsetWidth ) ? document.body.scrollWidth : document.body.offsetWidth;
		var viewOffsetWidth  = viewWidth + ( ( document.all ) ? scrollLeft : window.pageXOffset );

		if( tooltipRight > viewOffsetWidth )
		{
			tooltipLeft = x - 20 - ( tooltipRight - tooltipLeft );
		
			if( tooltipLeft >= 0 )
			{
				currentTooltip.style.left = tooltipLeft + "px";
			}
		}
		
		var tooltipTop    	 = parseInt( currentTooltip.style.top ) + 70;
		var tooltipBottom 	 = tooltipTop + currentTooltip.offsetHeight;
		var viewHeight    	 = ( document.body.scrollHeight > document.body.offsetHeight ) ? document.body.scrollHeight : document.body.offsetHeight;
		var viewOffsetHeight = viewHeight + ( ( document.all ) ? scrollTop : window.pageYOffset );

		if( tooltipBottom > viewOffsetHeight )
		{
			tooltipTop 				-= ( tooltipBottom - viewOffsetHeight ) + 70;
			currentTooltip.style.top = tooltipTop + "px";
		}
	}
}