$(document).ready(function() {

	$('#upArrow').css('visibility','hidden');
	$('#downArrow').click(function() {
		$('#upArrow').css('visibility','visible');
		var thumbSectionHeight = $('#thumb_menu').height();
		var thumbMenuHeight = thumbSectionHeight-448;
		var thumbMenuPos = $('#thumb_menu').css('top');
		var newValue = thumbMenuPos.replace('px', '');
		
		if (!$("#thumb_menu").is(':animated')){
			if(-thumbMenuHeight != newValue){
				$('#thumb_menu').animate({
					top: '-='+448
				}, 500, function() {
					var newthumbMenuPos = $('#thumb_menu').css('top');
					var newPos = newthumbMenuPos.replace('px', '');
					if(newPos <= -thumbMenuHeight){
						$('#downArrow').css('visibility','hidden');
					}
				});
			}
		}
	});
	
	$('#upArrow').click(function() {
		$('#downArrow').css('visibility','visible');
		var thumbMenuPos = $('#thumb_menu').css('top');
		var newValue = thumbMenuPos.replace('px', '');
		
		if (!$("#thumb_menu").is(':animated')){
			if(newValue < 0){
				$('#thumb_menu').animate({
					top: '+='+448
				}, 500, function() {
					var newthumbMenuPos = $('#thumb_menu').css('top');
					var newPos = newthumbMenuPos.replace('px', '');
					if(newPos >= 0){
						$('#upArrow').css('visibility','hidden');
					}
				});
			}
		}
	});
	
	$('.video_btn').click(function() {
		$('#vid_container').empty();
		$("#vid_container").html("<iframe width='560' height='345' src='http://www.youtube.com/embed/"+this.id+"' id='video' frameborder='0' allowfullscreen></iframe>");
		$title = $(this).parent().parent().children("li:first").html();
		$description = $(this).parent().parent().children("li.hide").html();
		$("#vid_title").html($title);
		$("#vid_description").html($description);
	});
	
	$(".image_btn").click(function(){
		$title = $(this).parent().parent().children("li:first").html();
		$description = $(this).parent().parent().children("li.hide").html();
		$(".img_title").html($title);
		$(".img_description").html($description);
	});
	
	$(".thumb_top").click(function(){
		$(".gallery_section").hide();
		$("#web"+this.id).show();
		$(".large_image").hide();
		var newValue = this.id.replace('site', '');
		$("#largeimage"+newValue+"1").show();
	});
	$(".gallery_section").hide();
	$("#website1").show();
	
	$(".thumb").click(function(){
		$(".large_image").hide();
		$("#large"+this.id).show();
	});
	$(".large_image").hide();
	$("#largeimage11").show();
	
	$(".design_btn").click(function(){
		$(".design").hide();
		$("#design"+this.id).show();
	});
	$(".design").hide();
	$("#designSkyline").show();
	
	$textLabel = '';
	
	$(".text_input").focus(function () {
		$textLabel = $(this).val();
		if($textLabel == 'Name...' || $textLabel == 'Email...' || $textLabel == 'Number...' || $textLabel == 'Company...' || $textLabel == 'Message...'){
			$(this).val('');
		 }
    });
	
	$(".text_input").focusout(function () {
		if($(this).val() == ''){
			$(this).val($textLabel);
		}
    });
	
	
	
	
	$("#contact_form").submit(function(event){
		return validate();
	});
	
	
	
	function validate() {
		var name = $("#name").val();
		var email = $("#email").val();
		var message = $("#message").val();
		var error = "";
		var submitForm = true;
		
		if (name=="" || name=="Name...") {
			error += "Please enter your name <br />";
			$("#name").css('background','#fdff5a');
			submitForm = false;
		}
		else {
			$("#name").css('background','#fff');
		}
		
		if ((email=="") || (email.indexOf("@") == -1) || (email.indexOf(".") == -1) || email=="Email...") {
			error += "Please enter a valid email address <br />";
			$("#email").css('background','#fdff5a');
			submitForm = false;
		}
		else {
			$("#email").css('background','#fff');
		}
		
		if (message=="" || message=="Message...") {
			error += "Please enter your name <br />";
			$("#message").css('background','#fdff5a');
			submitForm = false;
		}
		else {
			$("#message").css('background','#fff');
		}
		
		if (submitForm) {
			return true;
		}
		else {
			//error_message.html(error);
			return false
		}
	}

});
