var clicked=0;
   
function ChangeCountryBg(pref, status)
{
    document.getElementById('menu_'+pref).className="country_menu country_menu_"+status+"";
}
function ChangeMenuBg(pref, status)
{
    document.getElementById('mmenu_'+pref).className='menu f9 w90 menu_'+status;
}

function na_preload_img()
{
    var img_list = na_preload_img.arguments;
    if (document.preloadlist == null)
    document.preloadlist = new Array();
    var top = document.preloadlist.length;
    for (var i=0; i < img_list.length-1; i++) {
        document.preloadlist[top+i] = new Image;
        document.preloadlist[top+i].src = img_list[i+1];
    }
}

function na_change_img_src(name, nsdoc, rpath, preload)
{
    var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
    if (name == '')
    return;
    if (img) {
        img.altsrc = img.src;
        img.src    = rpath;
        //alert (document.getElementById('lnk_'+name));
        if (document.getElementById('lnk_'+name))
        {
            document.getElementById('lnk_'+name).className="red";
        }
    }
}

function na_restore_img_src(name, nsdoc)
{
    var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
    if (name == '')
    return;
    if (img && img.altsrc) {
        img.src    = img.altsrc;
        img.altsrc = null;
        if (document.getElementById('lnk_'+name))
        {
            document.getElementById('lnk_'+name).className="blue";
        }
    }
}

function MakePlayList(id)
{
    var pval=document.getElementById('usr_palylist_params').value;
    if (id!='')
    {
        if (pval.indexOf(':'+id+':')!=-1)
        {
            document.getElementById('usr_palylist_params').value=pval.replace(id+'::','');
            document.getElementById('opt_uncheck'+id).style.display='block';
            document.getElementById('opt_check'+id).style.display='none';
            ch_val=document.getElementById('usr_palylist_params').value;
            if (ch_val.replace('::','')=='')
            {
                document.getElementById('user_playlist_form').action='/help/';
            }

        }
        else {
            document.getElementById('usr_palylist_params').value=pval+id+'::';
            document.getElementById('opt_check'+id).style.display='block';
            document.getElementById('opt_uncheck'+id).style.display='none';
            document.getElementById('user_playlist_form').action='/user_playlist/';
        }

    }

}

function ShowFullPic(num, lang)
{
    var copyObj = document.getElementById('copy');
    
    if ( copyObj ) copyObj.style.paddingBottom = '2px';
    document.getElementById('media_layout').style.height = '240px';
    
    if (FrmeType!='img')
    {
        document.getElementById('MainSrc').innerHTML=FrmeHtml;
        HideButt(lang);
        document.getElementById('pic_nav').style.display='block';
    }
    pic=(num+((frm-1)*6));
    if (num>5)
    {
        if (pic+1<=imgs.length)
        {
            is_left=0;
        }
        else {
            is_left=5;
        }

        PRight(is_left);
        return;
    }
    if (num<0)
    {
        if (pic-1>0)
        {
            is_left=5;
        }
        else {
            is_left=0;
        }
        PLeft(is_left);
        return;
    }

    if (imgs[pic]){
        document.getElementById('fullpic').src='/'+Pics_news_folder+'/300_'+imgs[pic][1]+imgs[pic][0]+'.jpg';
        document.getElementById('fullpic').alt=imgs[pic][2];
        document.getElementById('fpleft').innerHTML=pic+1;

        if (num>=0)
        {
            hrf="javascript:ShowFullPic("+(num-1)+")";
        }
        else
        {
            hrf="javascript:void(0);";
        }
        document.getElementById('wleft').href=hrf;


        if (num<imgs.length)
        {
            hrf="javascript:ShowFullPic("+(num+1)+")";
        }
        else
        {
            hrf="javascript:void(0);";
        }
        document.getElementById('wright').href=hrf;
    }
}
function ShowPic (lft)
{
    el=0;
    to=frm*6;
    fm=to-6;

    for(i=fm; i<to; i++)
    {
        if (imgs[i])
        {
            document.getElementById('p_pic['+el+']').src='/'+Pics_news_folder+'/140_'+imgs[i][1]+imgs[i][0]+'.jpg';
            document.getElementById('p_pic['+el+']').alt=imgs[i][2];
            document.getElementById('linkp_pic['+el+']').title=imgs[i][2];
            document.getElementById('linkp_pic['+el+']').className='noline hand';
        }
        else
        {
            document.getElementById('p_pic['+el+']').src='/img/empty_'+el+'.jpg';
            document.getElementById('p_pic['+el+']').alt='';
            document.getElementById('linkp_pic['+el+']').title='';
            document.getElementById('linkp_pic['+el+']').className='noline nohand';
        }
        el++;
        document.getElementById('pright').innerHTML=to_max;
        document.getElementById('fpright').innerHTML=imgs.length;
        document.getElementById('pleft').innerHTML=(frm);
    }

    if (lft>0)
    {
        ShowFullPic(lft);
    }
    else
    {
        ShowFullPic(0);
    }
}

function PRight(lft)
{
    if (frm < to_max)
    {
        frm++;

    }
    ShowPic(lft);
}

function PLeft(lft)
{
    if (frm > 1)
    {
        frm=frm-1;
    }
    ShowPic(lft);
}
function HideButt(lang)
{
   var hi = document.getElementById('v200_'+id);
   var lo = document.getElementById('v40_'+id);
   if ( lo ) lo.src='/img/icons/'+lang+'_vi40.gif';
   if ( hi ) hi.src='/img/icons/'+lang+'_vi200.gif';

}
function ShowVideo(type, lang)
{
   var hi = document.getElementById('v200_'+id);
   var lo = document.getElementById('v40_'+id);

    var copyObj = document.getElementById('copy');
    var mediaLayout = document.getElementById('media_layout');
    var browser = (function x(){})[-5]=='x' ? 'ff3' : (function x(){})[-6]=='x' ? 'ff2' : /a/[-1]=='a' ? 'ff' : '\v'=='v' ? 'ie' :/a/.__proto__=='//' ? 'safari' : /s/.test(/a/.toString) ? 'chrome' : /^function \(/.test([].sort) ? 'opera' : 'unknown'; 
    
    // Fixing bottom padding of codes button (if IE 68px)
    if ( copyObj ) {
       copyObj.style.paddingBottom = ( type == 'low' ) ? (( browser == 'ie' ) ? '68px' : '2px') : '68px';
    }
    
    // Fixin gallery table height in Firefox
    if ( mediaLayout ) {
      if ( type == 'low' ) mediaLayout.style.height = '240px';
    }
    
    HideButt(lang);

    
    if (type=='low')
    {
        
        if ( lo ) lo.src='/img/icons/'+lang+'_vi40_over.gif';
        clicked=1;
        videoURL=lowresURL;
    }
    else{
        videoURL=hiresURL;
        clicked=1;
        if ( hi ) hi.src='/img/icons/'+lang+'_vi200_over.gif';
    }
    Makeold(videoURL,type);
}

function Makeold(videoURL,type)
{
    if (videoURL!='')
    {
        if (FrmeType!='video')
        {
            FrmeHtml=document.getElementById('MainSrc').innerHTML;
            FrmeType='video';
        }
        DoShow(type);
    }
}
function ChangeSrcVideo(pid, type, lang)
{
   var p_id = document.getElementById(pid);
    if ( clicked == 1 ) {
        clicked=0;
        return;
    }
    //alert(p_id.src);
    if ( p_id ) {
       if (p_id.src.indexOf('_over')!=-1) {
           p_id.src='/img/icons/'+lang+'_vi'+type+'.gif'
       } else {
           p_id.src='/img/icons/'+lang+'_vi'+type+'_over.gif'
       }
    }
}
function DoShow(type)
{
    document.getElementById('pic_nav').style.display='none';
    document.getElementById('MainSrc').innerHTML = '<object classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" height="309" width="320" standby="Loading Windows Media Player components..." type="application/x-oleobject" title="Stan On-Line TV">'
    +'\n<PARAM NAME="FileName" VALUE="'+videoURL+'">'
    +'\n<param name="height" value="309">'
    +'\n<param name="width" value="320">'
    +'\n<PARAM NAME="AutoSize" VALUE="0">'
    +'\n<PARAM NAME="AnimationAtStart" VALUE="1">'
    +'\n<PARAM NAME="TransparentAtStart" VALUE="0">'
    +'\n<PARAM NAME="DisplaySize" VALUE="0">'
    +'\n<PARAM NAME="autostart" VALUE="1">'
    +'\n<param name="autoplay" value="1">'
    +'\n<PARAM NAME="ShowControls" VALUE="1">'
    +'\n<PARAM NAME="ShowAudioControls" VALUE="1">'
    +'\n<PARAM NAME="ShowPositionControls" VALUE="1">'
    +'\n<PARAM NAME="ShowDisplay" VALUE="0">'
    +'\n<PARAM NAME="ShowGotoBar" VALUE="0">'
    +'\n<PARAM NAME="VideoBorder3D" VALUE="0">'
    +'\n<param name="ShowStatusBar" value="1">'
    +'\n<param name="volume" value="100">'
    +'\n<EMBED type="application/x-mplayer2" pluginspage = "http://www.microsoft.com/Windows/MediaPlayer/"'
    +'\n FileName = "'+videoURL+'"'
    +'\n uiMode = "full"'
    +'\n TransparentAtStart = "0"'
    +'\n AutoStart = "1"'
    +'\n AnimationAtStart = "1"'
    +'\n ShowControls = "1"'
    +'\n autoSize = "0"'
    +'\n displaySize = "0"'
    +'\n height = "'+((type=='low')?'190':'309')+'"'
    +'\n width = "350"'
    +'\n showdisplay = "0"'
    +'\n TransparentAtStart = "1"'
    +'\n ShowStatusBar = "1"'
    +'\n volume = "100">'
    +'\n</EMBED>';
}

function SetLocTime()
{

    loc=new Date();
    locTimestamp=parseInt(loc.getTime()/1000);
    loc_off=loc.getTimezoneOffset()*60;
    curDate = new Date((tm+(locTimestamp-startTimestamp+(serv_off+loc_off)))*1000);
    SetTimer();

    if (call_date>=10)
    {
        call_date=0;
        SetDate();
    }
    call_date++;

    window.setTimeout('SetLocTime()',1000);
}


function SetTimer()
{

    h=curDate.getHours();
    if (h<10) h='0'+h;

    m=curDate.getMinutes();
    if (m<10) m='0'+m;

    s=curDate.getSeconds();
    if (s<10) s='0'+s;
    document.getElementById('clock').innerHTML=(h+':'+m+':'+s);

}

function SetDate()
{
    d=curDate.getDay();
    dat=curDate.getDate();
    mon=curDate.getMonth();
    y=curDate.getFullYear();
    document.getElementById('date').innerHTML=('<nobr>'+day_arr[d]+', '+dat+' '+month_arr[mon]+' '+y+'</nobr>');

}
function ShowBanner(src, h, w)
{
    if (AC_FL_RunContent == 0) {
        alert("This page requires AC_RunActiveContent.js.");
    } else {
        AC_FL_RunContent(
        'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
        'width', w,
        'height', h,
        'src', '/swf/'+src+'.swf',
        'quality', 'high',
        'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
        'align', 'middle',
        'play', 'true',
        'loop', 'true',
        'scale', 'exactfit',
        'wmode', 'window',
        'devicefont', 'false',
        'id', 'stan_tv',
        'bgcolor', '#ffffff',
        'name', 'stan_tv',
        'menu', 'true',
        'allowFullScreen', 'false',
        'allowScriptAccess','sameDomain',
        'wmode', 'transparent',
        'allowScriptAccess', 'always',
        'movie', '/swf/'+src,
        'salign', ''
        ); //end AC code
    }
}
function OpenPlayer()
{
    nph_open_window('/user_playlist/', 'nph_player', 'toolbar=yes,menubar=yes,status=yes,scrollbars=yes,resizable=yes');
    document.getElementById('user_playlist_form').submit();

}
function nph_open_window(url, name, feature)
{
    var new_window = window.open(url, name, feature);
    new_window.focus();
}
