﻿/*
// The Roanoke Times global script
// 12/15/2005 (updated 12/03/06)
//
*/


/* Gateway Page */
/* Featured Boxes */
var currentBox = '';

function setCurrent() {
    dteVar = new Date();
    
    if (dteVar.getMinutes()<=9) minVar = '0' + dteVar.getMinutes();
	else minVar = dteVar.getMinutes();
    
    timeVar = dteVar.getHours() + '.' + minVar
    
    switch (dteVar.getDay()) {
        case 6: { /* Saturday is ent */
            currentBox = 'ent';
            setInfoFocus('ent');
            break;
        }
    
        case 0: { /* Sunday is news */
            currentBox = 'news';
            setInfoFocus('news');
            break;
        }
    
        case 1: { /* Monday */
            if (timeVar<15.30) {
                currentBox = 'news';
                setInfoFocus('news');
            } else {
                if (timeVar>=15.30 && timeVar<18.30) {
                    if (document.getElementById("updateFlag").value == dteVar.getDay()) {
                        currentBox = 'web';        
                        setInfoFocus('web');
                    }
                } else {
                    currentBox = 'ent';
                    setInfoFocus('ent');
                }
            }
            break;
        }
        
        case 4: { /* Thursday */
            window.status=timeVar;
            if (timeVar>6.00 && timeVar<15.30) {
                currentBox = 'news';
                setInfoFocus('news');
            } else { 
                if (timeVar>=15.30 && timeVar<17.00) {
                    if (document.getElementById("updateFlag").value == dteVar.getDay()) {
                        currentBox = 'web';
                        setInfoFocus('web');
                    }
                } else {
                    if (timeVar>=17.00 && timeVar<19.00) {
                        if (document.getElementById("updateFlag").value == dteVar.getDay()) {
                            currentBox = 'sports';
                            setInfoFocus('sports');
                        }
                    } else {
                        currentBox = 'ent';
                        setInfoFocus('ent');
                    }
                }
            }
	    break;
        }
        
        default: { /* The other days */
            if (timeVar>6.00 && timeVar<15.30) {
                currentBox = 'news';
                setInfoFocus('news');
            } else { 
                if (timeVar>=15.30 && timeVar<18.30) {
                    if (document.getElementById("updateFlag").value == dteVar.getDay()) {
                        currentBox = 'web';
                        setInfoFocus('web');
                    }
                } else {
                    currentBox = 'ent';
                    setInfoFocus('ent');
                }
            }
	    break;
        }
    }
}

function setClassifiedTab(id) {
    if (id=="2") {
        currentBox = 'serv';
        setClassifiedFocus('serv');
    }

    if (id=="3") {
        currentBox = 'mark';
        setClassifiedFocus('mark');
    }

    if (id=="4") {
        currentBox = 'not';
        setClassifiedFocus('not');
    }
}

function setInfoFocus(b){
    if (currentBox == b) {
        var bxs=['news','sports','ent','web','cls'];
        for (var i=0;i<bxs.length;i++) {
            var bx=document.getElementById('featured-'+bxs[i]);
            var lk=document.getElementById(bxs[i]+'-lnk');
            if (b==bxs[i]){
                bx.style.display='block';
                lk.className='current';
             }else{
                bx.style.display='none';
                lk.className='';
            }
        }
    }
}

function setClassifiedFocus(b){
    if (currentBox == b) {
        var bxs=['feat','serv','mark','not','faq'];
        for (var i=0;i<bxs.length;i++) {
            var bx=document.getElementById('box-'+bxs[i]);
            var lk=document.getElementById(bxs[i]+'-lnk');
            if (b==bxs[i]){
                bx.style.display='block';
                lk.className='current';
             }else{
                bx.style.display='none';
                lk.className='';
            }
        }
    }
}

function setObitFocus(b){
    if (currentBox == b) {
        var bxs=['obit','mem','cards','place','arch'];
        for (var i=0;i<bxs.length;i++) {
            var bx=document.getElementById('box-'+bxs[i]);
            var lk=document.getElementById(bxs[i]+'-lnk');
            if (b==bxs[i]){
                bx.style.display='block';
                lk.className='current';
             }else{
                bx.style.display='none';
                lk.className='';
            }
        }
    }
}

function setCelebFocus(b){
    if (currentBox == b) {
        var bxs=['faq','Wed','Ann','Bir','Eng','Mil'];
        for (var i=0;i<bxs.length;i++) {
            var bx=document.getElementById('box-'+bxs[i]);
            var lk=document.getElementById(bxs[i]+'-lnk');
            if (b==bxs[i]){
                bx.style.display='block';
                lk.className='current';
             }else{
                bx.style.display='none';
                lk.className='';
            }
        }
    }
}

function setSideFocus(b){
    var bxs=['jobs','homes','autos','tmc'];
    for (var i=0;i<bxs.length;i++) {
        var bx=document.getElementById('side-tab-'+bxs[i]);
        var lk=document.getElementById(bxs[i]+'-lnk');
        if (b==bxs[i]){
            bx.style.display='block';
            lk.className='current';
         }else{
            bx.style.display='none';
            lk.className='';
        }
    }
}

/* pop-up window function (not being used) */
function makeLarge(url, wPx, hPx) {
	newWin=window.open(url, "popup", "width=" + wPx + ",height=" + hPx + ",top=50,left=50,scrollbars,resizable");
	newWin.focus();
}

/* Ad Control */
function adControl(h) {
        if (h < 705) document.getElementById("featured-jobs").style.display='none';
        if (h < 460) document.getElementById("ad-google").style.display='none';
}

/*Jobs Page-Tabs*/
function setJobFocus(b){
    var bxs=['seekerlogin','emplogin','product'];
    for (var i=0;i<bxs.length;i++) {
        var bx=document.getElementById('jobtabs-'+bxs[i]);
        var lk=document.getElementById(bxs[i]+'-lnk');
        if (b==bxs[i]){
            bx.style.display='block';
            lk.className='current';
         }else{
            bx.style.display='none';
            lk.className='';
        }
    }
}

/* date functions for the mast */

var months = new Array(12);
months[0] = "January";
months[1] = "February";
months[2] = "March";
months[3] = "April";
months[4] = "May";
months[5] = "June";
months[6] = "July";
months[7] = "August";
months[8] = "September";
months[9] = "October";
months[10] = "November";
months[11] = "December";

var weekDays = new Array(7);
weekDays[0] = "Sunday";
weekDays[1] = "Monday";
weekDays[2] = "Tuesday";
weekDays[3] = "Wednesday";
weekDays[4] = "Thursday";
weekDays[5] = "Friday";
weekDays[6] = "Saturday";

var dteBase = new Date();
var monthName = months[dteBase.getMonth()];
var weekDay = weekDays[dteBase.getDay()];
var date = dteBase.getDate();
var year = dteBase.getYear();

if (year < 2000) year = year + 1900; // Y2K Fix, Isaac Powell http://onyx.idbsu.edu/~ipowell

var formatDate = weekDay + ', ' + monthName + ' ' + date + ', ' + year;

function getFormattedDate() {
    return formatDate;
}

// addLoadEvent
// Use this function to load multiple functions when the document loads (it will not overwrite the window.onload event): addLoadEvent(FUNCTION);
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
			}
		}
	}

/* popUp script
Developer: Patrick Beeson
Created: 08/29/06
*/

// Soundslides popup function
function soundslideOpen (winURL) {
	window.open(winURL,"soundslide_popup","width=740,height=670");
}

// Photogallery popup function
function photogalleryOpen (winURL) {
	window.open(winURL,"photogallery_popup","width=645,height=725");
}

// Smith Mountain Lake Webcam popup function (not functioning)
/* function lakewebcamOpen (winURL) {
	window.open(winURL, "lakewebcam_popup","width=675,height=500");
}*/

// Contact online form popup function
function contactonlineOpen (winURL) {
	window.open(winURL, "contactonline_popup","width=500,height=400");
}

// Poll popup function
function pollOpen (winURL) {
	window.open(winURL, "poll_popup","width=400,height=450");
}

// Actual popup function
function popUp() {
	if (!document.getElementsByTagName) return false;
	var lnks = document.getElementsByTagName("a");
	for (var i=0; i<lnks.length; i++) {
		if (lnks[i].className == "soundslide_popup") {
			lnks[i].onclick = function() {
				soundslideOpen(this.getAttribute("href"));
				return false;
			}
		}
		else if (lnks[i].className == "photogallery_popup") {
				lnks[i].onclick = function() {
				photogalleryOpen(this.getAttribute("href"));
				return false;
			}
		}
		/* else if (lnks[i].className == "lakewebcam_popup") {
				lnks[i].onclick = function() {
				lakewebcamOpen(this.getAttribute("href"));
				return false;
			}
		} */
		else if (lnks[i].className == "contactonline_popup") {
				lnks[i].onclick = function() {
				contactonlineOpen(this.getAttribute("href"));
				return false;
			}
		}
		else if (lnks[i].className == "poll_popup") {
				lnks[i].onclick = function() {
				pollOpen(this.getAttribute("href"));
				return false;
			}
		}	
	}
}
addLoadEvent(popUp);


// Overlay function
function hideDiv() {
    document.getElementById('overLay').style.visibility = 'hidden';
}
