//<script type="text/javascript"> 

var tpo		= {

	toggleInterface		: function( target ) {
	
		target.observe( "click", function(){ $( document.body ).toggleClassName( 'active' )});
	},
	
	togglePasswidget	: function() {
	
		$( 'password' ).value = "";
		$( 'passwidget' ).toggle();
		
		tpo.dir = this.readAttribute( "dir" );	
	},
	
	seedInteraction		: function( children ) {
	
		children.each( tpo.observePassword );
		$( 'closepasswidget' ).observe( 'click', tpo.togglePasswidget );
	},
	
	observePassword		: function( element ) {
		
		element.observe( 'click', tpo.togglePasswidget.bind( element ) );
	},
	
	activate			: function() {

		$( 'login' ).observe( 'click', function( e ) {
			
			e.preventDefault();
			vars = { password: $( 'password' ).getValue(), dir: tpo.dir };
			
			new Ajax.Request( '/check.php', {
				method		: 'post',
				parameters	: { set: Object.toJSON( vars )},
				onSuccess	: tpo.pull_response
			});
		});
		
		
	},
	
	pull_response		: function( response ) {
	
		succes = ( response.responseText == "true" );
		
		$( 'login' ).up().insert( new Element( "span", { 'class': 'update ' + (succes? "succes":"error") }
						).update( succes? "Welcome, you will be redirected." : "Sorry, wrong password." ));
			
		if( succes )
			setTimeout( function(){ window.location= "/secure.php" }, 1000 );
	},
	
	redirect			: function( path ) {
	
		$( document.body ).update( new Element( "span", { 'class': "update error" }).update( "You are being redirected" ));
		
		setTimeout( function(){ window.location= path }, 1000 );
	}

}

/*
SocialMailchimp = function( vars )	{

	Object.extend( obj = $$( '.SocialMailchimp form' ).pop(), SocialMailchimp.proto );
	
	obj.vars		= vars;
	obj.enabled		= true;
	obj.submit		= obj.select( 'input[type="button"]' ).pop();
		
	return obj;
}



SocialMailchimp.proto =	{

	subscribe			: function() {
	
		this.submit.observe( 'click', function( e ) {
			
			e.preventDefault();
			var answer	= this.serialize( true );
			answer.listid = this.vars.listid
			xhttp.send( '/xhttp.mod', {
				mod: "social.mailchimp",
				action: "subscribe",
				vars: answer,
			}, this.pull_response.bind( this ) );
			
		}.bind( this ));
		
		
	},
	
	pull_response		: function( response ) {
	
		this.disable();
		this.insert( new Element( "span", { 'class': 'update' }).update( response.responseText ));
	}
	
	
	
	
}


*/
