// LIBtrimString start (dr-010223)

function LIBtrimString( val ){

        var a = 0; var e = val.length; while( val.charAt(a) == " " && a < e ){ a++; }

        if ( a >= e ) return ""; while( val.charAt(e-1) == " " ){ e--; }; return val.substring(a, e);

}

// LIBtrimString end



// LIBreplace start (dr-010223)

function LIBreplace( str ){

        var args=LIBreplace.arguments; var stro=str

        if ((args.length%2)!=1){alert("LIBreplace: illegal argument count");return}

        for( var i=1; i<args.length; i+=2){ var p=args[i]; var r=args[i+1]; var k=0; var pos=0;

                while ((pos=str.substring(k).indexOf(p)) != -1){str=str.substring(0,pos+k)+r+str.substring(pos+k+p.length,str.length);}} return str;

}

// LIBreplace start



// LIBdeleteChars start (dr-010223)

function LIBdeleteChars( str, chars ){

        var pos=0;for( var i=0; i<chars.length; i++){

                pos=0; while ((pos=str.indexOf(chars.charAt(i)))!=-1){

                        str=str.substring(0,pos)+str.substring(pos+1)}

        } return str;

}

// LIBdeleteChars end



// LIBallowCharsOnly start (dr-010223)

function LIBallowCharsOnly( str, chars, onlylowercase ){

        for( var i=0; i<str.length; i++){ if (chars.indexOf((onlylowercase?str.toLowerCase().charAt(i):str.charAt(i)))==-1){ str=str.substring(0,i)+str.substring(i+1);i--;}} return str;

}

// LIBallowCharsOnly end



// LIBcheckEmail start (dr-010223) :: ben&ouml;tigt LIBreplace, LIBallowCharsOnly, LIBdeleteChars

function LIBisEmail( mail, toString ){

        mail=LIBreplace(mail,"&auml;","ae","&uuml;","ue","&ouml;","oe","&szlig;","ss","&Auml;","Ae","&Uuml;","Ue","&Ouml;","Oe")

        mail=LIBallowCharsOnly(mail,"abcdefghijklmnopqrstuvwxyz.-_@0123456789", true);

        var u=mail.substring(0,mail.indexOf("@")); var d=LIBdeleteChars( mail.substring(mail.indexOf("@"),mail.length) ,"@");

        var tld=d.substring(d.lastIndexOf(".")+1,d.length);        d=d.substring(0,d.lastIndexOf("."));

        if(toString) if (u && d && tld)return u+"@"+d+"."+tld; else return mail; if(((u.length-1)<=0?0:1)*((d.length-1)<=0?0:1)*((tld.length-1)<=0?0:1))

        return true; return false;

}

// LIBcheckEmail end



// LIBopenWindow start (dr-010223)

function LIBopenWindow( url, winname, width, height, left, top, switches){

	function LIBopenWindowUtility( attribute ){ return ","+attribute+"="+(switches.indexOf(attribute)>-1?"yes":"no") }

	var attributes = (width?",width="+width:"")+ (height?",height="+height:"")+ (left?",left="+left:"")+ (top?",top="+top:"")+		

		LIBopenWindowUtility("toolbar")+LIBopenWindowUtility("directories")+LIBopenWindowUtility("status")+LIBopenWindowUtility("scrollbars")+

		LIBopenWindowUtility("resizable")+LIBopenWindowUtility("menubar")+LIBopenWindowUtility("location")

	return window.open( url, (winname?winname:"_blank"), attributes);

}

// LIBopenWindow end

function submitFormular() {

	helpervar = checkFormular();

	if (helpervar != false) {
		var form = $('newsletterform');

//		window.open('', 'newsletter_window').focus();

		form.submit();
	};
};



function submitNLFormular() {

	helpervar = checkNLFormular();

	if (helpervar != false) {
		var form = $('nlformular');

//		window.open('', 'newsletter_window').focus();

		form.submit();
	};

};



function checkFormular(){

        var f = $('newsletterform');

        if (f.email.value) f.email.value = LIBisEmail(f.email.value, true)



        if (!LIBisEmail(f.email.value)){

                alert("Die von Ihnen angegebene E-Mailadresse ist nicht korrekt.\n\nBitte geben Sie eine E-Mailadresse ein. Vielen Dank!")

                return false

        }

		var parameter = "email="+f.email.value

        /*if (f.aktion[0].checked){

			parameter += "&aktion=eintragen"

		} else {

			parameter += "&aktion=austragen"

		}

		var schalter="scrollbars, resizable"

		LIBopenWindow( "http://www.eichelberg.de/newsletter/inout.php?" + parameter ,"Newsletter",585,350,null,null,schalter)

        return false

		*/

}



function checkNLFormular(){

        var f = $('nlformular');

        if (f.email.value) f.email.value = LIBisEmail(f.email.value, true)



        if (!LIBisEmail(f.email.value)){

                alert("Die von Ihnen angegebene E-Mailadresse ist nicht korrekt.\n\nBitte geben Sie eine E-Mailadresse ein. Vielen Dank!")

                return false

        }

		var parameter = "email="+f.email.value

        /*if (f.aktion[0].checked){

			parameter += "&aktion=eintragen"

		} else {

			parameter += "&aktion=austragen"

		}

		var schalter="scrollbars, resizable"

		LIBopenWindow( "http://www.eichelberg.de/newsletter/inout.php?" + parameter ,"Newsletter",585,350,null,null,schalter)

        return false

		*/

}