$(document).ready(function() {
	// adds hooks to the first and last list items
  	$("ul li:first-child").addClass("first-item");
	$("ul li:last-child").addClass("last-item");
	$("ol li:first-child").addClass("first-item");
	$("ol li:last-child").addClass("last-item");
	$("<span>&rsaquo; </span>").prependTo(".sidebar-widget ul li");
	
	$("#content-form").validate();
	
	var imgpath="/wp-content/themes/nzfvwo/_assets/_img/header-images/";
	
	function random_imglink(){
	 	var myimages=new Array()

	 	myimages[1]=imgpath + "new-1.jpg"
	 	myimages[2]=imgpath + "new-2.jpg"

	 	var ry=Math.floor(Math.random()*myimages.length)
	 	if (ry==0) ry=1
			$("#tagline").after('<img src="'+myimages[ry]+'" class="header-img" />');
		} // This handles the random header images across the site.
	
	random_imglink();
	
	$('.back-to-top').click(function(event){
		event.preventDefault();
		$('html, body').animate({scrollTop:0}, 'slow');
	});
	
	
});	
	// Cufon font application
	Cufon.replace('#navigation a', {
		fontfamily: 'ScalaSanBold',
		hover: true
	});
	
	Cufon.replace('h1, h3.blue-heading', {
		fontfamily: 'ScalaSan'
	});
	
	Cufon.replace('#right-column h3, h2.widgettitle', {
		fontfamily: 'ScalaSanBold',
		hover: true
	});
	
	/*Cufon.replace('#right-column-home h3', {
		fontfamily: 'ScalaSanBold',
		hover: true
	});*/
	
	Cufon.replace('#post-list h3', {
		fontfamily: 'ScalaSanBold',
		hover: true
	});
	
	Cufon.replace('#post-content h2', {
		fontfamily: 'ScalaSanBold',
		hover: true
	});
	
	Cufon.replace('#post-content h3', {
		fontfamily: 'ScalaSanBold',
		hover: true
	});
	
	Cufon.replace('#post-content thead th', {
		fontfamily: 'ScalaSanBold',
		hover: true
	});
	
	Cufon.replace('#comments-box h3', {
		fontfamily: 'ScalaSanBold',
		hover: true
	});
	
	Cufon.replace('.big-blue-heading', {
		fontfamily: 'ScalaSanBold',
		hover: true
	});

	Cufon.replace('h6', {
		fontfamily: 'ScalaSan'
	});

