// JavaScript Document

function swopCourseDetails(courseID,targetID) {
		if (document.getElementById) {
			if(typeof targetID == "undefined") {var targetID = courseID}
			// this is the way the standards work
			target = document.getElementById(targetID);
			if (target.style.display == "none") {
				var url = 'coursedesc.php';
				var pars = 'id=' + courseID;
				var myAjax = new Ajax.Updater(targetID, url, {method: 'get', parameters: pars});
				target.style.display = "block";
			} else {
				target.style.display = "none";
			}
		}
}

function confirmDialog(dialogText,redirectURL) {
	var answer = confirm (dialogText);
	if (answer) {
		window.location=redirectURL;
		}
}

function obfuscateemail(name,domain){
	if ((name != null) && (domain != null)) {
		document.write('<a href=\"mailto:' + name + '@' + domain + '\">');
		document.write(name + '@' + domain + '</a>');
	}
}

function toggleDIVContent(contentURL,targetID) {
		if (document.getElementById) {
			// this is the way the standards work
			target = document.getElementById(targetID);
			if (target.style.display == "none") {
				var url = 'coursedesc.php';
				var myAjax = new Ajax.Updater(targetID, contentURL, {method: 'get'});
				target.style.display = "block";
			} else {
				target.style.display = "none";
			}
		}
}

// swap image named 'resource_image'
// images are in the '../images/resources/' subfolder
function swapPhoto(photoSRC) {
    document.images.resource_image.src = "../images/resources/" + photoSRC; 
}
