﻿function $(element) { return document.getElementById(element); }
function $S(element) { return document.getElementById(element).style; }

var polSubMenu_to, papersSubMenu_to, photo_to, papers_to, photo_to1;
var mainCurr = 0;
var weatherScrollInt;
var crawlState = 1;
var weatherTopCurr = 0;
var main1ScrollCurr = 0;
var eyeScrollCurr = 0;
changeMain();
function ShowPolSubMenu() {
    clearTimeout(polSubMenu_to);
    $S('divPolMenuItem').display = 'block';
}
function ShowPapersSubMenu() {
    clearTimeout(papersSubMenu_to);
    $S('divPapersSubMenu').display = 'block';
}
function HidePolSubMenu() {
    polSubMenu_to = setTimeout("$S('divPolMenuItem').display = 'none'", 1000);
}
function HidePapersSubMenu() {
    papersSubMenu_to = setTimeout("$S('divPapersSubMenu').display = 'none'", 1000);
}
function ShowPhoto() {
    clearTimeout(photo_to);
    $S('divPhotoMO').display = 'block';
}
function HidePhoto() {
    photo_to = setTimeout("$S('divPhotoMO').display = 'none'", 1000);
}

function ShowPapers() {
    clearTimeout(papers_to);
    $S('divPapersMO').display = 'block';
}
function HidePapers() {
    papers_to = setTimeout("$S('divPapersMO').display = 'none'", 1000);
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

showMain(0);
mainInterval = setInterval('playMain()', 10000);

//onmouseout='startMain();' onmouseover='stopMain();'

//////////////////////////////////////////////////////////////////////////////////
function opacity(id, opacStart, opacEnd, millisec) {
    var speed = Math.round(millisec / 100);
    var timer = 0;
    if (opacStart > opacEnd) {
        for (i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac('" + id + "', " + i + ")", (timer * speed));
            timer++;
        }
    }
    else if (opacStart < opacEnd) {
        for (i = opacStart; i <= opacEnd; i++) {
            setTimeout("changeOpac('" + id + "', " + i + ")", (timer * speed));
            timer++;
        }
    }
}
function changeOpac(id, opacity) {
    var object = $S(id);
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}
//////////////////////////////////////////////////////////////////////////////////

function minus(sectionID) {
    for (i = 0; i < 10; i++)
        if ($S('liSubNews_' + sectionID + '_' + i).display == 'none') {
        break;
    }
    if (i > 0)
        $S('liSubNews_' + sectionID + '_' + (i - 1)).display = 'none';
    if (i < 4 && i > 0)
        $S('divSubNewsImg_' + sectionID).display = 'none';
}
function plus(sectionID) {
    for (i = 0; i < 10; i++)
        if ($S('liSubNews_' + sectionID + '_' + i).display == 'none') {
        $S('liSubNews_' + sectionID + '_' + i).display = 'block';
        break;
    }
    if (i > 1)
        $S('divSubNewsImg_' + sectionID).display = 'block';
}
//var weatherMax = ($('spnWeather').offsetHeight * -1) + 90;
function weatherScroll(dir) {
    weatherScrollInt = setInterval('weatherUpDown(' + dir + ')', 100);
}
function weatherUpDown(dir) {
    if (dir == 0 && weatherTopCurr == 0) {
        clearInterval(weatherScrollInt);
        return;
    }
    if (dir == 1 && weatherTopCurr == -100) {
        clearInterval(weatherScrollInt);
        return;
    }
    weatherTopCurr = dir == 1 ? weatherTopCurr - 10 : weatherTopCurr + 10;
    $S('spnWeather').top = weatherTopCurr + 'px';
}
function toggleCrawl() {
    if (crawlState == 1) {
        marCrawl.stop();
        crawlState = 0;
    }
    else {
        marCrawl.start();
        crawlState = 1;
    }
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var _value;
var polSubNews = new Array();
function ShowResult(val) {
    if (_value.indexOf('getPolSection;') == 0) {
        var itemNo = _value.substring(_value.length - 1);
        $S('divPolitics').backgroundColor = '';
        $('divPolitics').innerHTML = val;
        polSubNews[itemNo] = val;
        for (i = 1; i < 6; i++)
            $('divPolSubNews' + i).className = 'rightPaneHeader1';
        $('divPolSubNews' + itemNo).className += ' sel';
    }
}
function getPolSection(sectionID) {
    //$S('divPolitics').backgroundColor = 'black';
    _value = 'getPolSection;' + sectionID;
    var itemNo = _value.substring(_value.length - 1);
    if (polSubNews[itemNo]) {
        $S('divPolitics').backgroundColor = '';
        $('divPolitics').innerHTML = polSubNews[itemNo];
        for (i = 1; i < 7; i++)
            $('divPolSubNews' + i).className = 'rightPaneHeader1';
        $('divPolSubNews' + itemNo).className += ' sel';
    }
    else
        Go_Server();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function searchChk() {
    var txtSearch = document.getElementById('txtSearch');
    if (txtSearch == null)
        txtSearch = document.getElementById('ctl00_txtSearch');
    if (txtSearch.value == '') {
        alert('Please enter the text you want to search for');
        return false;
    }
    if (document.getElementById('rdoWeb').checked == true) {
        location.href = 'http://google.com/search?hl=en&q=' + txtSearch.value;
        return false;
    }
}