var refresh_to = null;
var field_name_jx = null;
$(document).ready(function(){
var lang = 'es';
/*Solo numeros*/
  $('.OnlyNumbers').keypress(function(e){
    if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)){
      return false;
    }
  })

  $(".rtb").each(function(index) {
    rtbid = $(this).attr('id');
    WYSIWYG.attach(rtbid, full);
  });

/*Admin*/
$(".HeadModule").click(function(){
  id = $(this).attr('id');
  str = id.split("admingen_");
  module = str[1];
  $(".BodyModule").hide("normal");
  $(".BM_"+module).slideToggle('slow');
})

  $(".HeadTextModule").hover(
    function () {
      $(this).stop().animate({ paddingRight: "15px" }, 200);
    },
    function () {
      $(this).stop().animate({ paddingRight: "0px" });
    }
  );

/**/
  $(".gallery").prettyPhoto({
    theme:'facebook',
    animationSpeed: 'slow', /* fast/slow/normal */
    opacity: 0.00,
    modal:true
    });

//   $('.DatePicker').datepicker({
//   buttonImage:  
//   });
  $(".DatePicker").datepicker({showOn: 'button', buttonImage: baseurl+'media/js/calendar_icon.gif', buttonImageOnly: true});

  $('.DateTimePicker').datepicker({
        duration: '',
        showTime: true,
        constrainInput: false,
        stepMinutes: 1,
        stepHours: 1,
        altTimeField: '',
        time24h: true
  });
  $.datepicker.regional[lang];
  $(".SpinnerNumber").spinner();
   $(".AjaxOTO").click(function(){
     id = $(this).attr('id');
     field_name_jx = $(this).attr('field_name');
     refresh_to = $(this).attr('refresh_to');
     
     $.ajax({
       type: "GET",
       url: $(this).attr('href')+'?AJAX_NO_LOAD=TRUE',
       success: function(html){
         $("."+id).html(html);
         $("."+id).dialog({ width: 600,autoOpen: false,modal: true  });
         $("."+id).dialog('open');
       }
     });
     return false;
   });
   

})

   function post_ajax(form){
     $.ajax({
       type: "POST",
       url: $(form).attr('action'),
       data: $(form).serialize(),
       success: function(html){
         $("."+id).html(html);
         if(!(refresh_to == null && field_name_jx == null)   ){
           $.ajax({
             type: "GET",
             url: refresh_to+'?AJAX_NO_LOAD=TRUE',
             success: function(html){
               $(".tbltd_"+field_name_jx).html(html);
             }
           });
         }
         refresh_to = null;
         field_name = null;
       }
     });
     return false;
   }
