
// gibt den Cookie für den uebergeben Bezeichner zurueck
function getCookie(strBezeichner) {
	strCookie = document.cookie;
	// Leerzeichen entfernen
	strCookie = strCookie.replace(/\s/g, "");
	strCookie+=";";
	strValue = '';
 	while(strCookie != '') {
		strName = strCookie.substring(0, strCookie.search('='));
		strWert = strCookie.substring(strCookie.search('=')+1, strCookie.search(';'));
		if(strBezeichner == strName) {
			strValue = strHtmlEncode(strWert);
		}
		i = strCookie.search(';')+1;
		if(i == 0) {
			i = strCookie.length
		}
  		strCookie = strCookie.substring(i,strCookie.length);
 	}
 	return strValue;
}

// setzt den Cookie
function setCookie(strBezeichner, strWert, intTage) {
	var strExpires = '';
	if ( intTage > 0 ) {
		var intDauer = 1000 * 60 * 60 * 24 * intTage;
		var dtmNow = new Date();
		var dtmDauer = new Date(dtmNow.getTime() + intDauer);
		strExpires = " expires=" + dtmDauer.toGMTString() + ";"
	}
	document.cookie = strBezeichner + "=" + strWert + "; path = /;" + strExpires;
}

// entcodiert die Cookie, muss bei Wunsch entsprechend erweitert werden
function strHtmlEncode(Tmp) {
	var strTmp = new String(Tmp);
    strTmp = strTmp.replace(/%2E/g, "."); // "."
    strTmp = strTmp.replace(/%3A/g, ":"); // ":"
    strTmp = strTmp.replace(/\+/g, " ");  // " "
    strTmp = strTmp.replace(/%20/g, " ");  // " "
    return strTmp;
} 

// codiert die Daten für den Cookie, muss bei Wunsch entsprechend erweitert werden
function strUrlEncode(Tmp) {
	var strTmp = new String(Tmp);
    strTmp = strTmp.replace(/\./g, "%2E"); // "."
    strTmp = strTmp.replace(/\:/g, "%3A"); // ":"
    strTmp = strTmp.replace(/\s/g, "+");   // " "
    return strTmp;
} 

// falls im Cookie noch Unterwerte gesetzt sind, werde diese hier zurückgegeben
function getCookieValue(strBezeichner, strCookie) {
	strCookie = strCookie.replace(/&/g, ";");
	strCookie+=";";
	strValue = '';
	while(strCookie != '') {
		strName = strCookie.substring(0, strCookie.search('='));
		strWert = strCookie.substring(strCookie.search('=')+1, strCookie.search(';'));
		if(strBezeichner == strName) {
			strValue = strHtmlEncode(strWert);
			return strValue;
		}
		i = strCookie.search(';')+1;
		if(i <= 0) {
			i = strCookie.length;
		}
  		strCookie = strCookie.substring(i, strCookie.length);
 	}
 	return strValue;
}


function getIntCheckValue(strValue , intDefault) {
	// regulärer Ausdruck für Int
	var strRegExpMusterInt = /^\d+$/;
	if ( strRegExpMusterInt.test(strValue) )
		return strValue;
	else
		return intDefault;
}

