document.addEvent('domready', function() {
	
	// instantiate the formcheck stuff
	new Asset.javascript("/_js/plugins/formcheck/lang/en.js");
	new Asset.javascript("/_js/plugins/formcheck/formcheck.mootools.js");
	new Asset.css("/_js/plugins/formcheck/theme/classic/formcheck.css");
	
	// Add the Shim for pseudo vertical centering
	var shim = new Element("div", {
		id : "shim"	
	}).injectBefore("container");
	
	// if the browser isn't trident (IE)
	// if (!Browser.Engine.trident) {
		
		/*	TODO:
			-----
			-	Change how the password field changes,
				by overwriting and replacing the entire
				input rather than trying to convert it's
				"type" attribute. converting "type" isn't
				supported in IE (upto and including IE8)
		*/
	
		var eUsername = $("username");
		var ePassword = $("password");
		var tPassword = new Element("input", {
			type: "text",
			name: "password",
			id: "password"
		});
		
		// Label Values
		sUsernameLabel = $("username-label").get("text");
		sPasswordLabel = $("password-label").get("text");
	
		$("username-label").destroy();
		$("password-label").destroy();
	
		eUsername.set("value", sUsernameLabel).setStyle("color", "#cccccc");
		tPassword.replaces(ePassword).set("value", sPasswordLabel).setStyle("color", "#cccccc");
	
		eUsername.addEvents({
			"focus" : function(e) {
				if (this.get("value") == sUsernameLabel) {
					this.set("value", "");
					this.setStyle("color", "#666666");
				
				}
			},
			"blur" : function(e) {
				if (this.get("value") == "") {
					this.set("value", sUsernameLabel);
					this.setStyle("color", "#cccccc");
				}
			}
		
		});
	
		tPassword.addEvents({
			"focus" : function(e) {
				if (this.get("value") == sPasswordLabel) {
					ePassword.replaces(tPassword);
					ePassword.focus()
					ePassword.select();
				}
			}
		});
		
		ePassword.addEvents({
			"blur" : function(e) {
				if (this.get("value") == "") {
					tPassword.replaces(ePassword);
					tPassword.set("value", sPasswordLabel);
				}
			}
		});
	
		eLoginButton = $("login-button");
		eLoginButton.addEvents({
			"click" : function(e) {
			
				if (eUsername.value == sUsernameLabel) {
					eUsername.value = null;
				}
			
				if (ePassword.value == sPasswordLabel) {
					ePassword.value = null;
				}
			
			}
		});
	
		eLogin = $("login-form");
		eLogin.addEvents({
			"submit" : function(e) {
				e.stop();
			
				new FormCheck('login-form');
			
				// eLogin.submit();
			
			}
		});
	// }
	
});
