
if (top != self)
{
	top.location.href = unescape(window.location.pathname);
}
   
//v2.0
function MM_openBrWindow(theURL,winName,features)
{
	window.open(theURL,winName,features);
}

var CB = null;

function coursewindow(mypage,myname)
{
	if (CB && !CB.closed)CB.close();
	openitCB(mypage,myname);
}

function openitCB(mypage,myname)
{
	var w = 780
	var h = 550
	var t = ((self.screen.availHeight/2) - (h/2));
	var l = ((self.screen.availWidth/2) - (w/2));
	settings ='width=' + w + ',height=' + h + ',left=' + l + ',top=' + t + ',toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes'
	CB = window.open(mypage,myname,settings);
}
	
function coursewindowparams(mypage,myname,myparams)
{	
	if (CB && !CB.closed) CB.close();
	{
		openitCBParam(mypage,myname,myparams);
	}
}

function openitCBParams(mypage,myname,myparams)
{
	var w = 800
	var h = 550
	var t = ((self.screen.availHeight/2) - (h/2));
	var l = ((self.screen.availWidth/2) - (w/2));
	settings ='width=' + w + ',height=' + h + ',left=' + l + ',top=' + t + ',' + myparams
	CB = window.open(mypage,myname,settings);
}

//loc used as an alias for document.location.href
var loc = document.location.href;
var fontcol = "";
var fontcol2 = "";

//This function is used to restore the LHSMenu to the right position
function getlinks()
{
	//Get only the Anchors in the CasMenu
	var atags = document.getElementById("CASMenu").getElementsByTagName('a');
	//loop them
	for(i=0; i<atags.length; i++)
	{
		//hrefvalue is an alias for the anchor href
		hrefvalue = atags[i].attributes.href.value; 
		//The link we are currently looking at
		var casMenuItem = atags[i];
		//Use this variable to decide wether or not to highlight the casMenuItem
		var openThisItem = false
		
		//Using Binary assignment ors...
		
		//Link to current Page....
		openThisItem |= (loc.toLowerCase().indexOf(hrefvalue.toLowerCase())!= -1)
		//Enrolment_admin is accessed through schedule_admin
		openThisItem |= (loc.toLowerCase().indexOf("enrolment_admin.asp") != -1 && 
			hrefvalue.toLowerCase().indexOf("schedule_admin.asp") != -1)
		//partner_courses is accessed through partner_programmes
		openThisItem |= (loc.toLowerCase().indexOf("partner_courses.asp") != -1 && 
			hrefvalue.toLowerCase().indexOf("partner_programmes.asp") != -1)
		
		//Display this Item if it is pointing to the current page
		if(openThisItem)
		{
			casMenuItem.style.color=fontcol;
			casMenuItem.parentNode.style.display = "block";
		}
	}
}
// thelayer ref to the current dive
// submenu element name of child div of thelayer   
function showlayers(theLayer, submenu)
{
	theLayer.ondblclick = theLayer.onclick;
	theLayer.onselectstart = function(){return false;}
	var thesublayer = submenu;
	var otherlayers = document.getElementsByTagName("div");
	for (var ib = 0; ib < otherlayers.length; ib++)
	{
		tempLayer = otherlayers[ib];
		if(tempLayer.id.indexOf(thesublayer)!= -1)//check templayer is the sublayer we are looking for
		{
			if(document.getElementById(tempLayer.id).style.display != "block")//if the element is not displayed then display it
			{
				theLayer.style.color=fontcol;
				document.getElementById(tempLayer.id).style.display = "block";
				document.getElementById(tempLayer.id).style.visibility = "visible";
			}else{//if the element is not block then keep it hidden				
				document.getElementById(tempLayer.id).style.display = "none";
				theLayer.style.color=fontcol2;
			}
		}else if (tempLayer.id.indexOf("topmenu")!= -1){//changed layers close others
			document.getElementById(tempLayer.id).style.display = "none";			
			document.getElementById(tempLayer.id).style.color = fontcol2;
		}else if ((tempLayer.id.indexOf("top1")!= -1) && (tempLayer!=theLayer)){
			document.getElementById(tempLayer.id).style.color = fontcol2;
		}
	}
}

function donothing()
{
	//Do Nothing
} 

function cOn(roll)
{
	if (document.getElementById)
		roll.style.backgroundColor="#F0F0F0";
}

function cOut(roll)
{
	if (document.getElementById)
		roll.style.backgroundColor="";
}

var win6 = null;

function NewWindow(mypage,myname,w,h)
{
	if (win6 && !win6.closed)
		win6.close();
	openit5(mypage,myname,w,h);
}

function openit5(mypage,myname,w,h)
{
	var t = ((self.screen.availHeight/2) - (h/2));
	var l = ((self.screen.availWidth/2) - (w/2));
	settings ='width=' + w + ',height=' + h + ',left=' + l + ',top=' + t +
		',toolbar=no,border=0,location=no,directories=no,status=yes' +
		',menubar=no,scrollbars=no,copyhistory=yes,resizable=yes,dependent=yes'
	win6 = window.open(mypage,myname,settings);
}



function y2k(number)
{
	return (number < 1000) ? number + 1900 : number; 
}

var reason = '';

// checks if date passed is in valid dd/mm/yyyy format
function isValidDate (myDate,sep) {
	var myDate
	if (myDate.substring(1,2) == sep)
		myDate = "0" + myDate;
	
	if (myDate.substring(4,5) == sep)
		myDate  = myDate.substring(0,3)+ "0" + myDate.substring(3,9);
	
	if (myDate.length == 10)
	{
		if (myDate.substring(2,3) == sep && myDate.substring(5,6) == sep)
		{
			var date = myDate.substring(0,2);
			var month = myDate.substring(3,5);
			var year  = myDate.substring(6,10);
			var test = new Date(year,month-1,date);
			
			if (year == y2k(test.getYear()) && (month-1 == test.getMonth()) && (date == test.getDate()))
			{
				reason = '';
				return true;
			}else{
				reason = 'a valid format but an invalid date';
				return false;
			}
		}else{
			reason = 'invalid spearators';
			return false;
		}
	}else{
		reason = 'an invalid length';
		return false;
	}
}



function verifyPassword(which)
{
	if (which.reqpasPassword.value != which.reqpas2Password.value)
	{
		which.reqpasPassword.value = ""
		which.reqpas2Password.value = ""
		which.reqpasPassword.focus();
		alert("Your password did not match the verification password.  Please re-enter the password.");
		return false;
	}
	return true;
}

function confirmDelete(delUrl) {
  if (confirm("Are you sure you want to delete this item")) {
    document.location = delUrl;
  }
}

function confirmreset(fname,lname) {
  if (confirm("Are you sure you want reset the password for " + fname + " " + lname )) {
  return true;
  }
  else
  
  {return false;}
}

function GetImage(img_name,image) {
document.images[img_name].src=image;


}

var myWidth = 0, myHeight = 0;
var scrOfX = 0, scrOfY = 0;

function getWindowSize() {
	getScrollXY()
	if( typeof( window.innerWidth ) == 'number' ) 
	{
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if(document.documentElement &&	( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	//window.alert( 'Width = ' + myWidth );
	//window.alert( 'Height = ' + myHeight );
}
	
function getScrollXY() {
	scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} else if( document.documentElement &&
		( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			//IE6 standards compliant mode
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
	}
}

var hintShimIFrame

function showLessonHint(hint_id){
	//try{
		var hint = document.getElementById(hint_id);
		hint.style.zIndex  = 50;
		if(!hintShimIFrame)
		{
			hintShimIFrame = document.createElement("IFRAME");
			hintShimIFrame.style.display = "none";
			hintShimIFrame.style.position = "absolute";
			hintShimIFrame.style.borderWidth  = 0;
			hintShimIFrame.style.left = 0;
			hintShimIFrame.style.top = 0;
			hintShimIFrame.style.zIndex  = 49;
			hint.parentNode.appendChild(hintShimIFrame);
		}
		hint.style.display = "block";
		if(hint.style.position == "absolute")
		{
			getWindowSize();
			hint.style.left = ((myWidth - hint.offsetWidth)/2) + scrOfX;
			hint.style.top = ((myHeight - hint.offsetHeight)/2) + scrOfY;
			hintShimIFrame.style.left = hint.style.left;
			hintShimIFrame.style.top = hint.style.top;
			hintShimIFrame.style.width = hint.offsetWidth;
			hintShimIFrame.style.height = hint.offsetHeight;
			hintShimIFrame.style.display = "block";
		}
	//}catch(e){window.status+=e.message}
}
function closeLessonHint(hint_id){
	try{
		hintShimIFrame.style.display = "none";
		document.getElementById(hint_id).style.display = "none"
	}catch(e){}
}
	
function acceptcourse(accUrl, partnername) {
  if (confirm(partnername+" has accepted your registration, please click on the “OK” button to start the course and access the course materials.")) {
    document.location = accUrl;
  }
}



	//As the onkeypress for an input this will allow a select box with the id strSelectInput to 
	//have its selected option follow what is being typed
	function selectTool(textInput, strSelectInput)
	{
		var SelectInput = document.getElementById(strSelectInput);
		var TextInputValue = (textInput.value + String.fromCharCode(window.event.keyCode)).toLowerCase();
		if (!SelectInput) return;
		for(var i = 0; i<SelectInput.options.length; i++)
		{
			if(TextInputValue == SelectInput.options[i].text.substring(0,TextInputValue.length).toLowerCase())
			{
				SelectInput.selectedIndex = i;
				return false;
			}
		}
	}

	var inputCancelIndex = 0;

	//As the onkeypress for a selectbox this will allow the selection to follow continuous typing
	function selectHiddenTool(SelectInput)
	{
		if(typeof(SelectInput.keyFind) != "string") SelectInput.keyFind = "";
		var TextInputValue = (String.fromCharCode(window.event.keyCode)).toLowerCase();
		SelectInput.keyFind += TextInputValue;
		TextInputValue = SelectInput.keyFind.toLowerCase();
		find_Option:
		for(var i = 0; i<SelectInput.options.length; i++)
		{
			if(TextInputValue == SelectInput.options[i].text.substring(0,TextInputValue.length).toLowerCase())
			{
				SelectInput.selectedIndex = i;
				break find_Option;
			}
		}
		setTimeout("if(inputCancelIndex == " + ++inputCancelIndex + ") document.getElementById(\"" + SelectInput.id + "\").keyFind = \"\"", 1000);
		window.event.returnValue  = false;
	}

	//This will invert checkbox selection on a page
	function invertSelection()
	{
		var theBoxes = document.getElementsByTagName("INPUT");
		for (var i = 0; i < theBoxes.length; i++) if(theBoxes[i].type == "checkbox") theBoxes[i].checked = !theBoxes[i].checked;
	}
