function init()
{
  $("ul#nav li a").click( swap );
  $("a.contact").click( contact );
  
  $(".next").click( next );
  $(".prev").click( previous );
  
  $(".contact").click( contactForm );
  $(".cancel").click( closeForm );
  
  checkSubmit();
  
}

var page;

function swap( event )
{
  event.preventDefault();

  if ( $(this).attr("id") == page )
  {
    //do nothing
  }
  else{
    //add nav class
    $("ul#nav li a").removeClass("active");
    $(this).addClass("active");
  
    //get id of anchor clicked
    page = $(this).attr("id");

    //hide containers
    $(".content").fadeTo(0, 0).hide()
  
    if ( page == "about")
    {
      $("#content-1").show().fadeTo(800, 1);
    }
  
    if (page == "proPlan")
    {
      $("#content-2").show().fadeTo(800, 1);
    }
  
    if (page == "portfolio")
    {
      $("#content-3").show().fadeTo(800, 1);
    }
  }
}

function contact( event )
{
  page = contact;
  event.preventDefault();
}

currentEq = 0;

function next( event )
{
  currentEq++;
  if ( currentEq == $("#imgSet li").length )
  {
    currentEq = 0;
  }
  $("#imgSet li").fadeTo(0, 0).hide();
  $("#imgSet li:eq("+ currentEq +")").fadeTo(800, 1).show();
}

function previous()
{
  liLength = $("#imgSet li").length;
  liLength = liLength - 1;

  currentEq--;
  if ( currentEq < 0 )
  {
    currentEq = liLength;
  }

  $("#imgSet li").fadeTo(0, 0).hide();
  $("#imgSet li:eq("+ currentEq +")").fadeTo(800, 1).show();
}

function contactForm()
{
  $("#contactPos").fadeTo(400,1).show();
}

function closeForm()
{
  $("#contactPos").fadeTo(0,0).hide();
}

function checkSubmit()
{
  if ( $("#thanksMessage").length == 1 ){
    $("#thanksMessage").prependTo("#centerContain");
    $(".contact").hide();
    
    
    submitCheck = $('#thanksMessage').is(':visible');

    if( submitCheck == true ){

        $('#thanksMessage').fadeTo(3000, 0);
        $('#thanksMessage').hide(1000);
        $('#thanksMessage').click(function(){
            $(this).hide();
        });
    }
  }
}
$(document).ready(function(){
  init();
});

