function getCookieVal (offset)

{

	var endstr = document.cookie.indexOf (";", offset);

	if (endstr == -1)

		endstr = document.cookie.length;

	return unescape(document.cookie.substring(offset, endstr));	

}





/*

 *	Autor: Gregor

 *	Kommentar:	(von NETg)

 *	Die Funktion FixCookieDate(date) ist eine Korrekturfunktion 

 *	fuer das Cookie-Datum.

 *

 */

function FixCookieDate (date)

{

	var base = new Date(0);

	var skew = base.getTime(); // dawn of (Unix) time - sollte 0 sein

	if (skew > 0)  // Funktioniert nicht auf MAC-Systemen

		date.setTime (date.getTime() - skew);

} 

 

 

/*

 *	Autor: Gregor

 *	Kommentar:	(von NETg)

 *	Die Funktion GetCookie(name) dient dem Auslesen

 *	eines Cookies.

 *

 */

 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;

}





/*

 *	Autor:	Gregor

 *	Kommentar:	(von NETg)

 *	Die interne Funktion getSubCookieVal(fullCookie, offset) 

 *	liefert den dekodierten Wert aus dem Cookie-Value-String 

 *	ab der Stelle offset.

 *

 */

function getSubCookieVal(fullCookie, offset)

{

	var endstr = fullCookie.indexOf(";", offset);

	if(endstr < 0)

		endstr = fullCookie.length;

	return fullCookie.substr(offset,endstr-offset);	//	Gregor Fehler entfernt!

}





/*

 *	Autor: Gregor

 *	Kommentar:	(von NETg)

 *	Die Funktion fetchPath(loc) liefert den Pfad aus der

 *	URL loc . 

 *

 */

function fetchPath(loc)

{

	var myPth = loc + "";	// Coerce to string for IE 3.x

	var myPos = myPth.indexOf( "://" );	// ueberspringen des Protokoll-Strings z.B. "http://"

        myPth = myPth.substring( myPos + 3 );

	myPos = myPth.indexOf( "/" );	// ueberspringen des Domain-Strings z,B. "www.dumich.auch"

	myPth = myPth.substring( myPos + 1 );

	myPos = myPth.indexOf( "?" );			 



	if (myPos != -1)

		myPth = myPth.substring( 0, myPos);



	myPos = myPth.lastIndexOf( "/" );	// weglassen des .htlm Dateinamens 



	if ( myPos != -1 )

		return myPth.substring( 0, myPos );

	else

		return "";

}





/*

 *	Autor: Gregor

 *	Kommentar:	(von NETg)

 *	Die Funktion fetchDomain(loc) liefert die Domain aus der

 *	URL loc . 

 *

 */

function fetchDomain(loc)

{

	var myURL = loc + "";	// Coerce to string for IE 3.x

	var myPos = myURL.indexOf( "/",0 );

	var	myDom = "";

	myDom = myURL.substring( myPos+2 );

	myPos = myDom.indexOf( "/",0 );	

	if( myPos < 0 )

		return "";	 

	myDom = myDom.substring( 0, myPos );

	return myDom;	

}





/*

 *	Autor: Gregor

 *	Kommentar:	(nicht von NETg)

 *	Die Funktion NETgGetSubCookie(subcookieName, cookieName)

 *	liefert das Subcookie namens subcookieName des 

 *	Cookies namens cookieName. Das Ergebnis ist ein

 *	String oder null.

 *	! Laut NETg muss cookieName die Nummer des Kurses sein !

 *

 */

function NETgGetSubCookie(subcookieName, cookieName)

{

	var fullCookie= new String();

	fullCookie=GetCookie(cookieName);

	if (fullCookie!=null)

	{

		var arg = subcookieName + "=";

		var alen = arg.length;

		var clen = fullCookie.length;

		var i=0;

		while (i < clen)

		{

			var j = i + alen;

			if (fullCookie.substring(i, j) == arg)

				return getSubCookieVal (fullCookie, j);

			i = fullCookie.indexOf(";", i) + 2;

			if (i <= 0) break;

		}

	}

	return null;

}



 

/*

 *	Autor: Gregor

 *	Kommentar: (nicht von NETg)

 *	Die Funktion 

 *	NETgSetCookie(name,value,expires,path,domain,secure)

 *	dient dem Schreiben eines Cookies.

 *

 */

function NETgSetCookie (name,value,expires,path,domain,secure)

{

	document.cookie = name + "=" + escape (value) +

		((expires) ? "; expires=" + expires.toGMTString() : "") +

		((path) ? "; path=" + path : "") +

		((domain) ? "; domain=" + domain : "") +

		((secure) ? "; secure" : "") ;

} 

 

 

/*

 *	Autor: Gregor

 *	Kommentar:	(von NETg)

 *	Die interne Funktion

 *	RemoveSubCookie(fullCookie, subcookieName) liefert

 *	den NETg-Cookie String ohne dem SubCookie Inhalt.

 *

 */

function RemoveSubCookie(fullCookie, subcookieName)

{

	if (fullCookie!=null)

	{

		var arg = subcookieName + "=";

		var alen = arg.length;

		var clen = fullCookie.length;

		var i = 0;

		while (i < clen) 

		{

			var j = i + alen;

			if (fullCookie.substring(i, j) == arg) 

			{

				//subCookie found.  Remove it.

				var endstr = fullCookie.indexOf (";", i);

				if (endstr == -1)

					return fullCookie.substring(0,i)

				return fullCookie.substring(0,i) + fullCookie.substring(endstr +2,fullCookie.length);

			}

			i = fullCookie.indexOf(" ", i) + 1;

			if (i == 0) break;

		}

		return fullCookie;

	}

}



 

/*

 *	Autor: Gregor

 *	Kommentar:	(nicht von NETg)

 *	Die Funktion 

 *	NETgSetSubCookie(subcookieName,value,cookieName)

 *	setzt den Wert value des SubKooies subcookieName

 *	neu.

 *

 */

function NETgSetSubCookie (subcookieName,value,cookieName) 

{

	var fullCookie = new String();

	fullCookie = GetCookie(cookieName);

	expdate = false;

	

	//	determine if the cookie exists, if it does, remove it

	if (fullCookie!=null)

		fullCookie = RemoveSubCookie(fullCookie,subcookieName);

	else

		fullCookie="";



	//	add the subcookie to the end

	value = fullCookie + subcookieName + "=" + value + "; "	;

	

	NETgSetCookie(cookieName,value,expdate,"/","",0);

	

} 





/*

 *	Autor: Gregor

 *	Kommentar:	(nicht von NETg)

 *	Die Funktion 

 *	SetSubCookie(subcookieName,value,cookieName)

 *	setzt den Wert value des SubKooies subcookieName

 *	neu.

 *

 */

function SetSubCookie (subcookieName,value,cookieName,path,domain) 

{

	var fullCookie = new String();

	fullCookie = GetCookie(cookieName);

	expdate = false;

	

	//	determine if the cookie exists, if it does, remove it

	if (fullCookie!=null)

		fullCookie = RemoveSubCookie(fullCookie,subcookieName);

	else

		fullCookie="";



	//	add the subcookie to the end

	value = fullCookie + subcookieName + "=" + value + "; "	;

	if (domain)

		NETgSetCookie(cookieName,value,expdate,path,domain);

	else

		NETgSetCookie(cookieName,value,expdate,path);

} 



 

/*

 *	Autor: Gregor

 *	Kommentar:	(nicht von NETg)

 *	Die Funktion DeleteCookie (name,path,domain)

 *	dient dem Loeschen eines Cookies.

 *

 */

function DeleteCookie (name,path,domain)

{

	if (GetCookie(name))

	{

		document.cookie = name + "=" +

			((path) ? "; path=" + path : "") +

			((domain) ? "; domain=" + domain : "") +

			"; expires=Thu, 01-Jan-70 00:00:01 GMT";

	}

}





//	Der folgende JavaScript-Code setzt das expiration-Datum fuer die 

//	Cookies auf 1 Jahr (von jetzt an gerechnet).



var expdate = new Date ();

FixCookieDate (expdate);						//	Korrektur fuer den  Mac date bug

expdate.setTime (expdate.getTime() +  3600000);	//	1000 Stunde von jetzt an



var ERRASE = new Date ();

FixCookieDate (ERRASE);							//	Korrektur fuer den  Mac date bug

ERRASE.setTime (ERRASE.getTime() -  3600000);	//	1000 Stunde von jetzt an

				

var kuki = "MIDI";	//	Enthaelt den namen des Cookies





/*

 *	Autor: Gregor

 *	Kommentar:	(nicht von NETg)

 *	Die Funktion initNETgCookie() dient der Initialisierung 

 *	eines NETg-Cookies zu Testzwecken

 *

 */

function initNETgCookie(cookieName, tid, sid, kid, rid)

{



	kuki = cookieName;

	

	var start = new Date ();	//	Resourcen-Start-Zeitpunkt

	FixCookieDate (start);		//	Korrektur fuer den  Mac date bug

	

	NETgSetSubCookie ("timeStamp", start.getTime()/1000, cookieName);

	NETgSetSubCookie ("Duration", 0, cookieName);

	NETgSetSubCookie ("SVMUser", tid, cookieName);

	//NETgSetSubCookie ("svmdom", "", cookieName);

	//NETgSetSubCookie ("SessionGSF", "", cookieName);

	//NETgSetSubCookie ("wsvmtmp", "", cookieName);

	//NETgSetSubCookie ("home", "", cookieName);

	//NETgSetSubCookie ("HomeTip", "Lernphase beenden?", cookieName);

	NETgSetSubCookie ("SID",  sid  ,cookieName);	//	Seminar-ID

	NETgSetSubCookie ("TID",  tid  ,cookieName);	//	Teilnem-ID

	NETgSetSubCookie ("KID",  kid  ,cookieName);	//	Qualifi-ID

	NETgSetSubCookie ("RID",  rid  ,cookieName);	//	Resourc-ID

	

}





/*

 *	Autor:	Gregor

 *	Kommentar:

 *	Die Funktion showNETgCookie() dient der Ausgabe und

 *	Ueberpruefung von Laufzeit-Variablen und Cookies

 *

 */

function showNETgCookie(cookieName)

{

	var kuchen = GetCookie(cookieName);

	

	if(kuchen != null)

		alert( "Cookie " + cookieName + " hat folgenden Wert:\n" + kuchen );

	

	else 

		alert("Cookie " + cookieName + " wurde nicht gesetzt!");

	

}







function FixPhpBug(CookieName,path)

{

	value = GetCookie(CookieName);

	if (value)

	{

		value = value.replace(/\+/g," ");

		NETgSetCookie(CookieName,value,expdate,path);

	}

}



			function Login()

			{

				if((document.isn.username.value!="") && (document.isn.upw.value!=""))

				{

					SetSubCookie( "username", document.isn.username.value, "_dls", "/erp/" );

					document.isn.GoOn.value = "1";

				}

				else

				{

					alert("Bitte geben Sie zuerst den Benutzernamen und Ihr Passwort ein.");

				}

			}
			
		



         function DOGast()

         {

            document.isn.username.value = "gastzugang";
            document.isn.upw.value = "etsgast";

            Login();

				            document.isn.submit();

         }





			function ChangePW()

			{

				if( ( document.isn.username.value!="" ) || ( document.isn.upw.value!="" ) )

				{

					if ( document.isn.upwneu.value != "" )

					{

						if ( document.isn.upwneu.value == document.isn.upwneu2.value )

						{

							document.isn.GoOn.value = "1";

							document.isn.submit();

						}

						else

							alert("Das neue Passwort und die Wiederholung passen nicht zusammen!");

					}

					else

						alert("Bitte geben Sie ein neues Passwort ein!");

				}

				else

					alert("Bitte geben Sie erst den Benutzernamen und Ihr Passwort ein!");

			}





			var MySPF = 1 +0;

			var MyMID = 1 +0;

			var PATH = "";

			var PATH2 = "login.phtml";

			var PATH3 = "/";



			SetSubCookie( "MAID", MyMID, "_dls", "/erp/" );

			SetSubCookie( "MID", MyMID, "_dls", "/erp/" );

			SetSubCookie( "SPF", MySPF, "_dls", "/erp/" );

			SetSubCookie( "upw", "", "_dls", "/erp/" );
			
function logd(id)
{
if (id.value == "1")
	{
		document.isn.username.value = "00002";
        document.isn.upw.value = "000000";

         Login();
		 
		document.isn.action="http://vsbi-dls.learningsystem.de/login.phtml?PHPINI_CHECK=1&MAID=1";
	}
if (id.value == "0")
	{
		document.isn.username.value="name";
		document.isn.upw.value="passwort";
		document.isn.action="";
	}
}