this.Haus = new function Haus() {
	// require $$
	// require Ajax
	// require Geist
	this.author = window.author;
	this.version = 1.0;
	this.name = this.constructor.name;
	/* videos */
	this.Video = new function Video() {
		this.author = window.author;
		this.version = 1.0;
		this.name = this.constructor.name;
		this.MoveRight = function() {
			if( !this.atual )
				this.atual = 1;
			if( this.atual == arguments[0] )
				return;
			var obja = $( 'VideoN'+this.atual );
			var objb = $( 'VideoN'+(this.atual+1) );
			obja.style.display = "none";
			objb.style.display = "block";
			this.atual = this.atual+1;
		};
		this.MoveLeft = function() {
			if( !this.atual )
				this.atual = 1;
			if( this.atual == 1 )
				return;
			var obja = $( 'VideoN'+this.atual );
			var objb = $( 'VideoN'+(this.atual-1) );
			obja.style.display = "none";
			objb.style.display = "block";
			this.atual = this.atual-1;
		};
	};
	/* galeria */
	this.Image = new function Image() {
		this.author = window.author;
		this.version = 1.0;
		this.name = this.constructor.name;
		this.MoveRight = function() {
			var obj = $( 'VideoLine' );
			var objleft = obj.style.left.replace( /[^0-9-]/g, "" );
			var objleft = eval( ( objleft ) - 320 );
			if( parseInt( objleft ) <= parseInt( - arguments[0] ) )
				return;
			else {
				obj.style.left = objleft+"px";
			}
		};
		this.MoveLeft = function() {
			var obj = $( 'VideoLine' );
			var objleft = obj.style.left.replace( /[^0-9-]/g, "" );
			var objleft = eval( parseInt( objleft ) + 320 );
			if( parseInt( objleft ) > 0 )
				return;
			else {
				obj.style.left = objleft+"px";
			}
		};
	};
	/* login */
	this.Login = new function Login() {
		this.author = window.author;
		this.version = 1.0;
		this.Define = function() {
			this.user = $( 'LoginUser' );
			this.pass = $( 'LoginPass' );
			this.form = $( 'LoginForm' );
		};
		this.Do = function() {
			this.Define();
			if( this.user && this.pass ) {
				if( this.user.value == "" ||  this.pass.value == "" ) {
					this.user.value == "" ? this.ErrorUser() : this.OkUser();
					this.pass.value == "" ? this.ErrorPass() : this.OkPass();
					return false;
				} else
					return true;
			} else
				return false;
		};
		this.ErrorUser = function() {
			if( this.user ) this.user.className = "error";
		};
		this.ErrorPass = function() {
			if( this.pass ) this.pass.className = "error";
		};
		this.OkUser = function() {
			if( this.user ) this.user.className = "";
		};
		this.OkPass = function() {
			if( this.pass ) this.pass.className = "";
		};
		this.Box = function() {
			this.Define();
			this.OkUser();
			this.OkPass();
			if( this.form )
				if( this.form.style.display == 'block' ) {
					this.BoxClose();
				} else {
					window.Haus.Register.BoxClose(); // close register
					this.form.style.display = 'block';
					Geist.Open( "Haus" );
					$( "GeistHaus" ).onclick = function() { window.Haus.Login.BoxClose(); }
					if( this.user.value == '' )
						this.user.focus();
					else {
						this.ErrorPass();
						this.pass.focus();
					}
				}
			return;
		};
		this.BoxClose = function() {
			this.Define();
			Geist.Close( "Haus" );
			if( this.form ) this.form.style.display = 'none';
		};
		this.BoxError = function() {
			this.Define();
			this.ErrorPass();
			this.Box();
		};
		this.BoxOk = function() {
		};
	};
	/* cadastro */
	this.Register = new function Register() {
		this.author = window.author;
		this.version = 1.0;
		this.Define = function() {
			this.user = $( 'RegisterUser' );
			this.mail = $( 'RegisterMail' );
			this.pass = $( 'RegisterPass' );
			this.pass2 = $( 'RegisterPass2' );
			this.name = $( 'RegisterName' );
			this.form = $( 'RegisterForm' );
		};
		this.Do = function() {
			this.Define();
			if( this.user && this.mail && this.pass && this.pass2 && this.name ) {
				if(
					!this.user.value.match( /^[a-zA-Z0-9\._-]{3,}$/g ) ||
					!this.mail.value.match( /^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/g ) ||
					this.pass.value == "" ||
					this.pass2.value == "" ||
					this.pass.value != this.pass2.value ||
					this.user.value == "" ||
					this.name.value == ""
				) {
					!this.user.value.match( /^[a-zA-Z0-9\._-]{3,}$/g ) ? this.ErrorUser() : this.OkUser();
					!this.mail.value.match( /^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/g ) ? this.ErrorMail() : this.OkMail();
					this.pass.value == "" || this.pass.value != this.pass2.value ? this.ErrorPass() : this.OkPass();
					this.name.value == "" ? this.ErrorName() : this.OkName();
					return false;
				} else
					return true;
			} else
				return false;
		};
		this.ErrorUser = function() {
			if( this.user ) this.user.className = "error";
		};
		this.ErrorMail = function() {
			if( this.mail ) this.mail.className = "error";
		};
		this.ErrorPass = function() {
			if( this.pass ) this.pass.className = "error";
			if( this.pass2 ) this.pass2.className = "error";
		};
		this.ErrorName = function() {
			if( this.name ) this.name.className = "error";
		};
		this.OkUser = function() {
			if( this.user ) this.user.className = "";
		};
		this.OkMail = function() {
			if( this.mail ) this.mail.className = "";
		};
		this.OkPass = function() {
			if( this.pass ) this.pass.className = "";
			if( this.pass2 ) this.pass2.className = "";
		};
		this.OkName = function() {
			if( this.name ) this.name.className = "";
		};
		this.Box = function() {
			this.Define();
			this.OkUser();
			this.OkMail();
			this.OkPass();
			this.OkName();
			if( this.form )
				if( this.form.style.display == 'block' ) {
					this.BoxClose();
				} else {
					window.Haus.Login.BoxClose(); // close login
					this.form.style.display = 'block';
					Geist.Open( "Haus" );
					$( "GeistHaus" ).onclick = function() { window.Haus.Register.BoxClose(); }
					if( this.user.value == '' )
						this.user.focus();
					else {
						this.ErrorPass();
						this.pass.focus();
					}
				}
			return;
		};
		this.BoxClose = function() {
			this.Define();
			Geist.Close( "Haus" );
			if( this.form ) this.form.style.display = 'none';
		};
		this.BoxError = function() {
			this.Define();
			this.Do();
			this.Box();
			if( arguments[0] == 1 ) {
				this.user.className = "error";
				PopWin.Do( "<p>Este nome de usu&aacute;rio j&aacute; est&aacute; sendo usado.</p>", true );
			}
		};
		this.BoxOk = function() {
			this.Define();
			this.Box();
			this.form.innerHTML = "<p>Cadastro efetuado com sucesso.<br />Confira sua caixa de e-mail para validar sua conta.</p>";
		};
	};
};

