$(document).ready(function(){

	$(".zoom_nav_on a").click(function(){
		var largePath = $(this).attr("href");
		var largeAlt = $(this).attr("title");
		
		$('.zoom_nav span').remove()
		$(this).append("<span></span>")
		$(".zoom_nav a").removeClass("active")
		$(this).addClass("active")
		
		$('.zoom_nav span').show()
		$('#largeImg').attr({src: largePath}).load(function() {  
			$('.zoom_nav span').hide();
		});
		return false;
	});


	// thumb_nav
	$('.thumb_nav span').hide();
	$("#portfolio_pg .thumb_nav a").click(function(){
		var largePath = $(this).attr("href");
		var largeAlt = $(this).attr("title");
		
		$('.thumb_nav span').remove()
		$(this).append("<span></span>")
		$(".thumb_nav a").removeClass("active")
		$(this).addClass("active")
		
		$('.thumb_nav span').show()
		$('#largeImg').attr({src: largePath}).load(function() {  
			$('.thumb_nav span').hide();
		});
		return false;
	});


	// tabs
	$('ul.tabnav a').click(function() {
		var curChildIndex = $(this).parent().prevAll().length + 1;
		$(this).parent().parent().children('.current').removeClass('current');
		$(this).parent().addClass('current');
		$(this).parent().parent().next('.tabcontainer').children('.current').fadeOut('fast',function() {
			$(this).removeClass('current');
			$(this).parent().children('div:nth-child('+curChildIndex+')').fadeIn('normal',function() {
				$(this).addClass('current');
			});
		});
		return false;								
	});


	// add zoom icon span
	$(".gallery img, .wallpaper_list img").before('<span class="zoom"></span>');

	//validate forms
	$("#commentform").validate({
			rules: {
				comment: {
				required: true,
				minlength: 15
			}
			},
			messages: {
				comment: {
				required: "Please write your comment!",
				minlength: "Sorry, your comment is too short (minimum 15 characters)"
			}
			}
	});

	$(".wpcf7-form").validate();
	
	//scrollto
	$(".backtotop a").click(function(){
		$(window).scrollTo( '#header', 800 )
		return false;
	});
	
	//scrollto
	$(".backtotopservices a").click(function(){
		$(window).scrollTo( '#header', 800 )
		return false;
	});

	$(".jumptocomments").click(function(){
		$(window).scrollTo( '#comments', 800 )
		return false;
	});
	
	$(".jumptophotography").click(function(){
		$(window).scrollTo( '#photography', 800 )
		return false;
	});
	
	$(".jumptowebdesign").click(function(){
		$(window).scrollTo( '#webdesign', 800 )
		return false;
	});
	
	$(".jumptoprint").click(function(){
		$(window).scrollTo( '#print', 800 )
		return false;
	});

	$(".jumptorespond").click(function(){
		$(window).scrollTo( '#respond', 800 )
		return false;
	});

	//home splash hover
	$("#splash").append("<span></span>");	
	$("#splash a").hover(function() {
		$("#splash").append("<span class='"+ this.rel +"'></span>");
	}, function() {
		$("#splash").find("span").remove();
	});

	
	//append quotation mark to quotelist
	$(".quotelist li").append("<span class='hang_quote'>&#147;</span>");	
	
	
	//remove border / margin
	$(".tabnav li:last").addClass("no_border");
	$(".portfolio_gallery li:nth-child(3n)").addClass("no_margin");

}); //close doc ready
