// Suckerfish drop down menus
sfHover = function()
{
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++)
    {
		sfEls[i].onmouseover=function()
        {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function()
        {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent)
{
    window.attachEvent("onload", sfHover);
}

// Display the countdown timer
function addZero(n)
{
    var n = n + "";

    if (n.length == 1)
    {
        n = "0" + n;
    }

    return n;
}

function countdown_clock(year, month, day, hour, minute, div)
{
    Today = new Date();
    Todays_Year = Today.getFullYear() - 2000;
    Todays_Month = Today.getMonth();

    //Convert both today's date and the target date into miliseconds.
    Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(),
                         Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();
    Target_Date = (new Date(year, month - 1, day, hour, minute, 00)).getTime();

    //Find their difference, and convert that into seconds.
    Time_Left = Math.round((Target_Date - Todays_Date) / 1000);

    if ( Time_Left < 0 )
    {
        Time_Left = 0;
    }

	days = addZero(Math.floor(Time_Left / (60 * 60 * 24)));
	Time_Left %= (60 * 60 * 24);
    hours = addZero(Math.floor(Time_Left / (60 * 60)));
    Time_Left %= (60 * 60);
    minutes = addZero(Math.floor(Time_Left / 60));
    Time_Left %= 60;
    seconds = addZero(Time_Left);

    document.getElementById(div).innerHTML = days + ' : ' + hours + ' : ' + minutes;

    //Recursive call, keeps the clock ticking.
    setTimeout('countdown_clock(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ",  '" + div + "');", 60000);
}

// Function to clear input boxes background
function inputClear (obj, url)
{
	if (obj.value == "" && obj.style.backgroundImage == 'url(' +url + ')')
	{
		obj.style.backgroundImage = "";
	}
	else if (obj.value == "" && obj.style.backgroundImage == "")
	{
		obj.style.backgroundImage = 'url(' +url + ')';
	}
}

// Pop-up windows
function wopen(ele)
{
	url = ele.href;
	w = 800;
	h = 600;
	wleft = (screen.width - w) / 2;
	wtop = (screen.height - h) / 2;

	if (wleft < 0)
	{
		w = screen.width;
		wleft = 0;
	}

	if (wtop < 0)
	{
		h = screen.height;
		wtop = 0;
	}

	var win = window.open(url, 'name', 'width=' + w + ',height=' + h + ', ' + 'left=' + wleft + ',top=' + wtop + ', ' + 'location=yes,menubar=yes,' + 'status=yes,toolbar=yes,scrollbars=yes,resizable=yes');

	if (window.focus)
		{ win.focus(); }

	return false;
}

// Extend the left side
function extendLeft(divID)
{
    var scrolHeight = 0;
    if( window.scrollHeight )
    {
        scrolHeight = window.scrollHeight;
    }
    else if(document.documentElement && document.documentElement.scrollHeight)
    {
        scrolHeight = document.documentElement.scrollHeight;
    }
    else if(document.body && document.body.scrollHeight)
    {
        scrolHeight = document.body.scrollHeight;
    }

    document.getElementById(divID).style.height = scrolHeight + "px";
}

var myimages=new Array()
function preloadImages() {
	for (i=0;i<preloadImages.arguments.length;i++){
		myimages[i]=new Image()
		myimages[i].src=preloadImages.arguments[i]
	}
}
preloadImages(
	"images/homepage/basoc_mb_results_on.gif",
	"images/homepage/basoc_mb_schedules_on.gif",
	"images/homepage/basoc_mb_spec_events_on.gif",
	"images/homepage/basoc_mb_transportation_on.gif",
	"images/homepage/basoc_mb_photos_on.gif",
	"images/homepage2/basoc_banner_on.gif",
	"images/homepage2/basoc_cert_on.gif",
	"images/homepage2/basoc_photos_on.gif",
	"images/homepage2/basoc_results_on.gif",
	"images/homepage2/basoc_schedules_on.gif",
	"images/homepage2/basoc_transportation_on.gif",
	"images/homepage2/basoc_volunteertrib_on.gif",
	"images/homepage2/poster_on.gif"
);
	
function MM_swapImage() {
	var i, theObj, j = 0, swapArray = new Array, oldArray = document.MM_swapImgData;
		for (i = 0; i < (MM_swapImage.arguments.length - 2); i += 3) {
  		theObj = eval(MM_swapImage.arguments[(navigator.appName == 'Netscape')?i: i + 1])
   			if (theObj != null) {
 				swapArray[j++] = theObj;
   			swapArray[j++] = (oldArray == null || oldArray[j - 1] != theObj)?theObj.src: oldArray[j];
   			theObj.src = MM_swapImage.arguments[i + 2];
 			}
 		}
	document.MM_swapImgData = swapArray;
}

function MM_swapImgRestore() {
	if (document.MM_swapImgData != null)
		for (var i = 0; i < (document.MM_swapImgData.length - 1); i += 2)
 			document.MM_swapImgData[i].src = document.MM_swapImgData[i + 1];
}
