var PreloadFlag = false;
var expDays = 90;
var exp = new Date(); 
var tmp = '';
var tmp_counter = 0;
var tmp_open = 0;

exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function changeImages()
{
	if (document.images)
	{
		for (var i=0; i<changeImages.arguments.length; i+=2)
		{
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function newImage(arg)
{
	if (document.images)
	{
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}


function SetCookie(name, value) 
{
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape(value) +
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
		((path == null) ? "" : ("; path=" + path)) +
		((domain == null) ? "" : ("; domain=" + domain)) +
		((secure == true) ? "; secure" : "");
}

function getCookieVal(offset) 
{
	var endstr = document.cookie.indexOf(";",offset);
	if (endstr == -1)
	{
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie(name) 
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) 
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal(j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0)
			break;
	} 
	return null;
}


function openAllSmiles(){
        smiles = window.open('quick_reply.php?mode=smilies', '_phpbbsmilies', 'HEIGHT=300,resizable=yes,scrollbars=yes,WIDTH=250');
        smiles.focus();
        return false;
}

function quoteSelection() {

        theSelection = false;
        theSelection = document.selection.createRange().text; // Get text selection

        if (theSelection) {
                // Add tags around selection
                emoticon( '[quote]\n' + theSelection + '\n[/quote]\n');
                document.post.message.focus();
                theSelection = '';
                return;
        }else{
                alert('Bitte markiere den Teil des Textes in dem betreffenden Posting, den Du zitieren möchtest, bevor du diese Taste drückst');
        }
}

function storeCaret(textEl) {
        if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

function emoticon(text) {
        if (document.post.message.createTextRange && document.post.message.caretPos) {
                var caretPos = document.post.message.caretPos;
                caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
                document.post.message.focus();
        } else {
                document.post.message.value  += text;
                document.post.message.focus();
        }
}

function checkForm() {
        formErrors = false;
        if (document.post.message.value.length < 2) {
                formErrors = 'Du musst zu deinem Beitrag bitte noch einen Text eingeben.';
        }
        if (formErrors) {
                alert(formErrors);
                return false;
        } else {
                return true;
        }
}




  
function schreibe_verlinkungslink() {
	if(navigator.appName == 'Microsoft Internet Explorer') {
	with(document) {
		open("text/html");
		write("<A HREF=\"javascript:window.external.AddFavorite(\'http://www.Hohenlohe-Portal.de/\', \'Hohenlohe-Portal.de\')\" title=\"Bitte klicken Sie hier um die Startseite von www.Hohenlohe-Portal.de Ihren Lesezeichen hinzuzuf&uuml;gen.\" class=\"menuelinie\">Bookmark</A> ");
		write("<A HREF=\"javascript:window.external.AddFavorite(location.href, document.title)\" title=\"Bitte klicken Sie hier, um speziell diese Unterseite Ihren Lesezeichen hinzuzuf&uuml;gen.\" class=\"menuelinie\">Bookmark diese Seite</A> ");
		write("<a href=\"mailto:?subject=Hallo%20%2D%20eine%20interessante%20Seite&amp;body=Hallo%2C%0Ahabe%20eine%20interessante%20Seite%20gefunden%3A%0A" + window.location.href.replace(/&/g,"%26") + "\" title=\"Zeige deinen Freunden diese Seite (per email)\" class=\"menuelinie\">tell a friend</a> ");
		close();
		} 
	}
	Verlinkungs_Datei = "http://www.leichte.info/verlinken.php" ;
	Aktuelle_Url = window.location.href ;
	Aktuelle_Url = Aktuelle_Url.substr(0,127);
	Aktuelle_Url = Aktuelle_Url.replace(/&/g,":und:") ;
	Aktuelle_Url = Aktuelle_Url.replace(/\?/g,":frage:") ;
	Aktuelle_Url = Aktuelle_Url.replace(/ /g,"%20") ;
	Aktuelle_Url = Aktuelle_Url.replace(/=/g,":ist:") ;
	Aktuelle_Url = Aktuelle_Url.replace(/#/g,":raute:") ;
	Titel = document.title ;
	Titel = Titel.substr(0,127);
	Titel = Titel.replace(/'/g," ") ;
	Titel = Titel.replace(/"/g," ") ;
	Titel_x = Titel.replace(/&/g,":und:") ;
	Titel_x = Titel_x.replace(/\?/g,":frage:") ;
	Titel_x = Titel_x.replace(/ /g,"%20") ;
	Titel_x = Titel_x.replace(/=/g,":ist:") ;
	test_Url = Aktuelle_Url.substr(0,Verlinkungs_Datei.length);
	Aktuelle_Url = Verlinkungs_Datei + "?Url=" + Aktuelle_Url + "&Titel=" + Titel_x ;
	if (Aktuelle_Url.match(/["']/g)) { Aktuelle_Url = Verlinkungs_Datei ; }
	//	alert(Aktuelle_Url+" \n"+test_Url);
	if (test_Url!=Verlinkungs_Datei) {
		with(document) {
			open("text/html");
			write("<A HREF=\"" + Aktuelle_Url + "\"  title=\"Bitte klicken Sie hier um diese Seite zu verlinken. (" + Titel + ")\" class=\"menuelinie\">verlinken</A> ");
			close();
		}
	}
}

function PreloadImages()
{
	if (document.images)
	{
		// preload all rollover images
		img0 = newImage('http://www.Hohenlohe-Portal.de/images/lang_german/btn_login_on.gif');
		img1 = newImage('http://www.Hohenlohe-Portal.de/images/lang_german/btn_register_on.gif');
		img2 = newImage('http://www.Hohenlohe-Portal.de/images/lang_german/btn_pm_on.gif');
		img3 = newImage('http://www.Hohenlohe-Portal.de/images/lang_german/btn_profile_on.gif');
		img4 = newImage('http://www.Hohenlohe-Portal.de/images/lang_german/btn_groups_on.gif');
		img5 = newImage('http://www.Hohenlohe-Portal.de/images/lang_german/btn_logout_on.gif');
		img6 = newImage('http://www.Hohenlohe-Portal.de/images/lang_german/btn_faq_on.gif');
		img7 = newImage('http://www.Hohenlohe-Portal.de/images/lang_german/btn_search_on.gif');
		img8 = newImage('http://www.Hohenlohe-Portal.de/images/lang_german/btn_users_on.gif');
		img9 = newImage('http://www.Hohenlohe-Portal.de/images/lang_german/btn_index_on.gif');
		PreloadFlag = true;
	}
	return true;
}