function showLoginDialog() {
    $('email').value="";
    $('pswd').value="";
    $('error_mes1').hide();
    $('light').style.display='block';
    $('fade').style.display='block';
    $('email').focus();
}

function closeLoginDialog() {
    $('light').style.display='none';
    $('fade').style.display='none'
}

function showApplyDialog() {
    $('a_name').value="";
    $('a_url').value="";
    $('a_email').value="";
    $('a_comment').value="";
    $('error_mes2').hide();
    $('light1').style.display='block';
    $('fade').style.display='block';
    $('a_name').focus();
    
    $('a_dialog').show();
	$('a_msg').hide();
    
}

function closeApplyDialog() {
    $('light1').style.display='none';
    $('fade').style.display='none';
}
        
function loginUser(action) {
	var emailValue = $('email').getValue();
	var pswdValue = $('pswd').getValue();
	
	if (emailValue == null || emailValue.length == 0) {
		$("error_mes1").show().update("Please enter email");
		return;
	}
	
	if (pswdValue == null || pswdValue.length == 0) {
		$("error_mes1").show().update("Please enter password");
		return;
	}

	$("error_mes1").show().update("Logging in ...");
	
	new Ajax.Updater({ success: 'error_mes1' }, action, {
		method: 'post',
		parameters: { 
			email:		emailValue,
	  		pswd: 		pswdValue,
	  		remember: 	$('rememberMe').checked
		},
		evalScripts: true
	});	
}

function apply(action) {
   	var nameValue = $('a_name').getValue();
    var emailValue = $('a_email').getValue();
  	var urlValue = $('a_url').getValue();
 	var commentValue = $('a_comment').getValue();
	
	if (nameValue == null || nameValue.length == 0) {
		$("error_mes2").show().update("Please enter your name");
		return;
	}
	
	if (emailValue == null || emailValue.length == 0) {
		$("error_mes2").show().update("Please enter your email");
		return;
	}
	
	if (urlValue == null || urlValue.length == 0) {
		$("error_mes2").show().update("Please enter your MySpace URL");
		return;
	}
	
	new Ajax.Request(action, {
		method: 'post',
		parameters: { 
			userName:		nameValue,
	  		userEmail: 		emailValue,
	  		userProfile: 	urlValue,
	  		userComment:	commentValue
		}
	});	
	
	$('a_dialog').hide();
	$('a_msg').show();
}

function forgotPassword(action) {
	var emailValue = Form.Element.getValue('email');
	
	if (emailValue == null || emailValue.length == 0) {
		Element.update("error_mes1","Please enter email");
		Element.show("error_mes1");
		return;
	}
	
	Element.update("error_mes1","");
	Element.show("error_mes1");
	
	new Ajax.Updater({ success: 'error_mes1' }, action, {
		method: 'post',
		parameters: { email: emailValue	}
	});	
}