﻿function showDate(){    
    var d = new Date();
    var day = '';
    switch(d.getDay()){
        case 0: day = 'Ch&#7911; nh&#7853;t'; break;
        case 1: day = 'Th&#7913; 2'; break;
        case 2: day = 'Th&#7913; 3'; break;
        case 3: day = 'Th&#7913; 4'; break;
        case 4: day = 'Th&#7913; 5'; break;
        case 5: day = 'Th&#7913; 6'; break;
        case 6: day = 'Th&#7913; 7'; break;
    }
    document.write(day + ', ng&#224;y ' + d.getDate() + '/' + (d.getMonth() + 1) + '/' + d.getFullYear());
}

function showDate2(){    
    var d = new Date();
    var day = '';
    switch(d.getDay()){
        case 0: day = 'Ch&#7911; nh&#7853;t'; break;
        case 1: day = 'Th&#7913; 2'; break;
        case 2: day = 'Th&#7913; 3'; break;
        case 3: day = 'Th&#7913; 4'; break;
        case 4: day = 'Th&#7913; 5'; break;
        case 5: day = 'Th&#7913; 6'; break;
        case 6: day = 'Th&#7913; 7'; break;
    }
    document.write(day + ', ng&#224;y ' + d.getDate() + '/' + (d.getMonth() + 1) + '/' + d.getFullYear() + ' | ' + d.toLocaleTimeString());
}

function showDate3(){    
    var d = new Date();
    var day = '';
    switch(d.getDay()){
        case 0: day = 'Ch&#7911; nh&#7853;t'; break;
        case 1: day = 'Th&#7913; 2'; break;
        case 2: day = 'Th&#7913; 3'; break;
        case 3: day = 'Th&#7913; 4'; break;
        case 4: day = 'Th&#7913; 5'; break;
        case 5: day = 'Th&#7913; 6'; break;
        case 6: day = 'Th&#7913; 7'; break;
    }
	document.write(day + ', ng&#224;y ' + d.getDate() + '/' + (d.getMonth() + 1) + '/' + d.getFullYear() + ' | <span>' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds() + '</span>');    
}

var timg;
function slideShow(){
    var i = 0;
    $('.hotnews').each(function(){
        $(this).css('position', 'absolute');
        $(this).css('z-index', i);
        $(this).attr('id', 'topimg' + i);
        if (i > 0) $(this).hide();
        i++;
    });
    if (i > 1){
        $('#divOpacity').show();
        $('#divOImgLink').show();
        var links = '';
        for(var tmp=0; tmp<i; tmp++)
            links += '<a class="' + (tmp==0?'linktop_act':'linktop') + '" id="linktop' + tmp + '" onclick="gotoNewsTop(' + tmp + ',' + i + ')"' + '>' + (tmp+1) + '</a>';
        $('#pimglink').html(links);
        silideImg(0, i);
    }
}  
function silideImg(ind, len){
    if (ind==len) ind = 0;
    if(typeof(timg) != 'undefined' && timg != null){
        var prev = (ind == 0 ? len-1: ind - 1);
        $('#topimg' + prev).stop().fadeOut(3000);
        $('#topimg' + ind).stop().fadeIn(3000);          
        $('.linktop_act').removeClass('linktop_act').addClass('linktop');
        $('#linktop' + ind).addClass('linktop_act');     
    }
    ind++;
    ind = (ind == len+1 ? 0: ind);   
    timg = setTimeout('silideImg(' + ind + ',' + len + ')', 10000);
}
function gotoNewsTop(ind, len){
    clearTimeout(timg);
    $('.hotnews').hide();
    $('#topimg' + ind).stop().show();
    $('.linktop_act').removeClass('linktop_act').addClass('linktop');
    $('#linktop' + ind).addClass('linktop_act');
    ind++;
    ind = (ind == len+1 ? 0: ind);   
    timg = setTimeout('silideImg(' + ind + ',' + len + ')', 10000);
}

function gotoNewsByDate(strDate){
    var localstr = window.location;
    if (window.location.search != ''){    
        if(!window.location.search.match('&d='))
            localstr = localstr + '&d=' + strDate;
        else{
            var si = window.location.search.indexOf('&d='); 
            localstr = window.location.search.substring(0, si) + '&d=' + strDate
        }            
    }
    window.location = localstr;
}

function openPage(lnk, obj){
    if (lnk != ''){
        if (lnk.match('http://')) window.open(lnk, '', '', '_self');    
        else window.open('http://' + lnk, '', '', '_self');
    }
}

function setTabContentIndex(){
    var i = 0;
    $('.tabcontent').each(function(){
        $(this).attr('id', 'tabcontent' + i);
        i++;
    });
}

function showTabContent()
{
    i = 0;
    $('.tabcontent').hide();
    $('.tabcontent').eq(0).show();
    $('#tabheader').find('div').each(function(){
        $(this).attr('index', i);
        if (i == 0){
            $(this).removeClass('tab_header_nor').addClass('tab_header_act');
        }
        $(this).click(function(){
            $('div.tab_header_act').removeClass('tab_header_act').addClass('tab_header_nor');
            $(this).removeClass('tab_header_nor').addClass('tab_header_act');
            $('.tabcontent').hide();
            $('#tabcontent' + $(this).attr('index')).show();
        });
        i++;
    });
}
