/**FORMULARIO TARJETAS*/

jQuery.extend({
	
    stepForm: function(txtBack, txtNext, token){
    		var fieldsets = $((token || 'fieldset'), $("form.stepMe"));
        var total = $(fieldsets).length;
				$(fieldsets).each(function(x,el){
			
			    if (x > 0) {
			      $(el).hide();
			      $(el).append('<div class="botones"><a href="#x_' + (x-1) + '" title="anterior" id="btn_ant" class="ant">'+ (txtBack || 'Anterior') +'</a></div>');
			      $(".ant", $(el)).bind("click", function(){
			                $("#x_" + (x - 1)).show();                
			                $(el).hide();
					
							
			       });
				   
			    }
			    
			    if ((x+1)< total) {
			        $(el).append('<div class="botones ftr w40"><a href="#_' + (x+1) + '" title="Siguiente" class="sig">'+(txtNext || 'Siguiente')+'</a><label for="enviar"><input type="reset" id="borrar" class="reset" value="borrar" /></label></div>');
			        $(".sig", $(el)).bind("click", function(){
			                $("#x_" + (x + 1)).show();  							 
			                $(el).hide();
							
							
							
			        });
			    }
			    $(el).attr("id", "x_" + x);
				$('#acepto').attr('checked') == false;
				$('input').attr('disabled','disabled');
				$('select').attr('disabled','disabled');
				$('#voto input').removeAttr('disabled'); 
				$('#acepto').attr('disabled',false);	
				$('#c_buscador').attr('disabled',false);
				$('#c_buscGlobal').attr('disabled',false);
				$('#c_envioBusc').attr('disabled',false);				
				$('#acepto').click(function() 
				{
					if($(this).attr('checked') == true)
					{ 
						$('input').removeAttr('disabled'); 
						$('select').removeAttr('disabled'); 
					} 
					else { 
						$('input').attr('disabled','disabled'); 
$('select').attr('disabled','disabled');						
						$('#acepto').attr('disabled',false);
						$('#c_buscador').attr('disabled',false);
						$('#c_buscGlobal').attr('disabled',false);
						} 
						
				});
				
				
				
			
				
			});
			
	
			
	
 
  


}});
jQuery.extend({
		aniade:function() {
					var x =0;
				$('a.mas_info').click(function() {
				
				x++;
					$(this).parent('div.datos').append("<label for='entidad"+x+"'><span>"+x+"</span><input type='text' id='entidad"+x+"' class='required text' /></label>");
					});}
	
 
   	});



jQuery.extend({
//LIMPIA EL BUSCADOR
			valida:function(){	$("#c_buscador").focus(function() {
					if( this.value == this.defaultValue )
					{
						this.value = "";
					}
				}).blur(function() {
						if( !this.value.length ) {
						this.value = this.defaultValue;
						}
});
			//LIMPIA CAMPO DE CODIGO POSTAL
				$("#cod").focus(function() {
					if( this.value == this.defaultValue )
					{
						this.value = "";
					}
				}).blur(function() {
						if( !this.value.length ) {
						this.value = this.defaultValue;
						}
						});
			//LIMPIA CAMPO DE MES
				$("#fecha_mes").focus(function() {
					if( this.value == this.defaultValue )
					{
						this.value = "";
					}
				}).blur(function() {
						if( !this.value.length ) {
						this.value = this.defaultValue;
						}
						});
			//LIMPIA CAMPO DE DIA
				$("#fecha_dia").focus(function() {
					if( this.value == this.defaultValue )
					{
						this.value = "";
					}
				}).blur(function() {
						if( !this.value.length ) {
						this.value = this.defaultValue;
						}
						});
		//LIMPIA CAMPO DE AnIO
				$("#fecha_anio").focus(function() {
					if( this.value == this.defaultValue )
					{
						this.value = "";
					}
				}).blur(function() {
						if( !this.value.length ) {
						this.value = this.defaultValue;
						}
						});
						
	//ACCORDION
			$("#accordion").accordion({active:false});
	
	$("a.cerrar").click(function() {  
 $(this).parent('div').hide(); 
 $(this).parent('p').css('height','auto'); 
}); 
}});


	$(document).ready(function(){
	var menu = $('#submenu_lateral_n2');
	if(menu.length == 0 )
		{
			$('#contenido').addClass('home');
		} 
	else{$('#contenido').removeClass('home');}
	
	jQuery.extend($.stepForm());
	jQuery.extend($.valida());
	jQuery.extend($.aniade());

	


  });
 
 