﻿// JScript File
function ChangeUserChoiceTab(tab)
{
    if(tab == 1)
    {
        NormalVisited.style.display = 'block';
        MostVisited.style.display = 'none';
        document.getElementById("tdMostVisited").style.backgroundColor = 'white';
        document.getElementById("tdNormalVisited").style.backgroundColor = 'red';
        document.getElementById("t1").src = '/images/tab_red1.gif';
        document.getElementById("t2").src = '/images/tab_white.gif';
        document.getElementById("tdNormalVisited").style.color = 'white';
        document.getElementById("tdMostVisited").style.color = 'blue';
    }
    else if(tab == 2)
    {
        NormalVisited.style.display = 'none';
        MostVisited.style.display = 'block';
        document.getElementById("t2").src = '/images/tab_red.gif';
        document.getElementById("t1").src = '/images/tab_white1.gif';
        document.getElementById("tdMostVisited").style.backgroundColor = 'red';
        document.getElementById("tdNormalVisited").style.backgroundColor = 'white';
        document.getElementById("tdNormalVisited").style.color = 'blue';
        document.getElementById("tdMostVisited").style.color = 'white';
    }
}
    
function displaytime(){
    currTime.setSeconds(currTime.getSeconds()+1)
    var timestring=padlength(currTime.getHours())+":"+padlength(currTime.getMinutes())+":"+padlength(currTime.getSeconds())
    time.innerHTML= '<img src="/images/arrow_down.gif" width=\"13\" height=\"9\" />' + timestring + " &nbsp;| &nbsp;" + serverDate    
}

function padlength(what){
    var output=(what.toString().length==1)? "0"+what : what
    return output
}

var oldRss = 1;
function showRss(newRss)
{
    //rssWait.style.display = 'none';
	document.getElementById("rss" + oldRss).style.display = 'none';
	document.getElementById("rss" + newRss).style.display = 'block';
	document.getElementById("rssIcon" + oldRss).style.visibility = 'hidden';
	document.getElementById("rssIcon" + newRss).style.visibility = 'visible';

	oldRss = newRss;
}

var oldNews = '1';
function showNews(newNews,scroll)
{
	//newsWait.style.display = 'none';
    document.getElementById("newsAbstract" + oldNews).style.display = 'none';
    document.getElementById("newsAbstract" + newNews).style.display = 'block';
    if(scroll)
    {
        document.getElementById("NewsBoxScroller").scrollTop = getPositionTop(document.getElementById("News" + newNews));
    }
    document.getElementById("newsImage" + oldNews).style.display = 'none';
    document.getElementById("newsImage" + newNews).style.display = 'block';
    document.getElementById("News" + oldNews).style.backgroundColor = 'white';
    document.getElementById("News" + newNews).style.backgroundColor = '#ebf3fb';
    document.getElementById("News" + oldNews).style.backgroundImage = "";
    document.getElementById("News" + newNews).style.backgroundImage = "";
    document.getElementById("News" + newNews).style.backgroundPosition = 'top left'; 
    document.getElementById("News" + newNews).style.backgroundRepeat = 'repeat-x';
	oldNews = newNews;
}

function getPositionTop(This){
var el = This;var pT = 0;
while(el){pT+=el.offsetTop;el=el.offsetParent;}
return pT-159;
}

function changeNews()
{
    
	var newNews = (parseInt(oldNews)  + 1).toString();
	
	if(document.getElementById("newsAbstract" + newNews))
	{
        showNews(newNews,true);
	}
	else
	{
		//clearInterval(newsIntervalID);
		showNews(1,true);			

	}
}

var oldSubMenu = -1;
function ShowSubMenu(mainMenu)
{
    var i = 0;
    if(oldSubMenu != -1)
    {
        while(document.getElementById("SubMenu_" + oldSubMenu + "I" + i))
        {
            document.getElementById("SubMenu_" + oldSubMenu + "_" + i).style.display = 'none';
            i++;
        }
    }
    
    i = 0;
    while(document.getElementById("SubMenu_" + mainMenu + "_" + i))
    {
        document.getElementById("SubMenu_" + mainMenu + "_" + i).style.display = 'block';
        i++;
    }
    
    oldSubMenu = mainMenu;
}

var preload_imageIndex = -1;
var image_url = new Array();

function preLoad()
{
    if (document.images)
    {
      var preload_image_object = new Image();
      // set image url
      
      image_url[++preload_imageIndex] = "images/tab_white1.gif";
      image_url[++preload_imageIndex] = "images/tab_blue1.gif";
      image_url[++preload_imageIndex] = "images/tab_blue.gif";
      image_url[++preload_imageIndex] = "images/tab_white.gif";
      image_url[++preload_imageIndex] = "images/tab_red.gif";
      image_url[++preload_imageIndex] = "images/tab_red1.gif";

       var i = 0;
       for(i=0; i<=3; i++) 
       {
         preload_image_object.src = image_url[i];
       }
    }
}

function setActiveTab(i)
{
    tabWait.style.display = 'none';
    switch (i)
    {
        case 0:
        	tdTab22.style.cssText = 'border-bottom:solid 1px #AACBEE;cursor:hand';
        	tdTab11.style.cssText = 'border-bottom:solid 1px #FFFFFF;cursor:hand';
        	tdTab33.style.cssText = 'border-bottom:solid 1px #AACBEE;cursor:hand';		        
        	tdTab2.style.cssText = 'border-top:solid 1px #AACBEE;border-right:solid 1px #AACBEE;border-bottom:solid 1px #AACBEE;background-color:#EBF3FB;cursor:hand';
        	tdTab3.style.cssText = 'border-top:solid 1px #AACBEE;border-right:solid 1px #AACBEE;border-bottom:solid 1px #AACBEE;background-color:#EBF3FB;cursor:hand';
        	tdTab1.style.cssText = 'border-top:solid 1px #AACBEE;border-right:solid 1px #AACBEE;background-color:#FFFFFF;cursor:hand';        	        	        		        	
            document.getElementById("tbImg1").src = 'images/tab_white1.gif';
            document.getElementById("tbImg2").src = 'images/tab_blue1.gif';
            document.getElementById("tbImg3").src = 'images/tab_blue.gif';	       
            div1.style.display = 'block';     	            
            div2.style.display = 'none';     	            
            div3.style.display = 'none';     	            	            	            
            break;
        case 1:
        	tdTab22.style.cssText = 'border-bottom:solid 1px #FFFFFF;cursor:hand';
        	tdTab11.style.cssText = 'border-bottom:solid 1px #AACBEE;cursor:hand';
        	tdTab33.style.cssText = 'border-bottom:solid 1px #AACBEE;cursor:hand';	 	        
        	tdTab1.style.cssText = 'border-top:solid 1px #AACBEE;border-right:solid 1px #AACBEE;border-bottom:solid 1px #AACBEE;background-color:#EBF3FB;cursor:hand';
        	tdTab3.style.cssText = 'border-top:solid 1px #AACBEE;border-right:solid 1px #AACBEE;border-bottom:solid 1px #AACBEE;background-color:#EBF3FB;cursor:hand';
        	tdTab2.style.cssText = 'border-top:solid 1px #AACBEE;border-right:solid 1px #AACBEE;background-color:#FFFFFF;cursor:hand';
            document.getElementById("tbImg1").src = 'images/tab_blue1.gif';
            document.getElementById("tbImg2").src = 'images/tab_white1.gif';
            document.getElementById("tbImg3").src = 'images/tab_blue.gif';		   
            div1.style.display = 'none';     	            
            div2.style.display = 'block';     	            
            div3.style.display = 'none';     	            	            	            	                 
            break;
        case 2:
        	tdTab22.style.cssText = 'border-bottom:solid 1px #AACBEE;cursor:hand';
        	tdTab11.style.cssText = 'border-bottom:solid 1px #AACBEE;cursor:hand';
        	tdTab33.style.cssText = 'border-bottom:solid 1px #FFFFFF;cursor:hand';	        	
        	tdTab2.style.cssText = 'border-top:solid 1px #AACBEE;border-right:solid 1px #AACBEE;border-bottom:solid 1px #AACBEE;background-color:#EBF3FB;cursor:hand';
        	tdTab1.style.cssText = 'border-top:solid 1px #AACBEE;border-right:solid 1px #AACBEE;border-bottom:solid 1px #AACBEE;background-color:#EBF3FB;cursor:hand';	        	
        	tdTab3.style.cssText = 'border-top:solid 1px #AACBEE;border-right:solid 1px #AACBEE;background-color:#FFFFFF;cursor:hand';
            document.getElementById("tbImg1").src = 'images/tab_blue1.gif';
            document.getElementById("tbImg2").src = 'images/tab_blue1.gif';
            document.getElementById("tbImg3").src = 'images/tab_white.gif';
            div1.style.display = 'none';     	            
            div2.style.display = 'none';     	            
            div3.style.display = 'block';     	            	            	            	            
            break;	        
    }
}
var newsIntervalID;
function init(){
	//showRss('1');
	showNews('1',true);
	
	newsIntervalID = setInterval("changeNews()",10000);
	setInterval("displaytime()", 1000);
	//rssWait.style.display = 'none';
	//tabWait.style.display = 'none';
	
	setActiveTab(0);
	preLoad();
}


function initMasterPage(){
	setInterval("displaytime()", 1000);
	preLoad();
}
///////////////////////////////////////////////////////////////////////////////


