// Miscellaneous functions

//change background color of the sub-menu items when mouse over
function onStyle(cellId) {
	document.getElementById(cellId).style.backgroundColor = '#003366';
}

function offStyle(cellId) {
	document.getElementById(cellId).style.backgroundColor = '';
}

//change background color of the Quick Link
function onQStyle(cellId) {
	document.getElementById(cellId).style.backgroundColor = '#C7E2FE';
}

function offQStyle(cellId) {
	document.getElementById(cellId).style.backgroundColor = '';
}


//swapimage function for menu title
function swapImg(idImg) {
	if(v_page != 'default'){
	MM_swapImage(idImg,'','../images/roll/'+idImg+'.gif',1);
	}
	else {
	MM_swapImage(idImg,'','images/roll/'+idImg+'.gif',1);
	}
}

//Hide selection box when layered menu drop down
function hideSel(idSel) {
	document.getElementById(idSel).style.visibility = "hidden";
}

//Show selection box when the layereed menu disappear
function showSel(idSel) {
	document.getElementById(idSel).style.visibility = "visible";
}

//Process selection box
function submitSel(selection) {
	var sel = document.getElementById(selection);
	var url = sel.options[sel.selectedIndex].value;
	if (sel.options[sel.selectedIndex].id == "pdf")
		window.open(url, "StudentBooklet0304", "toolbar, status, resizable, scrollbars");
	else
		window.location = url;
}


//menu rollover for default.asp page Quick Links
function qlrollover( tableCellRef, hoverFlag, navStyle ) {
	if ( hoverFlag ) {
		switch ( navStyle ) {
			case 1:
				tableCellRef.style.backgroundColor = '#C7E2FE'
				break;
			default:
//				tableCellRef.style.backgroundColor = '#ccc';
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#999999';
				}
		}
	} else {
		switch ( navStyle ) {
			case 1:
				tableCellRef.style.backgroundColor = ''
				break;
			default:
//				tableCellRef.style.backgroundColor = '#ddd';
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#999999';
				}
		}
	}
}

//Rotate image for homepage (Image name: homeImgN, N=1,2,3,...)
//Random number generator: 0 to (max -1)
function pickRandom(max) {
	return Math.floor(Math.random()*max);
}
//image selector
function buildImage(n) {
	var ran = pickRandom(n) + 1; // parameter for pickRandom() is the number of images to be rotated
	var str = '<img src="images/rotate/homeImg' + ran +'.jpg" width="540" height="270" alt="Rotate Splash Page" border="0">';
	document.write(str);
}
//image selector
function buildImageComp(n) {
	var ran = pickRandom(n) + 1; // parameter for pickRandom() is the number of images to be rotated
	var str = '<img src="../images/rotate2/image' + ran +'.jpg" width="540" height="270" alt="Rotate Splash Page" border="0">';
	document.write(str);
}