$(document).ready(function() {
  
/* CACHE IMAGES
 var images = [ 'image1.jpg', 'image2.png', 'image3.gif' ];
  jQuery.each(images, function(i) {
    images[i] = new Image();
    images[i].src = this;
  });
*/
  
  
//SLIDE-DOWN-PANEL
  $("#open").click(function(){
    $("div#panel").slideDown("slow");
  });  
  $("#close").click(function(){
    $("div#panel").slideUp("slow");  
  });    
  $("#toggle a").click(function () {
    $("#toggle a").toggle();
  });
  
// has sub nav?
$("#jsddm > li:has(ul)").addClass("hasSubNav");

// no idea what this does but it works :D
$('#slideshow').cycle({ fx: 'fade', random: 1, pause: 1 });

//tweet
$("#tweet").tweet({
  username: twitterName,
  count: 1,
  intro_text: null,
  outro_text: null,
  join_text:  null,
  loading_text: "Loading tweets..."
});
  
// raf input fields  
$('#home input[title]').each(function() {
    if($(this).val() == '') {
      $(this).val($(this).attr('title'));  
    }
    
    $(this).focus(function() {
      if($(this).val() == $(this).attr('title')) {
        $(this).val('').addClass('focused');
      }
    });
    $(this).blur(function() {
      if($(this).val() == '') {
        $(this).val($(this).attr('title')).removeClass('focused');  
      }
    });
  });

$(function() {
jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
phone_number = phone_number.replace(/\s+/g, "");
return this.optional(element) || phone_number.length > 9 && phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);}, "Please specify a valid phone number");
$(".cForm").validate({rules:{phone:{required:true,phoneUS:true}}});
  });
 
  
  
});
