// Javascript for masking email - prevent spamming
function email(text1, text2, text3)
{
	window.location = "mailto:" + text1 + text2 + text3;
}

/****************************************
Javascript to high light the current menu
****************************************/
function currentItem()
{
	var currentLocation = document.location.href;
	var currentAddress = currentLocation.substring(currentLocation.lastIndexOf("/")+1);
	
	// BEGIN eliminate the # sign & the following letters at the end of the address
	//newAddress = currentAddress.substring(0,currentAddress.indexOf("#"));
	// END eliminate the # sign & the following letters at the end of the address
	
	var links = document.getElementById("leftMenu").getElementsByTagName("a");
	
	for (var i=0; i<links.length; i++)
	{
		var currentHref = links[i].getAttribute("href");
		var currentItem = currentHref.substring(currentHref.lastIndexOf("/")+1);

		//if (currentItem == currentAddress || currentItem == newAddress)
		if (currentItem == currentAddress)
		{
			var newAttr = document.createAttribute("style");
			links[i].setAttribute('style','color:#C60;');
		}
	}
}

/*****************************************
Javascript to check if user selects a date
	before registering a workshop
*****************************************/
function isSelect(myForm, comboBoxID)
{
	var value = document.getElementById(myForm).elements[comboBoxID].value;
	
	if (value == 0)
	{
		alert("Please select a date.");
		return false; // No, user not select any
	}
	
	return true; // Yes, user selected
}

/***************************************************
Javascript to submit form for registering a workshop
***************************************************/
function submitForm(myForm, comboBoxID)
{
	if (isSelect(myForm,comboBoxID))
	{
		document.getElementById(myForm).action="https://www.securewebexchange.com/beyond-training.ca/OnlineCourse/WorkshopRegister.php?" + Math.random();
		document.getElementById(myForm).target="_blank";
		document.getElementById(myForm).submit();
		return true;
	}
	
	return false;
	
}

// Change font size
function changeTextSize(size)
{
	document.body.style.fontSize = size + "px";
}
