var name = "#quicklinks";
var firstPos = null; // First Position of a #quicklinks div.
var offset = null; // Position of #quicklinks div after scroll

$(function(){

    // Mainpage Slider
    $("#slider-nav").tabs("#slider-items > .slider-item", {
        // enable "cross-fading" effect
        effect: 'fade',
        fadeOutSpeed: "slow",

        // start from the beginning after the last tab
        rotate: true
    // use the slideshow plugin. It accepts its own configuration
    }).slideshow({
        autoplay: true,
        interval: '7000',
        clickable: true
    });

    $('#right-menu li:not(".last")').hover(
      function () {
        $(this).css({'background':'#21221c'});
        $('a',this).css({'color':'#ecd3b1'});
      }, 
      function () {
        $(this).css({'background':'#efd6b3'});
        $('a',this).css({'color':'#000'});
    });

    // Hidden Content for Type 5
    $('.con-title').click(function(){
        $(this).next('.hidden-con').slideToggle(750);
    });

    // Newsletter Form
    $('#newsletter-form').submit(function(){
        $.ajax({
            url       : NEWSLETTER_URL,
            type      : 'POST',
            data      : $(this).serialize(),
            success   : function (response){
                if(response == 'ok'){
                    $('#newsletter-form').hide();
                    $('.nl-form-success').delay(1000).show();
                }else{
                    $.jGrowl(response, {position: 'top-right'});
                }
            },error: function (data, error){
                //console.log(error);
            }
        });
        return false;
    });

    $('#nl_name, #nl_email').focus(function(){
        $(this).css({backgroundPosition: "0px 0px"});
    });
    
    $('#nl_name, #nl_email').blur(function(){
        if($(this).val() == ""){
           $(this).css({backgroundPosition: "0 -18px"});
        }else {
           $(this).css({backgroundPosition: "0 -0px"});
        }
    });

    /*Pretty Photo*/
    $("a[rel^='prettyPhoto']").prettyPhoto({
        social_tools: false
    });

    /*Floating Div*/
    firstPos = ($(name).offset()).top;

    $(window).scroll(function () {

        if($(document).scrollTop() > firstPos){
            offset = ($(document).scrollTop() - firstPos)+"px";
        }else{
            offset = "0px";
        }

        $(name).animate({top:offset},{duration:500,queue:false});
    });
    
    $('#qlTopPage').click(function(){
       $( 'html, body' ).animate( { scrollTop: 0 }, 'slow' ); 
    });
    
});
























