// FUNCTIONS

(function ($) {
// VERTICALLY ALIGN FUNCTION
 $.fn.vAlign = function() { 
	return this.each(function(i){
	var ah = $(this).height();
	var ph = $(this).parent().height();
	var mh = Math.ceil((ph-ah) / 2);
	$(this).css('padding-top', mh);
	});
 };
})(jQuery);


$(document).ready(function(){

 $(function() {
 $("#mainbanner").tabs({ fx: { opacity: 'toggle' } }).tabs('rotate', 4000);
 $('#mainbanner').hover(function(){
  $(this).tabs('rotate', 0, false);
  },function(){
  $(this).tabs({ fx: { opacity: 'toggle' } }).tabs('rotate', 4000);
  }
 );   

 $(".tabbed, #tweets").tabs({ selected: 0 });
 });  

 // Shadow fade effects
 $(".listPost, .banner, .monthBanner").hover(
 function() {
 $(this).find('.topShadow, .bottomShadow').stop().animate({"opacity": "0"}, "medium");
 },
 function() {
 $(this).find('.topShadow, .bottomShadow').stop().animate({"opacity": "1"}, "medium");
 });

 // Cufon
 Cufon.replace('#banner .meta, h1, h2, h3', { fontFamily: 'vegur' });
 Cufon.replace('.heading', { textShadow: '#000 1px 1px' });
 Cufon.replace('.blueheading', { textShadow: '#265396 1px 1px' });

 // BigTarget Banner meta anchors
 $(".banner .meta a, .monthBanner .meta a").bigTarget({
 hoverClass: 'over', // CSS class applied to the click zone onHover
 clickZone : 'div:eq(1)' // jQuery parent selector
 });
 
 // BigTarget Generic divs
 $(".bigtarget a").bigTarget({
 hoverClass: 'over bigtargetover', // CSS class applied to the click zone onHover
 clickZone : 'div:eq(0)' // jQuery parent selector
 });

// BigTarget box headers
$(".listPost h3 a").bigTarget({
hoverClass: 'over listPostOver', // CSS class applied to the click zone onHover
clickZone : 'li:eq(0)' // jQuery parent selector
});

// BigTarget procuct boxes
$(".productList h3 a").bigTarget({
hoverClass: 'over productOver', // CSS class applied to the click zone onHover
clickZone : 'li:eq(0)' // jQuery parent selector
});

$('.alignwrap').find('h3').css('padding-top','0');
$('.alignwrap').vAlign();
$('.alignwrap').find('h3.long').parent().css('padding-top','12px');


$(".fb_ltr").contents().find(".connect_widget_number_cloud").css("visibility","visible");

$("textarea.code").focus(
 function()
 {
  // only select if the text has not changed
  if(this.value == this.defaultValue)
  {
   this.select();
  }
 }
)

$('#datenav').jcarousel(
{
'start' : 6
}
);


$('.product').click(function() {
_gaq.push(['_trackEvent', 'Useful Exits', 'Product', window.location.pathname]);
        });


});


