/* <![CDATA[ */
		function MM_findObj(n, d) { //v4.01
			var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
			d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
			if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
			for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
			if(!x && d.getElementById) x=d.getElementById(n); return x;
		}
/* ]]> */

/*
Popup Funktion

@param url	zu Ã¶ffnende URL
@param name Name des Fensters
@param width Breite des Fensters
@param height HÃ¶he des Fensters
@param top Abstand des Popups vom oberen Rand des Bildschirms
@param left Abstand des Popups vom linken Rand de Bildschirms
@param toolbar Toolbar anzeigen = yes nicht anzeigen = no
@param status Statusbar anzeigen = yes nicht anzeigen = no
@param scrollbars Scrollbalken anzeigen = yes nicht anzeigen = no
@param resize GrÃ¶ÃŸe des Fensters verÃ¤nderbar = yes fixiert = no
*/
var win = null;
function windowOpen(url,name,width,height,top,left,toolbar,status,scrollbars,resize){
	
	//schliesse das fenster wenn es bereits geÃ¶ffnet ist
	if( win != null )win.close();
	var attrib_str = 'toolbar='+toolbar+',width='+width+',height='+height+',top='+top+',left='+left+',directories=no,status='+status+',scrollbars='+scrollbars+',resize='+resize
	win = window.open(url,name,attrib_str);
	return false;
}

/*
Katalogbestellformular

Ã¼bernehme Daten des kleinen Katalogbestellformulars wenn auf weitere Produkte geklickt wurde
@param modifier
*/
function getOrderNumbers(modifier){

	//artikel 1
	if(document.getElementById( 'f1'+modifier ).value.match(/[0-9]+/) && document.getElementById( 'f2'+modifier ).value.match(/[0-9]+/)){
		document.getElementById( 'cat'+modifier ).href += '&f1='+document.getElementById( 'f1'+modifier ).value+'&f2='+document.getElementById( 'f2'+modifier ).value;
	}

	//artikel 2
	if(document.getElementById( 'f3'+modifier ).value.match(/[0-9]+/) && document.getElementById( 'f4'+modifier ).value.match(/[0-9]+/)){
		document.getElementById( 'cat'+modifier ).href += '&f3='+document.getElementById( 'f3'+modifier ).value+'&f4='+document.getElementById( 'f4'+modifier ).value;
	}

}

/*
Counter fÃ¼r Linkcatalog
*/

function textlimit(Obj,maxcount,counter)
{
    function c_len(){    
        if(this.value.length > this.maxcount && this.maxcount != 0) 
            return false;
        update_count(this);    
    }
    
    function upd_count(){    update_count(this);}
    
    function update_count(elem){
        if(elem.counter != null){
            cnt = getObj(elem.counter);
            cnt.innerHTML = elem.value.length
    }}
    
    function check(){
        if (this.value.length  > this.maxcount && this.maxcount != 0) 
            this.value = this.value.substr(0,this.maxcount);
        update_count(this); 
    }
    
    Obj.counter   = counter;      Obj.maxcount  = maxcount;
    Obj.onkeypress= c_len;        Obj.onkeydown = upd_count;    
    Obj.onkeyup   = check;        Obj.onfocus   = check;
    Obj.onblur    = check;        
    Obj.onmouseup = check;

    update_count(Obj);
    
/*************** OTHER USED / NEEDED FUNCTIONS ***************************/
function getObj( ref ) { if( document.getElementById( ref ) != null )//W3C/
return document.getElementById(ref); else if(document.all[ref]!=null)//IE5/
return document.all[ ref ]; else if( document.layers[ ref ] != null )//NN4/
return document.layers[ref]; else alert('Object "'+ref+'" not Found')//ERR/
}/************************************************************************/
}

/*
PrÃ¼ft die Bestellnummern der Katalogbestellungen ob diese >= 6 Stellen besitzt
und gibt bei einem Fehler einen Alertfenster mit einem Hinweistext aus 
*/
function checkOrderNumbers(idTag,type)
{
	////////////////////////////
	//kleines Katalogbestellformular auf Homepage
	if(type == 1){
			value = document.getElementById( 'f2'+idTag ).value;
			//wenn value gesetzt prÃ¼fe auf lÃ¤nge
			if(value != ''){
				//gebe eine Meldung aus
				if(value.length <= 5 ){
					alert('Bestellnummern bestehen aus 6 bis 8 Zahlen.\nBitte korrigieren Sie Ihre Angaben.');
					return false;
				}	
			}
			value = document.getElementById( 'f4'+idTag ).value;
			//wenn value gesetzt prÃ¼fe auf lÃ¤nge
			if(value != ''){
				//gebe eine Meldung aus
				if(value.length <= 5 ){
					alert('Bestellnummern bestehen aus 6 bis 8 Zahlen.\nBitte korrigieren Sie Ihre Angaben.');
					return false;
				}	
			}
	}else{
	////////////////////////////
	//GroÃŸes Katalogbestellformular
		//durchlaufe die schleife solage bis iTag+1 = undefined und breche schleife ab
		for(i=1;i<100;i++){
			
			if(document.getElementById( idTag+i )){
	
				value = document.getElementById( idTag+i ).value;
				//wenn value gesetzt prÃ¼fe auf lÃ¤nge
				if(value != ''){
					//gebe eine Meldung aus
					if(value.length <= 5 ){
						alert('Bestellnummern bestehen aus 6 bis 8 Zahlen.\nBitte korrigieren Sie Ihre Angaben.');
						return false;
					}	
				}
			}else{
				break;
			}
		}
	}
}


function changeClass(id,first,secound){
	
	if( document.getElementById(id).className==first){
		document.getElementById(id).className=secound;
	}else{
		document.getElementById(id).className=first;
	}
}

/**
Generiert zufÃ¤lligen Wert und prÃ¼ft, ob er im Ã¼bergebenen Wertebereich liegt
Wird z.b. fÃ¼r zufÃ¤lliges Ã–ffnen eines Popup benutzt (Sammler-Editionen)
@autor Oliver Deul
@param range = Wertebereich

**/
function my_rand(range){
	a=Math.random();
	a*=100;
	a=Math.ceil(a)
	if (a <= range)
		return true;
	else
		return false;		
}

/**
Ersetzt den Inhalt vom 1. Element mit dem Inhalt vom 2. Element und umgekehrt
und weist den neuen Inhalt den Elementen entsprechend zu
@autor Oliver Deul
@param id1 = id des 1. Elementes
@param id2 = id des 2. Elementes

**/
function flipContent (id1, id2){
	var content1 = document.getElementById(id1).innerHTML;
	var content2 = document.getElementById(id2).innerHTML;
	document.getElementById(id1).innerHTML = content2;
	document.getElementById(id2).innerHTML = content1;
}

/*
ZÃ¤hlt bei Textarea Felder die noch verfÃ¼gbaren
Zeichen runter

@param Anzahl der
@param Anzahl der max. Zahlen
@param ID des Formularfeldes
*/
function checkLen(val,zeichen,formid) {

objLen 		= document.getElementById("objLen");
formid	= document.getElementById(formid);

tmpLen		= zeichen - formid.value.length;
if(tmpLen >= 0) {
svobjComment = formid.value;
} else {
formid.value = svobjComment;
tmpLen = zeichen - svobjComment.length;
}
objLen.value = tmpLen;
}

/*
ZÃ¤hlt bei Textarea Felder die noch verfÃ¼gbaren
Zeichen runter und zwar FÃœR BELIEBIGE TEXTAREAS UND NICHT NUR FÃœR DIE MIT ID objLen :-)

@param Objekt (Textarea)
@param Anzahl der max. Zahlen
@param ID des Ausgabefeldes
*/
function limitChars(obj,max,leftId)
{
if (obj.value.length > max) {
	obj.value = obj.value.substring(0,max);
	alert("Es dÃ¼rfen nicht mehr als "+max+" Zeichen eingegeben werden");
}
iZeichen = max - obj.value.length

document.getElementById(leftId).value = iZeichen >= 0 ? iZeichen : 0;

}


/**
Speicherbarer Warenkorb - Daten aus dem Cookie holen
**/
function getStorableCartData(){

		if( window.XMLHttpRequest ) {
          req = new XMLHttpRequest();
        } else if( window.ActiveXObject ) {
          req = new ActiveXObject( "Microsoft.XMLHTTP" );
        } else {
          return;
        }
        
        
	    req.open( "GET", '/index.html?f=cart.add&mode=sc', true );
	    req.onreadystatechange = callbackStorableCart;
	    req.send( null );

}
/*
Speicherbarer Warenkorb - Setzen der Anzeige Artikel im Warenkorb  
*/
function callbackStorableCart() {
	 if( 4 == req.readyState ) 
		if (200 == req.status){
			if (req.responseText != null && req.responseText != "0" && req.responseText != ""){
				values=req.responseText.split("|");
				if (values != null){
					if (values.length > 0)				
				    	if (document.getElementById("set_aiw") != null)
							document.getElementById("set_aiw").innerHTML = values[0];
					if (values.length > 1)
						if (document.getElementById("set_sav") != null)
							document.getElementById("set_sav").innerHTML = values[1];
				}
				if (window.location.href.indexOf('cart.wk') != -1){
					window.location.href=window.location.href;
				}	
			} 
		}
			
}

//100 milisekunden * suggestTime dann feuer
var suggestTime = 1;
var suggestCounter = 0;
var intervalObj = null;
var stopSuggestionAfterEnter = 0;
var dontRequestSuggestion = 0;
var maxCharforSuggestBox = 2;
var registerClickeventforBoxclosing = 0;
var BoxclosingonClick = 1;
var globalsuggestDiv = '';
var actualSerachphrase = '';
/*
Initalisiert die Suggestion
@textFieldId	id des Such-Inputfields
@width			breite des Vorschlagfelds
@height			hÃ¶he des Vorschlagfelds
@suggestDiv		id des Vorschlag-DIVs
@activeColor	Farbe wenn Div ausgewÃ¤hlt
@inactiveColor	Farbe wenn Div nicht ausgewÃ¤hlt
*/
function fireSuggestions(textFieldId,width,suggestDiv,activeColor,inactiveColor){

	// Globalisierung der Suggestbox
	globalsuggestDiv = suggestDiv;
	
	// aktuelle Eingabe speichern, wenn Zeichen im Suchfeld hinzugefÃ¼gt oder entfernt werden:
	if (dontRequestSuggestion != 1) {
		actualSerachphrase = document.getElementById(textFieldId).value;
	}

	// registriere Clickevent zum Schliessen der Suggestbox
	if (registerClickeventforBoxclosing == 0){
		document.getElementById(suggestDiv).onmousedown = switchsuggestboxshow;
		document.onmouseup = closeSuggestorBoxEvent;
		registerClickeventforBoxclosing = 1;
	}

	suggestCounter = 0;

	//feuer pfeiltasten
	arrowKeyListener(textFieldId,suggestDiv,activeColor,inactiveColor);
		
	if(intervalObj == null)
		intervalObj = window.setInterval("suggestTimer('"+textFieldId+"','"+width+"','"+suggestDiv+"','"+activeColor+"','"+inactiveColor+"')", 100);
}

/*
Timer zÃ¤hlt nach Ablauf des Intervals suggestCounter +1 und feuert die Anfrage
wenn suggestTime < suggestCounter

@textFieldId	id des Such-Inputfields
@width			breite des Vorschlagfelds
@suggestDiv		id des Vorschlag-DIVs
@activeColor	Farbe wenn Div ausgewÃ¤hlt
@inactiveColor	Farbe wenn Div nicht ausgewÃ¤hlt
*/
function suggestTimer(textFieldId,width,suggestDiv,activeColor,inactiveColor){
	
	suggestCounter++;

	if(suggestCounter > suggestTime){
		suggestCounter = 0;
		window.clearInterval(intervalObj);
		intervalObj = null;
		//eventkeylistener aktivieren
		document.getElementById(textFieldId).onkeydown = keyEventListener;
		
		// Suggestlist erst nach bestimmter Anzahl (maxCharforSuggestBox) an Zeichen ein- bzw. ausblenden inkl. Searchrequest
		if (document.getElementById(textFieldId).value.length <= maxCharforSuggestBox) {
			document.getElementById(suggestDiv).innerHTML = "";
			dontRequestSuggestion = 1;
		}
		//vorschlagsliste anfordern
		if(dontRequestSuggestion == 0)
			getSuggestion(textFieldId,width,suggestDiv,activeColor,inactiveColor);	
	}
}

/*
wenn auÃŸerhalb der Suggestbox geklickt wurde, diese ausblenden:
Beim Event onmouseup wird geprÃ¼ft, ob der onmousedown auÃŸerhalb der Suggestbox stattgefunden hat.
Falls ja, wird Box ausgeblendet, ansonsten geht es ganz normal weiter.
*/
function closeSuggestorBoxEvent() {
	if (document.getElementById(globalsuggestDiv).innerHTML != "" && BoxclosingonClick == 1) {
		document.getElementById(globalsuggestDiv).innerHTML = "";
	}
	BoxclosingonClick = 1;
}

/*
Hilfsfunktion zum Ausblenden der Suggestbox -> closeSuggestorBoxEvent()
*/
function switchsuggestboxshow() {
	BoxclosingonClick = 0;
}

/**
/**
Autosuggestion der Suche
fÃ¼hrt einen Ajax-Request durch und zeigt das Vorschlagsfenster an

@textFieldId	id des Such-Inputfields
@width			breite des Vorschlagfelds
@height			hÃ¶he des Vorschlagfelds
@suggestDiv		id des Vorschlag-DIVs
@activeColor	Farbe wenn Div ausgewÃ¤hlt
@inactiveColor	Farbe wenn Div nicht ausgewÃ¤hlt
*/
function getSuggestion(textFieldId,width,suggestDiv,activeColor,inactiveColor){
	//return
	if(stopSuggestionAfterEnter)
		return;
	//hole input aus suchefeld
	searchPhrase = document.getElementById(textFieldId).value;
	
	//return wenn searchphrase leer
	if(searchPhrase.length == 0)
		document.getElementById(suggestDiv).innerHTML = "";
	
	if( window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if( window.ActiveXObject ) {
		req = new ActiveXObject( "Microsoft.XMLHTTP" );
	} else {
		return;
	}

	// Leerzeichen mitnehmen (request::trustnoone umgehen)
	var s_searchPhrase = searchPhrase.replace(/ /g, "###");
	
	req.open( "GET", '/index.html?f=search.getsuggestions&com='+encodeURIComponent(s_searchPhrase), true );
	//hole daten
	req.onreadystatechange = function(){getSuggestionBox(width,suggestDiv,searchPhrase,textFieldId,activeColor,inactiveColor);};	
	req.send( null );
}

/*
Erstelle die Dropdownbox

@width 			breite des divs
@suggestDiv 	id des Divs welches per innerHTML gefÃ¼llt werden soll
@searchPhrase 	Eingabetext des Users
@searchBox 		id des Sucheingabetextfelds
@activeColor		Farbe wenn Div ausgewÃ¤hlt
@inactiveColor	Farbe wenn Div nicht ausgewÃ¤hlt
*/
function getSuggestionBox(width,suggestDiv,searchPhrase,searchBox,activeColor,inactiveColor){
	 
	if( 4 == req.readyState ) {
		
	 	if (200 == req.status){
			jsonData = JSON.parse(req.responseText);
			suggestJson = jsonData.a.rs;
			if(suggestJson.length > 0){
				
				//erstelle rexEx Object
				var regObj = new RegExp("^("+searchPhrase+")",'i');
				
				//erstelle autocomplet div
				//height:"+height+"px;
				html = "<div id=\""+suggestDiv+"inner\" style=\"position:absolute;z-index:550;margin-left:-1px;background-color:white;border:1px solid #cccccc;width:"+width+"px;overflow:auto;\">"+
				"<div style=\"text-align:right;margin-right:2px\" class=\"text08\">Suchvorschl&auml;ge<a href=\"\" onclick=\"document.getElementById('"+suggestDiv+"').innerHTML='';return false;\"></div>";
			
				
				//durchlaufe ergebnisliste aus json
				for(i = 0;i<suggestJson.length;i++){
					
					search = suggestJson[i];
					
					if(search.match(regObj)){
						//substring des textstrings
						txt = suggestJson[i].substring(0,searchPhrase.length);
						search = search.replace(txt,"<b>"+txt+"</b>");
					}
				
					
					html += "<div style=\"width:97%;padding: 1px 1px 1px 5px;cursor:pointer\" id=\"sug"+i+"\""+
					" onmouseover=\"overOut('sug"+i+"','"+activeColor+"',1)\" onmouseout=\"overOut('sug"+i+"','"+inactiveColor+"',0)\""+
					"  title=\""+suggestJson[i]+"\">"+
					"<a onclick=\"fillSearchBox('"+searchBox+"','"+suggestJson[i]+"','"+suggestDiv+"')\">"+
					""+search+"</a></div>";
				}
				html +="</div>";
				
				//insert div
				document.getElementById(suggestDiv).innerHTML = html;
			}else{
				//insert div
				document.getElementById(suggestDiv).innerHTML = "";
			}
		}
	 }
}

/*
Setze HintergrundFarbe der divs mit suchbegriffen

@idSuggest 	id des div
@color		Hintergrundfarbe
@inOut		true aktiv false inaktiv
*/
function overOut(idSuggest,color,inOut){
	
	if(inOut)
	{
		document.getElementById(idSuggest).style.backgroundColor = color;
	}else{
		document.getElementById(idSuggest).style.backgroundColor = color;
	}
}

var eventKeyCode = "";
/*
Textfeld der Suche fÃ¼llen und gleich Suche abschicken

@box 			id des Textfelds
@searchSuggest	asugewÃ¤hlter Suchbegriff
@suggestDiv		id des groÃŸen Vorschlags-DIV
*/
function fillSearchBox(box,searchSuggest,suggestDiv){
	
	document.getElementById(box).value = searchSuggest;
	document.getElementById(suggestDiv).innerHTML = "";
	document.getElementById(box+"Button").click();
}

/*
KeyDownUp Listener um mit Pfeiltasten zu navigieren
*/
function arrowKeyListener(searchBoxObject,suggestDiv,activeColor,inactiveColor){
	
	active = 1;
	
	suggestObj = document.getElementById(suggestDiv+"inner");
	//event
	//wenn nicht leer
	if(eventKeyCode != "" && suggestObj != ""){
		divs = suggestObj.getElementsByTagName("div");
		
		//KeyCode down
		if(eventKeyCode == "down"){
			//durchlaufe divs
			for(i = 1; i < divs.length;i++){

				if(divs[i].style.zIndex == 1){
					active = i+1;
					divs[i].style.backgroundColor = inactiveColor;
					divs[i].style.zIndex = 0;
					break;
				}
			}
			//nun aktiviere nÃ¤chstes div
			if(divs.length == active){
				active = 1;
				document.getElementById(searchBoxObject).value = actualSerachphrase;
			} else {
				divs[active].style.backgroundColor = activeColor;
				divs[active].style.zIndex = 1;
				document.getElementById(searchBoxObject).value = divs[active].title;
			}
		}
		
		//KeyCode up
		if(eventKeyCode == "up"){
			if (active == 1) {
				active = divs.length-1;
			}
			//durchlaufe divs
			for(i = (divs.length-1); i > 0;i--){
	
				if(divs[i].style.zIndex == 1){
					active = i-1;
					divs[i].style.zIndex = 0;
					divs[i].style.backgroundColor = inactiveColor;
					break;
				}
				
			}
			//nun aktiviere nÃ¤chstes div
			if(active == 0){
				active = divs.length-1;
				document.getElementById(searchBoxObject).value = actualSerachphrase;
			} else {
				divs[active].style.backgroundColor = activeColor;
				divs[active].style.zIndex = 1;
				document.getElementById(searchBoxObject).value = divs[active].title;
			}
		}
		//KeyCode enter
		if(eventKeyCode == "enter"){
			//ausgewÃ¤hltes div
			selectedDiv = "";
			//durchlaufe divs
			for(i = 1; i < divs.length;i++){
	
				if(divs[i].style.zIndex == 1){
					selectedDiv = divs[i];
					break;
				}
			}
			
			if(selectedDiv != ""){
				document.getElementById(searchBoxObject).value = selectedDiv.title;
				document.getElementById(searchBoxObject).style.zIndex = 1;
				document.getElementById(suggestDiv).innerHTML = "";
				eventKeyCode = "";
				stopSuggestionAfterEnter = 1;
			}
		}
	}
}

/*
Eventhandler Key up down
*/
function keyEventListener(ev){

	if(window.event){
		ev = window.event;
	}
	
	//up 38
	if(ev.keyCode == 38){
		eventKeyCode = "up";
		dontRequestSuggestion = 1;
	}
	//down 40
	else if(ev.keyCode == 40){
		eventKeyCode = "down";
		dontRequestSuggestion = 1;
	//enter 13
	}else if(ev.keyCode == 13){
		eventKeyCode = "enter";
	}else{
		eventKeyCode = "";
		dontRequestSuggestion = 0;
	}
}



	//Speichern der Zahlart PayPal und anfordern der Url fï¿½r Saferpay
	function getPayPal(){
	 
		if( window.XMLHttpRequest ) {
	          req = new XMLHttpRequest();
	     } else if( window.ActiveXObject ) {
	          req = new ActiveXObject( "Microsoft.XMLHTTP" );
	     } else {
	          return;
	     }
	   
		 req.open( "GET", '/index.html?f=cart.controller&step=paypal', true );
	
		 req.onreadystatechange = showPayPal;
		   
		 req.send( null );
	}
	
	function showPayPal(){
		if( 4 == req.readyState ){ 
			if (200 == req.status){
				if (req.responseText != null)
					window.location.href=req.responseText;
					
			}
		}
	}
	
	Tracking = function(){

		function setTrackingsOrderId(article,qed,source){
			if (source != ''){
				setTrackingInformation(article,source);
				if (cm_tracking_enabled)
					cmCreateConversionEventTag(article, 1,'Suche_Product_Bestellnummer', 1 );
			}
			if (qed != true){
				searchTrackLogging(article,qed);
			}
			
		}
		
		function setSearchTrackings(article,qed,type,tracking,linktype,source){
		    
			var source=source;
			var categorie='';
			var information='';
			if (linktype == 'wklink'){
				if(tracking == '1'){
				    
				    if(type == 'article') this.source='se.wk';
				    if (source == 'seeker') this.source = 'se.wksek';
				    if (source == 'crossselling') this.source  = 'se.wkxsel';
					information=setTrackingInformation(article,this.source);
				}
				
			   if (cm_tracking_enabled){
			        categorie='Suche_Direct_Cart';
			        if (source == 'seeker') categorie='StoebernSuche_Direct_Cart';
			        if (source == 'crossselling') categorie = 'Suche_Xsell_Direct_Cart';
			        if (existTrackingSourceArticle(information,article,this.source) == true){
						cmCreateConversionEventTag(article, 1,categorie, 1 );
					}
			   }
			}else if (linktype == 'detail'){
			    if(qed != '')	searchTrackLogging(article,qed);
				if(tracking == '1'){
				    if(type == 'article') this.source='se.art';
				    if (source == 'seeker') this.source = 'se.sek';
				    if (source == 'crossselling') this.source  = 'se.xsel';
				  
					setTrackingInformation(article,this.source);
				}
			}
			
		}
		
		//Aufruf Function-Controller für Search Loganalyzer
		function searchTrackLogging(id,qed){
			var req = getAjaxReq();
			 req.open( "GET", '/index.html?f=search.track&qed='+qed+'&rand='+Math.random(), true );
		     req.send(null);
		}
		
		
		/**
		Setzt ein Cookie mit der Quelle für Tracking
		*/
		
		function setTrackingInformation(article,source) {
			var expires = new Date();
			var information = '';
			information = getCookie('tracking_source');	
			information=setTrackingArticle(information,article, source);
		     
			expires = new Date(expires.getTime() + (5400000)); 
			document.cookie = 'tracking_source='+escape(information)+';expires='+expires.toGMTString()+';path=/;';
			return information;
		}
		
		
		/**
		Tracking-Informationen im Cookie ergï¿½nzen
		*/
		function setTrackingArticle(information,article, source){
			var skip = false;
			var content;
			var listtype;
			var element;
			var listelements;
			var count=0;
			var listexists = false;
			var sourcetype = source.split('.');
			
			if (information != ''){
				if (existTrackingArticle(information,article,source) == true)
					return information;
			}
			
			//Cookie leer
			if (information == ''){
				information=source+'_'+article;
				return information;
			}
			
			//Verschiedene Listen
			content = information.split('~-~');
			
			information='';
			
			count=0;
			//Anzahl ermitteln
			for (var i=0; i<content.length;i++){
				listtype=content[i].split('_');
		
			 	if (listtype[0].indexOf(source) != -1){
			 		element=listtype[1].split('~');
			 		count=count+element.length;
			 	}
			}
			
			//Anzahl 10 pro Trackingart ï¿½berschritten
			if (count >= 10){
				for (var i=0; i<content.length;i++){
					listtype=content[i].split('_');
				 	if (listtype[0].indexOf(source) != -1){
				 		element=listtype[1].split('~');
				 		element.shift();
		
				 	
					 	listelements='';
				   		for (var j=0; j<element.length;j++){
				   		   if (listelements == '')
				   		   	 listelements=element[j];
				   		   else
				   		   	 listelements=listelements+'~'+element[j];
				   		} 
					 	content[i]=listtype[0]+'_'+listelements;	   	
				 	break;
				 	}
				 }
			}
			
			count=0;
			//Ermitteln, welche Liste zu ergï¿½nzen ist
			for (var i=0; i<content.length;i++){
			   listtype=content[i].split('_');
			   
			   if (listtype[0]==source){
			   		element=listtype[1].split('~');
		
			   		listelements='';
			   		for (var j=count; j<element.length;j++){
			   		   if (listelements == '')
			   		   	 listelements=element[j];
			   		   else
			   		   	 listelements=listelements+'~'+element[j];
			   		} 	
			   		listelements=listelements+'~'+article;	
			   		content[i]=listtype[0]+'_'+listelements;
			   		listexists = true;
			   }  	 
			}
			
			
			for (var i=0; i<content.length;i++){
				if (information == '')
					information=content[i];
				else
					information=information+'~-~'+content[i];
			}
			
			// Liste noch nicht vorhanden
			if (listexists == false)
				information=information+'~-~'+source+'_'+article;
			
				
			return information;
		}
		
		/**
		Prüfen, ob der Tracking-Artikel bereits existiert
		*/
		function existTrackingArticle(information,article,source){
		
			var content = information.split('~-~');
			var element = null;
			var sourcetype = source.split('.');
			
			for (var i=0; i<content.length;i++){
			 	listtype=content[i].split('_');
		
			 	if (listtype[0].indexOf(sourcetype[0]+'.') != -1){
			 		element=listtype[1].split('~');
			 		for (var j=0; j<element.length; j++)
			 			if (element[j] == article)
			 				return true;
			 	}
			}
			return false;
		}
		
		/**
		Prüfen, ob der Tracking-Artikel bereits existiert
		*/
		function existTrackingSourceArticle(information,article,source){

			var content = '';
			var element = null;
			var sourcetype = '';
			
			if (source != undefined && information != undefined && information != null){
			    content=information.split('~-~');
				sourcetype=source.split('.');
			
				for (var i=0; i<content.length;i++){
				 	listtype=content[i].split('_');
			        if (listtype[0] == source){
				 		element=listtype[1].split('~');
				 		for (var j=0; j<element.length; j++)
				 			if (element[j] == article)
				 				return true;
				 	}
				}
			}
			return false;
		}
		
		
		return {
			setTrackingsOrderId : setTrackingsOrderId,
			setSearchTrackings : setSearchTrackings,
			searchTrackLogging : searchTrackLogging,
			setTrackingInformation : setTrackingInformation,
			setTrackingArticle : setTrackingArticle,
			existTrackingArticle : existTrackingArticle,
			existTrackingSourceArticle : existTrackingSourceArticle
			};

	}();

