// JavaScript Document
function indexNews(lang, page) {
    if (!lang || !page)
        return;
        
    $('#newsInner').animate({opacity: 0}, 150, 'linear', function(){
        $('#newsInner').empty();
        $("#newsInner").load('/?lang='+lang+'&__exec_mod=Index&m=news&page='+page, function() {
                $('#newsInner').animate({opacity: 1}, 150, 'linear');
            });

        });
}

//var current_tab = 1;
//var max_tab = 4;
//var wait_time = 10000;
//var animation_time = 150;
//var timer = 0;
//function showTab(id, force) {
    //if (!id)
        //return;

    //if (force) {
        //clearTimeout(timer);
    //}

    //current_tab = id;

    //$('#opacity_div').animate({opacity: 0.5}, animation_time, 'linear', function(){
        //$('.visible-tab').css('display','none').removeClass('visible-tab');
        //$('#page'+id).css('display', 'block').addClass('visible-tab');
        //$('#opacity_div').animate({opacity: 0}, animation_time, 'linear', function (){
            //if(current_tab == 4)
                //current_tab = 0;

            //timer = setTimeout('showTab(' + (current_tab+1) + ')', wait_time);
        //});
    //});
//}
var prevaTag="";
var current_tab = 1;

function showTab(id, aTag) {
    if (!id&&id==current_tab)
        return;
        
    $('#links').children().removeClass('activeLinks');
    $('#atag'+id).addClass('activeLinks');
    $('.visible_tab').animate({opacity: 0.5}, 150, 'linear', function(){
        $('.visible_tab').removeClass('visible_tab').addClass('hide');
        $('#news'+id).css('opacity', '0.4').addClass('visible_tab').removeClass('hide');
        $('#news'+id).animate({opacity: 1}, 150, 'linear');
    });
    //$('#topic_desc'+id).html($('#tit'+id).text());
    //$('#news'+id+' > .arrows > #topic_desc').html($('#tit'+id).text());
    current_tab=id;
}

function slideNews(direction)
{   var tempInd=current_tab;
    tempInd+=direction;
    if(tempInd>4){tempInd=1;}
    if(tempInd<1){tempInd=4;}
    showTab(tempInd);
}

$().ready(function(){
$('#atag1').addClass('activeLinks');
$(".hovera").mouseenter(function(event){
   var cel = $('div', this);
   cel.addClass('to_sub_menu_delay');
   setTimeout(function(){cel.removeClass('to_sub_menu_delay')},200);
  }
 )
    //timer = setTimeout('showTab(2)', wait_time);
/*
    $('.specy_div').click(function(){
        var el = $(this);
        if (!el.attr('img') || !el.attr('flv'))
            return;

        dl.swf("flash/multimedia", null, {type: 'video', flv: el.attr('flv'), img: el.attr('img')}, 10).write("flash_player");

        $('#flash_player').addClass('display');
        el.addClass('open_specy');
        el.click(function() {
            $('#flash_player').empty();
            $(this).removeClass('open_specy');
            $('#flash_player').removeClass('display');
        });
    },
    function(){
        $('#flash_player').removeClass('display');
    });
*/

    // bind print event
    $('.print').bind('click', function(){ window.print(); });
});

var initFontSize = 12;
var fontSizeTagNames = new Array('p','span','pre','ul','li','a');

function fontSize(direction,objectId) {
    fontSizeObj = document.getElementById(objectId);
        
    for (tagName in fontSizeTagNames) {
        tagsInObj = fontSizeObj.getElementsByTagName(fontSizeTagNames[tagName]);
        for (tagObj in tagsInObj) {
            if (tagsInObj[tagObj].tagName == fontSizeTagNames[tagName].toUpperCase()) {
                if (direction == 'up') {
                    tagsInObj[tagObj].style.font = 'normal '+(initFontSize+1)+'px Verdana, Arial, Helvetica, sans-serif';
                    tagsInObj[tagObj].style.fontSize = (initFontSize+1)+'px';
                } else {
                    tagsInObj[tagObj].style.font = 'normal '+(initFontSize-1)+'px Verdana, Arial, Helvetica, sans-serif';
                    tagsInObj[tagObj].style.fontSize = (initFontSize-1)+'px';
                }

            }

        }
        
    }

    if (direction == 'up') {
        fontSizeObj.style.fontSize = (initFontSize+1)+'px';
        fontSizeObj.style.font = 'normal '+(initFontSize+1)+'px Verdana, Arial, Helvetica, sans-serif !important';
        initFontSize++;
    } else {
        fontSizeObj.style.fontSize = (initFontSize-1)+'px';
        fontSizeObj.style.font = 'normal '+(initFontSize-1)+'px Verdana, Arial, Helvetica, sans-serif !important';
        initFontSize--;
    }

}

function buildPath (obj) {
    if (!obj)
        return;

    var path = new Array();
    var parents = $(obj.get(0)).parents('li');
    
    for(i=0;parents.length > i;i++){
        var el = $(parents.get(i)).find('a:first');
        if (parents.length == (1+i)) {
            el.addClass('here');
            path.push('<a class="nachalo" href="'+el.attr('href')+'">'+el.text()+'</a>');
        } else if(i == 0) {
            path.push(el.text());
        } else {
            path.push('<a href="'+el.attr('href')+'">'+el.text()+'</a>');
        }
    }

    $('#breadcrumb').html(path.reverse().join(' » '));
}

function getInfoNode(letter, lang) {
    if (!letter)
        return;
    var temp=letter.charCodeAt(0);
    var temp2=String.fromCharCode(temp);
    
    if (letter.length == 1) {
        $('#letters').empty();
        $("#letters").load('/?__exec_mod=fdb&m=list_node_bg&letter='+temp+'&lang='+lang);
    }
}

function getInfoNodeFg(letter, lang) {
    if (!letter)
        return;
    
    var temp=letter.charCodeAt(0);
    var temp2=String.fromCharCode(temp);

    
    if (letter.length == 1) {
        $('#letters').empty();
        $("#letters").load('/?__exec_mod=fdb&m=list_node_fg&letter='+temp+'&lang='+lang);
    }
}

function getInfoNodeCR(letter, lang) {
    if (!letter)
        return;
    var temp=letter.charCodeAt(0);
    var temp2=String.fromCharCode(temp);
    
    if (letter.length == 1) {
        $('#letters').empty();
        $("#letters").load('/?__exec_mod=fdb&m=list_node_cr&letter='+temp+'&lang='+lang);
    }
}
