 $(document).ready(function() {
/*	$('.error').hide();
	$('#contact-submit').click(function() {
 		$('.error').hide();
		var name = $('#contact-name').val();
		var email = $('#contact-email').val();
		var message = $('#contact-message').val();
		if (name == '') {
			$('#contact-name-error').show();
			$('#contact-name').focus();
			return false;
		} else if (email == '') {
			$('#contact-email')
		}
  })*/
	$("a[href^='http:']").not("[href*='yupso.com']").attr('target','_blank'); 
 	$('a', '.gallery-nav').live('click', function(e){
		var i = parseInt($(this).html(), 10), offset = 400*(i-1);
		$(this).parent('li').addClass('selected').siblings('li').removeClass('selected').parents('.gallery-nav').siblings('.gallery-slides').animate({
			top: -offset
		}, 400);
		e.preventDefault();
	})
	
 	$('a', '#portfolio-nav').live('click', function(e){
		var i = parseInt($(this).attr('data-num'), 10), offset = 960*(i-1);
		$('#portfolio-gallery').animate({
			left: -offset
		}, 400);
		e.preventDefault();
	})
	
	$('.gallery-slides').find('li:not(:last-child) img').live('click', function(){
		$(this).parents('.gallery-slides').animate({
			'top': '-=400px'
		}, 400).siblings('.gallery-nav').find('li.selected').removeClass('selected').next('li').addClass('selected');
	}).end().find('li:last-child img').live('click', function(){
		$(this).parents('.gallery-slides').animate({
			'top': '0px'
		}, 400).siblings('.gallery-nav').find('li.selected').removeClass('selected').siblings('li:first-child').addClass('selected');
	})
	

	var tmbList = $('#portfolio-nav').find('ul');
	var tmbListWidth = tmbList.width();
	var tmbOffset = tmbList.find('li').first().outerWidth(true);
	var tmbLength = tmbList.find('li').length;

	$('#portfolio-nav').find('.back a').live('click', function(e){
		var leftPos = tmbList.position().left;
		if (leftPos >= 0) {
			tmbList.animate({
				'left': '0'
			}, 400)
		} else {
			tmbList.animate({
				'left': '+=' + tmbOffset + 'px'
			}, 400)
		}
		e.preventDefault();
	}).end().find('.forward a').live('click', function(e){
		var leftPos = tmbList.position().left;
		var maxLeft = tmbOffset*(tmbLength - 4)
		if (leftPos > -maxLeft) {
			tmbList.animate({
				'left': '-=' + tmbOffset + 'px'
			}, 400)
		} else {
			tmbList.animate({
				'left': -maxLeft + 'px'
			}, 400)
		}
		e.preventDefault();
	});
	$('#social-links').find('a').tipTip({
		delay: 0
	});
	$('#portfolio-nav').find('ul').find('a').tipTip({
		delay: 0
	});
	
/*	$('#submit').live('click', function(){
		$('.error').hide();
		var hasError = false;
		
		var nameVal = $('#contact-name').val();
		if (nameVal == '') {
			$('#contact-name').after('<div class="error">Let me know who you are.</div>');
			hasError = true;
		}
		
		var emailReg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
		var emailVal = $('#contact-email').val();
		if (emailVal == ''){
			$('#contact-email').after('<div class="error">Let me know how to contact you.</div>');
			hasError = true;
		} else if(!emailReg.test(emailVal)) {
			$("#contact-email").after('<div class="error">Enter a valid email address.</div>');
			hasError = true;
		}
		
		var messageVal = $('#contact-message').val();
		if (messageVal = ''){
			$('#contact-message').after('<div class="error">What do you want to say?</div>');
			hasError = true;
		}
		return false;
	})*/
 });
