var isIE6 = function() {
	if(Prototype.Browser.IE) {
		var IEVersion = navigator.appVersion;
		var IERE = /(MSIE.6)/;
		if(IEVersion.search(IERE)) {
			return true;
		}
	}
	return false;
}

var isIE = function() {
	if(Prototype.Browser.IE) {
		var IEVersion = navigator.appVersion;
		var isIE6 = /(MSIE\s6)/gi.test(IEVersion);
		var isIE7 = /(MSIE\s7)/gi.test(IEVersion);
		var isIE8 = /(MSIE\s8)/gi.test(IEVersion);
		
		if(isIE6) return 6;
		if(isIE7) return 7;
		if(isIE8) return 8;
	}
	// is anything but not an IE *cool*
	return false;
}

var siteMthd = {
	usernameValue:"Benutzername",
	passwordValue:"Passwort",
	focusClassName:"",
	blurClassName:"",
	
	clearLogin: function(e) {
		el = e.element();
		if(el.id) {
			if(el.id == 'user' && el.value == siteMthd.usernameValue) {
				el.value = '';
				el.className = siteMthd.focusClassName;
			}
			else if(el.id == 'pass' && el.value == siteMthd.passwordValue) {
				el.value = '';
				el.className = siteMthd.focusClassName;
			}
			else {
				el.select();
			}
		}
	},
	
	checkLogin: function(e) {
		el = e.element();
		if(el.id) {
			if(el.id == 'user' && el.value == '') {
				el.value = siteMthd.usernameValue;
				el.className = siteMthd.blurClassName;
			}
			else if(el.id == 'pass' && el.value == '') {
				el.value = siteMthd.passwordValue;
				el.className = siteMthd.blurClassName;
			}
		}
	},
	
	doJump: function(event) {
		var e = Event.element(event);
		document.location = e.value; 
	},
	
	popup: function(uri, w, h) {
		if(typeof uri == "string") {
			var width 	= (typeof w == "int") ? w : 560;
			var height 	= (typeof h == "int") ? h : 800;
			window.open(uri,"","toolbar=0,scrollbars=0,location=1,statusbar=1,menubar=1,resizable=0,width="+width+",height="+height);
			return;
		}
		return;
	},
	
	doList: function() {
		var secondNav = $('nav');
		for(i=0; i<secondNav.childNodes.length; i++) {
			var node = secondNav.childNodes[i];
			if (node.nodeName == "LI") {
				node.onmouseover = function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
};

Event.observe(window, 'load', function() {
	if ($('user') != null) {
		$('user').observe('focus', siteMthd.clearLogin);
		$('pass').observe('focus', siteMthd.clearLogin);
		$('user').observe('click', siteMthd.clearLogin);
		$('pass').observe('click', siteMthd.clearLogin);
		$('user').observe('blur', siteMthd.checkLogin);
	}
	if ($('pass') != null) {
		$('pass').observe('blur', siteMthd.checkLogin);
	}
});

// wrapper methods (bcuz of old scrits in content):
var popup = function(uri, w, h) {
	siteMthd.popup(uri, w, h);
	return;
}
