timeOn=0;
lastmenu=0;
pagechanged=0;

function pageChanged(){
	pagechanged=1;
}

function checkChange(type){
	if(pagechanged==0){
		document.getElementById('formAction').value=type;
		document.myForm.submit();
	}
	if(confirm('Do you really want to change the page? You\'ll lose any unsaved changes')){
		document.getElementById('formAction').value=type;
		document.myForm.submit();
	}
}

function showHiddenDiv(id){
	document.getElementById('hidden').style.visibility = "visible";
	document.getElementById('hidden').style.display = "block";
	document.getElementById('targetLink').innerHTML = "<b>URL:</b> http://www.studyincanada.ca/index.php?page="+id;
}


function showMenuTest(eventObj,menu) {
	clearTimeout(timeOn);
	if(menu!=lastmenu)
	{
		changeObjectVisibility('myMenu' + lastmenu, 'hidden');
	}
	lastmenu=menu;
    if(changeObjectVisibility('myMenu'+menu, 'visible')) {
	return true;
    } else {
	return false;
    }
}
function hideMenuTest(eventObj) {
//	eventObj.cancelBubble = true;
	menuOut();
	return true;
}

function menuOut() {
  timeOn = setTimeout("hideAllMenus()", 100);
  return true;
}

function menuOver() {
  clearTimeout(timeOn);
  return true;
}

function hideAllMenus() {
	counter=1;
	while(getStyleObject('myMenu' + counter) != false) 
	{
		changeObjectVisibility('myMenu' + counter, 'hidden');
		counter++;
    }
}

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	//we couldn't find the object, so we can't change its visibility
	return false;
    }
} // changeObjectVisibility

function MM_total(obj)
{ //v3.0
	var total = 0;
   	for (counter = 0; counter < document.main.length; counter++)
	{
		if (document.main[counter].name.indexOf("total_")>=0)
		{
			if(!isNaN(document.main[counter].value))total = total + parseInt(document.main[counter].value);
		} 
	}
	
	obj.value=total.toFixed(2);
}