function SucheSpeichern() {
	var sg = document.suche.SGeschlecht.options[document.suche.SGeschlecht.selectedIndex].value;
	if (sg > 0) { var cc = sg; }
	else { cc = cc + '0'; }

	var av = document.suche.AlterVon.selectedIndex + 13;
	if (av > 13) { cc = cc + av; }
	else { cc = cc + '00'; }
	
	var ab = document.suche.AlterBis.selectedIndex + 13;
	if (ab > 13) { cc = cc + ab; }
	else { cc = cc + '00'; }
	
	var pv = document.suche.PLZVon.selectedIndex;
	if (pv > 9) { cc = cc + pv; }
	else if (pv > 0) { cc = cc + '0' + pv; }
	else { cc = cc + '00'; }
	
	var pb = document.suche.PLZBis.selectedIndex;
	if (pb > 9) { cc = cc + pb; }
	else if (pb > 0) { cc = cc + '0' + pb; }
	else { cc = cc + '00'; }
	
	cc = cc + document.suche.Land.options[document.suche.Land.selectedIndex].value;

	var so = document.suche.sort.options[document.suche.sort.selectedIndex].value;
	if (so == "Username") { cc = cc + 'u'; }
	else if (so == "GebDatum") { cc = cc + 'a'; }
	else if (so == "PLZOrt") { cc = cc + 'p'; }
	else { cc = cc + 'l'; }

	var wp = document.suche.withPic.options[document.suche.withPic.selectedIndex].value;
	if (wp > 0) { cc = cc + wp; }
	else { cc = cc + '0'; }
	
	var fp = document.suche.Flirt.options[document.suche.Flirt.selectedIndex].value;
	if (fp == 1) { 
		cc = cc + '1'; 

		var swe = document.suche.SSucheWen.options[document.suche.SSucheWen.selectedIndex].value;
		if (swe > 0) { cc = cc + swe; }
		else { cc = cc + '0'; }

		var sw = document.suche.SucheWofuer.options[document.suche.SucheWofuer.selectedIndex].value;
		if (sw > 0) { cc = cc + sw; }
		else { cc = cc + '0'; }

		var ra = document.suche.Raucher.options[document.suche.Raucher.selectedIndex].value;
		if (ra > 0) { cc = cc + ra; }
		else { cc = cc + '0'; }

		var ki = document.suche.Kinder.options[document.suche.Kinder.selectedIndex].value;
		if (ki > 0) { cc = cc + ki; }
		else { cc = cc + '0'; }

		var hf = document.suche.Haarfarbe.options[document.suche.Haarfarbe.selectedIndex].value;
		if (hf > 0) { cc = cc + hf; }
		else { cc = cc + '0'; }

		var gv = (document.suche.GroesseVon.selectedIndex * 5) + 95;
		if (gv > 99) { cc = cc + gv; }
		else { cc = cc + '000'; }
		
		var gb = (document.suche.GroesseBis.selectedIndex * 5) + 95;
		if (gb > 99) { cc = cc + gb; }
		else { cc = cc + '000'; }
		
	}
	else { 
		cc = cc + '000000000000000'; 
	}
	
	document.images['searchcc'].src = '/setconfcookie.php?key=UserSearch&val=' + cc;
	alert('Deine Sucheinstellungen wurden nun gespeichert.');
}

function SucheLaden() {
	document.suche.reset();

	var AllCookies = document.cookie.split("; ");
	for (var i=0;i<AllCookies.length;i++) {
		var cpair = AllCookies[i].split("=");
		if (cpair[0] == 'Conf')  ConfCookie = unescape(cpair[1]); 
	}
	if (ConfCookie) {
		var AllConfSettings = ConfCookie.split("&");
		for (var i=0;i<AllConfSettings.length;i++) {
			var spair = AllConfSettings[i].split(":");
			if (spair[0] == 'UserSearch') SuchCookie = spair[1];
		}
	}

	if (SuchCookie) {
		document.suche.SGeschlecht.selectedIndex = SuchCookie.substr(0,1);

		if (SuchCookie.substr(1,2)-13 > 0) document.suche.AlterVon.selectedIndex = SuchCookie.substr(1,2)-13;
		if (SuchCookie.substr(3,2)-13 > 0) document.suche.AlterBis.selectedIndex = SuchCookie.substr(3,2)-13;
		if (SuchCookie.substr(5,2) > 0) document.suche.PLZVon.selectedIndex = SuchCookie.substr(5,2);
		if (SuchCookie.substr(7,2) > 0) document.suche.PLZBis.selectedIndex = SuchCookie.substr(7,2);
		if (SuchCookie.substr(9,2) == 'DE') document.suche.Land.selectedIndex = 1;
		if (SuchCookie.substr(9,2) == 'AT') document.suche.Land.selectedIndex = 2;
		if (SuchCookie.substr(9,2) == 'CH') document.suche.Land.selectedIndex = 3;
		if (SuchCookie.substr(11,1) == 'u') document.suche.sort.selectedIndex = 1;
		if (SuchCookie.substr(11,1) == 'a') document.suche.sort.selectedIndex = 2;
		if (SuchCookie.substr(11,1) == 'p') document.suche.sort.selectedIndex = 3;
		if (SuchCookie.substr(12,1) > 0) document.suche.withPic.selectedIndex = SuchCookie.substr(12,1);

		if (SuchCookie.substr(13,1) > 0) {
			document.suche.Flirt.selectedIndex = 1;
			var  klappobject = document.getElementById('ErwSuche');
			if ( klappobject == null ) return;
			klappobject.style.display = "";
			
			if (SuchCookie.substr(14,1) > 0) {
				for (i=0;i<=2;i++) {
					if (document.suche.SSucheWen.options[i].value == SuchCookie.substr(14,1)) {
						document.suche.SSucheWen.selectedIndex = i;
						break;
					}
				}
			}
			if (SuchCookie.substr(15,1) > 0) {
				for (i=0;i<=9;i++) {
					if (document.suche.SucheWofuer.options[i].value == SuchCookie.substr(15,1)) {
						document.suche.SucheWofuer.selectedIndex = i;
						break;
					}
				}
			}
			if (SuchCookie.substr(16,1) > 0) document.suche.Raucher.selectedIndex = SuchCookie.substr(16,1);
			if (SuchCookie.substr(17,1) > 0) document.suche.Kinder.selectedIndex = SuchCookie.substr(17,1);
			if (SuchCookie.substr(18,1) > 0) {
				for (i=0;i<=9;i++) {
					if (document.suche.Haarfarbe.options[i].value == SuchCookie.substr(18,1)) {
						document.suche.Haarfarbe.selectedIndex = i;
						break;
					}
				}
			}
			if ((SuchCookie.substr(19,3)-95)/5 > 0) document.suche.GroesseVon.selectedIndex = (SuchCookie.substr(19,3)-95)/5;
			if ((SuchCookie.substr(22,3)-95)/5 > 0) document.suche.GroesseBis.selectedIndex = (SuchCookie.substr(22,3)-95)/5;
		}
		else {
			document.suche.Flirt.selectedIndex = 0;
			var  klappobject = document.getElementById('ErwSuche');
			if ( klappobject == null ) return;
			klappobject.style.display = "none";
		}
	}
	else {
		alert('Es wurde keine gespeicherte Suche gefunden.');
	}
}
