/****************************************
 * Login manager
 */
$(function($) {

    
   $("#loginLink").click(function(e) {
       e.preventDefault();
      $('#loginPanel #loginLoader').hide();
      $('#loginPanel #error').hide();
      $('#loginPanel').show("slow");
      $('#createAccountPanel').hide("slow");
   });

   $("#loginPanel input[name='password']").keydown(function(e) {
      if (e.keyCode == 13) {
          e.preventDefault();
          $("#loginPanel input[name='loginBtn']").click();
      }
   });
   
   $("#loginPanel input[name='loginBtn']").click(function(e) {
       
       e.preventDefault();
       $('#loginLoader').show();
       $("#loginPanel #error").html("");
       $("#loginPanel #error").hide();
       
       var uname = $("input[name='uname']").val();
       var pw = $("input[name='password']").val();

       $.getJSON("/login2.php?uname=" + uname + "&password=" + pw,
        function(data, textStatus){
          
          if (data[0].login == "OK")
             window.location.reload();
          else {
              $('#loginLoader').hide();
              $('#loginPanel #error').show();
              $("#loginPanel #error").html("login failed. please enter your login information or <a href='/rescuepw.html'>reset your password</a>");
          }
          
        });


   });
});


/****************************************
 * recommendation streams
 */
$(function($) {
   $("#recommendStream").kidyos_stream();
   $("#recentStream").kidyos_stream({loadURL:'/recommends/recent.php?recCount=4', refreshRate:0, emptyText:"<p>kidyos will show the things you watch the most here</p>"});
   $("#sampleStream").kidyos_stream({loadURL:'/recommends/samples.php?recCount=16', refreshRate:10000});
});

/****************************************
 * grass fun
 */
$(function($) {
    $("#grass").hover(
        function(){
            $(this).css("margin-top", "0px");
        },

        function() {
            $(this).css("margin-top", "5px");
        });
});
/*****************************
 * text field hints
 */
$(function($) {
 $("input.miniField").ezpz_hint();
});

$(function($) {
   $("#suggestSites").cycle({
       fx: "scrollLeft",
       timeout:8000,
       pause:true,
       next: "#suggestNext"
   });
});

//$(function($) {
//   $("input[name='searchBtn']").click(function(e) {
//        e.preventDefault();
//        var search = $("input[name='search']").val();
//        $.get("/eck/log.php?category=search&action=" + search + "&label="+window.location.href);
//   });
//});

$(function($) {

    
    var now = new Date();
   if (now.getHours() >= 18) {
       $("#header").css("background", "url('/images/headerBg_nighttime.png') repeat-x");
       $("#header .centerContent").css("background", "url('/images/night.png') no-repeat -1px 0px");
       $("#kidyosBulletsOn").css("color", "white");
       $("#kidyosBullets").css("color", "white");
   }
       
})
