$(document).ready(function(){

	// superfish drop down menu

	$('ul.sf-menu').superfish();



// colorbox overlay

$(".iframe").colorbox({width:"75%", height:"75%", iframe:true});

$(".login").colorbox({width:"420px", height:"550px", iframe:true});

// superfish drop down menu

$('ul.sf-menu').superfish();



	

	

// convert emails from form like <span class="email">someone at somedomain dot com</span>

$('span.email').each(function(){

 var email = $(this).html();

 var match = email.match(/([\w\-]+)\sat\s([\w\-]+)\sdot\s(\w+)/);

 if (match && match[1] && match[2] && match[3]){

  email = match[1] + '@' + match[2] + '.' + match[3];

  $(this).html('<a href="mailto:' + email + '">' + email + '</a>');

 }

});



// add pagination buttons/functionality to 'In the News' page

if ($('h2.in-the-news').length > 0){

 articles = $('h2.in-the-news').parent('div').find('.news-article');

 num_articles = articles.length;

 articles_per_page = 4;

 num_pages = Math.ceil(num_articles/articles_per_page);

 

 // remove <hr> from last article on each page

 for (var i=0; i< num_articles; i++){

	if((i+1)%articles_per_page == 0)

		articles.eq(i).children('hr').remove();

 }

 

 // create and add the paginator buttons/list

 lister_html = '<ul class="lister"><li><a href="#" class="active">1</a></li>';

 for (var i=2; i <= num_pages; i++){

  lister_html += '<li><a href="#">' + i + '</a></li>';

 }

 lister_html += '</ul>';

 $('div.body_right').prepend(lister_html).append(lister_html);

 articles.slice(articles_per_page).hide();

 

 paginators = $('ul.lister a');

 paginators.click(function(e){

  e.preventDefault();

  target = $(e.target);

  target.blur();

  page = parseInt($(e.target).html())-1;

  paginators.removeClass('active');

  // style paginator links

  paginators.each(function(){

   if (parseInt($(this).html()) -1 == page) $(this).addClass('active');

  });

  articles.hide();

  articles.slice(articles_per_page*page, articles_per_page*(page + 1)).fadeIn('slow');

 });

}

});









