$(function(){ // document ready...
  
  $("#index_page #primary_content").css("height","263px").jScrollPane();
  $("#latest_club_photos li a").find("img").css("opacity",".5").bind("mouseenter",function(e){$(this).css("opacity","1");}).bind("mouseleave",function(e){$(this).css("opacity",".5")});
  $("span.mailto").each(function(){
	  exp = jQuery(this).text().search(/\((.*?)\)/) != -1 ? new RegExp(/(.*?) \((.*?)\)/) : new RegExp(/.*/);
	  match = exp.exec($(this).text());
	  addr = match[1] ? match[1].replace(/ at /,"@").replace(/ dot /g,".") : match[0].replace(/ at /,"@").replace(/ dot /g,".");
	  link = match[2] ? match[2] : addr;
	  subject = jQuery(this).attr('title') ? "?subject="+jQuery(this).attr('title').replace(/ /g,"%20") : "";
    jQuery(this).after('<a href="mailto:'+addr+subject+'" class="mailto">'+ link + '</a>');
		jQuery(this).remove();
	})
	$("a[rel~=external]").attr("target","_blank");
	$("#banner .banner_image").cycle({timeout: 5000});
	
	//gallery - hide/show thumbnails
  $('.hide_me').hide();
  

  
  $('a.show_div').click(function() {
    var show_me = $(this).attr('href');
    $('.hide_me').hide();
    $(show_me).fadeIn();
    return false;
  });
  
  
  /* If there is an anchor it shows that corrosponding li */
  var myFile = document.location.toString();
  if (myFile.match('anchor=')) { // the URL contains an anchor
    var myAnchor = myFile.split('anchor=')[1];
    $('#'+myAnchor).show();
    return false;
  } else {
    $('#primary_whats_on').show();
  }
  
});