function myaccount() {
		new Ajax.Request('http://www.modellainc.com/my_account/login/1',{
			method: 'get',
			onSuccess:function(response) {
				var opacity_div = document.createElement('div');
				opacity_div.id = 'opacity_div';
				var dimensions = $(document.body).getDimensions();
				if (self.innerWidth)
				{
					dimensions.width = Math.max(dimensions.width,self.innerWidth);
					dimensions.height = Math.max(dimensions.height,self.innerHeight);
				}
				else if (document.documentElement && document.documentElement.clientWidth)
				{
				    dimensions.width = Math.max(dimensions.width,document.documentElement.clientWidth);
				    dimensions.height = Math.max(dimensions.height,document.documentElement.clientHeight);
				}
				else if (document.body)
				{
					dimensions.width = Math.max(dimensions.width,document.body.clientWidth);
					dimensions.height = Math.max(dimensions.height,document.body.clientHeight);
				}
		    	$(opacity_div).setStyle({
					backgroundColor: '#000',
					opacity: 0.5,
					width: Math.max(dimensions.width) + 'px',
					height: Math.max(dimensions.height) + 'px',
					position: 'absolute',
					top: 0,
					left: 0,
		    		zIndex: '10'
				});
				document.body.insertBefore(opacity_div,document.body.firstChild);
				var div = document.createElement('div');
				div.id = 'login_div';
				div.innerHTML = response.responseText;
				$(div).setStyle({position:"relative",zIndex: '20'});
				if($("main").offsetTop==0) $(div).setStyle({top:"100px"});
				$('main').insertBefore(div,$('main').firstChild);
				$('close').onclick = function () {
					$('login_div').remove();
					$('opacity_div').remove();
//					return false;
					return;
				}
				var forms = $('login').getElementsByTagName('form');
				for (var a = 0; a < forms.length; a++) {
					forms[a].onsubmit = function() {
						var parameters = $(this).getElementsByTagName('input');
						var values = {};
						for (var b = 0; b < parameters.length; b++) values[parameters[b].name] = parameters[b].value;

						new Ajax.Request(this.action + '/1',{
							method: 'post',
							parameters: $H(values).toQueryString(),
							onSuccess: function(response) {
								if (response.responseText.indexOf('http') === 0) location.href = response.responseText;
								else $('error').innerHTML = response.responseText;
							}
						});
						return false;
//						return;
					}
				}
			},
			onFailure: function (error) {
				alert(error);
			}
		});
//		return false;
		return;
	}

function forgot_pass() {
	var confirmation = confirm("If you proceed, your password will be reseted an a new password will be sent to your email address");
	var mail = $('login_email').value;
	if(!mail) {
		alert("Please insert your email address so we can send you a new password");
		return;
	}
	if(mail.indexOf('@')<1 || mail.indexOf('.') < 1) {
		alert("Please insert a valid email address");
		return;
	}
	new Ajax.Request('http://www.modellainc.com/my_account/forgot_pass',{
		method: 'post',
		parameters: {mail:mail},
		onSuccess: function(trans){
			try{
				var response = eval('('+trans.responseText+')');
			} catch(e) {
				alert("Wrong response from the server. Please try Again");
				return;
			}
			if(response.error) {
				alert(response.error);
				return;
			} else {
				alert("A new password has been sent to your email address");
				//window.location.reload();
				return;
			}
		}
	});

}

Event.observe(window,'load',function(){
	var myaccount_bt = $('floating_menu_my_account-');
	if(myaccount_bt) myaccount_bt.getElementsByTagName('a')[0].onclick = function() {myaccount(); return false;};
});
