$(document).ready(function(){
  $("#VideoType").change(function(){
    $.post("/videos/ajax", { "user": $("#VideoUser").val(), "type":$(this).val() },
       function(data){
         $('#Owner').html(data);
       });
  });
  $("#ListingCountryId").change(function(){
    $.post("/listings/countries", { "country": $(this).val() },
       function(data){
         $('#ListingStateId').html(data);
       });
  });
  
    $("#UserCountryId").change(function(){
    $.post("/listings/countries", { "country": $(this).val() },
       function(data){
         $('#UserStateId').html(data);
       });
  });


  if(typeof initialize == 'function') {
    initialize();
  }

$(".ui-widget-content:not(.ui-tabs):not(.ui-helper-clearfix)").addClass("ui-helper-clearfix"); 

$('#UserSlug').keyup(function(){
  var slug = $(this).val();
  if(slug.length>2){
    $.post("/users/slug", { "slug": slug },
       function(data){        
         if(data=='0'){
           $('#slug').css('background-color', 'green');
           $('#slugResponse').html('<b>Available</b>')
         }else{
           $('#slug').css('background-color', 'red');
           $('#slugResponse').html('<b>Not Available</b>');
         }
         //$('#UserStateId').html(data);
    });
  }
});

$('.testimonyCheck').click(function(){
  if($(this).is(':checked')){
    var val = 1;
  }else{
    var val = 0;
  }
  
  $.post("/videos/testimony", { "testimony": val, "id": $(this).attr('name') },
    function(data){            
  });
});


});
