Cufon.replace('h1', { fontFamily: 'Greyscale' });
Cufon.replace('h2', { fontFamily: 'Greyscale' });
Cufon.replace('h3', { fontFamily: 'Greyscale' });
Cufon.replace('#content .big', { fontFamily: 'Greyscale' });
Cufon.replace('#menu-main li a', { fontFamily: 'Greyscale' });
Cufon.replace('.booking-button', { fontFamily: 'Greyscale' });

$(document).ready(function(){
//Page navigation rollovers
	$('#sideNav ul li').each(function(){
		if(!$(this).hasClass('active')){
			$(this).mouseenter(function(){
				var thisLink = $(this).children('a');
				//if(thisLink.parents('ul').hasClass('menu-sub-nav')){
					thisLink.prepend('&gt;&nbsp;');
				//}
			}).mouseleave(function(){
				var thisLink = $(this).children('a');
				var linkContent = thisLink.html();
				var strippedContent = linkContent.replace('&gt;&nbsp;','');
				thisLink.html(strippedContent);
			});
		}else{
			if($(this).parent('ul').hasClass('menu-sub-nav')){
				$(this).parent('ul.menu-sub-nav').css('display','block');	
			}
		}
	});//end $('#sideNav ul li').each(function(){
//Insert clearing div after h4s in secondary content area
	$('#secondary-content h4').each(function(){ $(this).after('<div class="clear"></div>')});
//Insert clearing div after checkbox in signup form
	$('.add-email-list .wpcf7-list-item-label').after('<div class="clear"></div>');
//Add classees to error fields on validation and remove generic message
	$('.wpcf7-not-valid-tip-no-ajax').each(function(){
		$(this).addClass('generic-validation-message');
		$(this).siblings('.wpcf7-validates-as-required').addClass('invalid-field');
	});
//Remove invalid class when focused on
	$('.invalid-field').focus(function(){ $(this).removeClass('invalid-field');	});
//Don't allow form to be submitted unless checkbox is ticked
	$('#form-wrap .actions input').click(function(e){
		if($('.checkbox-area input').attr('checked') != true){
			e.preventDefault();
			alert('Please check the box if you would like to be subscribed to the mailing list');	
		}
	});
//Replace any stray localhost paths with live URL
	/*$('img').each(function(){
		var imgSrc = $(this).attr('src');
		if(imgSrc.indexOf('localhost') != -1){
			var newImgSrc = imgSrc.replace('http://localhost/toiwhakaari2011', 'http://www.the-church.co.nz/preview/toiwhakaari');
		}
		$(this).attr('src', newImgSrc);
	});
	$('a').each(function(){
		var theURL = $(this).attr('href');
		if(theURL.indexOf('localhost') != -1){
			var newHref = theURL.replace('http://localhost/toiwhakaari2011', 'http://www.the-church.co.nz/preview/toiwhakaari');
		}
		$(this).attr('href', newHref);
	});*/
//Show google map if on contact page
	if($('body').hasClass('page-template-contact-php')){
		showGoogleMap('google-map-wrap');	
	}
	
//----------------ROTATOR
	if($('body').hasClass('home')){
		$('.slideshow').cycle({
			fx: 'fade', speed: 'fast', timeout: 3000, pager: '#slideshow-paging'
		});
	}	
//---------------PHOTO GALLERY
	$('h1.gallery-link a').click(function(){
		var galDiv = $('#post-gallery-content');
		if(galDiv.hasClass('open')){
			galDiv.hide('fast').removeClass('open');
			$(this).css('display','none');
			$(this).siblings('a').css('display','block');
			
		}else{
			galDiv.show('fast').addClass('open');
			$(this).css('display','none');
			$(this).siblings('a').css('display','block');
		}
	});
//----------------TEMPORARY STUFF
//Disable "read more" links in Past Productions page
	$('#past-productions a').each(function(){
		$(this).attr('href','#');
	});
	
});//end $(document).ready(function(){
	
window.onload = function(){
//Get rid of sneaky sponsor message inserted by events calendar plugin
	$('table#wp-calendar').siblings('span').css('display','none');
}

function showGoogleMap(mapDiv){
	var latlng = new google.maps.LatLng(-41.3077683, 174.7745702);
	var latlng2 = new google.maps.LatLng(-41.3084683, 174.7745702);
	var myOptions = {
	  zoom: 16,
	  center: latlng,
	  mapTypeId: google.maps.MapTypeId.ROADMAP,
	  mapTypeControl: false
	};
	var map = new google.maps.Map(document.getElementById(mapDiv), myOptions);
//Add marker
	var marker = new google.maps.Marker({
	  position: latlng, 
	  map: map, 
	  title:"Toi Whakaari: NZ Drama School, 11 Hutchison Road, Newtown, Wellington"
	});
	var contentString = '<div id="map-inner"><h3>Toi Whakaari: NZ Drama School</h3><p>Te Whaea: National Dance and Drama Centre<br />11 Hutchison Road, Newtown<br />Wellington, New Zealand</p></div>';
	
	var infowindow = new google.maps.InfoWindow({
		content: contentString
	});

//Add second marker
	var marker2 = new google.maps.Marker({
	  position: latlng2, 
	  map: map, 
	  title:"Te Whaea: National Dance and Drama Centre, 11 Hutchison Road, Newtown, Wellington"
	});
	google.maps.event.addListener(marker, 'click', function() {
	  infowindow.open(map,marker);
	});
	google.maps.event.addListener(marker2, 'click', function() {
	  infowindow.open(map,marker2);
	});
}
