$(document).ready(function () {
      $('#socialMedia').show();
        $('#edge').show();
        $('#iphoneDev').show();
        $('#lightbulb').show();


  $('.button').click(function() {
      var target = $(this).attr('rel');
      if (target.length) {
	$.scrollTo( '#' + target, 800);
      }
  });

  $('.intLink').click(function() {
      var target = $(this).attr('rel');
      if (target.length) {
	$.scrollTo( '#' + target, 800);
      }
  });

  $('#homeButton').click(function() {
	$.scrollTo( '#first', 800);
	
  });

  $('#aboutButton').click(function() {
	$.scrollTo( '#second', 800);
  });

  $('#solutionsButton').click(function() {
	$.scrollTo( '#fifth', 800);
  });

  $('#contactButton').click(function() {
	$.scrollTo( '#sixth', 800);
  });
	
	$(window).scroll(function() {
		var offset = window.pageYOffset;

	if (isScrolledIntoView(	$('#first'))) {
		clearAllNav();
		$('#homeButton').css({
			"background-color" : "#666666"
  		});
	}

	if (isScrolledIntoView(	$('#second'))) {
		clearAllNav();
		$('#aboutButton').css({
			"background-color" : "#666666"
  		});
	}


	if (isScrolledIntoView(	$('#fourth'))) {
		clearAllNav();
		$('#aboutButton').css({
			"background-color" : "#666666"
  		});
	}

	if (isScrolledIntoView(	$('#fifthSlide'))) {
		clearAllNav();
		$('#solutionsButton').css({
			"background-color" : "#666666"
  		});
	}

	if (isScrolledIntoView(	$('#sixth'))) {
		clearAllNav();
		$('#contactButton').css({
			"background-color" : "#666666"
  		});
	}

  	$('#first header').css({
  		"top" : (12+(offset/20))+"%"
  	});
  	
  	$('#firstImage').css({
  		"top" : 0 + (offset/1.5) + ""
  	});

  	$('#second section').css({
  		"top" : (-18.4+(offset/30))+"%"
  	});

	$('#skull').css({
  		"top" : -500 + (offset/1.5) + ""
  	});

	$('#coffee').css({
  		"top" : -1000 + (offset/1.5) + ""
  	});


	$('#notebook').css({
  		"top" : -1700 + (offset/1.5) + ""
  	});

  	
  	$('#third section').css({
  		"top" : (-75+(offset/25))+"%"
  	});

  	$('#fourth section').css({
  		"top" : (-75+(offset/35))+"%"
  	});

   	$('#fifth section').css({
   		"top" : (-85+(offset/45))+"%"
   	});

   	$('#thirdImage').css({
   		"top" : -2690 + (offset/1.5)+ ""
   	});

   	$('#sixth footer').css({
   		"top" : (-95+(offset/55))+"%"
   	});

	});

    $("#socialMedia").hide();
    $("#emailMarketing").hide();
    $("#analytics").hide();
    $("#strategy").hide();
    $("#edge").hide();
    $("#additional").hide();
    $("#androidDev").hide();

(function($) {
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
})(jQuery);


   $('.webDev').click(function () {
        $('#socialMedia').hide();
        $('#androidDev').hide();
        $('#emailMarketing').hide();
        $('#analytics').hide();
        $('#strategy').hide();
        $('#edge').hide();
        $('#additional').customFadeOut('fast', function () {
            $('#webDev').customFadeIn('slow');
        });
        $('#lightbulb').show();

    });

    $('.iphoneDev').click(function () {
        $('#socialMedia').hide();
        $('#androidDev').hide();
        $('#emailMarketing').hide();
        $('#analytics').hide();
        $('#strategy').hide();
        $('#webDev').hide();
        $('#edge').hide();
        $('#androidDev').hide();
        $('#additional').customFadeOut('fast', function () {
            $('#iphoneDev').customFadeIn('slow');
        });
        $('#lightbulb').show();

    });

    $('.androidDev').click(function () {
        $('#socialMedia').hide();
        $('#androidDev').hide();
        $('#emailMarketing').hide();
        $('#analytics').hide();
        $('#strategy').hide();
        $('#webDev').hide();
        $('#edge').hide();
        $('#iphoneDev').hide();
        $('#additional').customFadeOut('fast', function () {
            $('#androidDev').customFadeIn('slow');
        });
        $('#lightbulb').show();

    });

    $('.socialMedia').click(function () {
        $('#webDev').customFadeOut('fast', function () {
            $('#androidDev').hide();
            $('#socialMedia').customFadeIn('slow');
        });
        $('#emailMarketing').hide();
        $('#analytics').hide();
        $('#strategy').hide();
        $('#edge').hide();
        $('#additional').hide();
        $('#iphoneDev').hide();
        $('#lightbulb').show();
    });

    $('.emailMarketing').click(function () {
        $('#webDev').customFadeOut('fast', function () {
            $('#emailMarketing').customFadeIn('slow');
        });
        $('#socialMedia').hide();
        $('#analytics').hide();
        $('#strategy').hide();
        $('#androidDev').hide();
        $('#edge').hide();
        $('#additional').hide();
        $('#iphoneDev').hide();
        $('#lightbulb').show();
    });

    $('.analytics').click(function () {
        $('#webDev').customFadeOut('fast', function () {
            $('#analytics').customFadeIn('slow');
        });
        $('#socialMedia').hide();
        $('#emailMarketing').hide();
        $('#strategy').hide();
        $('#androidDev').hide();
        $('#edge').hide();
        $('#additional').hide();
        $('#iphoneDev').hide();
        $('#lightbulb').show();
    });

    $('.strategy').click(function () {
        $('#webDev').customFadeOut('fast', function () {
            $('#strategy').customFadeIn('slow');
        });
        $('#socialMedia').hide();
        $('#emailMarketing').hide();
        $('#analytics').hide();
        $('#androidDev').hide();
        $('#edge').hide();
        $('#additional').hide();
        $('#iphoneDev').hide();
        $('#lightbulb').show();
    });

    $('.edge').click(function () {
        $('#webDev').customFadeOut('fast', function () {
            $('#edge').customFadeIn('slow');
        });
        $('#socialMedia').hide();
        $('#emailMarketing').hide();
        $('#androidDev').hide();
        $('#analytics').hide();
        $('#strategy').hide();
        $('#additional').hide();
        $('#iphoneDev').hide();
        $('#lightbulb').show();
    });

    $('.additional').click(function () {
        $('#webDev').customFadeOut('fast', function () {
            $('#additional').customFadeIn('slow');
        });
        $('#socialMedia').hide();
        $('#emailMarketing').hide();
        $('#androidDev').hide();
        $('#analytics').hide();
        $('#strategy').hide();
        $('#edge').hide();
        $('#iphoneDev').hide();
        $('#lightbulb').hide();

    });

   $('#jillMore').hide();

 $('#jillReadMore').click(function () {
        $('#jillMore').customFadeIn('slow');
	 $('#jillReadMore').hide();	
    });

   $('#charlieMore').hide();

 $('#charlieReadMore').click(function () {
    	$('#charlieMore').customFadeIn('slow');
	$('#charlieReadMore').hide();
	
    });
});

function clearAllNav() {
	$("nav a").css({
		"background-color" : "transparent"
    	});
}

function isScrolledIntoView(elem)
{
    var docViewTop = $(window).scrollTop();
    var docViewBottom = docViewTop + $(window).height();

	if ($(elem).offset() != null) {
    		var elemTop = $(elem).offset().top;
    		var elemBottom = elemTop + $(elem).height();
		return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom));
	}
	return false;
}


