var slideItems = 0;
var slideCount = 0;
var slideIndex = 1;
var slideStep = 4;

$(document).ready(function(){
/*
    $(document).bind("contextmenu",function(e){
            return false;
    });

    $(document).attr('unselectable', 'on')
           .css('-moz-user-select', 'none')
           .each(function() {
               this.onselectstart = function() {return false;};
            });
    
    $(document).keydown(function(event){
        console.log(event);
        if (event.keyCode == '17') {
            event.preventDefault();
        }
    });
  */
    slideItems = $(".slide-image-wrap").children("li");
    slideCount = slideItems.length;

    $(".slide-image-wrap").children("li").mouseenter(function() {
        $(this).children("a").css("margin-top", "-160px");
    }).mouseleave(function() {
        $(this).children("a").css("margin-top", "-30px");
    });
});

function slideLeft(){
    if(slideIndex-1 > 0){
        slideIndex--;
        $("#slideItem"+slideIndex).show();

        return slideIndex;
    }
}

function slideRight(){
    if(slideIndex+slideStep <= slideCount){
        $("#slideItem"+slideIndex).hide();
        slideIndex++;

        return slideIndex;
    }
}

function showFirstTab(){
    $(".content-tab-wrap").hide();
    $(".content-tab-wrap:first").show();
}
function showTab(tab, el){
    $(".content-tab-wrap").hide();
    $("#tab"+tab).show();
    $(".content-menu > li > a").removeClass("content-menu-selected");
    $(el).addClass("content-menu-selected");
}


var sliderIndex = 0;
var sliderLength = 0;
function slideshow(){
    $(".slide-show").children("li").children("img").first().addClass('active');
    $(".slide-show").children("li").children("img").css({opacity: 0.0});
    $(".slide-show").children("li").children("img").first().css({opacity: 1.0});
    setTimeout('nextSlide();', 3100);
}
function nextSlide(){
    var el = $(".slide-show").find("img.active");
    var nextEl = $(".slide-show").find("img.active").next();
    if($(".slide-show").find("img.active").next().is("img")){
        nextEl.css({opacity: 0.0});
        nextEl.animate({opacity: 1.0}, 1000);
        el.animate({opacity: 0.0}, 1000);

        el.removeClass('active');
        nextEl.addClass('active');
        //$(".slide-show").find("li:visible").fadeOut(1000).next().fadeIn(500);
    }else{
        nextEl = $(".slide-show").children("li").children("img").first();
        nextEl.css({opacity: 0.0});
        nextEl.animate({opacity: 1.0}, 1000);
        el.animate({opacity: 0.0}, 1000);
         el.removeClass('active');
        nextEl.addClass('active');
    }
    setTimeout('nextSlide();', 3100);
}

function changeNews(item){
    var items = $(".news-tool > li");
    $(".news-tool > li").hide();
    $(items[item]).show();
}
