function form_Join(auto_id) {
	this.DOMConstruct('form_Join', auto_id);
}
form_Join.prototype = new SK_FormHandler({
	name: 'profile_join',
	
	fields: {
		email: {
			construct: 
							function($input) {
								var handler = this;
								
								this.lastValue = $input.parent().find("input[name=last_value]").val();
								
								if($input.val()!="" && $input.val()!=this.lastValue){
									handler.check_email($input);
								}		
								
								$input.change(function(){
									handler.changed = true;
								});
												
								$input.blur(function() {
									if($input.val()!="" && $input.val()!=handler.lastValue && handler.changed ){
										handler.check_email($input);
									}
									else{
										$input.parent().find(".success").remove();
									}						
								});
							},
			validate: function(value, required) {},
			focus: function() {},
			lastValue: "",
			changed: true,
			check_email: 
							function($input){
							var handler = this;
							
								$.ajax({
										url: "http://www.citaxcita.es/field_responder.php",
										method: "post",
										dataType: "json",
										data: {action: "check_email_exists", email: $input.val()},
										success: function(result){
												$input.parent().find(".success").remove();
												handler.changed = false;
												if (result==2){
													SK_drawError("Lo sentimos, este Email ya fue utilizado en otro perfil");
												}
		   										else if(result==1){
		   											$input.after('<span class="success">&nbsp;</span>');
		   										}
		   										else{
		   											SK_drawError("Por favor, escribe un Email válido");
		   										}
		   										
		   										
		  								}
									});
							}
							
		},
		password: {
			construct: function($input, form_handler) {},
			validate: function(value, required) {},
			focus: function() {}
		},
		username: {
			construct: 
							function($input) {
								var handler = this;
								
								if($input.val()!="" && $input.val()!=handler.lastValue){
									handler.check_username($input);
								}
		
								$input.change(function(){
									handler.changed = true;
								});
													
								$input.blur(function() {
									if($input.val()!="" && $input.val()!=handler.lastValue && handler.changed ){
										handler.check_username($input);
									}
									else{
										$input.parent().find(".success").remove();
									}
								});
							},
			validate: function(value, required) {},
			focus: function() {},
			changed: true,
			lastValue: "",
			check_username: 
							function($input){
							
							var handler = this;
								$.ajax({
										url: "http://www.citaxcita.es/field_responder.php",
										method: "post",
										dataType: "json",
										data: {action: "check_username_exists", username: $input.val()},
										success: function(result){
												$input.parent().find(".success").remove();
												handler.changed = false;
												if (result==2){
													SK_drawError("Lo sentimos, este nombre de usuario ya está siendo utilizado, por favor elige otro");
												}
		   										else if(result==1){
		   											$input.after('<span class="success">&nbsp;</span>');
		   										}
		   										else if(result==4) {
		   											SK_drawError("Lo sentimos, este nombre de usuario está restringido");
		   										}
		   										else{
		   											SK_drawError("Por favor, escribe un nombre de usuario valido, recuerda que no debe tener espacios ni caracteres especiales.");
		   										}
		  								}
									});
							}
							
		},
		sex: {
			construct: function($input, form_handler) {},
			validate: function(value, required) {},
			focus: function() {}
		},
		match_sex: {
			construct: function($input, form_handler) {},
			validate: function(value, required) {},
			focus: function() {}
		},
		i_agree_with_tos: {
			construct: function($input, form_handler) {},
			validate: function(value, required) {},
			focus: function() {}
		},
		partner_code: {
			construct: function($input, form_handler) {},
			validate: function(value, required) {},
			focus: function() {}
		},
		wt_mc_id: {
			construct: function($input, form_handler) {},
			validate: function(value, required) {},
			focus: function() {}
		}
	},
	actions: {
		action_1___: {
		fields: {"email":true,"password":true,"username":true,"sex":true,"match_sex":true,"i_agree_with_tos":true,"partner_code":false,"wt_mc_id":false}
		},
		action_1___2: {
		fields: {"email":true,"password":true,"username":true,"sex":true,"match_sex":true,"i_agree_with_tos":true,"partner_code":false,"wt_mc_id":false}
		},
		action_1___1: {
		fields: {"email":true,"password":true,"username":true,"sex":true,"match_sex":true,"i_agree_with_tos":true,"partner_code":false,"wt_mc_id":false}
		}
	},
	default_action: ''
});

