$(document).ready(function(){
var isiPad = navigator.userAgent.match(/iPad/i) != null;
  if(isiPad) document.getElementById("viewport").setAttribute('content','user-scalable=yes, width=1030, minimum-scale = 0.5, maximum-scale = 2');

// check if on buzz page since we break out of structure for it and lose active state.
if($('body.buzz').length > 0){
  $("#primary_nav a").each(function(){
    if($(this).text() == "Buzz"){
      $(this).parent().addClass('here');
    }
  })
}
$("#header h1").click(function(){
  location.href = "/";
})
$("#primary_nav li:not('.here') a").hover(
  function(){
    $(this).stop().animate({color: '#fff'}, 400);
  },
  function(){
    $(this).stop().animate({color: '#5a9aa2'}, 400);
  }
);
$("#freeform input.input, #news input.input").each(function(){
  titleField($(this));
});
// twitter
$("#twitfeed").tweet({
    username: "karmagaming",
    join_text: "auto",
    count: 3,
    auto_join_text_default: null,
    auto_join_text_ed: null,
    auto_join_text_ing: null,
    auto_join_text_reply: null,
    auto_join_text_url: null,
    loading_text: "loading tweets..."
});
//fancybox
$("#gallery div.item a").fancybox(
  {
    'showCloseButton' : true,
    'speedIn' : 600,
    'overlayColor' : '#000',
    'overlayOpacity' : 0.7,
    'width' : 720,
    'height' : 450,
    'autoDimensions' : false
  });


function titleField(n){
  var title = n.attr('title');
  n.val(title);
  n.focus(function(){
    if(n.val() == title) n.val('');
  });
  n.blur(function(){
    if(n.val() == ''){
      n.val(title);
    }
  });
}



});
