/* 
 * This code is licensed by w3des.net
 * 
 */

//menu
var tmpDesc = '';
$(function() {
    tmpDesc = $('#bar .desc .t').html();
    $('#menu a').hover(function() {
        $('#bar .desc .t').html($(this).attr('title'));
    }, function() {
        $('#bar .desc .t').html(tmpDesc);
    });
});
var splashActive = 0;
var maxSplash = 0;
var splashTimeout = null;
//splash
$(function() {
    $('#splash .select a').each(function(i) {
        $(this).attr('num', i);
        $($('#splash .texts .txt').get(i)).attr('num', i);
        maxSplash = i;
    }).hover(function(){
        splashLink($(this).attr('num'))
    }).click(emptyLink);
    $('#splash').hover(function() {
        if(splashTimeout != null) {
            clearTimeout(splashTimeout);
        }
    }, function() {
        splashTimeout = setTimeout(splashTimeoutF, 5000);
    });
    splashTimeout = setTimeout(splashTimeoutF, 5000);
});

function emptyLink() {
    return false;
}

function splashLink(num) {
    if(num == splashActive) {
        return;
    }
    $($('#splash .texts .txt').get(splashActive)).fadeOut('fast');
    $($('#splash .select a').get(splashActive)).removeClass('active');
    splashActive = num;
    $($('#splash .texts .txt').get(splashActive)).fadeIn('fast');
    $($('#splash .select a').get(splashActive)).addClass('active');
    $('#splash .ico').animate({'backgroundPosition': '0px -' +(num*228)+'px'}, 'fast' );
}
function splashTimeoutF() {
    var num = splashActive+1;

    if(num>maxSplash)
        num = 0;
    splashLink(num);
    splashTimeout = setTimeout(splashTimeoutF, 5000);
}

/**
 * shadow
 */
$(function(){
    $('.shadow').each(function() {
        var txt = $(this).html();
        $(this).html('<span class="shtxt">' + txt + '</span><span class="shshadow">' + txt + '</span>');
    });
});

/**
 * Tech
 */
var maxTech = 0;
var techTimeout = null;
var techActive=0;
$(function() {
    $('#tech .btt a').each(function(i) {
        $(this).attr('num', i);
        $($('#tech .txt').get(i)).attr('num', i);
        maxTech = i;
    }).hover(function(){
        techLink($(this).attr('num'))
    }).click(emptyLink);
    $('#tech').hover(function() {
        if(techTimeout != null) {
            clearTimeout(techTimeout);
        }
    }, function() {
        techTimeout = setTimeout(techTimeoutF, 5000);
    });
    techTimeout = setTimeout(techTimeoutF, 5000);
});

function techLink(num) {
    if(num == techActive) {
        return;
    }
    $($('#tech .txt').get(techActive)).fadeOut('fast');
    $($('#tech .btt a').get(techActive)).removeClass('active');
    techActive = num;
    $($('#tech .txt').get(techActive)).fadeIn('fast');
    $($('#tech .btt a').get(techActive)).addClass('active');
}
function techTimeoutF() {
    var num = techActive+1;

    if(num>maxTech)
        num = 0;
    techLink(num);
    techTimeout = setTimeout(techTimeoutF, 5000);
}