			/*

			var log = {
			  toggle: function() {},
			  move: function() {},
			  resize: function() {},
			  clear: function() {},
			  debug: function() {},
			  info: function() {},
			  warn: function() {},
			  error: function() {},
			  profile: function() {}
			};
			*/

			function toggle(id){
				alert('toggle');
			/*	var el = document.getElementById(id);
				var display = el.style.display;

				if(display == 'block'){
				 	el.style.display = 'none';
				}else{
				 	el.style.display = 'block';
				}
				*/

			}

			function show(id){
				var el = document.getElementById(id);
				var display = el.style.display;
				el.style.display = 'block';
			}



			function isBrowser(){
					/*  Autor, Entwicklung 2003-2008 Kristof Lipfert Duesseldorf    */
					/*  Version 20080522                                            */

					check=[
					['window.postMessage',
					 'window.XMLHttpRequest&&(document.postMessage||window.external)',
					 'document.compatMode',
					 '(document.detachEvent||document.contentType)'
					 ],
					['window.execScript',
					'window.pkcs11',
					'window.opera',
					  'window.navigator&&window.navigator.vendor'],
					[
						['IE-8','FF-3','Op-9.5','KDE?'],
					 	['IE-7','FF-2','Op-9','KDE?'],
					 	['IE-6','FF-1.5','Op-8','KDE/Safari-3'],
					 	['IE-5x','NN 7','Op-7','KDE/Konqu.-3']]];
					var j; var b;
					for(n=0;n<check[1].length;n++)
					{
							if(!eval(check[1][n])==0)
								b=n;
					}
					for(n=check[0].length;n>-1;n--)
					{
						if(!eval(check[0][n])==0)
							j=n;
					}
					var test = (j>-1&&b>-1)?check[2][j][b]:'Älterer Browser o. unbekannt.';
					if(test == 'IE-6'){
						return false;
					}
					return true;




			}






			function openWindow (strUrl, name, width, height, scroll)
			{
				if(isShopOnCD()){
					if((name == 'print') || (name == 'bild')){
						if(strUrl.lastIndexOf(".htm") < 0){
							strUrl = strUrl + '.htm';
						}
					}
				}


				features  = "resizeable=1,location=0,directories=0,status=1,menubar=0,toolbar=0,scrollbars=";
				features += (scroll ? "1" : "0");
				features += ",width=" + width + ",height=" + height;
				window.open(strUrl, name, features);
			}


			function isShopOnCD(){
				return false;
			}

			function openWindowPDF (strUrl, name, width, height, scroll){
				window.open(strUrl, name, '');
			}


			function MM_jumpMenu (targ, selObj, restore)
			{
			  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
			  if (restore) selObj.selectedIndex = 0;
			}

			function openBasketWindow (qty, pid, strUrl, name, width, height, scroll)
			{

				if(qty == 0){qty = 1;}
				if (isNaN(qty) == true){
					qty = 1;
				}

				var hlp = parent.frames['Navigation'].cart.basket.value;
				var hlpstr = ';' + pid + '-';
				var posItem = hlp.indexOf(hlpstr);
				if(posItem >= 0){
					var datei = 'intobasket';
					datei += '1';
					datei += '.';
					datei += 'h';
					datei += 'tm';
					openWindow(datei, name, 275, 192, false);
				}else{
					hlp += ';';
					hlp += pid;
					hlp += '-';
					hlp += qty;
					hlp += ';';
					parent.frames['Navigation'].cart.basket.value = hlp;
					var datei = 'intobasket';
					datei += '.';
					datei += 'h';
					datei += 'tm';
					openWindow(datei, name, 275, 192, false);
				}
			}








	function openBasketWindowServer(qty, pid, strUrl){

		var link = strUrl + '?pid=' + pid + '&qty=' + qty + '&source=add';


		window.location.href = link;
	}


	function openBasketWindowCD(qty, pid, strUrl){
		var myUrl = document.URL;
		var Suche = myUrl.indexOf("shop");
		var link;
		if(Suche > 0){
				link = 'basketCD.php?pid=' + pid + '&qty=' + qty + '&source=add';
		}else{
				link = 'basketCD.php?pid=' + pid + '&qty=' + qty + '&source=add';
		}
		window.location.href = link;
	}

	function changeVersion(myUrl, version) {

		var url, v;
		if( version == "metric") {
			v = "v=0";
		}
		else {
			v = "v=1";
		}

		myUrl = 'index.php';



		var Suche = myUrl.indexOf("v=");
		if( Suche > 0 ) {
			var suche2 = myUrl.indexOf("?v=");
			tmp = myUrl.substring(0,Suche-1) + myUrl.substring(Suche+3);
			if( suche2 > 0 ) {

				url = myUrl.substring(0,Suche-1) + '?' + v + myUrl.substring(Suche+3);
			}
			else {
				url = tmp + '&' + v;
			}
		}
		else {
			var suche3 = myUrl.indexOf("?");
			if( suche3 > 0 ) {
				url = myUrl + '&' + v;
			}
			else {
				url = myUrl + '?' + v;
			}
		}



		//return;
		window.location.href = url;




	}
	function changeLang(myUrl, lang) {
		//var myUrl = document.URL;

		var url, l;
		l = "L="+lang;
		if(myUrl.indexOf("search.php") > -1){
			url = 'index.php?' + l;
			window.location.href = url;
			return;
		}

		var Suche = myUrl.indexOf("L=");
		if( Suche > 0 ) {
			var suche2 = myUrl.indexOf("?L=");
			tmp = myUrl.substring(0,Suche-1) + myUrl.substring(Suche+4);
			if( suche2 > 0 ) {
				url = myUrl.substring(0,Suche-1) + '?' + l + myUrl.substring(Suche+4);
			} else {
				url = tmp + '&' + l;
			}
		}
		else {
			var suche3 = myUrl.indexOf("?");
			if( suche3 > 0 ) {
				url = myUrl + '&' + l;
			} else {
				url = myUrl + '?' + l;
			}
		}

		window.location.href = url;
	}


	function updateBasket(qty, pid, strUrl){
		var link = strUrl + '?pid=' + pid + '&qty=' + qty + '&source=upd';
		window.location.href = link;
//		var newQuantity = number;
//
//		var hasError = false;
//
//		if (newQuantity.indexOf(',') > 0){
//			hasError = true;
//		}
//
//		if (newQuantity.indexOf('.') > 0){
//			hasError = true;
//		}
//
//		if (isNaN(newQuantity) == true){
//			hasError = true;
//		}
//
//		if(hasError == false){
//			var basketOld = parent.frames['Navigation'].cart.basket.value;
//
//			var searchString = ';' + pid + '-';
//
//			var basketNewFirst = basketOld.substring(0 , basketOld.indexOf(searchString));
//
//			var tmp = new Number(basketOld.indexOf(searchString)) + new Number(searchString.length);
//			var basketNewEndTemp = basketOld.substring(tmp);
//			var basketNewEnd = basketNewEndTemp.substring(basketNewEndTemp.indexOf(';')+1);
//
//			var basketNew = basketNewFirst + searchString + newQuantity + ';' + basketNewEnd;
//
//			parent.frames['Navigation'].cart.basket.value = basketNew;
//			parent.frames['Navigation'].cart.submit();
//		}else{
//			alert("Please enter a valid number!");
//		}
	}


	function deleteBasketItem(pid, strUrl){
		var link = strUrl + '?pid=' + pid + '&source=del';
		window.location.href = link;

//		var basketOld = parent.frames['Navigation'].cart.basket.value;
//		var searchString = ';' + pid + '-';
//		var basketNewFirst = basketOld.substring(0 , basketOld.indexOf(searchString));
//		var tmp = new Number(basketOld.indexOf(searchString)) + new Number(searchString.length);
//		var basketNewEndTemp = basketOld.substring(tmp);
//		var basketNewEnd = basketNewEndTemp.substring(basketNewEndTemp.indexOf(';')+1);
//		var basketNew = basketNewFirst + basketNewEnd;
//		parent.frames['Navigation'].cart.basket.value = basketNew;
//		parent.frames['Navigation'].cart.submit();
	}


		
	function sendBasket(strSource, strOrderType, strLink){
		/* Bislang gibt es keine AGBs, die akzeptiert werden m�ssen
		if(window.document.forms.fbasket.agb.checked == false){
			var div = document.getElementById('diverror');
			div.style.display = 'block';
			return;
		}
		*/

		// Checken ob "Purpose of Request" ausgew�hlt wurde
		/*
		var fPurposeOfReq = document.getElementById('field_purposeRequest');
		if(fPurposeOfReq.value == 'nothing'){
			var div = document.getElementById('error_purposeOfReq');
			div.style.display = 'block';
			return;
		}
		*/
		
	
		if(strSource == 'creditcard' || strSource == 'advancepayment' || strSource == 'quotation'){
			
			var totalprice = $('TOTALPRICE').value;
			
			if(totalprice  <= 0 ){
				
				jQuery.alerts.dialogClass = 'jquerydialog'; // set custom style class
				jQuery.alerts.overlayOpacity=  0.70;               // transparency level of overlay
				jQuery.alerts.overlayColor = '#000';               // base color of overlay
				jQuery.alerts.okButton = 'Yes'; // set custom style class
				jQuery.alerts.cancelButton = 'No'; // set custom style class
				jAlert('You have only "on demand" items in your cart. We will send you a quotation upon request. Please click to continue.', 'Please note:', function(r) {
						if(r){				
										
						window.document.forms.fbasket.source.value = strSource;
						window.document.forms.fbasket.submit();
										
						}
				});
				
				
				return;
			}
			
			if(totalprice < 150){
				
				jQuery.alerts.dialogClass = 'jquerydialog'; // set custom style class
				jQuery.alerts.overlayOpacity=  0.70;               // transparency level of overlay
				jQuery.alerts.overlayColor = '#000';               // base color of overlay
				jQuery.alerts.okButton = 'Yes'; // set custom style class
				jQuery.alerts.cancelButton = 'No'; // set custom style class
				jAlert('Sorry, the minimum order value is 150.00 €.', 'Sorry', function(r) {
						if(r){				
										
						}
				});
				
				
				return;
			}
			
			value = $('agbcheck').checked;					
			if(value == null ||value == false || value=='' || value == undefined){
				error = 'You have to accept the Terms & Conditions.';
				jQuery.alerts.dialogClass = 'jquerydialog'; // set custom style class
				jQuery.alerts.overlayOpacity=  0.70;               // transparency level of overlay
				jQuery.alerts.overlayColor = '#000';               // base color of overlay
				jQuery.alerts.okButton = 'Yes'; // set custom style class
				jQuery.alerts.cancelButton = 'No'; // set custom style class
				jAlert(error, 'Terms & Conditions', function(r) {
						if(r){				
										
						}
				});
				
				
				return;
			
			
			}
			
		
			window.document.forms.fbasket.source.value = strSource;
			window.document.forms.fbasket.submit();
			
		}else	if(strSource == 'mail')
		{
			window.document.forms.fbasket.source.value = strSource;
			window.document.forms.fbasket.submit();
		}
		else if (strSource == 'preview')
		{
			if (document.getElementById('field_ta_note4articles') != undefined) {
				var note4articles = document.getElementById('field_ta_note4articles').value;
				note4articles = note4articles.replace(/\n/g, '<br/>'); //alle Zeichen ersetzen
				window.document.forms.fbasket.basketnote4articles.value = note4articles;
			}
			if (document.getElementById('field_ta_note4parts') != undefined) {
				var note4parts = document.getElementById('field_ta_note4parts').value;
				note4parts = note4parts.replace(/\n/g, '<br/>'); //alle Zeichen ersetzen
				window.document.forms.fbasket.basketnote4parts.value = note4parts;
			}
			window.document.forms.fbasket.submit();
		}
		else
		{
			var link = strLink;
			link += '&spring=fax&ordertype=' + strOrderType;
			link += '&' + linkPartNote4Articles;
			link += '&' + linkPartNote4Parts;
			openWindow(link, 'fax', 690, 600, true);
		}
	}

	function changeBasket(strUrl) {
		var link = strUrl;
		window.location.href = link;
	}


	function openSubCategory(pgid, strUrl){
		var link;
		var index = strUrl.indexOf("&pgid=");
		if( index > 0 ) {
			tmp1 = strUrl.substring(0,index);
			tmp2 = strUrl.substring(index+5);

			index2 = tmp2.indexOf("&");

			if( index2 > 0 ) {
				tmp3 = tmp2.substring(index2);
				link = tmp1 + tmp3 + '&pgid=' + pgid;
			}
			else {
				link = tmp1 + '&pgid=' + pgid;
			}
		}
		else {
			link = strUrl + '&pgid=' + pgid;
		}
		window.location.href = link;
	}

	function update(id,value){

		document.getElementById(id).value = value;

	}

	function updateP(id,value){

		document.getElementById(id).value = value;
	}

	function repairValueIfBroken(value){

		value = value.replace(/,/g, '.');

		if(isNaN(value)){

			value=0;
		}



		return value;
	}


	function cel2far (cel){
		cel = repairValueIfBroken(cel);
		return Math.round((cel*1.8) + 32 );
	}

	function far2cel(far){

		far = repairValueIfBroken(far);

		return Math.round(( (far-32) * (5/9.0) ));
	}

	function inch2mm(inch){
		inch = repairValueIfBroken(inch);
		var faktor = 25.400;

		return Math.round(inch * faktor*1000) / 1000;
	}

	function mm2inch(mm){

		mm = repairValueIfBroken(mm);
		faktor = 25.400;
		return Math.round(mm / faktor * 1000) / 1000;

	}

	function ms2fs(ms){
		ms = repairValueIfBroken(ms);
		faktor = 3.281;

		return  roundSDZ((ms * faktor), 3);
	}

	function fs2ms(fs){

		fs = repairValueIfBroken(fs);
		faktor = 0.305  ;
		return  roundSDZ((fs * faktor), 3);
	}



function psi2mpa(psi){
		psi = repairValueIfBroken(psi);
		faktor = 0.006894759086775369;

		return roundSDZ((psi * faktor), 3);
	}

	function mpa2psi(mpa){

		mpa = repairValueIfBroken(mpa);
		faktor = 145.0377 ;
		return roundSDZ((mpa * faktor), 3);
	}



function roundSDZ(zahl,n_stelle){
   n_stelle = (n_stelle == "" || n_stelle == 0 ? 1 : Math.pow(10,n_stelle));

   zahl = Math.round(zahl * n_stelle) / n_stelle;

   return zahl;
}




	function ajaxExtendedSearch(divID, txtID, propertyID, tgrpid, currentValue, url,formularname)
	{
		
		if(formularname == ''|| formularname == undefined)		
			formularname = "f_param";
			
		var formular = document.getElementById(formularname);

		var parsAdd = getAllFilledSearchFields(formular);

		ExtendedSearch_hideOther();
		var div = document.getElementById(divID);
		ExtendedSearch_remember(divID);
		div.style.display ='block';
		//if(div.innerHTML.indexOf('warten.gif') == -1){
		//	return ExtendedSearch_suggestionShow(divID, txtID);
		//}
		//div.innerHTML = '<img src="img/warten.gif" /><span style="color:#23A0B4;">&nbsp;[[_LOADING]]</span>';

		if(url == ''|| url == undefined)		
			url = "ajax.php";
		
		var pars = url + "?propertyID=" +propertyID + "&tgrpid=" + tgrpid + "&value=" + currentValue + parsAdd;
		new Ajax.Updater(div, url,
		{
			method: "post",
	    	parameters: pars
		});
	}


	
function trim (str) {
 return str.replace(/[\n\r]/g, '').replace(/ +/g, ' ').replace(/^\s+/g, '').replace(/\s+$/g, '');
} 

	function getAllFilledSearchFields(formular)
	{
		var pars = "";
		for (var i=0; i<formular.length; i++)
		{
			if (((formular.elements[i].type == "text") || (formular.elements[i].type == "hidden")) && (formular.elements[i].value != "")){
				if(formular.elements[i].name.startsWith("prop") ||  formular.elements[i].name.startsWith("oper") ||  formular.elements[i].name.startsWith("pgid")){
					pars += "&" + formular.elements[i].name + "=" + formular.elements[i].value;
				}
			}
		}
		return pars;
	}


	function ExtendedSearch_suggestionSelect(textfield, value_encoded, option_desc,  divID, hiddenfieldID)
	{

		$(textfield).value = unescape(option_desc);
		$(hiddenfieldID).value = unescape(value_encoded);
		var div = document.getElementById(divID);
		var txt = document.getElementById(textfield);
		txt.blur();
		div.style.display ='none';
	}




	function ExtendedSearch_suggestionHide (div_suggestion)
	{
		$(div_suggestion).hide();
	}

	function ExtendedSearch_hideOther(){
			var hf = document.getElementById('ex-search-reminder');
			if(hf.value.length == 0)
				return;
			if(hf.value.indexOf(';') == -1){
				var div = document.getElementById(hf.value);
				div.hide();
				hf.value = '';
			}
	}


	function ExtendedSearch_remember(divID){
		var hf = document.getElementById('ex-search-reminder');
		hf.value = divID;

	}

function hideShowElement(el){
	
	var s = $(el);
	
	if(s.style.display=='block')
		s.style.display='none';
	else
		s.style.display='block';
}

function ExtendedSearch_IE6(textfield, div_suggestion){

	$(textfield).onkeydown = function (event) {
			event = event || window.event;
			switch(event.keyCode) {
				case 8:
				case 46:
				case 53:
				case 27:
					$(textfield).value = '';
					return false;
				case  9:
					$(div_suggestion).hide();
				break;

			}
		}
		return false;

}


function ExtendedSearch_suggestionShow (div_suggestion, textfield)
{
	ExtendedSearch_remember(div_suggestion);
	if(!isBrowser())
		return ExtendedSearch_IE6(textfield, div_suggestion);

	if (ExtendedSearch_suggestionSuggest(div_suggestion, textfield))
	{

		ExtendedSearch_suggestionDiv = div_suggestion;
		ExtendedSearch_suggestionTextfield = textfield;

		$(textfield).onkeydown = function (event) {
			event = event || window.event;
			switch(event.keyCode) {
				case 13: ExtendedSearch_suggestionSelectHighlighted(); break;
				case 38: ExtendedSearch_suggestionHighlight(false);    break;
				case 40: ExtendedSearch_suggestionHighlight(true);     break;

			}
		}
		$(div_suggestion).show();

	}
	/* else {
		ExtendedSearch_suggestionShow(div_suggestion);
	}
	*/
}




function ExtendedSearch_suggestionSuggest (div_suggestion, textfield)
{
	//alert(div_suggestion);
//	var list = $(div_suggestion).firstDescendant().firstDescendant().childElements();
//sug-[[[ATTRIBUTEID]]]
	var divsug = div_suggestion.replace('div-', 'sug-');


	var list = $(divsug).firstDescendant().childElements();
	var foundSomething = false;

	//if ($(textfield).value.length == 0 && list.length > 10) return false;

	var needle = new String($(textfield).value);

	var counter = 0;
	for (var i = 0; i < list.length; i++)
	{
		var haystack = new String(list[i].firstDescendant().innerHTML);


		if ((haystack.substring(0, needle.length) == needle) || (needle.length == 0)) {
			list[i].show();
			foundSomething = true;
			counter++;
		} else {
			list[i].hide();
		}
	}



	return foundSomething;
}

function ExtendedSearch_suggestionSelectHighlighted ()
{
	var list = $(ExtendedSearch_suggestionDiv).firstDescendant().childElements();
	for (var i = 0; i < list.length;	i++)
	{
		if (list[i].hasClassName('current')) {
			eval(list[i].firstDescendant().readAttribute('onmousedown'));
			break;
		}
	}
}



function ExtendedSearch_suggestionHighlight (down)
{

	var list = $(ExtendedSearch_suggestionDiv).firstDescendant().childElements();
	var nextIsCurrent = false;
	var noneIsSelected = true;
	for (
		var i = down ? 0 : list.length - 1;
		(down && i < list.length) || (!down && i >= 0);
		i += down ? 1 : -1
	) {
		// ausgeblendete überspringen
		if (list[i].getStyle('display') == 'none') {
			list[i].removeClassName('current');
			continue;
		}
		// wenn dieser der aktuelle ist, muss der nächste Markiert werden
		if (list[i].hasClassName('current')) {
			list[i].removeClassName('current');
			nextIsCurrent = true;
			continue;
		}
		// den nächsten markieren
		if (nextIsCurrent) {
			list[i].addClassName('current');
			nextIsCurrent = false;
			noneIsSelected = false;
		}
	}
	// wenn gar nichts ausgewählt ist, den ersten auswählen
	if (noneIsSelected || nextIsCurrent) {
	for (
		var i = down ? 0 : list.length - 1;
		(down && i < list.length) || (!down && i >= 0);
		i += down ? 1 : -1
		) {
			if (list[i].getStyle('display') != 'none') {
				list[i].addClassName('current');
				break;
			}
		}
	}
}


function checkEnter(event,elid){
	
	event = event || window.event;
	
	if(elid == null || elid == '' || elid == 'undefined')
		elid = '#basketbutton';
	
	switch(event.keyCode) {
				case 13: jQuery(elid).click(); return false;
	}
	
	return true;
}

