/**
 * !!!!!
 * WIRD NICHT MEHR GENUTZT! VERSCHOBEN IN FRAMEWORK NACH P_C_SUCHE !!!!!!!!!
 * !!!!!
 **/

var searchHTTP = null;
var changeCache = "";
var searchCache = "";
var extend_Cache = new Object();



function getSelectedText( obj )
{
	return obj.options[obj.selectedIndex].text;
}


function evalScripts(scripts)
{try
	{if(scripts != '')	
		{var script = "";
			scripts = scripts.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){
	       	                         if (scripts !== null) script += arguments[1] + '\n';
 	        	                        return '';});
			if(script) (window.execScript) ? window.execScript(script) : window.setTimeout(script, 0);
			}
		return false;
	}
	catch(e)
	{	
		alert(e)
	}
	return false;
}

function catalog(rubrick) {
	request3();
	
	var poststr = 'spalte='+rubrick;
	
	searchHTTP.onreadystatechange = update;
	searchHTTP.open('POST', window.location.protocol + '//' + window.location.host + '/home/stellen/suche_katalog_update.phtml', true);
	searchHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	searchHTTP.setRequestHeader("Content-length", poststr.length);
	searchHTTP.setRequestHeader("Connection", "close");
	searchHTTP.send(poststr);
	return false;
}

function changeKatalog(rubrik) {
	document.getElementById('katalog_value').onclick = "";
	if(changeCache != "") {
		document.getElementById('katalog_value').className = "value_change";
		document.getElementById('katalog_value').innerHTML = changeCache;
		document.getElementById('new_katalog_value').value = document.getElementById('suche').value;
		return;
	}
			
	document.getElementById('katalog_value').innerHTML = "<img src='/gifs/stelle/loader.gif' />";
	
	
	var poststr = 'spalte=' + rubrik;
	
	backupChangeKatalog = document.getElementById('katalog_value').onclick;
	request3();
	
	searchHTTP.onreadystatechange = update_katalog;
	searchHTTP.open('POST', window.location.protocol + '//' + window.location.host + '/home/stellen/suche_katalog_reload.phtml', true);
	searchHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	searchHTTP.setRequestHeader("Content-length", poststr.length);
	searchHTTP.setRequestHeader("Connection", "close");
	searchHTTP.send(poststr);	
}

function update_katalog(response) {
	if (searchHTTP.readyState == 4) {
		if (searchHTTP.status == 200) {
			document.getElementById('katalog_value').className = "value_change";
			document.getElementById('katalog_value').innerHTML = searchHTTP.responseText;
			document.getElementById('new_katalog_value').value = document.getElementById('suche').value;
			changeCache = searchHTTP.responseText;
			searchHTTP = null;
		}
	}
}

function detail(page) {
	if(page == undefined) page = 1;
	request3();
	if(top.document.getElementById('sort') == undefined) {
		sortRow = "modify DESC";
	} else {
		sortRow = document.getElementById('sort').value;
	}
	
	var poststr = 'sortierung=' + sortRow + '&page=' + page + '&spalte='+document.getElementById('spalte').value;
	//var a = ['qualifikation', 'praktikumsart', 'studienrichtung', 'branche', 'berufsfeld', 'beschaeftigung', 'position', 'zeitraum', 'dauer', 'land', 'bundesland', 'grossraum'];
	//for(var i = 0; i < a.length; i++) if(document.getElementById("'"+a[i]+"'").value != '') poststr += document.getElementById("'"+a[i]+"'").value;//poststr += '&'+a[i];
	if(document.getElementById('qualifikation').value != '') poststr += '&qualifikation='+document.getElementById('qualifikation').value;
	// if(document.getElementById('praktikumsart').value != '') poststr += '&praktikumsart='+document.getElementById('praktikumsart').value;
	if(document.getElementById('studienrichtung').value != '') poststr += '&studienrichtung='+document.getElementById('studienrichtung').value;
	if(document.getElementById('branche').value != '') poststr += '&branche='+document.getElementById('branche').value;
	if(document.getElementById('berufsfeld').value != '') poststr += '&berufsfeld='+document.getElementById('berufsfeld').value;
	if(document.getElementById('beschaeftigung').value != '') poststr += '&beschaeftigung='+document.getElementById('beschaeftigung').value;
	if(document.getElementById('position').value != '') poststr += '&position='+document.getElementById('position').value;
	if(document.getElementById('zeitraum').value != '') poststr += '&zeitraum='+document.getElementById('zeitraum').value;
	if(document.getElementById('dauer').value != '') poststr += '&dauer='+document.getElementById('dauer').value;
	if(document.getElementById('land').value != '') poststr += '&land='+document.getElementById('land').value;
	if(document.getElementById('bundesland').value != '' && document.getElementById('bundesland').value != '%') poststr += '&bundesland='+document.getElementById('bundesland').value;
	if(document.getElementById('grossraum').value != '' && document.getElementById('grossraum').value != '%') poststr += '&grossraum='+document.getElementById('grossraum').value;
	//alert(poststr);
	
	xhr(window.location.protocol + '//' + window.location.host + '/home/stellen/suche_detail_update.phtml', poststr, update_V3);
			
	/* searchHTTP.onreadystatechange = update;
	searchHTTP.open('POST', window.location.protocol + '//' + window.location.host + '/home/stellen/suche_detail_update.phtml', true);
	searchHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	searchHTTP.setRequestHeader("Content-length", poststr.length);
	searchHTTP.setRequestHeader("Connection", "close");

	searchHTTP.send(poststr); 
	document.body.style.cursor="wait";*/
	return false;
	
}

function extended(art) {
	request3();
	//alert(art);
	var poststr = 'suchwahl='+art;
	//alert(poststr);
	
	if(extend_Cache[art] != undefined) {
		document.getElementById('result').innerHTML = extend_Cache[art];
		    
		if(document.getElementById('land') != undefined) {
			land.init();
		    bundesland.init();
			addEvent_1(window, "land", land);	
			addEvent_1(window, "bundesland", bundesland);	
		} 		
		return;
	}
	
	searchHTTP.art = art;
	
	searchHTTP.onreadystatechange = update_ext;
	searchHTTP.open('POST', window.location.protocol + '//' + window.location.host + '/home/stellen/suche_erweitert_update.phtml', true);
	searchHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	searchHTTP.setRequestHeader("Content-length", poststr.length);
	searchHTTP.setRequestHeader("Connection", "close");
	searchHTTP.send(poststr);
}

function update_ext() {
	if (searchHTTP.readyState == 4) {
		if (searchHTTP.status == 200) {
			document.getElementById('result').innerHTML = searchHTTP.responseText;
		    extend_Cache[searchHTTP.art] = searchHTTP.responseText;
			
		    if(document.getElementById('land') != undefined) {
				land.init();
			    bundesland.init();
				addEvent_1(window, "land", land);	
				addEvent_1(window, "bundesland", bundesland);	
			}
			searchHTTP = null;
			//evalScripts( searchHTTP.responseText );
		} else {
			alert('Es trat leider ein Problem bei ihrer Anfrage auf.\n\nBitte probieren sie es erneut.');
		}
	}
}

function filter(bereich,searchname) {
	request3();
	if (!searchHTTP) {
		alert('Es konnte mit diesem Browser keine Verbindung aufgebaut werden.');
		return false;
	}
	//document.getElementById('category').value = bereich;
	
	var poststr = 'suche='+document.getElementById('suche').value+'&spalte='+bereich+'&sortierung='+document.getElementById('sort').value;
	
	searchHTTP.onreadystatechange = update;
	searchHTTP.open('POST', window.location.protocol + '//' + window.location.host + '/home/stellen/'+searchname+'_update.phtml', true);
	searchHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	searchHTTP.setRequestHeader("Content-length", poststr.length);
	searchHTTP.setRequestHeader("Connection", "close");
	searchHTTP.send(poststr);
	return false;
}

function deactivateFilter(id) {
			request3();
			var poststr = 'act=activate&eid='+id;
	
			searchHTTP.open('POST', window.location.protocol + '//' + window.location.host + '/home/stellen/anzeigeoptionen.php', true);
	
			searchHTTP.onreadystatechange = deactivateFilter_result;
			searchHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			searchHTTP.setRequestHeader("Content-length", poststr.length);
			searchHTTP.setRequestHeader("Connection", "close");
			searchHTTP.send(poststr);	
}

function deactivateFilter_result(response) {
	if (searchHTTP.readyState == 4) {
		if (searchHTTP.status == 200) {
			searchHTTP = null;
			catalog(document.getElementById('bereich').value);
		}
	}
}

function option(id) {
	request3();
	
	location.href = "/katalogsuche/" + document.getElementById('rubrik').value + "/" + id;
/*	var poststr = 'spalte='+document.getElementById('bereich').value+'&suche='+id;
	
	searchHTTP.onreadystatechange = update;
	searchHTTP.open('POST', window.location.protocol + '//' + window.location.host + '/home/stellen/suche_katalog_update.phtml', true);
	searchHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	searchHTTP.setRequestHeader("Content-length", poststr.length);
	searchHTTP.setRequestHeader("Connection", "close");
	searchHTTP.send(poststr);*/
	return false;
}
// Wraper für option()
function resetFilter(id, deactivateUrl) {
	request3();
	
	var poststr = 'spalte='+document.getElementById('bereich').value+'&suche='+id+"&deactivateFilter=true";
	
	searchHTTP.onreadystatechange = update;
	searchHTTP.open('POST', deactivateUrl, true);
	searchHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	searchHTTP.setRequestHeader("Content-length", poststr.length);
	searchHTTP.setRequestHeader("Connection", "close");
	searchHTTP.send(poststr);
	return false;	
}

function cssNachladen() {
	var qs='?'+new Date().getTime(),l,i=0;
	while(l=document.getElementsByTagName('link')[i++]){
		
		if(l.rel&&'stylesheet'==l.rel.toLowerCase()&&l.href.indexOf("suche.css") != -1){
			if(!l._h)l._h=l.href;l.href=l._h+qs
		}
	}
}

function setFilter(typ, value) {
	request3();
	switch(typ) {
		case 1:
			filterTyp = "branche";
			filterData = "branche";
		break;
		case 2:
			filterTyp = "berufsfeld";
			filterData = "berufsfeld";
		break;		
	}
	
	var poststr = 'ajax=1&filterTyp=' + filterTyp + '&save=save&filterData[' + filterData + ']=' + value;
	
	searchHTTP.onreadystatechange = setFilter_response;
	searchHTTP.open('POST', window.location.protocol + '//' + window.location.host + '/home/stellen/anzeigeoptionen.php', true);
	searchHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	searchHTTP.setRequestHeader("Content-length", poststr.length);
	searchHTTP.setRequestHeader("Connection", "close");
	searchHTTP.send(poststr);
	return false;
}

function setFilter_response() {
	if (searchHTTP.readyState == 4) {
		if (searchHTTP.status == 200) {
			searchHTTP = null;
			page(1,"suche" + document.getElementById('modus').value);
		}
	}
}

function page(i,searchname) {
	if(searchHTTP != null) return false;
	request3();
	
	if (!searchHTTP) {
		alert('Es konnte mit diesem Browser keine Verbindung aufgebaut werden.');
		return false;
	}
	
	document.body.style.cursor="wait";
	var poststr = 'suche='+document.getElementById('suche').value+'&spalte='+document.getElementById('bereich').value+'&sortierung='+document.getElementById('sort').value+'&page='+i;
	xmlRequestUrl = window.location.protocol + '//' + window.location.host + '/home/stellen/'+searchname+'_update.phtml';
	
	searchHTTP.onreadystatechange = update;
	searchHTTP.open('POST', window.location.protocol + '//' + window.location.host + '/home/stellen/'+searchname+'_update.phtml', true);
	searchHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	searchHTTP.setRequestHeader("Content-length", poststr.length);
	searchHTTP.setRequestHeader("Connection", "close");
	searchHTTP.send(poststr);
	return false;
}

function search(string,searchname) {
	request3();
	var poststr = 'suche=' + string;

	searchHTTP.onreadystatechange = update;
	searchHTTP.open('POST', window.location.protocol + '//' + window.location.host + '/home/stellen/'+searchname+'_update.phtml', true);
	searchHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	searchHTTP.setRequestHeader("Content-length", poststr.length);
	searchHTTP.setRequestHeader("Connection", "close");
	searchHTTP.send(poststr);
}

function sort(column, searchname) {
	request3();
	if (!searchHTTP) {
		alert('Es konnte mit diesem Browser keine Verbindung aufgebaut werden.');
		return false;
	}
	
	var poststr = 'suche='+document.getElementById('suche').value+'&spalte='+document.getElementById('bereich').value+'&sortierung='+column;
	
	searchHTTP.onreadystatechange = update;
	searchHTTP.open('POST', window.location.protocol + '//' + window.location.host + '/home/stellen/'+searchname+'_update.phtml', true);
	searchHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	searchHTTP.setRequestHeader("Content-length", poststr.length);
	searchHTTP.setRequestHeader("Connection", "close");
	searchHTTP.send(poststr);
	return false;
}

function alertContents() {
	if (searchHTTP.readyState == 4) {
		if (searchHTTP.status == 200) {
			searchHTTP = null;
			//alert(http.responseText);
			
			/*var id = http.responseText;
			
			result = http.responseText;
			
			var data = http.responseText.split('+++#+++');

			var section = data[0] + '_rg_display_section';
			var regular = data[0] + '_rg';
			var edit = data[0] + '_hv';
			var editImage = data[0] + '_editImage';
			var replaceText = document.getElementById(data[0]).value;
	
			document.getElementById(section).innerHTML = replaceText.replace(/\n/g, '<br />') + '<br /><img src="/gifs/bcenter/bearbeiten.gif" alt="bearbeiten" />';
			document.getElementById(regular).style.display = '';
			document.getElementById(edit).style.display = 'none';*/
			/*var data = http.responseText.split('+++#+++');
			document.getElementById('template'+data[0]).style.border = '2px solid #FFFFFF';
			document.getElementById('template'+data[1]).style.border = '2px solid #7FD7F7';
			//alert(data[2]);
			//alert(type);
			document.getElementById('cat').value = data[2];
			document.getElementById('submit').style.display = '';*/
		} else {
			alert('Es trat leider ein Problem bei ihrer Anfrage auf.\n\nBitte probieren sie es erneut.');
		}
	}
}

function stelleMerken(firmenID, stellenID) {
	request3();
	if (!searchHTTP) {
		alert('Es konnte mit diesem Browser keine Verbindung aufgebaut werden.');
		return false;
	}
	
	var poststr = 'firmenid=' + firmenID + '&stellenid=' + stellenID;
	
	document.getElementById('gemerkt_' + stellenID).innerHTML = "<img src='/gifs/stelle/loader_merken.gif' />";		
	searchHTTP.stellenid = stellenID;
	searchHTTP.onreadystatechange = stelleMerken_response;
	searchHTTP.open('POST', window.location.protocol + '//' + window.location.host + '/home/praktikanten/stelle_merken.phtml', true);
	searchHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	searchHTTP.setRequestHeader("Content-length", poststr.length);
	searchHTTP.setRequestHeader("Connection", "close");
	searchHTTP.send(poststr);
	return false;	
}

function stelleMerken_response(response) {
	if (searchHTTP.readyState == 4) {
		if (searchHTTP.status == 200) {
			
			document.getElementById('gemerkt_' + searchHTTP.stellenid).className = "merken already";
			document.getElementById('gemerkt_' + searchHTTP.stellenid).onclick = "";
			document.getElementById('gemerkt_' + searchHTTP.stellenid).innerHTML = "Stelle gemerkt";
			searchHTTP = null;
		}
	}
}

function request3() {
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		searchHTTP = new XMLHttpRequest();
		if (searchHTTP.overrideMimeType) {
			// set type accordingly to anticipated content type
			//searchHTTP.overrideMimeType('text/xml');
			searchHTTP.overrideMimeType('text/html');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			searchHTTP = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				searchHTTP = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) { }
		}
	}
	if (!searchHTTP) {
		alert('Es konnte mit diesem Browser keine Verbindung aufgebaut werden.');
		return false;
	}
}

function update() {

	if (searchHTTP.readyState == 4) {

		if (searchHTTP.status == 200) {
			
			
			document.getElementById('result').innerHTML = searchHTTP.responseText;
			document.body.style.cursor="default";
			// cssNachladen();
			searchHTTP = null;
			pageTracker._trackPageview(xmlRequestUrl);
			
			url = xmlRequestUrl.split("/");
			url = url[url.length-1].split(".");
			url=url[0];
			if(window.location.protocol=='http:') {
				var IVW = window.location.protocol+"//praktika.ivwbox.de/cgi-bin/ivw/CP/" + url + ";LoggedIn";
				document.getElementById('result').innerHTML = document.getElementById('result').innerHTML + "<img src=\""+IVW+"?r="+escape(document.referrer)+"&d="+(Math.random()*100000)+"\" width=\"1\" height=\"1\" alt=\"\" align=\"left\" />";
			}	
							
			decoGreyboxLinks();
		    //evalScripts( searchHTTP.responseText );
		    
		    
		    document.body.style.cursor="default";
		    if(GB_CURRENT != null) GB_hide();
		} else {
			alert('Es trat leider ein Problem bei ihrer Anfrage auf.\n\nBitte probieren sie es erneut.');
			//alert(searchHTTP.status);
		}
		return false;
	}
}

function search_hideLoadingOverlay() {
	document.body.style.cursor="default";
}

function update_V3(text) {
	
	document.getElementById('result').innerHTML = P_Template.parse(search_lastTemplate, JSON.parse(text));

	search_hideLoadingOverlay();	
	
	// pageTracker._trackPageview(xmlRequestUrl);
			
	/*url = xmlRequestUrl.split("/");
	url = url[url.length-1].split(".");
	url=url[0];
	if(window.location.protocol=='http:') {
		var IVW = window.location.protocol+"//praktika.ivwbox.de/cgi-bin/ivw/CP/" + url + ";LoggedIn";
		document.getElementById('result').innerHTML = document.getElementById('result').innerHTML + "<img src=\""+IVW+"?r="+escape(document.referrer)+"&d="+(Math.random()*100000)+"\" width=\"1\" height=\"1\" alt=\"\" align=\"left\" />";
	}*/		
}

function show(type) {
	// Art des Praktikums
	document.getElementById('internship').style.display = 'none';
	if(type != '1') document.getElementById('praktikumsart').options[0].selected = true;
	// Studienrichtung
	document.getElementById('study').style.display = 'none';
	if(type != '1' && type != '2') document.getElementById('studienrichtung').options[0].selected = true;
	// Art der Anstellung und Position
	document.getElementById('job').style.display = 'none';
	if(type != '5') {
		document.getElementById('beschaeftigung').options[0].selected = true;
		document.getElementById('position').options[0].selected = true;
	}
	// Datum
	document.getElementById('date').style.display = '';
	// Dauer
	document.getElementById('duration').style.display = '';
	
	switch (type) {
		case '1': // Praktikum
			document.getElementById('study').style.display = '';
			break;
		case '2': // Bachelor- / Masterarbeit
			document.getElementById('study').style.display = '';
			document.getElementById('date').style.display = 'none'; // nur hier
			document.getElementById('zeitraum').options[0].selected = true;
			break;
		case '4': // Ausbildung
			document.getElementById('duration').style.display = 'none';
			document.getElementById('dauer').options[0].selected = true;
			break;
		case '5': // Berufseinstieg
			document.getElementById('job').style.display = ''; // nur hier
			document.getElementById('duration').style.display = 'none';
			document.getElementById('dauer').options[0].selected = true;
			break;
		default:
			break;
	}
}

document.writeln('<script src="/scripts/wz_tooltip.js" type="text/javascript"></script>');

detailSuche = {
	prepare:function() {
		var suche = {};

		if(document.getElementById('qualifikation').value != '') 
			suche["qualifikation"] = document.getElementById('qualifikation').value;
			
		if(document.getElementById('studienrichtung').value != '') 
			suche["studienrichtung"] = document.getElementById('studienrichtung').value;
			
		if(document.getElementById('branche').value != '') 
			suche["branche"] = document.getElementById('branche').value;
			
		if(document.getElementById('berufsfeld').value != '') 
			suche["berufsfeld"] = document.getElementById('berufsfeld').value;
			
		if(document.getElementById('beschaeftigung').value != '') 
			suche["beschaeftigung="] = document.getElementById('beschaeftigung').value;
			
		if(document.getElementById('position').value != '') 
			suche["position"] = document.getElementById('position').value;
			
		if(document.getElementById('zeitraum').value != '') 
			suche["zeitraum"] = document.getElementById('zeitraum').value;
			
		if(document.getElementById('dauer').value != '') 
			suche["dauer"] = document.getElementById('dauer').value;
			
		if(document.getElementById('land').value != '') 
			suche["land"] = document.getElementById('land').value;
		
		if(document.getElementById('bundesland').value != '' && document.getElementById('bundesland').value != '%') 
			suche["bundesland"] = document.getElementById('bundesland').value;
			
		if(document.getElementById('grossraum').value != '' && document.getElementById('grossraum').value != '%') 
			suche["grossraum"] = document.getElementById('grossraum').value;
				
		return suche;
	}
};

	var webSearch;
	
	
	function searchComplete() {
	  // Check that we got results
	  if (webSearch.results && webSearch.results.length > 0) {
	    // Grab our content div, clear it.
	    var contentDiv = document.getElementById('googleResult');
	    contentDiv.innerHTML = '<b>Gefundene Webseiten auf Praktika.de</b><br />';
	
	    // Loop through our results, printing them to the page.
	    var results = webSearch.results;
	    for (var i = 0; i < results.length && i < 3; i++) {
	      // For each result write it's title and image to the screen
	      var result = results[i];
		  
	      var title = document.createElement('div');
		  title.className="title";
		  
	      // We use titleNoFormatting so that no HTML tags are left in the title
		  if (result.url.indexOf('/cms/') != -1) {
		  	title.innerHTML = "<a href='" + result.url + "'>" + result.title + "</a>";
		  } else {
		  	/* title.innerHTML = "<a href='" + result.url + "' target='_blank'>" + result.title + "</a>"; */
		  }
		  
		  suche.googleResults = contentDiv.innerHTML;
	      // Put our title + image in the content
	      contentDiv.appendChild(title); 
		 
	    }
		// contentDiv.innerHTML += '<br /><b>Gefundene Stellenangebote auf Praktika.de</b>';
	  }
	}
   
    function loadGoogleSearch(suchstring) {
      
	  // Create a search control
      // var searchControl = new google.search.SearchControl();
	// alert("TEST");
   	  webSearch = new google.search.WebSearch();
	  webSearch.setSiteRestriction('www.praktika.de');
	  webSearch.setSearchCompleteCallback(this, searchComplete, null);
      webSearch.setQueryAddition("cms");
	  
	  //searchControl.addSearcher(webSearch);

      // tell the searcher to draw itself and tell it where to attach
      //searchControl.draw(document.getElementById("googleResult"));

      // execute an inital search
      webSearch.execute(suchstring);
    }
	
suche = {
	// Zuletzt angesehene Seite
	lastPage:0,
	// Nach welcher Column soll sortiert werden?
	sortRow:"modify",
	// In welcher Richtung soll Sortiert werden?
	sortDesc:"DESC",
	// Funktion wird vor jeder Suchanfrage aufgerufen und gibt evtl. ein Array aus Suchparametern zurück
	preSearchCallback:undefined,
	// Eingesetzte Filter
	filterArray:{},
	// Welcher Typ wurde zuletzt genutzt
	lastType:"",
	// Cached den Inhalt der weniger Box neben der suche
	filterCache:{},
	// Zuletzt getätigter suchstring
	lastSuchString:"",
	// Ergebnisse von Google werden zwischengespeichert
	googleResults:"",
	// Welche Box wurde zuletzt aufgeklappt
	lastOpenBox:"",
	// Schaltet Option ein/aus und aktuallisiert Ergebnisse
	toogleOption:function(id) {
		if($(id).checked == true) 
			$(id).checked = false; 
		else 
			$(id).checked = true;
			
		// g suche.page(1);
	},
	// Initialisiert die Suche
	initSuche:function(searchname,callback) {
		if(callback != undefined) {
			// preSearchCallback Speichern
			suche.preSearchCallback = callback;
		}
		suche.lastType = searchname;
	},
	// Funktion ruft eine bestimmte Seitennummer auf oder aktuallisiert die aktuelle Seite (pageNumber = -1)
	page:function(pageNumber, options) {
		if(pageNumber == undefined) pageNumber = -1;

		if(pageNumber == -1) pageNumber = suche.lastPage;
		if(options == undefined) options = {};

/*		if(top.document.getElementById('sort') == undefined) {
			sortRow = "modify DESC";
		} else {
			sortRow = document.getElementById('sort').value;
		}
	*/	
                var postArray = ['sort=' + suche.sortRow + '/' + suche.sortDesc,'page='+pageNumber,'suchid=' + suchid];
                if(options.hash != undefined) {
                    postArray.push("filterHash=" + options.hash);
                }

		if(suche.preSearchCallback != undefined) {
			suchArray = suche.preSearchCallback();
		}
		
		if(document.getElementById("start_monat").value != "" && document.getElementById("start_jahr").value != "") {
			postArray.push("startzeit="+document.getElementById("start_monat").value+"-" + document.getElementById("start_jahr").value);
		} else if(document.getElementById("start_jahr").value != "") {
			postArray.push("von_jahr="+document.getElementById("start_jahr").value);
		}
                
                
		for(var key in suche.filterArray) {
			if(suche.filterArray[key] != undefined)
				suchArray[key] = suche.filterArray[key];
		}


		if($('plzort').value != "") {
			suchArray["umkreis"] = $('plzort').value + "_" + $('radius').value;
		}
		
		spalten = "";
		for(a = 1;a <= 7;a++) {
			if ($('such_spalte_' + a).checked == true) {
				spalten += a + ",";
			}
			 
		}
		
		spalten = spalten.substr(0,spalten.length - 1);
		suchArray["spalte"] = spalten;
		
		for(var key in suchArray) {
			postArray.push(key + "=" + suchArray[key]);
		}
                var postStr = postArray.join("&");
                
		NachOben();
		suche.lastPage = pageNumber;
		
		suchArray["url"] = window.location.protocol + '//' + window.location.host + '/home/stellen/' + suche.lastType+ '_update.phtml';
		
		suche.showLoadingScreen();
		
		xhr(window.location.protocol + '//' + window.location.host + '/home/stellen/' + suche.lastType+ '_update.phtml', 
			postStr, 
			suche.updateResults.bind(suchArray));
			
	},
	showLoadingScreen:function() {
            $('loadingScreen').style.display="";
	},
	hideLoadingScreen:function() {
            $('loadingScreen').style.display="none";
	},
	updateResults: function(text) {
		
		var data = JSON.parse(trim(text));
		if(data.sendfilter != undefined) {
                    suche.cleanFilter();
                    for(var key in data.sendfilter) {
                        var parts = data.sendfilter[key].split("_");
                        suche.activateFilter(key, parts[0], parts[1], false);
                    }
                }
		
		if (data.row == false) {
                    kat = "ohne";
		} else if(data.searchResult_count == "mehr als 120") {
                    kat = "viele";
		} else {			
                    kat = "normal";
		}

/*	  var m3_u = (location.protocol=='https:'?'https://ads.praktika.de/www/delivery/ajs.php':'http://ads.praktika.de/www/delivery/ajs.php');
	   var m3_r = Math.floor(Math.random()*99999999999);
	   if (!document.MAX_used) document.MAX_used = ',';
	   html2 = "<script type='text/javascript' src='"+m3_u;

	   html2 = html2 + "?zoneid=44";
	   
	   html2 = html2 + "&cb=" + m3_r;
	   if (document.MAX_used != ',') html2 = html2 + "&exclude=" + document.MAX_used;
	   html2 = html2 + (document.charset ? '&charset='+document.charset : (document.characterSet ? '&charset='+document.characterSet : ''));
	   html2= html2 + "&loc=" + escape(window.location);
	   
	   if (document.referrer) html2 = html2 + "&referer=" + escape(document.referrer);
	   if (document.context) html2 = html2 + "&context=" + escape(document.context);
	   if (document.mmm_fo) html2 = html2 + "&mmm_fo=1";
	   	
	   html2 = html2 + "'><\/script>";*/
	   
		document.getElementById('result').innerHTML = P_Template.parse(search_lastTemplate, data).replace(/~~/g,"}").replace(/~/g,"{");
		// alert(html2);

		/* document.getElementById('searchAdvert').innerHTML = html2;
		alert(html2);
		evalScripts(document.getElementById('searchAdvert').innerHTML); */
		
		if(data.row != false) {
			$('filterContainer_radius').style.display = "";
		} else {
			$('filterContainer_radius').style.display = "none";
		}

		suche.createPageNavigation(data["navi"]);

                suche.hideLoadingScreen();
	
		if (this.suchstring != suche.lastSuchString) {
			if (this.suchstring != undefined && this.suchstring != "") 
				suche.spellchecker(this.suchstring);
				
			suche.lastSuchString = this.suchstring;
		}
		
		if(suche.googleResults == "" && this.suchstring != "") {
			window.setTimeout("loadGoogleSearch('"+this.suchstring+"');", 1000);			
		} else if(suche.googleResults != "") {
			document.getElementById('googleResult').innerHTML = suche.googleResults;
		}
				
/*		autoCompleter.initAutoComplete($('plzort'),"/admin/ajax/einsatzort.phtml", function(value) {
			parts = value.split("-"); 
			$('plzort').value = trim(parts[0]);
       	}, {width:"300px"});*/
		
		var paraNormal;
		var paraViele;
		
		function setKategorie(value) {
			if (paraNormal == undefined) {
				paraNormal = value;
			} else if(paraViele == undefined){
				paraViele = value;
			}
		}

		if(this.branche != undefined) {
			setKategorie("Branche " + this.branche);
		}
		if(this.berufsfeld != undefined){
			setKategorie("Berufsfeld " + this.berufsfeld);
		} 
		if(this.bundesland != undefined) {
			setKategorie("Bundesland " + this.bundesland);
		}
		if(this.startup != undefined) {
			setKategorie("Startup " + this.startup);
		}
		if(this.einsatzland != undefined) {
			setKategorie("Einsatzland " + this.einsatzland);
		}
		if(this.firmensize != undefined) {
			setKategorie("Firmengr&ouml;&szle;e " + this.firmensize);
		}
		
		pageTracker._trackPageview("/suche_update/?suche=" + urlencode(this.suchstring.toLowerCase()) + "&ohne=" + kat + (paraNormal!=undefined?("&normel=" + paraNormal):"") + (paraViele!=undefined?("&viele=" + paraViele):""));
			
		url = this.url.split("/");
		url = url[url.length-1].split(".");
		url = url[0];

                suche.setHash();
		
    },
    parseHash:function(hash) {
        // Nur parsen, wenn Hash in URL sich von dem letzten bewusst geladenem unterscheidet
      if(suche.lastHash != hash) {
            
            // Wenn Hash ein String ist (Zu Anfang ist er eine Integer (1))
            if(typeof hash != "string") return;
            
            var parts = hash.split("l");

            var page = 1;
            for(a=0;a<parts.length;a++) {
                // Die Seiteninformation aus dem Hash auslesen und nutzen
                if(parts[a].substr(0, 2) == "pp") {
                    page = parts[a].substr(2);
                }
            }

            suche.page(page, {hash:hash});
        }
    },
    setHash:function() {
     //   alert(window.location.hash);
   //     alert();
        var hashes = [];
//        console.log(suche.filterArray);
//        console.log(suche.filterArray.length);
//        alert(suche.filterArray.length);

        if(obj_len(suche.filterArray.length)) {
            // console.log(suche.filterArray);
            for(var key in suche.filterArray) {
//                    console.log(key);
               //     alert("PRE_SWITCH");
                    if(suche.filterArray[key] != undefined) {
                        var value = "";
                        value = suche.filterArray[key].split("_")[0];
                        switch(key) {
                            case "branche":
                                prefix = "bB";
                                break;
                            case "berufsfeld":
                                prefix = "bF";
                                break;
                            case "bundesland":
                                prefix = "pB";
                                break;
                            case "grossraum":
                                prefix = "pG";
                                break;
                            case "einsatzland":
                                prefix = "pE";
                                break;
                            case "firmensize":
                                prefix = "fS";
                                break;
                            case "bezahlt":
                                prefix = "sB";
                                break;
                            case "startup":
                                prefix = "sS";
                                value = 1;
                                break;
                        }

                        //alert(key + "->" + value);
                        // console.log(suche.filterArray[key] + value);
                        hashes.push(prefix + value);
                    }
                    //alert("AFTER_PUSH");
                }
                hashes.push("pp" + suche.lastPage);
            
        }

//alert("POST FOR");
        suche.lastHash = hashes.join("l");
        newURL = window.location.href.substr(0, (window.location.href.length - window.location.hash.length));
//alert("POST FOR2");
if(newURL.substr(-1) == "#") newURL = newURL.substr(0, newURL.length - 1);
//        alert("POST FOR3");
        window.location.href = newURL + "#" + hashes.join("l");
//         console.log(window);
        //window.location =
    },
    lastHash:"1",
    createJobmail:function() {
		var postStr = 'sort=' + suche.sortRow + '/' + suche.sortDesc + '&page=' + pageNumber + '&suchid=' + suchid;
		if(suche.preSearchCallback != undefined) {
			suchArray = suche.preSearchCallback();
		}

		if(document.getElementById("start_monat").value != "" && document.getElementById("start_jahr").value != "") {
			postStr += "&startzeit="+document.getElementById("start_monat").value+"-" + document.getElementById("start_jahr").value;
		} else if(document.getElementById("start_jahr").value != "") {
			postStr += "&von_jahr="+document.getElementById("start_jahr").value;
		}

		for(var key in suche.filterArray) {
			if(suche.filterArray[key] != undefined)
				suchArray[key] = suche.filterArray[key];
		}
		if($('plzort').value != "") {
			suchArray["umkreis"] = $('plzort').value + "_" + $('radius').value;
		}

		spalten = "";
		for(a = 1;a <= 7;a++) {
			if ($('such_spalte_' + a).checked == true) {
				spalten += a + ",";
			}

		}

		spalten = spalten.substr(0,spalten.length - 1);
		suchArray["spalte"] = spalten;

		for(var key in suchArray) {
			postStr += "&" + key + "=" + suchArray[key];
		}
		suche.lastPage = pageNumber;

		// if (pageTracker != undefined) {
			// pageTracker._trackPageview(window.location.protocol + '//' + window.location.host + '/home/stellen/' + suche.lastType + '_update.phtml');
		// }
		suchArray["url"] = window.location.protocol + '//' + window.location.host + '/home/stellen/' + suche.lastType+ '_update.phtml';

		xhr(window.location.protocol + '//' + window.location.host + '/jobmail/anlegen.html',postStr);
        },
	spellchecker:function(suchstring) {
		// $('divSpellchecker').innerHTML = "Meinten Sie: <a href="/suche/{meanThisUrl}">{meanThis}</a>";
		$('divSpellchecker').style.display="";
		$('divSpellchecker').innerHTML = "Rechtschreibpr&uuml;fung: <img src='/styles/images/ajax/loading_2.gif' title='Rechtschreibprüfung' alt='Rechtschreibprüfung' />";
		
		xhr('/home/stellen/spellchecker.php', 'suchstring=' + suchstring, function(text) {
			var data = JSON.parse(trim(text));
			
			if(data["show"] == true) {
				$('divSpellchecker').innerHTML = 'Meinten Sie: <a href="/suche/' + data["meanThisUrl"] + '">' + data["meanThis"] + '</a>';
			} else {
				$('divSpellchecker').style.display="none";
			}
		});
	},
	setFilter:function(opt) {

		if (opt["spalte"] == undefined) {
			opt["spalte"] = {};
		}
			
		for (var a = 1; a <= 7; a++) {
			if (opt["spalte"] == undefined || opt["spalte"][a] == undefined) {opt["spalte"][a] = 0;}
				
			$('spalteCount_' + a).innerHTML = opt["spalte"][a];
				
		}

		
		if (opt["bundesland"] != undefined) {
			if(suche.filterArray["bundesland"] != undefined || opt["bundesland"].length <= 1) {
				$('filterContainer_bundesland').style.display = "none";
			} else {
				$('filterContainer_bundesland').style.display = "";
			}
			
			html = "";
			for (var a = 0; a < opt["bundesland"].length; a++) {
				value = opt["bundesland"][a];
				if (value == "more") {
					html += suche.generateMoreLink("bundesland");
				}
				else {
					html += suche.generateFilterRow(value, "bundesland");
				}
			}
			
			$('bundesland_filter').innerHTML = html;
		} else {
			$('filterContainer_bundesland').style.display = "none";
		}

		if (opt["grossraum"] != undefined) {
			if(suche.filterArray["grossraum"] != undefined || opt["grossraum"].length <= 1) {
				$('filterContainer_grossraum').style.display = "none";
			} else {
				$('filterContainer_grossraum').style.display = "";
			}
			
			html = "";
			for (var a = 0; a < opt["grossraum"].length; a++) {
				value = opt["grossraum"][a];
				if (value == "more") {
					html += suche.generateMoreLink("grossraum");
				}
				else {
					html += suche.generateFilterRow(value, "grossraum");
				}
			}
			
			$('grossraum_filter').innerHTML = html;
		} else {
			$('filterContainer_grossraum').style.display = "none";
		}		
		
		if (opt["berufsfeld"] != undefined) {
			if(suche.filterArray["berufsfeld"] != undefined || opt["berufsfeld"].length <= 1) {
				$('filterContainer_berufsfeld').style.display = "none";
			} else {
				$('filterContainer_berufsfeld').style.display = "";
			}			
			html = "";
			for (var a = 0; a < opt["berufsfeld"].length; a++) {
				value = opt["berufsfeld"][a];
				if (value == "more") {
					html += suche.generateMoreLink("berufsfeld");
				}
				else {
					html += suche.generateFilterRow(value, "berufsfeld");
				}
			}
			
			$('berufsfeld_filter').innerHTML = html;
		} else {
			$('filterContainer_berufsfeld').style.display = "none";
		}
		
		if (opt["branche"] != undefined) {
			if(suche.filterArray["branche"] != undefined || opt["branche"].length <= 1) {
				$('filterContainer_branche').style.display = "none";
			} else {
				$('filterContainer_branche').style.display = "";
			}				
			html = "";
			for (var a = 0; a < opt["branche"].length; a++) {
				value = opt["branche"][a];
				if (value == "more") {
					html += suche.generateMoreLink("branche");
				}
				else {
					html += suche.generateFilterRow(value, "branche");
				}
			}
			
			$('branche_filter').innerHTML = html;
		} else {
			$('filterContainer_branche').style.display = "none";
		}	
		
		$('filterContainer_startzeit').style.display = "";
		if (opt["startzeit"] != undefined) {
/*
			if(opt["startzeit"].length > 1) {
				$('filterContainer_startzeit').style.display = "";
			} else {
				$('filterContainer_startzeit').style.display = "none";
			}				

			html = "";
			for (var a = 0; a < opt["startzeit"].length; a++) {
				value = opt["startzeit"][a];
				if (value == "more") {
					html += suche.generateMoreLink("startzeit");
				}
				else {
					html += suche.generateFilterRow(value, "startzeit");
				}
			}
			
			$('startzeit_filter').innerHTML = html; */
		} else {
			$('filterContainer_startzeit').style.display = "";
		}		
			
		if (opt["sprache"] != undefined) {

			if(opt["sprache"].length > 1) {
				$('filterContainer_sprache').style.display = "";
			} else {
				$('filterContainer_sprache').style.display = "none";
			}				

			html = "";
			for (var a = 0; a < opt["sprache"].length; a++) {
				value = opt["sprache"][a];
				if (value == "more") {
					html += suche.generateMoreLink("sprache");
				}
				else {
					html += suche.generateFilterRow(value, "sprache");
				}
			}
			
			$('sprache_filter').innerHTML = html;
		} else {
			$('filterContainer_sprache').style.display = "none";
		}		
		
		if (opt["firmensize"] != undefined) {

			if(opt["firmensize"].length > 1) {
				$('filterContainer_firmensize').style.display = "";
			} else {
				$('filterContainer_firmensize').style.display = "none";
			}				
			
			html = "<select id='firmensize' onchange='suche.deactivateFilter(\"firmensize\"); suche.activateFilter(\"firmensize\", this.value, getSelectedText(this).substr(0,getSelectedText(this).indexOf(\"(\")));' name='firmensize' style='width:auto; float:right;'><option value=''>- -</option>";
			for (var a = 0; a < opt["firmensize"].length; a++) {
				value = opt["firmensize"][a];
				if (value == "more") {
					html += suche.generateMoreLink("firmensize");
				}
				else {
					html += "<option value='"+value[0]+"'>"+value[1]+" ("+value[2]+")</option>"; //suche.generateFilterRow(value, "firmensize");
				}
			}
			
			$('firmensize_filter').innerHTML = html + "</select>";
		} else {
			$('filterContainer_firmensize').style.display = "none";
		}		
		
		if (opt["startup"] != undefined) {

			if(opt["startup"].length > 0) {
				$('filterContainer_startup').style.display = "";
			} else {
				$('filterContainer_startup').style.display = "none";
			}				
			if(suche.filterArray["startup"] != undefined) {
				$('filterContainer_startup').style.display = "none";
			}
			
			html = "";
			for (var a = 0; a < opt["startup"].length; a++) {
				value = opt["startup"][a];
				if (value == "more") {
					// html += suche.generateMoreLink("startup");
				}
				else {
					html += suche.generateFilterRow(value, "startup");
				}
			}
			
			$('startup_filter').innerHTML = html;
		} else {
			$('filterContainer_startup').style.display = "none";
		}			
		if (opt["bezahlt"] != undefined) {

			if(opt["bezahlt"].length > 0) {
				$('filterContainer_bezahlt').style.display = "";
			} else {
				$('filterContainer_bezahlt').style.display = "none";
			}
			if(suche.filterArray["bezahlt"] != undefined) {
                                $('filterContainer_bezahlt').style.display = "none";
			}

			html = "";
			for (var a = 0; a < opt["bezahlt"].length; a++) {
				value = opt["bezahlt"][a];
				if (value == "more") {
					// html += suche.generateMoreLink("startup");
				}
				else {
					html += suche.generateFilterRow(value, "bezahlt");
				}
			}

			$('bezahlt_filter').innerHTML = html;
		} else {
			$('filterContainer_bezahlt').style.display = "none";
		}

		if (opt["einsatzland"] != undefined) {
			//console.log(opt["einsatzland"]);
			if(opt["einsatzland"].length > 1) {
				$('filterContainer_einsatzland').style.display = "";
			} else {
				$('filterContainer_einsatzland').style.display = "none";
			}				
			
			html = "";
			for (var a = 0; a < opt["einsatzland"].length; a++) {
				value = opt["einsatzland"][a];
				if (value == "more") {
					html += suche.generateMoreLink("einsatzland");
				}
				else {
					if(value[0] != 68) html += suche.generateFilterRow(value, "einsatzland");
				}
			}
			
			$('einsatzland_filter').innerHTML = html;
		} else {
			$('filterContainer_startup').style.display = "none";
		}					
	},
	generateMoreLink:function(mode) {
		return "<span class='filterOption moreLink' style='float:right;'><a href='#' onclick='suche.loadMoreFilter(\"" + mode + "\");return false;' alt='Mehr Eintraege' title='Mehr Eintraege'><b>aufklappen ...</b></a><br /></span>";
	},
	generateFilterRow:function(value, mode) {
		return "<span class='filterOption'><a href='#' onclick='suche.activateFilter(\"" + mode + "\",\"" + value[0] + "\",\"" + value[1] + "\");return false;' alt='"+value[1]+"' title='"+value[1]+"'>" + cutWord(value[1],25) + " (" + value[2] + ")</a><br /></span>";
	},
	setStartDate:function() {
		suche.deactivateFilter("")
	},
	loadMoreFilter:function(mode) {
		if(suche.lastOpenBox != "") {
			// suche.loadLesserFilter(suche.lastOpenBox);
		}
		
		if (suche.filterCache[mode] != undefined && suche.filterCache[mode]["mehr"] != undefined) {
			$(mode + '_filter').innerHTML = suche.filterCache[mode]["mehr"];
			suche.lastOpenBox = mode;
		} else {
			suche.filterCache[mode] = {};
			suche.filterCache[mode]["wenig"] = $(mode + '_filter').innerHTML;
			$(mode + '_filter').innerHTML = "<div style='text-align:center;'><br /><br /><img src='/styles/images/ajax/loading_2.gif' alt='Lade' title='Lade' /><br /><br /></div>";
			
			xhr(window.location.protocol + '//' + window.location.host + '/home/stellen/filter.phtml', 'mode=' + mode, function(text){
				text += "<span class='filterOption' style='float:right;'><a title='Weniger' alt='weniger' onclick='suche.loadLesserFilter(\"" + this.mode + "\"); return false;' href='#'><b>Weniger ...</b></a></span>";
				$(this.mode + '_filter').innerHTML = text;
				suche.filterCache[mode]["mehr"] = text;
				suche.lastOpenBox = this.mode;
			}.bind({"mode": mode
			}));
		}
	},
	loadLesserFilter:function(mode) {
		$(mode + '_filter').innerHTML = suche.filterCache[mode]["wenig"];
	},
        cleanFilter:function() {
            for(var key in suche.filterArray) {
                suche.deactivateFilter(key, false);
            }
            suche.filterArray = {};
        },
	deactivateFilter:function(mode, reload) {
		if($('filterSummary_' + mode) == undefined) return;
                if(reload == undefined) reload = true;


                suche.removeFilterLine(mode);
                suche.filterArray[mode] = undefined;
		if(reload != false) { suche.page(1);}
	},
        removeFilterLine:function(mode) {
            $('filterSummary_' + mode).parentNode.removeChild($('filterSummary_' + mode));

            if ($('filterSummary').innerHTML == "") {
                $('actFilterBox').style.display = 'none';
            }

        },
        writeFilterLine:function(mode, title) {
            $('filterSummary').innerHTML = $('filterSummary').innerHTML + "<span onclick='suche.deactivateFilter(\"" + mode + "\")' id='filterSummary_" + mode + "' class='filterSummaryEntry'>" + cutWord(title,25) + "&nbsp;<img src='/styles/images/icons/loeschen_mini_wht.png' alt='Filter entfernen' title='Filter entfernen' />&nbsp;<br /></span>";
            $('actFilterBox').style.display = '';
        },
	activateFilter:function(mode, id, title, reload) {
                if(reload == undefined) reload = true;
                if(id==0 && id !== "0") return;
		if(suche.filterArray[mode] != undefined) return;

                suche.writeFilterLine(mode, title);
                //window.opera.postError(mode);
                //window.opera.postError(parseInt(id));
                // pageTracker._trackEvent('suche', 'activate Filter', 'Mode ' + mode, parseInt(id));
		
		suche.filterArray[mode] = id + "_" + escape(title);
		if(reload != false) { suche.page(1);}
	},
	createPageNavigation:function(opt, arrows) {
		if(arrows == undefined) arrows = false;
		
		maxPage = opt["maxPage"];
		pageNumber = opt["pageNumber"];
		html = "";
		
		if(maxPage <= 1) {
			$('pageSwitcher_bottom').innerHTML = "";
			$('pageSwitcher_top').innerHTML = "";
			return;
		}
		
		if (pageNumber > 2) {
			startPage = pageNumber - 1;
		} else {
			startPage = 1;
		}
		if(pageNumber < maxPage - 1) {
			endPage = pageNumber + 1;
		} else {
			endPage = maxPage;
		}
		
		for(a=startPage; a <= endPage; a++) {
			html += "<span class='pageButton " + (pageNumber==a?"aktPage":"") + " ' onclick='suche.page("+a+")'>" + a + "</span>";
		}
		
		if(pageNumber > 3) {
			html = "<span class='pageButton' onclick='suche.page(1)'>1</span> ... " + html;
		}
		if(pageNumber < maxPage - 2) {
			html += " ... <span class='pageButton' onclick='suche.page("+maxPage+")'>" + maxPage + "</span>";
		}
		
		bottomHTML = html;
		if(pageNumber > 1) {
			bottomHTML = "<span class='pageButton' onclick='suche.page("+(pageNumber-1)+")'>&lt;</span>&nbsp;" + bottomHTML;
		}
		if(pageNumber < maxPage) {
			bottomHTML = bottomHTML + "&nbsp;<span class='pageButton' onclick='suche.page("+(pageNumber+1)+")'>&gt;</span>";
		}
		$('pageSwitcher_bottom').innerHTML = bottomHTML;
		$('pageSwitcher_top').innerHTML = html;
	},
	sort:function(value) {
		parts = value.split("-");
		
		suche.sortRow = parts[0];
		suche.sortDesc = parts[1];
		
		suche.page();
	},
	stelleMerken:function(firmenID, stellenID) {
		var poststr = 'firmenid=' + firmenID + '&stellenid=' + stellenID;
		document.getElementById('gemerkt_' + stellenID).innerHTML = "<img src='/gifs/stelle/loader_merken.gif' />";
		xhr(window.location.protocol + '//' + window.location.host + '/home/praktikanten/stelle_merken.phtml', poststr, function(text) {
			
			removeClass(document.getElementById('gemerkt_' + this.stellenid),"stelle_merken");
			addClass(document.getElementById('gemerkt_' + this.stellenid),"stelle_gemerkt");

			document.getElementById('gemerkt_' + this.stellenid).onclick = "";
			document.getElementById('gemerkt_' + this.stellenid).innerHTML = "<span>Stelle gemerkt</span>";
			
			anzahl = parseInt(document.getElementById('count_merkzettel').innerHTML);
			document.getElementById('count_merkzettel').innerHTML = anzahl + 1;
			pageTracker._trackEvent('suche', 'Stelle merken', 'Stelle ' + this.stellenid, this.stellenid);
			
		}.bind({stellenid:stellenID}));
		
		return false;	
	},
	deleteMerkzettelEntry:function(id) {
		var poststr = 'act=del&id=' + id;
		xhr(window.location.protocol + '//' + window.location.host + '/home/praktikanten/stelle_merken.phtml', poststr, function(text) {
			$('sucheMerkzettel_' + this.id).parentNode.removeChild($('sucheMerkzettel_' + this.id));
		}.bind({'id': id}));
	},
	loadMerkzettel:function() {
		smallbox.loadUrl($('resultContainer'),"/home/stellen/merkzettel.php");

	},
	saveSearch:function() {
		var postStr = '';
		if(suche.preSearchCallback != undefined) {
			suchArray = suche.preSearchCallback();
		}
		
		for(var key in suche.filterArray) {
			if(suche.filterArray[key] != undefined)
				suchArray[key] = suche.filterArray[key];
		}
		if($('plzort').value != "") {
			suchArray["umkreis"] = $('plzort').value + "_" + $('radius').value;
		}
		
		spalten = "";
		for(a = 1;a <= 7;a++) {
			if ($('such_spalte_' + a).checked == true) {
				spalten += a + ",";
			}
			 
		}
		
		spalten = spalten.substr(0,spalten.length - 1);
		suchArray["spalte"] = spalten;
		
		for(var key in suchArray) {
			postStr += "&" + key + "=" + suchArray[key];
		}
		
		xhr(window.location.protocol + '//' + window.location.host + '/home/stellen/suche_speichern.php', 
			postStr, 
			function(text) {
				if (text == "MUST_LOGIN") {
					smallbox.alert("Diese Funktion steht nur registrierten Nutzern zur Verfügung.");
				}
				else {
					alert("Ready");
				}
			});
	}

};

function cutWord(string, length) {
	if(string == undefined) return "";
        return string.length > length?string.substring(0,length)+"...":string;
}
		
		