var Singin = new function() {
		
		
	this.signup= function(){
		var url = "index.php?mod=login";
		document.location.href=url;
	
	}	
	this.profile= function(){
		var url = "index.php?mod=profile";
		document.location.href=url;
	
	}
	this.logout = function() {

		var url = "index.php?mod=login&exec=logout";
		var params = "";
		var target = 'showLogin';

		var ajax = new Ajax.Updater(
			{success: target},
			url,
			{	method: 'post', 
				evalScripts: true,
				parameters: params,
				onLoading: function(res) { 
					$(target).innerHTML = "<img src='images/loading.gif'/>"; 
				},
					onComplete: function(res) { 
				//	document.write(res.responseText);
				},
				onFailure: function() { 
					$(target).innerHTML = "An error occurred"; 
				} 
			});
	};
	this.forgot = function() {
		var url = "index.php?mod=login&exec=forgot";
		var params = ""
		var target = 'showLogin';

		var ajax = new Ajax.Updater(
			{success: target},
			url,
			{	method: 'post', 
				evalScripts: true,
				parameters: params,
				onLoading: function(res) { 
					$(target).innerHTML = "<img src='images/loading.gif'/>"; 
				},
				onComplete: function(res) { 
					//document.write(res.responseText);
				},
				onFailure: function() { 
					$(target).innerHTML = "An error occurred"; 
				} 
			});
	};
	
	this.validate = function() {
		var url = "index.php?mod=login&exec=login";
		//var params = Form.serialize("logintopForm");
		var params = "logintop="+$("logintop").value+"&clavetop="+$("clavetop").value;
		var target = 'showLogin';
	
		var ajax = new Ajax.Updater(
			{success: target},
			url,
			{	method: 'post', 
				evalScripts: true,
				parameters: params,
				onLoading: function(res) { 
					$(target).innerHTML = "<img src='images/loading.gif'/>"; 
				},
				onComplete: function(res) { 
				//	document.location.href=document.location.href;
				//	document.write(res.responseText);
				},
				onFailure: function() { 
					$(target).innerHTML = "An error occurred"; 
				} 
			});
	};
	
	this.resetForm = function() {
		//$("logintop").focus();
	//	$("logintop").value="Username...";
	//	$("clavetop").value="Password...";
//		$("logintop").focus();
	};

	this.switchType = function(fieldPassword) {
		if (fieldPassword.value=='Password...') {
			try {
				fieldPassword.type='password';
				fieldPassword.value='';
			} catch(e){
				$("changePassword").innerHTML="<input name=\"clavetop\" type=\"password\" class=\"bgcelda2\" id=\"clavetop\" value=\"\"/>";
				$("clavetop").focus();
				$("clavetop").focus();
			}
		}
	};
	
	
	this.getPassword = function() {

		var url = "index.php?mod=login&exec=forgot&accion=1";
		var params = Form.serialize("logintopForm");
		var target = 'showLogin';

		var ajax = new Ajax.Updater(
			{success: target},
			url,
			{	method: 'post', 
				parameters: params,
				onLoading: function(res) { 
					$(target).innerHTML = "<img src='images/loading.gif'/>";
				},
				onComplete: function(res) { 
				//	alert(res.responseText);
				},
				onFailure: function() { 
					$(target).innerHTML = "An error occurred"; 
				} 
			});
	};
}
