
var holdingtext = new Array()
var holdinglayername = new Array ()

function returnLink(n) {
this.linkForm.Resource_URL.value=n;
}
function openlinkwindow(coursename) {
url = 'CourseFileTreeDisplay.asp?CourseName=' + coursename;
WinId = window.open(url,'linkswindow','width=300,height=400,scrollbars=1,status=1');
if (!WinId.opener) WinId.opener=self;
}


function ToggleTips()
{
ToggleTipsWin= open ("help_toggletips.asp", "ToggleTips", "status=no,toolbar=no,menubar=no,titlebar=no,location=no,directories=no,location=no,width=10,height=10");
}
function OpenFlashWindow(url)
{
myWin= open ("intro_video1.asp", "flashwindow", "status=no,toolbar=no,menubar=no,titlebar=no,location=no,directories=no,location=no,width=550,height=400");
}
function OpenHelpWindow() {

OpenAdminEditWindow('help/default.asp', 830, 600)
}
function OpenAdmin()
{
myWin= open ("admin_frameset.asp", "AdminpopWindow", "status=no,toolbar=no,menubar=no,titlebar=no,location=yes,directories=no,location=no,width=780,height=500");
}
function OpenLimitedWindow(url)
{
myWin= open (url, "popWindow3", "status=no,toolbar=no,menubar=no,titlebar=no,location=no,directories=no,location=no,width=550,height=400");
}
function OpenAdminEditWindow(url, x, y)
{
myWin=window.open (url, "popWindow1", "status=no,toolbar=no,menubar=no,titlebar=no,location=yes,scrollbars=yes,directories=no,location=no,width=" + x + ",height=" + y);
myWin.focus()
} 
function OpenWindow(url, x, y)
{
myWin=window.open (url, "popWindow1", "status=no,toolbar=no,menubar=no,titlebar=no,location=yes,directories=no,location=no,width=" + x + ",height=" + y);
myWin.focus()
} 
function OpenNormalWindow(url)
{
myWin= open (url, "popWindow2", "status=yes,toolbar=yes,menubar=yes,titlebar=no,location=yes,directories=no,width=780,height=500,resizable=yes,scrollbars=yes");
}
function ConfirmRedirect (url, message)
{
    var answer = confirm(message)
     if (answer){
     location.href = url;
     }
}
function CallExternalPage (url) {

  try
	{
	// Firefox, Opera 8.0+, Safari
	var http=new XMLHttpRequest();
	}
  catch (e)
	{
	// Internet Explorer
	try
	  {
	  var http=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	catch (e)
	  {
	  try
		{
		var http=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  catch (e)
		{
		alert("Your browser does not support AJAX!");
		}
	  }
	}

  http.open("GET", url, true);

  http.send(null);
}
function OpenGeneralFolder()
{
OpenWindow('foldercontrols_frameset.asp?GeneralFiles=1', 700, 400)
}

function CallExternalPageIntoLayer (url,layername, hourglass,confirmdialogue,confirmtext) {
	var http;
	var httplayer;
	if (confirmdialogue == 1) {
		var answer = confirm(confirmtext)
	}
	else {
		var answer = true;
	}
	if (answer) {
		
			  try
				{
				// Firefox, Opera 8.0+, Safari
				var http=new XMLHttpRequest();
				}
			  catch (e)
				{
				// Internet Explorer
				try
				  {
				  var http=new ActiveXObject("Msxml2.XMLHTTP");
				  }
				catch (e)
				  {
				  try
					{
					var http=new ActiveXObject("Microsoft.XMLHTTP");
					}
				  catch (e)
					{
					alert("Your browser does not support AJAX!");
					}
				  }
				}		
		httplayer = document.getElementById(layername); 
		httplayer.style.display = 'block';
		if (hourglass == 1) {	
		httplayer.innerHTML = "<img src='images/clocks.gif' />";
		}
		http.onreadystatechange = function () {
		  if (http.readyState == 4) {
			httplayer.innerHTML = http.responseText;
		  }
		}
		http.open("GET", url, true);
		http.send(null);
	}
}

function showHideContent(id)
{
	var elem = document.getElementById(id);
	
	if (elem) 
	{
	  if (elem.style.visibility=='hidden') 
	  {
		elem.style.display = 'block';
		elem.style.visibility = 'visible';
	  } 
	  else if (elem.style.visibility=='visible')
	  {
		elem.style.display = 'none';
		elem.style.visibility = 'hidden';
	  }
	}
}  

function showHideContentadd(id,url,id1,url1)
{
	var elem = document.getElementById(id);
	
	if (elem) 
	{
	  if (elem.style.visibility=='hidden') 
	  {
		elem.style.display = 'block';
		elem.style.visibility = 'visible';
		CallExternalPageIntoLayer(url,id, 1, 0, '');
	  } 
	  else if (elem.style.visibility=='visible')
	  {
		elem.style.display = 'none';
		elem.style.visibility = 'hidden';
	  }
	}
	
	var elem = document.getElementById(id1);
	
	if (elem) 
	{
	  if (elem.style.visibility=='hidden') 
	  {
		elem.style.display = 'block';
		elem.style.visibility = 'visible';
		CallExternalPageIntoLayer(url1,id1, 1, 0, '');
	  } 
	  else if (elem.style.visibility=='visible')
	  {
		elem.style.display = 'none';
		elem.style.visibility = 'hidden';
	  }
	}	
}  

function toggleimage(id, toggleA, toggleB) {
  var elem = document.getElementById(id);
	if (elem) 
	{
	  if (elem.src.indexOf(toggleA) > 0) 
	  {
		elem.src = toggleB;
	  } 
	  else if (elem.src.indexOf(toggleB) > 0)
	  {
		elem.src = toggleA;
	  }
	}
}

function checkifaddtextbox (mainrecid, layername, textboxname, submittext, holdingvar) {
	if (mainrecid==-1) {
		var elem = document.getElementById(layername);
		if (elem) {
			holdingtext[holdingvar] = elem.innerHTML
			holdinglayername[holdingvar] = layername
			elem.innerHTML = "<input name='" + textboxname + "' size='20' />&nbsp;<input name='Submit' type='submit' value='" + submittext + "'>&nbsp;<input name='Button' type='button' value='Cancel' onClick='canceltextbox(" + holdingvar + ")'>";
		}
	}

}

function canceltextbox (holdingvar, layername) {
	var elem = document.getElementById(holdinglayername[holdingvar]);
	if (elem) {
		elem.innerHTML = holdingtext[holdingvar]
	}
}

function writeeventselect (unitid, layername) {
	if (unitid > 0) {
		url = "xmlinterface.asp?XMLCommandType=19&UnitID=" + unitid + "&EventID=0"
		CallExternalPageIntoLayer(url,layername, 1,0,"")
	}
}

function showactivitydetails (eventid, enrolmentid) {
	CallExternalPageIntoLayer('xmlinterface.asp?xmlcommandtype=21&eventid=' + eventid + '&enrolmentid=' + enrolmentid,'activitydetails', 0,0,'')
	CallExternalPageIntoLayer('xmlinterface.asp?xmlcommandtype=22&eventid=' + eventid,'activitydetailstitle', 0,0,'')
	var elem = document.getElementById("activitydetails_holder");	
	if (elem) {
		elem.style.display = 'block';
		elem.style.visibility = 'visible';
		elem.style.top = 130;
		elem.style.left = 60;
	}

}
function closeactivitydetails () {
	var elem = document.getElementById("activitydetails_holder");
	if (elem) {
		elem.style.display = 'none';
		elem.style.visibility = 'hidden';
	}
}

function showuserdetails () {
	CallExternalPageIntoLayer('xmlinterface.asp?xmlcommandtype=24','userdetails', 0,0,'')
	var elem = document.getElementById("userdetails_holder");	
	if (elem) {
		elem.style.display = 'block';
		elem.style.visibility = 'visible';
		elem.style.top = 130;
		elem.style.left = 60;
	}
}

function closeuserdetails () {
	var elem = document.getElementById("userdetails_holder");
	if (elem) {
		elem.style.display = 'none';
		elem.style.visibility = 'hidden';
	}
}
  
function makePOSTRequest(url, parameters) {

}

function postmydetails(url) {
	var emailaddress
	emailaddress = document.getElementById("User_EmailAddress").value
	if (document.getElementById("User_Password").value != document.getElementById("User_Password_Confirm").value) {
		alert('The two passwords you have entered do not match')
	} else if (emailaddress.match("@") == null) {
		alert('You have not entered a valid e-mail address.')
	} else if (document.getElementById("User_Password").value == "") {
		alert('Your password cannot be blank')
	} else {
		var createdetailsfield = new Array()
		var poststr
		var x
		createdetailsfield[0] = "User_FirstName";
		createdetailsfield[1] = "User_LastName";
		createdetailsfield[2] = "User_EmailAddress";
		createdetailsfield[3] = "User_TelephoneNo";
		createdetailsfield[4] = "User_Password";
		poststr = ""
		for (x in createdetailsfield) {
			if (x > 0) {
				poststr = poststr + "&"
			}
			poststr = poststr + createdetailsfield[x] + "=" + document.getElementById(createdetailsfield[x]).value
		}

			  try
				{
				// Firefox, Opera 8.0+, Safari
				var http_request=new XMLHttpRequest();
				}
			  catch (e)
				{
				// Internet Explorer
				try
				  {
				  var http_request=new ActiveXObject("Msxml2.XMLHTTP");
				  }
				catch (e)
				  {
				  try
					{
					var http_request=new ActiveXObject("Microsoft.XMLHTTP");
					}
				  catch (e)
					{
					alert("Your browser does not support AJAX!");
					}
				  }
				}
		//alert(poststr)
		http_request.open('POST', url, true);
		http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http_request.onreadystatechange = function () {
			  if (http_request.readyState == 4) {
				closeuserdetails();
				alert("Changes Saved")
			  }
			}
		http_request.send(poststr);
	}
}
