var NavImgArray = [];
function PreloadNavImage(src)
{
	NavImgArray[NavImgArray.length] = new Image();
	NavImgArray[NavImgArray.length-1].src = src;
}
function NavOver(img) {	img.src = img.src.split('out.').join('over.'); }
function NavOut(img) { img.src = img.src.split('over.').join('out.'); }

function hilite(obj){obj.style.background='#fffb94';}
function lolite(obj){obj.style.background='#ffffff';}
function GiveFocus(id){var obj=document.getElementById(id); if(obj==null||obj=='undefined') return; if(obj.type=='hidden') return GiveFocus(id+'_description'); if(obj.length && isNaN(obj.selectedIndex))obj=obj[0]; obj.focus();}
function roundNumber(num, dec) {return Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);}
function getFileName(url) {var index = url.lastIndexOf('\\'); if (index != -1) retVal = url.substring(index + 1); else retVal = url; return retVal;}

function LeftPad(str,n,ch) {return Right(Repeat(ch, n)+str, n);}
function RightPad(str,n,ch) {return Left(str+Repeat(ch, n), n);}
function Repeat(str,n) {var tmp=new Array(n+1);return tmp.join(str);} // repeat str n times
function Left(str, n){if (n <= 0) return ""; else if (n > String(str).length) return str; else return String(str).substring(0,n);}
function Right(str, n){if (n <= 0) return ""; else if (n > String(str).length) return str; else {var iLen = String(str).length; return String(str).substring(iLen, iLen - n);}}

function opacity(id, opacStart, opacEnd, millisec)
{ 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id)
{ 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}

function ChangeTextSize(amount)
{
	if (!document.styleSheets) return;
	for (var i=0;i<document.styleSheets.length;i++)
	{
		var cssRules = document.styleSheets[i].rules?document.styleSheets[i].rules:document.styleSheets[i].cssRules;
		if (!cssRules) return;
		for (var j=0;j<cssRules.length;j++)
		{
			var cssRule = cssRules[j];
			var fs = cssRule.style.fontSize.toLowerCase();
			var fst = fs.substring(fs.length-2);
			if (fst=='pt'||fst=='px')
				cssRule.style.fontSize = (parseInt(cssRule.style.fontSize)+amount)+fst;
		}
	}
}

function ToggleTextSize()
{
    document.cookie = "largetext="+!(document.cookie.indexOf('largetext=true')>-1);
    ChangeTextSize(document.cookie.indexOf('largetext=true')>-1 ? 2: -2);
}

function SetTextSizeButton(obj)
{
    obj.innerHTML = document.cookie.indexOf('largetext=true')>-1 ? "- Smaller Text": "+ Larger Text";
}

// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}