jQuery(function($){
  $.supersized({
    //Functionality
    slideshow : 1,            //Slideshow on/off
    autoplay : 1,             //Slideshow starts playing automatically
    start_slide : 0,          //Start slide (0 is random)
    slide_interval : 8000,    //Length between transitions
    transition : 3,           //0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
    transition_speed : 1000,   //Speed of transition
    new_window : 0,           //Image links open in new window/tab
    pause_hover : 0,          //Pause slideshow on hover
    keyboard_nav : 0,         //Keyboard navigation on/off
    performance : 1,          //0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed
    
    // (Only works for Firefox/IE, not Webkit)
    image_protect : 1,        //Disables image dragging and right click with Javascript
    image_path : 'img/',      //Default image path

    //Size & Position
    min_width : 500,          //Min width allowed (in pixels)
    min_height : 500,         //Min height allowed (in pixels)
    vertical_center : 1,      //Vertically center background
    horizontal_center : 1,    //Horizontally center background
    fit_portrait : 0,         //Portrait images will not exceed browser height
    fit_landscape : 0,        //Landscape images will not exceed browser width

    //Components
    navigation : 1,           //Slideshow controls on/off
    thumbnail_navigation : 0, //Thumbnail navigation
    slide_counter : 0,        //Display slide numbers
    slide_captions : 0,       //Slide caption (Pull from "title" in slides array)
    slides : [                //Slideshow Images
      {image : 'img/work1.jpg', title : '', url : ''},
      {image : 'img/work2.jpg', title : '', url : ''},
      {image : 'img/work5.jpg', title : '', url : ''},
      {image : 'img/work3.jpg', title : '', url : ''},
      {image : 'img/work4.jpg', title : '', url : ''},
      {image : 'img/work6.jpg', title : '', url : ''},
      {image : 'img/work7.jpg', title : '', url : ''},
      {image : 'img/work8.jpg', title : '', url : ''},
      {image : 'img/work9.jpg', title : '', url : ''}
    ]
  });
});
jQuery(document).ready(function($){
  
  if(window.location.hash == "#about") {
    $("#aboutPage").stop().css({"right":"0%"});
    setTimeout(function(){
      $("#aboutLink").addClass("active");
    },10);
  }
  if(window.location.hash == "#contact") {
    $("#contactPage").stop().css({"right":"0%"});
    setTimeout(function(){
      $("#contactLink").addClass("active");
    },10);
  }

  setTimeout(function(){
    $("#mask").animate({"opacity":0},1000,function(){
      $("#mask").hide();
      $("#footer").animate({"bottom":0},800,'easeOutExpo',function(){
        $("h1").animate({"top":-110},1000,'easeOutExpo',function(){
          $("#progressBar").animate({"opacity":1},1000);
        });
      });
    });
  },1500);


  $("#aboutLink").click(function(){
    if($("#contactLink").hasClass("active")) {
      document.location.hash="#";
      $("#contactPage").stop().animate({"right":"100%"},1000,"easeInOutExpo",function(){
        $(this).css("right","-100%");
        if($(this).hasClass("active")) {

        } else {
          $("#aboutPage").stop().animate({"right":"0%"},1000,"easeInOutExpo");
          setTimeout(function(){
            $("#aboutLink").addClass("active");
          },10);
        }
      });
      $("#contactLink").removeClass("active");
    } else {
      if($(this).hasClass("active")) {

      } else {
        $("#aboutPage").stop().animate({"right":"0%"},1000,"easeInOutExpo");
        setTimeout(function(){
          $("#aboutLink").addClass("active");
        },10);
      }
    }
  });

  $("#contactLink").click(function(){
    if($("#aboutLink").hasClass("active")) {
      document.location.hash="#";
      $("#aboutPage").stop().animate({"right":"100%"},1000,"easeInOutExpo",function(){
        $(this).css("right","-100%");
        if($(this).hasClass("active")) {

        } else {
          $("#contactPage").stop().animate({"right":"0%"},1000,"easeInOutExpo");
          setTimeout(function(){
            $("#contactLink").addClass("active");
          },10);
        }
      });
      $("#aboutLink").removeClass("active");
    } else {
      if($(this).hasClass("active")) {

      } else {
        $("#contactPage").stop().animate({"right":"0%"},1000,"easeInOutExpo");
        setTimeout(function(){
          $("#contactLink").addClass("active");
        },10);
      }
    }
  });

  $(".closeBtn").click(function(){
    if($("#aboutLink").hasClass("active")) {
      document.location.hash="#";
      $("#aboutPage").stop().animate({"right":"100%"},1000,"easeInOutExpo",function(){
        $(this).css("right","-100%");
      });
      $("#aboutLink").removeClass("active");
    }
    
    if($("#contactLink").hasClass("active")) {
      document.location.hash="#";
      $("#contactPage").stop().animate({"right":"100%"},1000,"easeInOutExpo",function(){
        $(this).css("right","-100%");
      });
      $("#contactLink").removeClass("active");
    }
  });

  $("#submitBtn").click(function() {
    $('.error').each(function(){
      $(this).removeClass("error");
    });
		
	  var name = $("input#name").val();
		if (name == "") {
      $("input#name").addClass("error").focus();
      return false;
    }
		var email = $("input#email").val();
		if (email == "") {
      $("input#email").addClass("error").focus();
      return false;
    }
		var subject = $("input#subject").val();
		if(subject == "") { subject = "No Subject"; }
    subject = "Contact Message: " + subject;
		var message = $("textarea").val();
		if (message == "") {
      $("textarea").addClass("error").focus();
      return false;
    }
		
		var dataString = 'name='+ name + '&email=' + email + '&subject=' + subject + '&message=' + message;
    // alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "http://www.jfdsf.com/process.php",
      data: dataString,
      success: function() {
        $("#alert").animate({"opacity":1},1000);
      }
     });
    return false;
	});

});
