/* START CUFON REPLACEMENT */
Cufon.replace('.about')('.navigation a', {hover: true})('#content p', {hover: true})('#footer', {hover: true})('.wpcf7-form label')('a.form-submit')('.wpcf7-response-output')('.wpcf7-not-valid-tip-no-ajax');
/* END CUFON REPLACEMENT */

$(window).bind('load', function() {
    
    
});

$(function() {
	
	$('.navigation li a').attr('title','');
		
	$('gallery a').bind("click", function(event){
			event.preventDefault(); //Kill the existing click function
	});
	
	$('.gallery a').each(function (i) {
		
		//$(this).addClass("loading");
		var destiName = $(this).attr('title'); //Get the title to use as a unique ID
		var currentLink = $(this);
		
		$(this).bind("click", function(event){
			event.preventDefault(); //Kill the existing click function
			$('#parallax img#'+ destiName).show();
			$('#parallax img:not(#'+ destiName +')').hide();
			$('.gallery a').removeClass("selected").fadeTo(1, 1);
			currentLink.addClass("selected").fadeTo("fast", 0.5);	
		});	
		
   	});
	
	//display the hover div
	$(".navigation li:not(.current_page_item)").show(1, function() {
	
		//append the background div
		$(this).append("<div></div>");
	
		//on link hover
		$(this).children("a").hover(function(){
			//fade in the background
			$(this).parent().children("div")
				.stop()
				.css({"display": "none", "opacity": "1"})
				.fadeIn("fast");
	
		},function(){
	
			//fade out the background
			$(this).parent().children("div")
				.stop()
				.fadeOut("slow");
	
		});
	});
	
	$(".navigation li.current_page_item").show(1, function() {
	
		//append the background div
		$(this).append("<div></div>");
	
	});
	
	function removeSpaces(string) {
		return string.split(' ').join('');
	}
	

	$('.submit-button input').each(function() {
		var fstext = $(this).val();
		var fsid = $(this).attr("id");
		$(this).parent('.submit-button').append('<a href="#" class="form-submit">'+fstext+'</a>');
		Cufon.replace('a.form-submit');
		$(this).hide();
	});
	
	$('a.form-submit').click(function() {
		$('.submit-button input').trigger('click');
	});


	$('#parallax img').each(function() {
		$(this).load(function() {
        	var cName = $(this).attr('id');
        	var cName = '.gallery a[title="'+ cName +'"]';
        	$(cName).addClass("loaded");
        	if( !$(this).hasClass('selected') ) {
        		$(this).hide();
        	} else {
        		$(cName).addClass("selected").fadeTo("fast", 0.5);
        	}
		});
	});	

/*	$('#parallax img').load(function() {
        	
        	var cName = $(this).attr('id');
        	var cName = '.gallery a[title="'+ cName +'"]';
        	$(cName).removeClass("loading");
        	if( !$(this).hasClass('selected') ) {
        		$(this).hide();
        	} else {
        		$(cName).addClass("selected").fadeTo("fast", 0.5);
        	}
	});	*/
	
});
