var t;
var featured_delay = 8000;

function sliderStart() {
    if($('#featured_button_4').hasClass("featured_button_active")){
        a = $('#featured_button_1');
    }else{
        a = $('.featured_button_active').next();
    }
    a.trigger("click");
    $('.featured_button_active').removeClass("featured_button_active");
    a.addClass("featured_button_active");
    t = setTimeout("sliderStart()",featured_delay);
}


function hideSubMenu(){
    $('#header_submenu div').css("display","none");
}





$(document).ready(function(){
	  
    $('#featured_button_1').click(function(){
        clearTimeout(t);
        $('#featured_post_content_1').animate({
            left: '0px'
        }, 'slow');
        $('#featured_post_content_2').animate({
            left: '0px'
        }, 'slow');
    });

    $('#featured_button_2').click(function(){
        clearTimeout(t);
        $('#featured_post_content_1').animate({
            left: '-290px'
        }, 'slow');
        $('#featured_post_content_2').animate({
            left: '-290px'
        }, 'slow');
    });
    $('#featured_button_3').click(function(){
        clearTimeout(t);
        $('#featured_post_content_1').animate({
            left: '-580px'
        }, 'slow');
        $('#featured_post_content_2').animate({
            left: '-580px'
        }, 'slow');
	  
    });
    $('#featured_button_4').click(function(){
        clearTimeout(t);
        $('#featured_post_content_1').animate({
            left: '-870px'
        }, 'slow');
        $('#featured_post_content_2').animate({
            left: '-870px'
        }, 'slow');
	  
    });
    //$('#featured_button_1,#featured_button_2,#featured_button_3,#featured_button_4').click(function(){
    //	$('#featured_button_1,#featured_button_2,#featured_button_3,#featured_button_4').css({backgroundColor : '#999999'});
    //	$(this).css({backgroundColor : '#EC6605'});
    //});
    $('#featured_button_1,#featured_button_2,#featured_button_3,#featured_button_4').click(function(){
        $('#featured_button_1,#featured_button_2,#featured_button_3,#featured_button_4').addClass("featured_button_inactive");
        $('#featured_button_1,#featured_button_2,#featured_button_3,#featured_button_4').removeClass("featured_button_active");
        $(this).removeClass("featured_button_inactive");
        $(this).addClass("featured_button_active");
    });

    $('#submit').click(function(){
        $(this).css("border", "2px inset #29447e");
    });

    setTimeout("sliderStart()",featured_delay);


    $('#header_menu_list li').hover(function(){
        $('#header_menu_list li').removeClass("active_list");
        $('#header_menu_list li').removeClass("inactive_list");
        $('#header_menu_list li a').removeClass("inactive_link");
        $('#header_menu_list li a').removeClass("active_link");
        $('#header_menu_list li a').addClass("inactive_link");
        $(this).children('a').removeClass("inactive_link");
        $(this).addClass("active_list");
        $(this).children('a').addClass("active_link");
    }, function(){

        });


    $('#head_menu_li_1').mouseover(function(){
        hideSubMenu();
        $('#submenu_div_1').css("display","block");
    });


    $('#head_menu_li_2').mouseover(function(){
        hideSubMenu();
        $('#submenu_div_2').css("display","block");
    });

    $('#head_menu_li_3').mouseover(function(){
        hideSubMenu();
        $('#submenu_div_3').css("display","block");
    });


    $('#head_menu_li_4').mouseover(function(){
        hideSubMenu();
        $('#submenu_div_4').css("display","block");
    });

    $('#head_menu_li_5').mouseover(function(){
        hideSubMenu();
        $('#submenu_div_5').css("display","block");
    });


    $('#head_menu_li_6').mouseover(function(){
        hideSubMenu();
        $('#submenu_div_6').css("display","block");
    });


    $('#home_featured_post').mouseover(function(){
        clearTimeout(t);
    });

    $('#home_featured_post').mouseout(function(){
        t = setTimeout("sliderStart()",featured_delay);
    });
    
    $('.kontakt_submit_div').children('input').attr("value", "");
    
    // testing stuff url("images/button-mh-nokia.jpg") no-repeat scroll 0 0 transparent

    $(".clickplace").click(function(){
            window.location = $(this).find(".more-link").attr("href");
      });

});


