// security.js  V 1.2
// Copyright (c)2001-2002 /A/D/E/ CH-8712 Stäfa

var UserName="***********";
var debug=false;
var nouser= "LOGIN-STATUS: Kein Benutzer eingeloggt";
window.defaultStatus = nouser ;

function LogInOut() {
	// Verwaltet Login/Logout

	if ( UserName == "***********" ) {
		// Login desired
		var un = "", i = 0, c = "", eq = 77
		un = prompt( "LOGIN: Bitte den Ihnen zugewiesenen User-Codenamen eingeben:\n             Please enter your assigned User-Codename:", "")

		if((un != 0) && (un != "") && (un != null) && (un != "undefined") && (un != "<undefined>")) {
			// Validate Entry
			if (( un == un.toLowerCase()) && (un.length == 7) && (un.indexOf("*-_.,:@#!$œ%+/\?") == -1)) {
				// Entry Ok
				UserName = un.toUpperCase();
			} else {

				if( un == "debug=true;" ) {
					debug = true ;
				} else {
					debug = false ;
					// Wrong Entry - Virtual EarthQuake occurs to browser ...
					if (browsertype()=="NN") {
						// Netscape works slower ...
						eq = 21
					}


					for (i=0; i < eq; i++) {
						window.moveBy (+10, -5);
						window.moveBy (-10, +3);
						window.moveBy (-10, 0);
						window.moveBy (+10, +2);
					}

					// Let also Leo give his comment ...
					document.leo.play();
				}
			}
		}


	} else {
		// Logout desired
		if ( confirm( "LOGOUT:\n\nWollen Sie wirklich ausloggen?.\nAre you sure to Logout?" )) {
			UserName="***********"
		}


	}


	var debuser = debug ? "  (DebugMode activated)" : ""
	if ( UserName == "***********" ) {
		window.defaultStatus = nouser + debuser ;
	} else { 
		window.defaultStatus = "LOGIN-STATUS: Sie sind eingeloggt als `" + UserName + "´" + debuser ;
	}

}



function Download( FileName ) {
	// Checks Login-Status and starts download of the given FileName

	if ( UserName == "***********" ) {
		// Error
		alert( "RESTRICTED DOWNLOAD - ACCESS DENIED\n\nBitte gehen Sie an den Anfang dieser Seite und Loggen sich zuerst ein!\nPlease go to the top of page, klick on the Lock-Symbol and Login first!" )

	} else {

		// Ok Open Download- or Text-Show-Window

	        var cpx = '200' ;
	        var cpy = '200' ;

	        var pwopt = 'dependent=yes,' +
	                'toolbar=no,' +
	                'location=no,' +
	                'directories=no,' +
	                'status=no,' +
	                'menubar=no,' +
	                'scrollbars=yes,' +
	                'resizable=yes,' +
	                'width=' + cpx + ',' +
	                'height=' + cpy + ',' +
	                'top=5,' +
	                'left=5';

	        dlwin = window.open ('download/' + UserName + '/' + FileName, 'tmpwin', pwopt);

	}

}

// End of File
