﻿$(function() {
    // Carousel for home page.
    $("#carousel").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev",
        auto: 10000,
        speed: 1200,
        vertical: false,
        visible: 1
    });
    // END Carousel for home page.
    
    // Accordion on Services
    $("#accordion p.service_head").click(function() {
        $(this).next("div.service_body").slideToggle(500).siblings("div.service_body").slideUp("slow");

        //$(this).css({ background: "#594E3B", color: "#D9BE90" }).next("div.service_body").slideToggle(500).siblings("div.service_body").slideUp("slow");
        //$(this).siblings().css({ background: "#B39D77", color: "#3f3728" });
    });
    $("#accordion p.service_head_inner").click(function() {
        $(this).next("div.service_body_inner").slideToggle(500).siblings("div.service_body_inner").slideUp("slow");
    });
    // End Accordion
    
    // NEWS
    $(".newsbox0").hide();
    $(".newsbox1").hide();
    $(".newsbox2").hide();
    $(".newsbox3").show();
    
    $('a.newsbox-toggle0').click(function() {
        $('.newsbox0').slideToggle(400);
        return false;
    });
    $('a.newsbox-toggle1').click(function() {
        $('.newsbox1').slideToggle(400);
        return false;
    });
    $('a.newsbox-toggle2').click(function() {
        $('.newsbox2').slideToggle(400);
        return false;
    });
    $('a.newsbox-toggle3').click(function() {
        $('.newsbox3').slideToggle(400);
        return false;
    });
    // END NEWS



    // WORK
    $('#tabContent>li:gt(0)').hide();
    $('#tabsNav li:first').addClass('active');
    $('#work-container #tabsNav li').bind('click', function() {
        $('li.active').removeClass('active');
        $(this).addClass('active');
        var target = $('a', this).attr('href');
        $(target).show().siblings().hide();
        return false;
    });

    $('.gallery a').lightBox({ 
        fixedNavigation: true 
    
    });
    // END WORK

    // CONTACT
    $("#name,#email,#phone,#company,#message,#stopspam").addClass("required");
    $("#email").addClass("required email");
    $("#contact").validate({
      submitHandler: function(form) {
        $.ajax({
          type: "POST",
          url: $("#contact").attr('action'),
          data: $("#contact").serialize(),
          dataType: "text/plain",
          success: function(response) {
            $("#contactform").hide('slow');
            response == "True" ? $("#thanks").show('slow') : $("#oops").show('slow');
          },
          error: function(response) {
            $("#contactform").hide('slow');
            $("#oops").show('slow');
          }
        });
      }
    });
    // END CONTACT
});
