function getCookie( check_name ) {

	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return 0;
	}
}
function setCookie( name, value, expires, path, domain, secure ) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}
function generateGuid() {
	var result, i, j;
	result = '';
	for(j=0; j<32; j++)	{
	    if( j == 8 || j == 12|| j == 16|| j == 20)
	        result = result + '-';
	        i = Math.floor(Math.random()*16).toString(16).toUpperCase();
	        result = result + i;
	    }
	// strip result
    var ergebnis = result.replace(/-/g, '');
    var rueckgabe = ergebnis.slice(0,17);
	return rueckgabe;
}
function getPAN () {
	var oldPAN = jQuery("#zoombeschreibung .artikelnr").html();
    var Ausdruck = /(.*):\s(.*)/g;
    Ausdruck.exec(oldPAN);
    var pan = RegExp.$2;
    return pan;
}
function switchPAN (newPAN) {
	var oldPAN = jQuery("#zoombeschreibung .artikelnr").html();
  var newContent = oldPAN.replace(/(\D*)(\d*)/, '$1'+newPAN);
  var newNumber = newContent.replace(/\D*/, '');
	jQuery("#zoombeschreibung .artikelnr").html(newContent);
	jQuery("#innerPan").attr({value: newNumber});
}
function parseMoney (strValue) {
	
	// console.log(strValue);
	//var strValue;
	var zw = strValue; //value.replace(/,/g, ".");
  if (strValue < 1000) {
  	//console.log(zw);
  	var ret;
  	if (zw != null) {
  		ret = zw.replace(/\./g, ",");
  	} else {
  		// console.log(strValue);
  	}
    return ret;
  }
  else {
    var zw2 = zw.replace(/(\d*)(\d{3})\.(\d{2})/g, '$1.$2,$3');
    return zw2;
  }
  return strValue;
  
}
function calc () {

	// absolute pfade!
	var host = 'http://'+window.location.host;
	var complete = 1;
	var defaultDeliveryTime = jQuery("#products_deliverytimes_name").attr("title");
	
	// basisPreis vorbereiten
	var basisPreis = jQuery(".produktoptionen").find("#basispreis").html();
	//basisPreis = basisPreis.replace(/\./g, "");
	basisPreis = Number(basisPreis.replace(/,/g, ".")).toFixed(2);
	var neuGesamt = basisPreis;
	// pan vorbereiten
	var pan = jQuery(".produktoptionen").find("#panbase").html();
	var basepan = pan;
 	// products_id vorbereiten
 	var products_id = jQuery("#products_id").html();
 	// language vorbereiten
	var lang = getCookie('nisLang');
	// loop options
	var variP = new Array ();;
	
	jQuery(".produktoptionen select option:selected").each(function () {
   	var selectedValue = jQuery(this).val();
		if (selectedValue == 'XXXYYY') {
			// incomplete
			complete = -1;
			pan += "00";
			jQuery("#werktage .mwst").html(defaultDeliveryTime);
			//console.log('reset formular: ' + defaultDeliveryTime);
		}
		else {
			// Preis berechnen
			var partz = selectedValue.split(";");
      neuGesamt = (Number(neuGesamt) + Number(partz[2])).toFixed(2);
			// pan erweitern
			variP[partz[3]] = partz[1]; 
			//pan += partz[1];
		}
	});

  // vollstaendig ?
  if (complete > 0) {

		variP.shift(); // console.log(variP);

		pan = basepan + variP.join("");

  	// display new money value
    var neuGesamtDisplay = parseMoney(neuGesamt);
    jQuery("span").find("#jsPrice").html(neuGesamtDisplay);

    // show order button
  	jQuery("#orderButton").attr({src: "/nolte.internet/shop/images/"+lang+"/detail_img_bestellen.gif"});

  	// pan erweitern
  	if (pan.length < 19) {
  		for (var i=pan.length; i < 19; i++) {
  			pan += "0";
  		}
  	}

  	// pan aktualisieren
  	switchPAN(pan);

  	// Lieferzeit holen
    if (products_id != null) {
    	
				var deliveryTimeText = jQuery("#werktage .mwst").html();
				var orderButtonText = jQuery("#orderButton").find("input").attr("title");	    	
 		 		jQuery("#werktage .mwst").html('<img src="/nolte.internet/shop/images/ajax_indicator.gif">');
    		jQuery("#orderButton").html('<img src="/nolte.internet/shop/images/' + lang + '/detail_img_bestellen.gif">');

        var url = host+'/cgi-bin/nolte.internet/shop/scripts/shop_ajax.pl';
        var returnValue = jQuery.ajax({
            type: "GET",
            url: url,
            data: "action=getDeliveryTime&language="+lang+"&pan="+pan+"&products_id="+products_id,
            dataType: 'text',
            async: true,
            error: function(event, request) {
                // do something on error
            },
            success: function(msg){
            	var result = JSON.parse(msg);
            	//console.log('result: '+result.deliverytimes_name );
            	if (result.deliverytimes_name) {
                jQuery("#werktage .mwst").html(result.deliverytimes_name);
                jQuery("#orderButton").html('<input type="image" title="'+orderButtonText+'" src="/nolte.internet/shop/images/'+lang+'/detail_img_bestellen.gif"/>');
            	}
            	else {
                jQuery("#werktage .mwst").html(deliveryTimeText);
                jQuery("#orderButton").html('<input type="image" title="'+orderButtonText+'" src="/nolte.internet/shop/images/'+lang+'/detail_img_bestellen.gif"/>');           		
            	}
            }
        });
        var oldDelivIcon = jQuery("#werktage img").attr("src");
    }

      // switch field value LT_PRICEFROM
      var currentVal = jQuery("#jsPricePrefix").html();
      var url = host+'/cgi-bin/nolte.internet/shop/scripts/shop_get_cart.pl';
      var returnValue = jQuery.ajax({
          type: "GET",
          url: url,
          data: "action=getText&language="+getCookie('nisLang'),
          dataType: 'text',
          async: false,
          success: function(msg){
              var result = JSON.parse(msg);
              jQuery("#jsPricePrefix").html(result.LT_PRICESTD);
          }
      });
  }
  else {
  	
  	switchPAN (jQuery("#panbase").html());
  	// display new money value
    var neuGesamtDisplay = parseMoney(neuGesamt);
    jQuery("span").find("#jsPrice").html(neuGesamtDisplay);

    // empty pan field
    jQuery("#innerPan").attr({value: ''});
  }
}
function showCountry () {
	if (jQuery("#moreCountry").css('display') == 'none') {
		jQuery("#moreCountry").css({'display':'table'})
	}
	return false;
}
function hideCountry () {
	if (jQuery("#moreCountry").css('display') != 'none') {
		jQuery("#moreCountry").css({'display':'none'})
	}
	return false;
}
function do_search () {

	var searchItemFound = jQuery("#searchFor").val();
	var searchItem = searchItemFound.replace(/\s\[\d*\]/g, "");
	searchItem = searchItem.replace(/&/g, "");		
	searchItem = searchItem.replace(/\s{2}/g, " ");		
	
	
	// console.log(searchItem);
	window.location.href = "/cgi-bin/nolte.internet/shop/shop.cgi?func=search_new&wkid=&sbeg="+searchItem;
}
function makeSessionCookies (clickurl, country, hosturl, affiliate, docReferrer) {
	
	var zanpid;
	var result = clickurl.match(/\zanpid=(\d+)/g);
	if (result) {
		result = ""+result+"";
		result.match(/zanpid=(\d+)/g);
		zanpid = RegExp.$1;
	}
  var url = hosturl+'/cgi-bin/nolte.internet/shop/scripts/shop_ajax.pl';
  var dataStrg = "action=createSession&l="+country;
  if (affiliate) {
  	dataStrg = dataStrg + "&pid="+affiliate;
  }
  if (zanpid) {
  	dataStrg = dataStrg + "&zanpid="+zanpid;
  }
  dataStrg = dataStrg + "&referrer="+docReferrer;
  // console.log(dataStrg);
  var returnValue = jQuery.ajax({
    type: "GET",
    url: url,
    data: dataStrg,
    dataType: 'text',
    async: true,
    success: function(msg){
    	// console.log( msg );
    	var result = JSON.parse(msg);
    	// console.log(result);
    	if (result.error) {
    	}
			// session cookie
			// console.log('createSession cookie');
			if (result.nisSession) {
	    	setCookie('nisSession', result.nisSession, '', "/");
	    	sessionCookie = result.nisSession;				
			}
    	// partner cookie pid
    	if (result.nisPID) {
    		// console.log('set nisPID !!!');
    		setCookie( 'nisPID', '0', -1, '/' );
    		var affiliateCookie = getCookie('nisPID');
    		var nisPID_validTime = result.nisPID_validTime;
    		if (!affiliateCookie) {
    			setCookie('nisPID', result.nisPID, nisPID_validTime, "/");
    		}
    	}
    }
  });	
	
}

function tooltip(){	
	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		

	var langNotice = new Array();
	langNotice['de'] ="<p><strong>Besonderer Hinweis zu den in 24 Stunden versandfertigen Produkten:</strong></p><p>24 h / 48 h Lieferservice bedeutet, dass dieser Artikel entweder bei uns oder beim Hersteller ab Lager vorrätig ist und innerhalb von 24 h / 48 h zum Versand übergeben wird. Der Versand per UPS dauert 1 bis max. 3 Werktage, sperrige Güter werden von uns per Spedition mit einer Lieferzeit von 4-7 Werktagen versendet.</p>";
	langNotice['en'] ="<p><strong>Particular reference to our 24/48 hours delivery times:</strong></p><p>24/48 hours delivery service means that the article is stored from stock and that it can be consigned to our logistic centre within 24/48 hours.</p><p>Normally the dispatch per UPS will take 1-3 days. Voluminous goods need about 4-7 days.</p>";
	langNotice['fr'] ="<p><strong>Note spéciale concernant notre livraison en 24/48heures:</strong></p><p>Le service de livraison en 24h/48h implique que l’article est disponible en stock soit chez nous soit chez le fabricant et qu’il sera expédié au cours des 24h/48h.</p><p>Généralement, la livraison par UPS prend 1 à -3 jours. Les marchandises encombrantes sont expédiées par un transporteur dans un délai de livraison d’environ 4 à 7 jours.</p>";
	langNotice['es'] ="<p><strong>Indicación especial relativa a nuestro servicio de entregas dentro de 24h/48h:</strong</p><p>La entrega dentro de 24h/48h implica que el artículo respectivo esté disponible en nuestro almacén o el del fabricante, y que será suministrado dentro de 24h/48h para envío.</p><p>Por lo general, el envío por UPS tarda aprox. 1 a 3 días. Artículos voluminosos son expedidos por una agencia de transportes con un plazo de entrega de aprox. 4 a 7 días.</p>";
	langNotice['it'] ="<p><strong>Riferimento particolare ai nostri termini di consegna 24h/48h:</strong></p><p>il servizio di distribuzione 24h/48h significa il fatto che questo articolo con noi o con il fornitore dalle azione esso è disponibile ed all'interno di 24h/48h alla spedizione è cosegnato.</p><p>La spedizione occorre solitamente approssimativamente 1-3 giorni, merci ingombranti dall'UPS dal commercio di spedizione con un termine di consegna da approssimativamente 4-7 giorni è spedita.</p>";
	langNotice['ru'] ="<p><strong>Что такое 24/48ч. доставка:</strong></p><p>24/48 часовая доставка означает что, товар находится в наличии у нас на складе или на складе у производителя и будет выслан в течении 24/48 часов.</p><p>Обычно доставка через UPS занимает 1-3 дня. При объёмном грузе, мы отправляем товар через другие компании. В этом случаи срок доставки займёт 4-7 дней.</p>";
	langNotice['pl'] ="<p><strong>Szczególna informacja do zamówień 24h/48h:</strong></p><p>Zamówienie 24h/48h znaczy że artykuł jest u nas lub u producenta na składzie i zostanie poddany w przeciągu 24/48 godzin do wysyłki.</p><p>Z reguły wysyłka przez UPS trwa 1-3 dni, towar zajmujący dużo miejsca zostaje wysyłany firmą spedycyjną i trwa 4-7 dni.</p>";
	langNotice['nl'] ="<p><strong>Extra informatie over onze 24h/48h levertijden:</strong></p><p>24h/48h leverservice betekent dat deze artikelen bij ons of bij de fabrikant op voorraad zijn en binnen 24/48 uur worden verstuurd.</p><p>Normaalgesproken duurt de verzending met UPS ca. 1-3 dagen, volumineuze goederen worden door een expeditiebedrijf met een levertijd van ca. 4-7 dagen verstuurd.</p>";
	langNotice['el'] ="<p><strong>Ιδιαίτερη επισήμανση για τους χρόνους παράδοσης 24h/48h:</strong></p><p>Υπηρεσία παράδοσης 24h/48h σημαίνει ότι το είδος αυτό είναι διαθέσιμο στην αποθήκη τη δική μας ή του κατασκευαστή και μπορεί να παραδοθεί για αποστολή εντός 24/48 ωρών.</p><p>Κατά κανόνα, η αποστολή διαρκεί μέσω UPS περ. 1-3 ημέρες, ενώ τα ογκώδη αγαθά αποστέλλονται μέσω μεταφορικής εταιρείας με χρόνο παράδοσης περ. 4-7 ημερών.</p>";	

	jQuery("#werktage").hover(function(e){

		jQuery("body").append('<div id="tooltip"><div class="tipBody">' + langNotice[getCookie('nisLang')] + '</div></div>');
		jQuery("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		// this.title = this.t;		
		jQuery("#tooltip").remove();
    });	
	jQuery("#werktage").mousemove(function(e){
		jQuery("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

$(document).ready(function() {
	
	var DeliveryTimeID;
	
  // long text: only show if wanted
  if (jQuery(".longText")) {
  	// console.log('+' + jQuery(".longText").html());
		jQuery('.longText').hide();
		jQuery('a.click').click(function(){
			jQuery('.longText').show();
			jQuery('.aMore').hide();
  	});
  }	
	
	// absolute pfade!
	var host = 'http://'+window.location.host;
  // base product
 	var pan = getPAN();
  // optionen: name-tag
	var selectCounter = 1;
	jQuery(".produktoptionen select").each(function () {
		var name = jQuery(this).attr("name");
		var n2 = name.replace(/(.*_\d)(\d)/, '$1'+selectCounter );
		jQuery(this).attr({name: n2});
		selectCounter++;
	});
	if (selectCounter == 1) {
	  pan = pan + "0000000000";
	  jQuery("#innerPan").attr({value: pan});
	}
 	// products_id
 	var products_id = jQuery("#products_id").html();
  jQuery("#artnr").attr({value: products_id});
	// language cookie -- nisLang

  if (window.location.pathname == '/') {
  	             var Ausdruck = /(\w*)$/;
                 Ausdruck.exec(window.location.host);               
                 var country = RegExp.$1;
                 RegExp.$1 = null;                            
  } else {
                 var Ausdruck = /\/(\w{2})\//;
                 Ausdruck.exec(window.location.pathname);
                 var country = RegExp.$1;
                 RegExp.$1 = null;
  }
	var country = country.toLowerCase();

	if (country == 'cb'){
		var country = 'de';
	}
	if (country == 'uk'){
		var country = 'en';
	}
	if (country == 'gr'){
		var country = 'el';
	}	

	if (country != 'shop') {
		// html-action
  	// console.log('country: ' + country);
  	var stored = getCookie('nisLang');
  	//console.log(' 1 nisLang: ' + stored);
  	if (!stored  || stored == '') { // || stored != country  		
  		if(window.location.protocol == 'http:'){
  			setCookie('nisLang', country, 20000, "/");
  		}
  	}
	}	else {
  	var stored = getCookie('nisLang');
  	if (stored) {
  		country = stored;
  	}
	}
	// affiliate -- nisPID
	var ort = ""+document.location+"";
	var result = ort.match(/\?pid=(\d+)/g);
	var affiliate;
	if (result) {
		result = ""+result+"";
		result.match(/pid=(\d+)/g);
		affiliate = RegExp.$1;	
		// console.log('found partner in document location : '+affiliate);
	}	
	else {
		var affiliateCookie = getCookie('nisPID');
		if (affiliateCookie) {
			var affilitest = affiliateCookie.match(/^(\d+)/g);
			affiliate = RegExp.$1;
			// console.log('found partner in cookie : '+affiliate);
		}	
	}
  // session cookie -- nisSession (inkl.zanpid)
  var sessionCookie = getCookie('nisSession');
	if ((!sessionCookie) || (sessionCookie == 0)) {
		makeSessionCookies(ort, country, host, affiliate, document.referrer);
  } else {
  	// ajax cart holen
    var url = host+'/cgi-bin/nolte.internet/shop/scripts/shop_get_cart.pl';
    var returnValue = jQuery.ajax({
      type: "GET",
      url: url,
      data: "action=getCart&session="+sessionCookie,
      dataType: 'text',
      async: false,
      cache: false,
      success: function(msg){
        var result = JSON.parse(msg);
        // console.log(affiliate);
        jQuery("#amountTotal").html(parseMoney(result.amountTotal));
        var articlesTotal = jQuery("#articlesTotal").html();
        // console.log(articlesTotal);
        jQuery("#articlesTotal").html(result.articlesTotal);
        if (result.articlesTotal > 0) {
        	jQuery("#warenkorbcontainer").find("span:last").after('<br /><br /><a href="'+host+'/cgi-bin/nolte.internet/shop/shop.cgi?func=scartshow&amp;wkid=' + sessionCookie + '" target="_self" title="Zum Warenkorb"><img src="/nolte.internet/shop/images/' + country + '/img_btn_zum-warenkorb.gif" alt="" border="0" /></a>');
        	jQuery("#_last").after('<br /><br /><a href="'+host+'/cgi-bin/nolte.internet/shop/shop.cgi?func=scartshow&amp;wkid=' + sessionCookie + '" target="_self" title="Zum Warenkorb"><img src="/nolte.internet/shop/images/' + country + '/img_btn_zum-warenkorb.gif" alt="" border="0" /></a>');
        }
        
      }
    });
  }
  // wkid feld(er) ersetzen
  jQuery("#wkid").attr({value: sessionCookie});
  // popups
	var result = ort.match(/\?(.*)/g);
	if (result) {
		result = ""+result+"";
		var popup = result.match(/popup=(.*)/g);
		if (popup != null) {
			popup = ""+popup+"";
      var type = popup.replace(/\w*=/, '');
      if (type.match(/cartAdd/)) {
        var url = host+'/cgi-bin/nolte.internet/shop/scripts/shop_get_cart.pl';
        var returnValue = jQuery.ajax({
          type: "GET",
          url: url,
          data: "action=getText&language="+country,
          dataType: 'text',
          async: false,
          success: function(msg){
            var result = JSON.parse(msg);
            // Create buttons from json-data
            var buttons = {};
						var reg = /(title=".*").*(title=".*")/gi;
						var results = reg.exec(result.SM_BUY);
						results.splice(1,1);
						var buttonLabels = new Array();
						for (var i=0;i<results.length;i++) {
							var val = results[i];
		          var val2 = val.replace(/title="/, '');
		          var val3 = val2.replace(/".*/, '');
		          if (i == 0) {
		            buttons[val3] = function() {
	                window.location.href = host+'/cgi-bin/nolte.internet/shop/shop.cgi?func=scartshow&wkid='+sessionCookie;
		            };
		          } else {
		        		buttons[val3] = function() {jQuery(this).dialog('destroy');};
		          }
						}
		        // Strip content
		        var showText = result.SM_BUY.replace(/<a href.*\/a>/g , '');
		        jQuery("#dialog").prepend(showText);
		        jQuery(function() {
	            jQuery("#dialog").dialog({
                bgiframe: true,
                modal: true,
                width: 500,
                title: result.AJAX_TXT_OK,
                buttons: buttons
	            });
		        });
  				}
  			});
  		}
		}
	}
	// pid ersetzen
	var affiliateCookie = getCookie('nisPID');	
  if (affiliateCookie) {
  	var pid = affiliateCookie.replace(/(\d*).*/, '$1');
  	if (pid != affiliate) {
			makeSessionCookies(ort, country, host, affiliate, document.referrer);
  	}
  	jQuery("#pid").attr({value: pid});
  }
  if (!affiliateCookie && affiliate) {
  	makeSessionCookies(ort, country, host, affiliate, document.referrer);
  	// console.log('neuer besuch mit affiliate ' + affiliate) ;
  }
  // check product if submitted to cart
  jQuery("#fDet").submit(function() {
   	if (jQuery("#innerPan").attr('value').length < 19) {
      var url = host+'/cgi-bin/nolte.internet/shop/scripts/shop_get_cart.pl';
      var returnValue = jQuery.ajax({
        type: "GET",
        url: url,
        data: "action=getText&language="+country,
        dataType: 'text',
        async: false,
        success: function(msg){
          var result = JSON.parse(msg);
          jQuery("#dialog").html(result.SC_NOCHOICE);
          jQuery(function() {
            jQuery("#dialog").dialog({
               bgiframe: true,
               modal: true,
               title: result.AJAX_TXT_ERROR,
               buttons: {
                 Ok: function() {
                   jQuery(this).dialog('destroy');
                 }
               }
             });
          });
        }
      });
    	return false;
   	}
  });
  // check deliverytime
 /*
  listing page: present products_ids as a class "products_id"
  single item view: present products_id as a named div
  */
	var productsID = jQuery("#products_id").attr("title");
	var sprache = getCookie('nisLang');
  var url = host+'/cgi-bin/nolte.internet/shop/scripts/shop_checkDeliveryTime.pl';
  var dataStrg = "action=checkDeliveryTime&l="+sprache+"&products_id="+productsID;	
  if (productsID > 0 && sprache != '') {
	  var returnValue = jQuery.ajax({
	    type: "GET",
	    url: url,
	    data: dataStrg,
	    dataType: 'text',
	    async: false,
	    success: function(msg){
	    	var result = JSON.parse(msg);
	    	// substitute deliverytimes
	    	if (result.lieferzeit) {
		    	var oldTime = jQuery("#werktage .mwst").html();
		    	jQuery("#werktage .mwst").html(result.lieferzeit);
		    	jQuery("#products_deliverytimes_name").attr({title: result.lieferzeit});
		    	// im title tag nur ersetzen, wenn lieferzeit > 48 Stunden
		    	if (result.lieferzeit_id) {
		    		DeliveryTimeID = result.lieferzeit_id;
		    		if(result.lieferzeit_id == 2 || result.lieferzeit_id == 3) {
		    			// console.log('change deltime');
				    	// var oldTitle = jQuery("title").html();
				    	// console.log(oldTitle);
				    	// var newTitle = oldTitle + ' - ' + result.lieferzeit_name + ': ' +  result.lieferzeit; //replace(/:.*$/, ": "+result.lieferzeit);
				    	// jQuery("title").html(newTitle);			    		
				    }
		    	}			    	
	    	}
	    	// substitute price
	    	if (result.preis) {
		    	var newPrice = result.preis.replace(/\./, ",");
		    	jQuery("#basispreis").html(result.preis);
		    	var newPriceDisplay = parseMoney(result.preis);
		    	// jQuery(".produktnamekasten .preis").html(newPriceDisplay + " &#x80;");
		    	jQuery("span").find("#jsPrice").html(newPriceDisplay);	    		
	    	}
	    }
	  });	   	
  } else {
  	var productsIDs = new Array();
  	jQuery(".products_id").each(function() {
  		productsIDs.push(jQuery(this).attr("title"));
  	});
  	productsIDs.unshift("");
  	var myCall = productsIDs.join("&products_id=");
  	var dataStrg = "action=checkDeliveryTime&format=list&l="+sprache+myCall;
	  var returnValue = jQuery.ajax({
	    type: "GET",
	    url: url,
	    data: dataStrg,
	    dataType: 'text',
	    async: false,
	    success: function(msg){
	    	var result = JSON.parse(msg);
	    	
		  	jQuery(".products_id").each(function() {
		  		var productsID = jQuery(this).attr("title");
					for (var i=0; i<result.length; i++ ) {
						if (result[i].product == productsID) {
							if (result[i].preis !== null) {
								result[i].preis = parseMoney (result[i].preis);
								jQuery(this).parent().find(".preis").html(result[i].preis+" &euro;");
							}
						}
					}
		  	});	    	
	    }
	  });	   	
  }
  
  // Suche
  if (jQuery("#searchFor")) {
/*
	  jQuery("#searchFor").autocomplete(
	  	host+'/cgi-bin/nolte.internet/shop/scripts/shop_get_searches.pl',
	  	{ 
	  		'delay':10,
	  		'width':150,
	  		'matchContains':1,
	  		'onItemSelect': do_search,
	  	}
	  );
	  jQuery("#searchFor").focus();
	  */
  }
  
  // manufacturers search
  if (jQuery("#toolboxTop")) {
    jQuery("#toolboxTop select").change( function () { 
    	var selectedValue2 = jQuery("#toolboxTop select option:selected").val();
      window.location.href = selectedValue2; 
    });  	
  }
  
  // TT
  if(DeliveryTimeID == 2 || DeliveryTimeID == 3) {
  	tooltip();
	}

  
});

/*


*/