var AjaxLogin = new Class({
	Implements: [Events, Options],
	options : {
		'elements' : [],
		'href' : {
			'login' : null,
			'register' : null
		}
	},
	
	initialize : function(options) {
		this.setOptions(options);
		if (technoVars.logged)
			return;
		if (Browser.Engine.trident)
			return;
		this.constructLoginBox();
		for (var i=0;i<this.options.elements.length;i++) {
			if ($chk(this.options.elements[i])) {
				this.options.elements[i].addEvent('click', function(e){
					this.showLoginBox();
					e.stop();
				}.bindWithEvent(this));
			}
		}
	},
	
	constructLoginBox : function(){
		this.content = new Element('div', {
			'class' : 'ajax_login_box'
		});
		// Login Side
		var left = new Element('div', {
			'class' : 'left_side'
		}).inject(this.content);
		
		new Element('h1', {
			'html' : slsBuild.langs.GENERIC_LOGIN
		}).inject(left);
		new Element('p', {
			'html' : slsBuild.langs.GENERIC_LOGIN_DESC
		}).inject(left);
			// Form
			var form = new Element('form', {
				'action' : this.options.href.login,
				'method' : 'post',
				'id' : 'ajax_form_login'
			}).inject(left);
			new Element('input', {
				'type' : 'hidden',
				'name' : 'reload_login',
				'value' : 'true'
			}).inject(form);
			new Element('input', {
				'type' : 'hidden',
				'name' : 'Redirect',
				'value': ''
			}).inject(form);
			new Element('input', {
				'type' : 'hidden',
				'name' : 'RedirectMore',
				'value': ''
			}).inject(form);
			new Element('input', {
				'type' : 'hidden',
				'name' : 'referrer',
				'value': ''
			}).inject(form);
			// Email
			var row = new Element('div', {
				'class' : 'row'
			}).inject(form);
			new Element('label', {
				'for' : 'ajax_user_email',
				'html' : slsBuild.langs.GENERIC_FORM_EMAIL
			}).inject(row);
			new Element('input', {
				'type' : 'text',
				'name' : 'user_email',
				'id'   : 'ajax_user_email'
			}).inject(row);
			// Password
			var row = new Element('div', {
				'class' : 'row'
			}).inject(form);
			new Element('label', {
				'for' : 'ajax_user_password',
				'html' : slsBuild.langs.GENERIC_FORM_PASSWORD
			}).inject(row);
			new Element('input', {
				'type' : 'password',
				'name' : 'user_password',
				'id'   : 'ajax_user_password'
			}).inject(row);
			// Lost password
			var links = new Element('div', {
				'class' : 'links'
			}).inject(form);
			new Element('a', {
				'class' : 'fLinks',
				'href' : '/User/ForgottenPassword.sls',
				'html' : slsBuild.langs.GENERIC_FORM_LOST_PASSWORD
			}).inject(links);
			// Remember
			var radio = new Element('div', {
				'class' : 'signup_radio'
			}).inject(form);
			new Element('input', {
				'type' : 'checkbox',
				'name' : 'remember',
				'id' : 'ajax_remember'
			}).inject(radio);
			new Element('label', {
				'for' : 'ajax_remember',
				'html' : slsBuild.langs.GENERIC_FORM_REMEMBER
			}).inject(radio);
			
			// Submit
			var blue_button = new Element('div', {
				'class' : 'blue_button'
			}).inject(form);
			new Element('div', {
				'class' : 'left'
			}).inject(blue_button);
			new Element('input', {
				'type' : 'submit', 
				'class': 'center',
				'value': slsBuild.langs.GENERIC_LOGIN
			}).setStyle('padding-top', '0').inject(blue_button);
			new Element('div', {
				'class' : 'right'
			}).inject(blue_button);
			// /Form
		// /Login Side
		
		// Register Side
		var right = new Element('div', {
			'class' : 'right_side'
		}).inject(this.content);
		new Element('h1', {
			'html' : slsBuild.langs.GENERIC_REGISTER
		}).inject(right);
		var desc = slsBuild.langs.GENERIC_REGISTER_DESC.replace(new RegExp("(&gt;)", 'gi'), '>').replace(new RegExp("(&lt;)", 'gi'), '<');
		
		var pdesc = new Element('div', {
			'html' : desc
		}).inject(right);
		// Link
		var blue_button = new Element('a', {
			'href' : this.options.href.register, 
			'class' : 'blue_button_up'
		}).inject(right);
		new Element('span', {
			'class' : 'left'
		}).inject(blue_button);
		new Element('span', {
			'class': 'center',
			'html': slsBuild.langs.GENERIC_REGISTER
		}).inject(blue_button);
		new Element('span', {
			'class' : 'right'
		}).inject(blue_button);
		// /Register Side
		
	},
	
	showLoginBox : function() {
		new OverflowWrapper(this.content.clone(), {
			'bgColor' : '#000000'
		});
		
	}
	
});

