
  function setFocusBorder(selector, estilo1, estilo2, callBackFocus, callBackBlur){
    jQuery(selector).each(function(){
      jQuery(this)
        .data("estilo1", estilo1)
        .data("estilo2", estilo2)
        .css("border",estilo1);
    }).blur(function(){
      jQuery(this).css("border",jQuery(this).data("estilo1"));
      if(callBackBlur)
        callBackBlur.apply(this);
    }).focus(function(){
      jQuery(this).css("border",jQuery(this).data("estilo2"));
      if(callBackFocus)
        callBackFocus.apply(this);
    })
  }


  function setFormSteps(contenedor, divs, callBackBefore, callBackAfter){
    contenedor = jQuery(contenedor);
    var ruta_divs = divs;
	divs = jQuery(divs);
	var size = divs.length;
	if(size > 0){
      contenedor.data("formStep_size",size);
      contenedor.data("formStep_pagActual",0);
      contenedor.data("formStep_rutaDivs",ruta_divs);
      if(callBackBefore){
        contenedor.data("formStep_before",true);
        contenedor.get(0).callBackBefore = callBackBefore;
      }
      if(callBackAfter){
        contenedor.data("formStep_after",true);
        contenedor.get(0).callBackAfter = callBackAfter;
      }
      divs.filter(":gt(0)").hide();
    }
  }
  
  function showStep(contenedor, actual){
    var contenedorId = contenedor;
    var contenedor = jQuery(contenedor);
    var size   = contenedor.data("formStep_size");
    var divs   = jQuery(contenedor.data("formStep_rutaDivs"));
    if((actual > -1) && (actual < size)){
      if(contenedor.data("formStep_before"))
        contenedor.get(0).callBackBefore(contenedorId, actual);
      divs.hide();
      divs.filter(":eq(" + actual + ")").show();
      contenedor.data("formStep_pagActual",actual);
      if(contenedor.data("formStep_after"))
        contenedor.get(0).callBackAfter(contenedorId, actual);
    }
  }

  function nextStep(contenedor){
    var contenedorId = contenedor;
    var contenedor = jQuery(contenedor);
    var size   = contenedor.data("formStep_size");
    var actual = contenedor.data("formStep_pagActual");
    var divs   = jQuery(contenedor.data("formStep_rutaDivs"));
    if(actual + 1 < size){
      if(contenedor.data("formStep_before")){
        var response = contenedor.get(0).callBackBefore(contenedorId, actual);
        if(response != undefined && response == false){
          return false;
        }
      }
      divs.filter(":eq(" + actual++ + ")").hide();
      divs.filter(":eq(" + actual + ")").show();
      contenedor.data("formStep_pagActual",actual);
      if(contenedor.data("formStep_after"))
        contenedor.get(0).callBackAfter(contenedorId, actual);
    }
  }
  
  function prevStep(contenedor){
    var contenedorId = contenedor;
    var contenedor = jQuery(contenedor);
    var size   = contenedor.data("formStep_size");
    var actual = contenedor.data("formStep_pagActual");
    var divs   = jQuery(contenedor.data("formStep_rutaDivs"));
    if(actual > 0){
      if(contenedor.data("formStep_before"))
        contenedor.get(0).callBackBefore(contenedorId, actual);
      divs.filter(":eq(" + actual-- + ")").hide();
      divs.filter(":eq(" + actual + ")").show();
      contenedor.data("formStep_pagActual",actual);
      if(contenedor.data("formStep_after"))
        contenedor.get(0).callBackAfter(contenedorId, actual);
    }
  }

