/* contact us page */
function contactUs()
{
	var form = document.pageform;

	form.hidValAction.value = "contactus";
	form.action="contactus.html";

	var name = form.txtName.value;
	var street  = form.txtStreet .value;
	var suburb = form.txtSuburb.value;
	var town = form.txtTown.value;
	var post = form.txtPost.value;
	var phone = form.txtPhone.value;
	var email = form.txtEmail.value;
	var message = form.txtMessage.value;
	var sub = form.txtSubject.value;


	if ((name==null)||(name=="")){
		alert("Please Enter your Name");
		form.txtName.focus();
		return false;
	}
	if ((street==null)||(street=="")){
		alert("Please Enter your Street Address");
		form.txtStreet.focus();
		return false;
	}
	if ((town==null)||(town=="")){
		alert("Please Enter your City / Town");
		form.txtTown.focus();
		return false;
	}
	if ((post==null)||(post=="")){
		alert("Please Enter your Post Code");
		form.txtPost.focus();
		return false;
	}
	if ((phone==null)||(phone=="")){
		alert("Please Enter your Daytime Phone Number");
		form.txtPhone.focus();
		return false;
	}

	if ((email==null)||(email=="")){
		alert("Please Enter your Email ID");
		form.txtEmail.focus();
		return false
	}
	if (validateEmail(email)==false){
		alert("Invalid E-mail ID");
		form.txtEmail.focus();
		return false
	}
	if ((sub==null)||(sub=="")){
		alert("Please Enter Subject");
		form.txtSubject.focus();
		return false;
	}
	if ((message==null)||(message=="")){
		alert("Please Enter Message");
		form.txtMessage.focus();
		return false;
	}
		form.submit();

}
/* joinDatabase page */
function joinDatabase()
{
	var form = document.pageform;

	form.hidValAction.value = "joinDatabase";

	var fName = form.txtfName.value;
	var lName = form.txtlName.value;
	var street  = form.txtStreet .value;
	var town = form.txtTown.value;
	var post = form.txtPost.value;
	var email = form.txtEmail.value;
	var phone = form.txtPhone.value;
	var cellphone  = form.txtCellPhone.value;
	var occupation = form.txtOccupation.value;
	var hearAbout = form.txtHearAbout.value;
	var courseInterested = form.txtCourseInterested.value;
	//var prospectus = form.radProspectus.value;
	var compTraining = form.txtCompTraining.value;
	var otherCourses = form.txtOtherCourses.value;

	if ((fName==null)||(fName=="")){
		alert("Please Enter your First Name");
		form.txtfName.focus();
		return false;
	}
	if ((lName==null)||(lName=="")){
		alert("Please Enter your Last Name");
		form.txtlName.focus();
		return false;
	}
	if ((street==null)||(street=="")){
		alert("Please Enter your Street Address");
		form.txtStreet.focus();
		return false;
	}
	if ((town==null)||(town=="")){
		alert("Please Enter your City / Town");
		form.txtTown.focus();
		return false;
	}
	if ((post==null)||(post=="")){
		alert("Please Enter your Post Code");
		form.txtPost.focus();
		return false;
	}
	if ((email==null)||(email=="")){
		alert("Please Enter your Email ID");
		form.txtEmail.focus();
		return false
	}
	if (validateEmail(email)==false){
		alert("Invalid E-mail ID");
		form.txtEmail.focus();
		return false
	}
	if ((phone==null)||(phone=="")){
		alert("Please Enter your Daytime Phone Number");
		form.txtPhone.focus();
		return false;
	}
	if ((cellphone==null)||(cellphone=="")){
		alert("Please Enter your Cell Phone Number");
		form.txtCellPhone.focus();
		return false;
	}


	if ((hearAbout=="")||(courseInterested=="")||(compTraining=="")||(otherCourses=="")){
		alert("Please fill required field");
		return false;
	}
		form.submit();

}


function validateEmail(value){
   var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
   return emailPattern.test(value);
 }

 // function to catch enter key event.eis event and functionName is the name of function which should be called when enter key pressed
function catchEnterKey(e)
{
    var key;
	// if IE
    if (window.event){
		// catch the event
        e = window.event;
		key = e.keyCode;
    }else if(e.which){
		// netscape
		key = e.which;
	}
	// if key pressed is enter key
	if ( key == '13' ){
		//continueOrder();
		showSearchResults(1);
	}
}


 /*******search********/

/**
* This fuction is used to
* show all search  results
*
* @access   public
* @param    null
*
* @return   null
*/
function showSearchResults(startAt)
{
    if(document.getElementById("txtSearch").value.match(/^ *$/)){
		alert("Plaese enter search keyword");
		document.getElementById("txtSearch").focus();
		return;
    }else if (document.getElementById("txtSearch").value =="KEYWORD"){
        alert("Plaese enter search keyword");
        document.getElementById("txtSearch").focus();
        return;
    }
	searchTxt=document.getElementById("txtSearch").value;
	document.frmSearch.action = "search-results.html?q="+searchTxt+"&p="+startAt;
	location.replace("search-results.html?q="+searchTxt+"&p="+startAt);

}

 /**************/


/****************dhtml window.js *********************/
// -------------------------------------------------------------------
// DHTML Window Widget- By Dynamic Drive, available at: http://www.dynamicdrive.com
// v1.0: Script created Feb 15th, 07'
// v1.01: Feb 21th, 07' (see changelog.txt)
// v1.02: March 26th, 07' (see changelog.txt)
// v1.03: May 5th, 07' (see changelog.txt)
// v1.1:  Oct 29th, 07' (see changelog.txt)
// -------------------------------------------------------------------

var dhtmlwindow={
imagefiles:['', 'images/close.gif', '', ''], //Path to 4 images used by script, in that order
ajaxbustcache: true, //Bust caching when fetching a file via Ajax?
ajaxloadinghtml: '<b>Loading Page. Please wait...</b>', //HTML to show while window fetches Ajax Content?

minimizeorder: 0,
zIndexvalue:100,
tobjects: [], //object to contain references to dhtml window divs, for cleanup purposes
lastactivet: {}, //reference to last active DHTML window

init:function(t){
	var domwindow=document.createElement("div") //create dhtml window div
	domwindow.id=t
	domwindow.className="dhtmlwindow"
	var domwindowdata=''
	domwindowdata='<div class="drag-handle">'
	domwindowdata+='DHTML Window <div class="drag-controls"><img src="'+this.imagefiles[0]+'" title="Minimize" /><img src="'+this.imagefiles[1]+'" title="Close" /></div>'
	domwindowdata+='</div>'
	domwindowdata+='<div class="drag-contentarea"></div>'
	domwindowdata+='<div class="drag-statusarea"><div class="drag-resizearea" style="background: transparent url('+this.imagefiles[3]+') top right no-repeat;">&nbsp;</div></div>'
	domwindowdata+='</div>'
	domwindow.innerHTML=domwindowdata
	document.getElementById("dhtmlwindowholder").appendChild(domwindow)
	//this.zIndexvalue=(this.zIndexvalue)? this.zIndexvalue+1 : 100 //z-index value for DHTML window: starts at 0, increments whenever a window has focus
	var t=document.getElementById(t)
	var divs=t.getElementsByTagName("div")
	for (var i=0; i<divs.length; i++){ //go through divs inside dhtml window and extract all those with class="drag-" prefix
		if (/drag-/.test(divs[i].className))
			t[divs[i].className.replace(/drag-/, "")]=divs[i] //take out the "drag-" prefix for shorter access by name
	}
	//t.style.zIndex=this.zIndexvalue //set z-index of this dhtml window
	t.handle._parent=t //store back reference to dhtml window
	t.resizearea._parent=t //same
	t.controls._parent=t //same
	t.onclose=function(){return true} //custom event handler "onclose"
	t.onmousedown=function(){dhtmlwindow.setfocus(this)} //Increase z-index of window when focus is on it
	t.handle.onmousedown=dhtmlwindow.setupdrag //set up drag behavior when mouse down on handle div
	t.resizearea.onmousedown=dhtmlwindow.setupdrag //set up drag behavior when mouse down on resize div
	t.controls.onclick=dhtmlwindow.enablecontrols
	t.show=function(){dhtmlwindow.show(this)} //public function for showing dhtml window
	t.hide=function(){dhtmlwindow.hide(this)} //public function for hiding dhtml window
	t.close=function(){dhtmlwindow.close(this)} //public function for closing dhtml window (also empties DHTML window content)
	t.setSize=function(w, h){dhtmlwindow.setSize(this, w, h)} //public function for setting window dimensions
	t.moveTo=function(x, y){dhtmlwindow.moveTo(this, x, y)} //public function for moving dhtml window (relative to viewpoint)
	t.isResize=function(bol){dhtmlwindow.isResize(this, bol)} //public function for specifying if window is resizable
	t.isScrolling=function(bol){dhtmlwindow.isScrolling(this, bol)} //public function for specifying if window content contains scrollbars
	t.load=function(contenttype, contentsource, title){dhtmlwindow.load(this, contenttype, contentsource, title)} //public function for loading content into window
	this.tobjects[this.tobjects.length]=t
	return t //return reference to dhtml window div
},

open:function(t, contenttype, contentsource, title, attr, recalonload){
	var d=dhtmlwindow //reference dhtml window object
	function getValue(Name){
		var config=new RegExp(Name+"=([^,]+)", "i") //get name/value config pair (ie: width=400px,)
		return (config.test(attr))? parseInt(RegExp.$1) : 0 //return value portion (int), or 0 (false) if none found
	}
	if (document.getElementById(t)==null) //if window doesn't exist yet, create it
		t=this.init(t) //return reference to dhtml window div
	else
		t=document.getElementById(t)
	this.setfocus(t)
	t.setSize(getValue(("width")), (getValue("height"))) //Set dimensions of window
	var xpos=getValue("center")? "middle" : getValue("left") //Get x coord of window
	var ypos=getValue("center")? "middle" : getValue("top") //Get y coord of window
	//t.moveTo(xpos, ypos) //Position window
	if (typeof recalonload!="undefined" && recalonload=="recal" && this.scroll_top==0){ //reposition window when page fully loads with updated window viewpoints?
		if (window.attachEvent && !window.opera) //In IE, add another 400 milisecs on page load (viewpoint properties may return 0 b4 then)
			this.addEvent(window, function(){setTimeout(function(){t.moveTo(xpos, ypos)}, 400)}, "load")
		else
			this.addEvent(window, function(){t.moveTo(xpos, ypos)}, "load")
	}
	t.isResize(getValue("resize")) //Set whether window is resizable
	t.isScrolling(getValue("scrolling")) //Set whether window should contain scrollbars
	t.style.visibility="visible"
	t.style.display="block"
	t.contentarea.style.display="block"
	t.moveTo(xpos, ypos) //Position window
	t.load(contenttype, contentsource, title)
	if (t.state=="minimized" && t.controls.firstChild.title=="Restore"){ //If window exists and is currently minimized?
		t.controls.firstChild.setAttribute("src", dhtmlwindow.imagefiles[0]) //Change "restore" icon within window interface to "minimize" icon
		t.controls.firstChild.setAttribute("title", "Minimize")
		t.state="fullview" //indicate the state of the window as being "fullview"
	}
	return t
},

setSize:function(t, w, h){ //set window size (min is 150px wide by 100px tall)
	t.style.width=Math.max(parseInt(w), 150)+"px"
	t.contentarea.style.height=Math.max(parseInt(h), 100)+"px"
},

moveTo:function(t, x, y){ //move window. Position includes current viewpoint of document
	this.getviewpoint() //Get current viewpoint numbers
	t.style.left=(x=="middle")? this.scroll_left+(this.docwidth-t.offsetWidth)/2+"px" : this.scroll_left+parseInt(x)+"px"
	t.style.top=(y=="middle")? this.scroll_top+(this.docheight-t.offsetHeight)/2+"px" : this.scroll_top+parseInt(y)+"px"
},

isResize:function(t, bol){ //show or hide resize inteface (part of the status bar)
	t.statusarea.style.display=(bol)? "block" : "none"
	t.resizeBool=(bol)? 1 : 0
},

isScrolling:function(t, bol){ //set whether loaded content contains scrollbars
	t.contentarea.style.overflow=(bol)? "auto" : "hidden"
},

load:function(t, contenttype, contentsource, title){ //loads content into window plus set its title (3 content types: "inline", "iframe", or "ajax")
	if (t.isClosed){
		alert("DHTML Window has been closed, so no window to load contents into. Open/Create the window again.")
		return
	}
	var contenttype=contenttype.toLowerCase() //convert string to lower case
	if (typeof title!="undefined")
		t.handle.firstChild.nodeValue=title
	if (contenttype=="inline")
		t.contentarea.innerHTML=contentsource
	else if (contenttype=="div"){
		var inlinedivref=document.getElementById(contentsource)
		t.contentarea.innerHTML=(inlinedivref.defaultHTML || inlinedivref.innerHTML) //Populate window with contents of inline div on page
		if (!inlinedivref.defaultHTML)
			inlinedivref.defaultHTML=inlinedivref.innerHTML //save HTML within inline DIV
		inlinedivref.innerHTML="" //then, remove HTML within inline DIV (to prevent duplicate IDs, NAME attributes etc in contents of DHTML window
		inlinedivref.style.display="none" //hide that div
	}
	else if (contenttype=="iframe"){
		t.contentarea.style.overflow="hidden" //disable window scrollbars, as iframe already contains scrollbars
		if (!t.contentarea.firstChild || t.contentarea.firstChild.tagName!="IFRAME") //If iframe tag doesn't exist already, create it first
			t.contentarea.innerHTML='<iframe src="" style="margin:0; padding:0; width:100%; height: 100%" name="_iframe-'+t.id+'"></iframe>'
		window.frames["_iframe-"+t.id].location.replace(contentsource) //set location of iframe window to specified URL
		}
	else if (contenttype=="ajax"){
		this.ajax_connect(contentsource, t) //populate window with external contents fetched via Ajax
	}
	t.contentarea.datatype=contenttype //store contenttype of current window for future reference
},

setupdrag:function(e){
	var d=dhtmlwindow //reference dhtml window object
	var t=this._parent //reference dhtml window div
	d.etarget=this //remember div mouse is currently held down on ("handle" or "resize" div)
	var e=window.event || e
	d.initmousex=e.clientX //store x position of mouse onmousedown
	d.initmousey=e.clientY
	d.initx=parseInt(t.offsetLeft) //store offset x of window div onmousedown
	d.inity=parseInt(t.offsetTop)
	d.width=parseInt(t.offsetWidth) //store width of window div
	d.contentheight=parseInt(t.contentarea.offsetHeight) //store height of window div's content div
	if (t.contentarea.datatype=="iframe"){ //if content of this window div is "iframe"
		t.style.backgroundColor="#F8F8F8" //colorize and hide content div (while window is being dragged)
		t.contentarea.style.visibility="hidden"
	}
	document.onmousemove=d.getdistance //get distance travelled by mouse as it moves
	document.onmouseup=function(){
		if (t.contentarea.datatype=="iframe"){ //restore color and visibility of content div onmouseup
			t.contentarea.style.backgroundColor="white"
			t.contentarea.style.visibility="visible"
		}
		d.stop()
	}
	return false
},

getdistance:function(e){
	var d=dhtmlwindow
	var etarget=d.etarget
	var e=window.event || e
	d.distancex=e.clientX-d.initmousex //horizontal distance travelled relative to starting point
	d.distancey=e.clientY-d.initmousey
	if (etarget.className=="drag-handle") //if target element is "handle" div
		d.move(etarget._parent, e)
	else if (etarget.className=="drag-resizearea") //if target element is "resize" div
		d.resize(etarget._parent, e)
	return false //cancel default dragging behavior
},

getviewpoint:function(){ //get window viewpoint numbers
	var ie=document.all && !window.opera
	var domclientWidth=document.documentElement && parseInt(document.documentElement.clientWidth) || 100000 //Preliminary doc width in non IE browsers
	this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
	this.scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
	this.scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
	this.docwidth=(ie)? this.standardbody.clientWidth : (/Safari/i.test(navigator.userAgent))? window.innerWidth : Math.min(domclientWidth, window.innerWidth-16)
	this.docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
},

rememberattrs:function(t){ //remember certain attributes of the window when it's minimized or closed, such as dimensions, position on page
	this.getviewpoint() //Get current window viewpoint numbers
	t.lastx=parseInt((t.style.left || t.offsetLeft))-dhtmlwindow.scroll_left //store last known x coord of window just before minimizing
	t.lasty=parseInt((t.style.top || t.offsetTop))-dhtmlwindow.scroll_top
	t.lastwidth=parseInt(t.style.width) //store last known width of window just before minimizing/ closing
},

move:function(t, e){
	t.style.left=dhtmlwindow.distancex+dhtmlwindow.initx+"px"
	t.style.top=dhtmlwindow.distancey+dhtmlwindow.inity+"px"
},

resize:function(t, e){
	t.style.width=Math.max(dhtmlwindow.width+dhtmlwindow.distancex, 150)+"px"
	t.contentarea.style.height=Math.max(dhtmlwindow.contentheight+dhtmlwindow.distancey, 100)+"px"
},

enablecontrols:function(e){
	var d=dhtmlwindow
	var sourceobj=window.event? window.event.srcElement : e.target //Get element within "handle" div mouse is currently on (the controls)
	if (/Minimize/i.test(sourceobj.getAttribute("title"))) //if this is the "minimize" control
		d.minimize(sourceobj, this._parent)
	else if (/Restore/i.test(sourceobj.getAttribute("title"))) //if this is the "restore" control
		d.restore(sourceobj, this._parent)
	else if (/Close/i.test(sourceobj.getAttribute("title"))) //if this is the "close" control
		d.close(this._parent)
	return false
},

minimize:function(button, t){
	dhtmlwindow.rememberattrs(t)
	button.setAttribute("src", dhtmlwindow.imagefiles[2])
	button.setAttribute("title", "Restore")
	t.state="minimized" //indicate the state of the window as being "minimized"
	t.contentarea.style.display="none"
	t.statusarea.style.display="none"
	if (typeof t.minimizeorder=="undefined"){ //stack order of minmized window on screen relative to any other minimized windows
		dhtmlwindow.minimizeorder++ //increment order
		t.minimizeorder=dhtmlwindow.minimizeorder
	}
	t.style.left="10px" //left coord of minmized window
	t.style.width="200px"
	var windowspacing=t.minimizeorder*10 //spacing (gap) between each minmized window(s)
	t.style.top=dhtmlwindow.scroll_top+dhtmlwindow.docheight-(t.handle.offsetHeight*t.minimizeorder)-windowspacing+"px"
},

restore:function(button, t){
	dhtmlwindow.getviewpoint()
	button.setAttribute("src", dhtmlwindow.imagefiles[0])
	button.setAttribute("title", "Minimize")
	t.state="fullview" //indicate the state of the window as being "fullview"
	t.style.display="block"
	t.contentarea.style.display="block"
	if (t.resizeBool) //if this window is resizable, enable the resize icon
		t.statusarea.style.display="block"
	t.style.left=parseInt(t.lastx)+dhtmlwindow.scroll_left+"px" //position window to last known x coord just before minimizing
	t.style.top=parseInt(t.lasty)+dhtmlwindow.scroll_top+"px"
	t.style.width=parseInt(t.lastwidth)+"px"
},


close:function(t){

	try{
		var closewinbol=t.onclose()
	}
	catch(err){ //In non IE browsers, all errors are caught, so just run the below
		var closewinbol=true
 }
	finally{ //In IE, not all errors are caught, so check if variable isn't defined in IE in those cases
		if (typeof closewinbol=="undefined"){
			alert("An error has occured somwhere inside your \"onclose\" event handler")
			var closewinbol=true
		}
	}
	if (closewinbol){ //if custom event handler function returns true
		if (t.state!="minimized") //if this window isn't currently minimized
			dhtmlwindow.rememberattrs(t) //remember window's dimensions/position on the page before closing
		if (window.frames["_iframe-"+t.id]) //if this is an IFRAME DHTML window
			window.frames["_iframe-"+t.id].location.replace("about:blank")
		else
			t.contentarea.innerHTML=""
		t.style.display="none"
		t.isClosed=true //tell script this window is closed (for detection in t.show())
	}
	return closewinbol
},


setopacity:function(targetobject, value){ //Sets the opacity of targetobject based on the passed in value setting (0 to 1 and in between)
	if (!targetobject)
		return
	if (targetobject.filters && targetobject.filters[0]){ //IE syntax
		if (typeof targetobject.filters[0].opacity=="number") //IE6
			targetobject.filters[0].opacity=value*100
		else //IE 5.5
			targetobject.style.filter="alpha(opacity="+value*100+")"
		}
	else if (typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax
		targetobject.style.MozOpacity=value
	else if (typeof targetobject.style.opacity!="undefined") //Standard opacity syntax
		targetobject.style.opacity=value
},

setfocus:function(t){ //Sets focus to the currently active window

	this.zIndexvalue++
	t.style.zIndex=this.zIndexvalue
	t.isClosed=false //tell script this window isn't closed (for detection in t.show())
	this.setopacity(this.lastactivet.handle, 0.5) //unfocus last active window
	this.setopacity(t.handle, 1) //focus currently active window
	this.lastactivet=t //remember last active window
},


show:function(t){
	if (t.isClosed){
		alert("DHTML Window has been closed, so nothing to show. Open/Create the window again.")
		return
	}
	if (t.lastx) //If there exists previously stored information such as last x position on window attributes (meaning it's been minimized or closed)
		dhtmlwindow.restore(t.controls.firstChild, t) //restore the window using that info
	else
		t.style.display="block"
	this.setfocus(t)
	t.state="fullview" //indicate the state of the window as being "fullview"
},

hide:function(t){
	t.style.display="none"
},

ajax_connect:function(url, t){
	var page_request = false
	var bustcacheparameter=""
	if (window.XMLHttpRequest) // if Mozilla, IE7, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE6 or below
		try {
		page_request = new ActiveXObject("Msxml2.XMLHTTP")
		}
		catch (e){
			try{
			page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
		}
	}
	else
		return false
	t.contentarea.innerHTML=this.ajaxloadinghtml
	page_request.onreadystatechange=function(){dhtmlwindow.ajax_loadpage(page_request, t)}
	if (this.ajaxbustcache) //if bust caching of external page
		bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
	page_request.open('GET', url+bustcacheparameter, true)
	page_request.send(null)
},

ajax_loadpage:function(page_request, t){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
	t.contentarea.innerHTML=page_request.responseText
	}
},


stop:function(){
	dhtmlwindow.etarget=null //clean up
	document.onmousemove=null
	document.onmouseup=null
},

addEvent:function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false)
	else if (target.attachEvent)
		target.attachEvent(tasktype, functionref)
},

cleanup:function(){
	for (var i=0; i<dhtmlwindow.tobjects.length; i++){
		dhtmlwindow.tobjects[i].handle._parent=dhtmlwindow.tobjects[i].resizearea._parent=dhtmlwindow.tobjects[i].controls._parent=null
	}
	window.onload=null
}

} //End dhtmlwindow object

document.write('<div id="dhtmlwindowholder"><span style="display:none">.</span></div>') //container that holds all dhtml window divs on page
window.onunload=dhtmlwindow.cleanup


if (typeof dhtmlwindow=="undefined")
alert('ERROR: Modal Window script requires all files from "DHTML Window widget" in order to work!')

var dhtmlmodal={
veilstack: 0,
open:function(t, contenttype, contentsource, title, attr, recalonload){
	var d=dhtmlwindow //reference dhtmlwindow object
	this.interVeil=document.getElementById("interVeil") //Reference "veil" div
	this.veilstack++ //var to keep track of how many modal windows are open right now
	this.loadveil()
	if (recalonload=="recal" && d.scroll_top==0)
		d.addEvent(window, function(){dhtmlmodal.adjustveil()}, "load")
	var t=d.open(t, contenttype, contentsource, title, attr, recalonload)
	t.controls.firstChild.style.display="none" //Disable "minimize" button
	t.controls.onclick=function(){dhtmlmodal.close(this._parent, true)} //OVERWRITE default control action with new one
	t.show=function(){dhtmlmodal.show(this)} //OVERWRITE default t.show() method with new one
	t.hide=function(){dhtmlmodal.close(this)} //OVERWRITE default t.hide() method with new one
return t
},


loadveil:function(){

	var d=dhtmlwindow
	d.getviewpoint()
	this.docheightcomplete=(d.standardbody.offsetHeight>d.standardbody.scrollHeight)? d.standardbody.offsetHeight : d.standardbody.scrollHeight
	//this.interVeil.style.width=d.docwidth+"px" //set up veil over page
	//this.interVeil.style.height=this.docheightcomplete+"px" //set up veil over page
	this.interVeil.style.left=0 //Position veil over page
	this.interVeil.style.top=0 //Position veil over page
	this.interVeil.style.visibility="visible" //Show veil over page
	this.interVeil.style.display="block" //Show veil over page
},

adjustveil:function(){ //function to adjust veil when window is resized
	if (this.interVeil && this.interVeil.style.display=="block") //If veil is currently visible on the screen
		this.loadveil() //readjust veil
},

closeveil:function(){ //function to close veil
	this.veilstack--
	if (this.veilstack==0) //if this is the only modal window visible on the screen, and being closed
		this.interVeil.style.display="none"
},


close:function(t, forceclose){ //DHTML modal close function
	t.contentDoc=(t.contentarea.datatype=="iframe")? window.frames["_iframe-"+t.id].document : t.contentarea //return reference to modal window DIV (or document object in the case of iframe
	if (typeof forceclose!="undefined")
		t.onclose=function(){return true}
	if (dhtmlwindow.close(t)) //if close() returns true
		this.closeveil()
},


show:function(t){
	dhtmlmodal.veilstack++
	dhtmlmodal.loadveil()
	dhtmlwindow.show(t)
}
} //END object declaration


document.write('<div id="interVeil"></div>')
dhtmlwindow.addEvent(window, function(){if (typeof dhtmlmodal!="undefined") dhtmlmodal.adjustveil()}, "resize")

function openTellFriendLayer(cn){
//Open a modal window populated with the contents of a hidden DIV, and assign the result to a global variable called "emailwindow"
	emailwindow = dhtmlmodal.open('tellFriendLayer', 'div', 'tellFriend', 'NCNZ :: Tell a Friend', 'width=375px,height=265px,center=1,resize=0,scrolling=0');
	document.getElementById("tellFriend_sub").value=cn;
	var msg = document.getElementById("tellFriend_msg").value;
	msg = msg.replace(/\[coursename\]/ig, cn);
	document.getElementById("tellFriend_msg").value = msg;

	if(document.getElementById('hidAttachment').value=='true')
	{
		document.getElementById("tellFriend_msg").value="Hi, I found an interesting article I thought you might be interested in reading. It's in the Naturopathic College of New Zealand newsletter";
		document.getElementById("tellFriend_sub").value='Natural Therapies Article';
		document.getElementById("hidAttachmentsub").value=cn;
	}


}


tellFriend=function(){


	name = document.getElementById('tellFriend_name').value;
	email = document.getElementById("tellFriend_email").value;
	frdName = document.getElementById('tellFriend_frdName').value;
	frdEmail = document.getElementById('tellFriend_frdEmail').value;
	sub = document.getElementById('tellFriend_sub').value;
	msg = document.getElementById("tellFriend_msg").value;

	if ((name==null)||(name=="")){
		alert("Please Enter your Name");
		document.getElementById('tellFriend_name').focus();
		return false;
	}

	if ((email==null)||(email=="")){
		alert("Please Enter your Email ID");
		document.getElementById("tellFriend_email").focus();
		return false
	}
	if (validateEmail(email)==false){
		alert("Invalid E-mail ID");
		document.getElementById("tellFriend_email").focus();
		return false
	}
	if ((frdName==null)||(frdName=="")){
		alert("Please Enter your Friend's Name");
		document.getElementById('tellFriend_frdName').focus();
		return false;
	}

	if ((frdEmail==null)||(frdEmail=="")){
		alert("Please Enter your Friend's Email ID");
		fdocument.getElementById('tellFriend_frdEmail').focus();
		return false
	}
	if (validateEmail(frdEmail)==false){
		alert("Invalid E-mail ID");
		document.getElementById('tellFriend_frdEmail').focus();
		return false
	}
	if ((sub==null)||(sub=="")){
		alert("Please Enter Subject");
		document.getElementById("tellFriend_sub").focus();
		return false;
	}
	if ((msg==null)||(msg=="")){
		alert("Please Enter Message");
		document.getElementById("tellFriend_msg").focus();
		return false;
	}

	if(document.getElementById('hidAttachment').value=='true')
	{
		params = 'hidValAction=tellFriendAttachment&';
		attch = document.getElementById("hidAttachmentsub").value;
		params += "hidAttachmentsub="+attch+"&";


	}
	else
	{

	params = 'hidValAction=tellFriend&';
	}

	params += "txtMessage="+msg+"&";
	params += "txtName="+name+"&";
	params += "txtEmail="+email+"&";
	params += "txtFrdName="+frdName+"&";
	params += "txtFrdEmail="+frdEmail+"&";
	params += "txtSubject="+sub;

	url = 'CommonClass.obj';
	http = getHTTPObject();
	http.open("POST", url, true);
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	http.onreadystatechange = function (){
		if(http.readyState==4){

		}


	};

	http.send(params);
	dhtmlmodal.close(emailwindow);
	alert("Your message has been sent");


}

//USED FOR AJAX
function getHTTPObject()
{
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try
	{
		xmlhttp = new XMLHttpRequest();
    }
	catch (e)
	{
      xmlhttp = false;
    }
  }
  return xmlhttp;
}


// Function to submit the user login form
	function loginUser()
	{	var form = document.frmLogin;

		var uname = form.txtUserName;
		var pwd   = form.txtPassword;

    	if ((uname.value == "") && (pwd.value=="")) {
			showError();
			return false;
        } else {
			form.hidValAction.value = "login";
			form.action="login.html";
			return true;
        }
	}


	// Function to show the login error section.
	function showError()
	{	alert('Please Enter Username and Password');
		//document.getElementById("loginerr").style.display='inline';
		document.getElementById("txtUsrName").focus();
	}

	// Function to logout
	function logout()
	{	var form = document.frmLogin;
		form.hidValAction.value = "logout";
		form.action="student/login.html";
		form.submit();
	}
/**************/

function openLayer(layerId,node,w,h,title){
	//Open a modal window populated with the contents of a hidden DIV
	layer = dhtmlmodal.open("layer", 'div', layerId, 'NCNZ :: '+title, 'width='+w+',height='+h+',center=1,resize=0,scrolling=1');
}

function NewStudent()
{
	fl = validate();
	if (fl)
	{
		var form = document.studentRegForm;
		document.getElementById('hidValAction').value = "saveStudent";

		form.submit();
	}
}

function DeleteStudent(id){
	var form = document.studentRegForm;
	document.getElementById('hidStudentId').value = id;
	var fl = confirm("Do you want to delete?")
	if(fl)
	{
		document.getElementById('hidValAction').value = "deleteStudent";
		form.submit();
	}

}
 function ChangeStudentDetails(){

	var form = document.studentRegForm;
	document.getElementById('hidValAction').value = "changeStudent";
	//var studentId = document.getElementById('allStudent').value;
	//document.getElementById('hidStudentId').value = studentId;
	form.submit();
 }

 function UpdateStudent(){

	fl = validate();
	if (fl)
	{
		var form = document.studentRegForm;
		document.getElementById('hidValAction').value = "UpdateStudent";
		form.submit();
	}


 }

 validate = function() {

	var form = document.studentRegForm;
	var firstName = document.getElementById('txtfirstname').value;
	var lastName  = document.getElementById('txtLastName').value;
	var enrolId   = document.getElementById('txtEnrolId').value;


	  if((firstName==null)||(firstName=="")){
		alert("Please enter First Name");
		document.getElementById('txtfirstname').focus();
		return false;
	 }
	 else if((lastName==null)||(lastName=="")){
		alert("Please enter Last Name");
		document.getElementById('txtLastName').focus();
		return false;
	 }

	 else if((enrolId==null)||(enrolId=="")){
		alert("Please enter Student ID");
		document.getElementById('txtEnrolId').focus();
		return false;
	 }
	return true;

 }

 function FillTxtValue(){

    var txtval = document.getElementById("txtfirstname").value.toLowerCase()+document.getElementById("txtLastName").value.toLowerCase();

    txtval = txtval.replace( new RegExp( " ", "g" ), "" );
    txtval = txtval.replace( new RegExp( "[!@#$%^&*_+\'\"()|/,.?<>{}:;[\\\]\\=]", "g" ), "" ); /* replace the occurances of special characters */

    if(txtval != '')
        document.getElementById("txtUserName").value = txtval;
    else
        document.getElementById("txtUserName").value = '';
}

/*function saveEnrolQualification(value){
	var buttonAction = value;
	var form =document.onlineEnrolment;
	var qualification = document.getElementById('txtNameOfQualification').value;
	var ID = document.getElementById('txtIDNum').value;

	var course1 = document.getElementById('txtcourse1').value;
	var course2 = document.getElementById('txtcourse2').value;
	var course3 = document.getElementById('txtcourse3').value;
	var course4 = document.getElementById('txtcourse4').value;
	var course5 = document.getElementById('txtcourse5').value;
	var course6 = document.getElementById('txtcourse6').value;


 if((qualification==null)||(qualification=="")){
		alert("Please enter Your Qualification");
		document.getElementById('txtIDNum').focus();
		return false;
	 }
 if (document.getElementById('chkQyes').checked==true){

	if((ID==null)||(ID=="")){
	alert("Please enter your old Naturopathic College ID");
	document.getElementById('txtIDNum').focus();
	return false;
	}
 }
 if( ((course1==null)||(course1==""))&&((course2==null)||(course2==""))&&((course3==null)||(course3==""))&&((course4==null)||(course4==""))&&((course5==null)|(course5==""))&&((course6==null)||(course6=="")) ){
		alert("Please enter Atleast one course you wish to enrol in for 2009");
		document.getElementById('txtcourse1').focus();
		return false;
	 }

		if (buttonAction=='SavenExit'){
			document.getElementById('hidValEnrol').value = "SavenExitEnrolQuali";
		}else{
		 	document.getElementById('hidValEnrol').value = "SaveEnrol1Quali";
		}

		form.submit();

}*/
/*
 function CheckStatusQNo(){

	if (document.getElementById('chkQno').checked){
		document.getElementById('chkQno').checked=true
		document.getElementById('chkQyes').checked=false;

	}
}

function CheckStatusQYes(){

	if (document.getElementById('chkQyes').checked){
		document.getElementById('chkQyes').checked=true
		document.getElementById('chkQno').checked=false;

	}

}

function CheckStatusQFultime(){

	if (document.getElementById('chkQfulltime').checked){
		document.getElementById('chkQfulltime').checked=true
		document.getElementById('chkQparttime').checked=false;

	}
}

function CheckStatusQParttime(){

	if (document.getElementById('chkQparttime').checked){
		document.getElementById('chkQparttime').checked=true
		document.getElementById('chkQfulltime').checked=false;

	}

}*/
/*
function EnrolEmailSent(){


	var form =document.onlineEnrolmentSavenExit;

	var Email = document.getElementById('txtEnrolEmail').value;
	if((Email==null)||(Email=="")){
		alert("Please enter Email ID");
		document.getElementById('txtEnrolEmail').focus();
		return false;
	 }else if(validateEmail(Email)==false){
		 alert("Invalid E-mail ID");
		document.getElementById("txtEnrolEmail").focus();
		return false
	 }
	document.getElementById('hidValEnrolSavenExit').value = "SavenExitSentEmail";
	form.submit();

}*/

function goBackToPreviousPage(formName,url){
	var form = document.getElementById(formName);
	form.action=url;
	form.submit();
}




/*************************************/

checkEthnicGroup = function(){
	var count = 0;
	document.onlineEnrolment.hidEthnicSelected.value='';
	div = document.getElementById('ethDiv');
	ethChecks = div.getElementsByTagName('input');
	var j=1;


	//for(var i in ethChecks){
	for(i=0;i<ethChecks.length;i++){
		if(ethChecks[i].checked){
			count++;
		}
		if(count>3){
			ethChecks[i].checked=false;
		}
		if(ethChecks[i].checked && count<=3){
			document.onlineEnrolment.hidEthnicSelected.value += j+','
		}j++;
	}
}

checkResourseGroup= function(){
	document.onlineEnrolment.hidResourseSelected.value='';
	div = document.getElementById('resDiv');
	resChecks = div.getElementsByTagName('input');

	var j = 1;
	for(i=0;i<resChecks.length;i++){
		if(resChecks[i].checked){
			k = resChecks[i].value

			document.onlineEnrolment.hidResourseSelected.value += k+','
		}j++;
	}
	 //for(var i in resChecks){

		//if(resChecks[i].checked){
		//	document.onlineEnrolment.hidResourseSelected.value += j+','
		//}j++;

	//}

}

enrollmentForm1Next = function(){
	if (validateForm1()) {
		document.onlineEnrolment.hidValEnrol.value = 'enrollmentForm1Write'
		document.onlineEnrolment.action = 'online_enrolment1.html'
		document.onlineEnrolment.hidFormNumber.value = 1;
		document.onlineEnrolment.submit();
	} else {
		return;
	}
}
enrollmentForm2Next = function(){
	if (validateForm2()) {
		document.onlineEnrolment.hidValEnrol.value = 'enrollmentForm2Write'
		document.onlineEnrolment.action = 'online_enrolment2.html'
		document.onlineEnrolment.hidFormNumber.value = 2;
		document.onlineEnrolment.submit();
	} else {
		return;
	}
}
enrollmentForm3Next = function(){
	if (validateForm3()) {
		document.onlineEnrolment.hidValEnrol.value = 'enrollmentForm3Write'
		document.onlineEnrolment.action = 'online_enrolment3.html'
		document.onlineEnrolment.hidFormNumber.value = 3;
		document.onlineEnrolment.submit();
	} else {
		return;
	}
}
enrollmentForm4Next = function(){
	if (validateForm4()) {
		document.onlineEnrolment.hidValEnrol.value = 'enrollmentForm4Write'
		document.onlineEnrolment.action = 'online_enrolment4.html'
		document.onlineEnrolment.hidFormNumber.value = 4;
		document.onlineEnrolment.submit();
	} else {
		return;
	}
}
enrollmentForm5Next = function(){
	if (validateForm5()) {
		document.onlineEnrolment.hidValEnrol.value = 'enrollmentForm5Write'
		document.onlineEnrolment.action = 'online_enrolment5.html'
		document.onlineEnrolment.hidFormNumber.value = 5;
		document.onlineEnrolment.submit();
	} else {
		return;
	}
}
enrollmentForm6Next = function(){
	sfunSniffBrowser();
	if (validateForm6()) {
		document.onlineEnrolment.hidValEnrol.value = 'enrollmentForm6Write'
		document.onlineEnrolment.action = 'online_enrolment5.html'
		document.onlineEnrolment.hidFormNumber.value = 6;
		document.onlineEnrolment.submit();
	} else {
		return;
	}
}

function sfunSniffBrowser()
{
	var flashinstalled = 0; var flashversion = 0; var flash_installed="false"; var javas="Disabled";
	if (navigator.plugins && navigator.plugins.length)
	{
		x = navigator.plugins["Shockwave Flash"];
		if (x)
		{
			flashinstalled = 2;
			if (x.description)
			{
				y = x.description;	flashversion = y.charAt(y.indexOf('.')-1);
			}
		}
		else
			flashinstalled = 1;
		if (navigator.plugins["Shockwave Flash 2.0"])
		{
			flashinstalled = 2;	flashversion = 2;
		}
	}
	else if (navigator.mimeTypes && navigator.mimeTypes.length)
	{
		x = navigator.mimeTypes['application/x-shockwave-flash'];
		if (x && x.enabledPlugin) flashinstalled = 2;
		else
			flashinstalled = 1;
	}

	if (flashinstalled == '2' || flashinstalled == '0')
		flash_installed="Enabled";
	else
		flash_installed="Disabled";
	/*
	flashinstalled =2 or 1 or 0
		* 2: Flash installed
		* 1: Flash not installed
		* 0: Unknown if Flash is installed
	*/
	//alert(screenWidth+"x"+screenHeight+"/"+colourDepth+" Java "+window.navigator.javaEnabled()+"  Flash	"+flash_installed);

	// client screen width and height inforamtion
	screenWidth = screen.width; screenHeight = screen.height; colourDepth = screen.colorDepth;
	screenWH=screenWidth+"x"+screenHeight+"/"+colourDepth;

	if(window.navigator.javaEnabled())
		javas="Enabled";
	else
		javas="Disabled";
	document.onlineEnrolment.hidSniffBrowser.value=screenWH+"$$$"+javas+"$$$"+flash_installed;

}
checkFile = function(filename){
	var goodExt = /[^/].(?:jpg|gif|bmp|png|tif|jepeg|jpeg)/i;
	if(!filename.match(goodExt) && filename !=''){
		alert('Invalid file format.');
		document.onlineEnrolment.passportPhoto.value ='';
		return false;
	}

	return true;
}
checkInputText = function(value){
	if(value.match(/^ *$/)){
		return false;
	}else{
		return true;
	}
}
checkDate = function(value){
	if (value.match(/^[0-9]{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])/)){
		return true;
	}else{
		return false;
	}
}
checkRadio = function(ele){
	var l = ele.length;
	for (var i=0;i<l;i++) {
		if (ele[i].checked == true) {
			return (parseInt(i)+1);
		}
	}
	return false;
}
checkYear = function(value){
	if(value.match(/^[1-2]\d{3}$/)){
		return true;
	}else{
		return false;
	}
}
checkEmail = function(value){
	if((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w+)+$/.test(value))){
		return true;
	}else{
		return false;
	}
}
validateForm1 = function(){
	form = document.onlineEnrolment;
	/*if(!checkInputText(form.txtQualification.value)){
		alert('Please enter name of the qualification.');
		form.txtQualification.focus();
		return false;
	}*/
	/*if (isDate(form.txtQualificationStartDate.value)==false) {
		form.txtQualificationStartDate.focus();
		return false;
	} */
	//alert(form.txtQualification.value);

	var selectedRadio = checkRadio(form.radStudiedNcnzBefore);
	if(selectedRadio ==false){
		alert("Please specify you studied at the Naturopathic College of NZ Ltd before?");
		document.getElementById('radStudiedNcnzBefore').focus();
		return false;
	}
	if(form.radStudiedNcnzBefore[selectedRadio-1].value=='y'){
		if(!checkInputText(form.txtPrevIdNo.value)){
			alert("Please enter your ID number.");
			form.txtPrevIdNo.focus();
			return false;
		}
	}
	if(!checkRadio(form.radTypeOfStudy)){
		alert("Please enter Fulltime or Part time study");
		document.getElementById('radTypeOfStudy').focus();
		return false;
	}

	if(!checkRadio(form.radCrossCrediting)){
		alert("Please specify intend to apply for Cross crediting");
		document.getElementById('radCrossCrediting').focus();
		return false;
	}
/*	if ((!checkInputText(form.txtCourse1.value)) && (!checkInputText(form.txtCourse2.value)) && (!checkInputText(form.txtCourse3.value)) && (!checkInputText(form.txtCourse4.value)) && (!checkInputText(form.txtCourse5.value)) && (!checkInputText(form.txtCourse6.value))) {
		alert("Please enter minimum one course.");
		form.txtCourse1.focus();
		return false;
	} */
	return true;
}
validateForm2 = function(){
	form = document.onlineEnrolment;
	if(!checkInputText(form.txtFamilyName.value)){
		alert('Please enter Family Name.');
		form.txtFamilyName.focus();
		return false;
	}
	if(!checkInputText(form.txtGivenName.value)){
		alert('Please enter Given Name(s).');
		form.txtGivenName.focus();
		return false;
	}
	if(!checkInputText(form.txtPreferredFirstName.value)){
		alert('Please enter Preferred first name.');
		form.txtPreferredFirstName.focus();
		return false;
	}
	/*if(!checkInputText(form.txtPrevNamesKnownBy.value)){
		alert('Please enter Previous name(s) known by.');
		form.txtPrevNamesKnownBy.focus();
		return false;
	} */
	if(checkRadio(form.radTitle) == false) {
		alert("Please specify Preferred title.");
		document.getElementById('radTitle').focus();
		return false;
	}
	var selectedRadio = checkRadio(form.radTitle);
	if(form.radTitle[selectedRadio-1].value=='5'){
		if(!checkInputText(form.txtOtherTitle.value)){
			alert("Please specify other Preferred title.");
			form.txtOtherTitle.focus();
			return false;
		}
	}
	/*if (!checkDate(form.txtDob.value)) {
		alert("Please enter date in yyyy-mm-dd format.");
		form.txtDob.focus();
		return false;
	}*/
	if (isDate(form.txtDob.value)==false) {
		form.txtDob.focus();
		return false;
	}

	if(checkRadio(form.radGender) == false){
		alert("Please specify Gender.");
		document.getElementById('radGender').focus();
		return false;
	}
	var selectedCitizen = checkRadio(form.radCitizen);
	if(selectedCitizen == false){
		alert("Please tick the box which best describes your citizenship");
		document.getElementById('radCitizen').focus();
		return false;
	}
	if(form.radCitizen[selectedCitizen-1].value=='Oth'){
		if(!checkInputText(form.txtOtherCitizen.value)){
			alert('Please specify your citizenship.');
			form.txtOtherCitizen.focus();
			return false;
		}
	}
	if(form.radCitizen[selectedCitizen-1].value=='Oth'){
		if(!checkRadio(form.radFeeOrAssistanceStatus)){
			alert('Please specify your fee / assistance status.');
			document.getElementById('radFeeOrAssistanceStatus').focus();
			return false;
		}
	}
	if(!checkRadio(form.radResidentInNzDuringStudy)){
		alert('Please specify you will be resident in New Zealand or overseas?');
		document.getElementById('radResidentInNzDuringStudy').focus();
		return false;
	}
	var flag = false;
	div = document.getElementById('ethDiv');
	var selectedEthinicities = Array();
	ethChecks = div.getElementsByTagName('input');
	for(var i in ethChecks){
		if(ethChecks[i].checked){
			flag = true;
			selectedEthinicities.push(ethChecks[i].value);
		}
	}
	if(!flag){
		alert('Please specify what ethnic group(s) do you belong to?');
		document.getElementById('chkEthnicGroup1').focus();
		return false;
	}
	for(var i in selectedEthinicities){
		if((selectedEthinicities[i] == 371) || (selectedEthinicities[i] == 129) || (selectedEthinicities[i] == 414) || (selectedEthinicities[i] == 444) || (selectedEthinicities[i] == 611)){
			if(!checkInputText(form.txtOtherEthnicGroup.value)){
				alert('Please specify ethnicity.');
				form.txtOtherEthnicGroup.focus();
				return false;
			}
		}
	}

	for(var i in selectedEthinicities){
		if((selectedEthinicities[i] == 211)) {
			if(!form.chkIwiNotKnown.checked){
				if( (!checkInputText(form.txtIwiCode1.value)) && (!checkInputText(form.txtIwiCode2.value)) && (!checkInputText(form.txtIwiCode3.value)) ){
					alert('Please specify the name of your Iwi or select \'Not Known\'');
					form.txtIwiCode1.focus();
					return false;
				}
			}
			if( (!checkInputText(form.txtIwiCode1.value)) && (!checkInputText(form.txtIwiCode2.value)) && (!checkInputText(form.txtIwiCode3.value)) ){
				if(!form.chkIwiNotKnown.checked){
					alert('Please specify the name of your Iwi or select \'Not Known\'');
					form.txtIwiCode1.focus();
					return false;
				}
			}
			break;
		}
	}
	if(!checkRadio(form.radActivityOrOccupation)){
		alert('Please specify your main activity or occupation in New Zealand at 1 October last year');
		document.getElementById('radActivityOrOccupation').focus();
		return false;
	}
	if(!checkRadio(form.radCriminalOffence)){
		alert('Please specify you ever been charged with a criminal offence.');
		document.getElementById('radCriminalOffence').focus();
		return false;
	}

	var selectedRadio = checkRadio(form.radCriminalOffence);
	if(form.radCriminalOffence[selectedRadio-1].value=='y'){
		if(!checkInputText(form.txtCriminalOffence.value)){
			alert("Please specify charged criminal offence.");
			form.txtCriminalOffence.focus();
			return false;
		}
	}


	if(!checkRadio(form.radAccessResource)){
		alert('Please select any resources that you have access to during the year.');
		document.getElementById('radAccessResource').focus();
		return false;
	}
	return true;
}
validateForm3 = function(){
	form = document.onlineEnrolment;
	if(!checkInputText(form.txtLastSecondarySchoolName.value)){
		alert('Please specify the name of last secondary school you attended.');
		form.txtLastSecondarySchoolName.focus();
		return false;
	}
	if(!checkYear(form.txtLastSecondarySchoolYear.value)){
		alert('Please specify your last year at secondary school.');
		form.txtLastSecondarySchoolYear.focus();
		return false;
	}
	var selectedAchievement = checkRadio(form.radHighestAchievement);
	if(selectedAchievement == false){
		alert("Please specify the highest level of achievement you hold from a secondary school.");
		document.getElementById('radHighestAchievement').focus();
		return false;
	}
	if(form.radHighestAchievement[selectedAchievement-1].value=='09' || form.radHighestAchievement[selectedAchievement-1].value=='98'){
		if(!checkInputText(form.txtOtherHighestAchievement.value)){
			alert("Please specify overseas or other qualification.");
			form.txtOtherHighestAchievement.focus();
			return false;
		}
	}
	var selectedTertiaryStudy = checkRadio(form.radTertiaryStudy);
	if(selectedTertiaryStudy == false){
		alert("Please specify Tertiary Study.");
		document.getElementById('radTertiaryStudy').focus();
		return false;
	}
	if(form.radTertiaryStudy[selectedTertiaryStudy-1].value=='n'){
		if(!checkInputText(form.txtFirstEnrolmentOrgName.value)){
			alert('Please enter name of the organisation you studied at your first enrolment.');
			form.txtFirstEnrolmentOrgName.focus();
			return false;
		}
		if(!checkYear(form.txtFirstEnrolmentOrgYear.value)){
			alert('Please enter the year of your first enrolment');
			form.txtFirstEnrolmentOrgYear.focus();
			return false;
		}
	}
	if(!checkYear(form.txtExpectedYearToComplete.value)){
		alert('Please enter year do you expect to complete.');
		form.txtExpectedYearToComplete.focus();
		return false;
	}
	/*if(!checkInputText(form.txtEduProfTechQualifications.value)){
		alert('Please enter Educational, Professional, Technical or Other Qualifications.');
		form.txtEduProfTechQualifications.focus();
		return false;
	} */
	if(!checkRadio(form.radDistanceEduFirstTime)){
		alert('Please specify is this the first time you have attempted a distance education course');
		document.getElementById('radDistanceEduFirstTime').focus();
		return false;
	}
	var selectedExtHelp = checkRadio(form.radExtraHelpLearning);
	if(selectedExtHelp == false){
		alert("Please specify you require extra help learning or not.");
		document.getElementById('radExtraHelpLearning').focus();
		return false;
	}
	if(form.radExtraHelpLearning[selectedExtHelp-1].value=='y'){
		if(!checkInputText(form.txtExtraHelpLearning.value)){
			alert('Please specify extra help learning.');
			form.txtExtraHelpLearning.focus();
			return false;
		}
	}
	return true;
}
validateForm4 = function(){
	form = document.onlineEnrolment;
	if(!checkInputText(form.txtHomeStreet.value)){
		alert('Please enter street address');
		form.txtHomeStreet.focus();
		return false;
	}
	/*if(!checkInputText(form.txtHomeSuburb.value)){
		alert('Please enter suburb');
		form.txtHomeSuburb.focus();
		return false;
	} */
	if(!checkInputText(form.txtHomeTownOrCity.value)){
		alert('Please enter town / city');
		form.txtHomeTownOrCity.focus();
		return false;
	}
	if(!checkInputText(form.txtHomePostCode.value)){
		alert('Please enter post code');
		form.txtHomePostCode.focus();
		return false;
	}
	if(!checkInputText(form.txtHomeDayPhone.value)){
		alert('Please enter day time phone');
		form.txtHomeDayPhone.focus();
		return false;
	}
	if(!checkInputText(form.txtHomeMobile.value)){
		alert('Please enter mobile number.');
		form.txtHomeMobile.focus();
		return false;
	}
	if(!checkInputText(form.txtHomeEveningPhone.value)){
		alert('Please enter evening phone');
		form.txtHomeEveningPhone.focus();
		return false;
	}
	/*if(!checkInputText(form.txtHomeFax.value)){
		alert('Please enter fax');
		form.txtHomeFax.focus();
		return false;
	}*/
	if(!checkEmail(form.txtHomeEmail.value)){
		alert('Please enter valid Email id');
		form.txtHomeEmail.focus();
		return false;
	}
	if(!checkInputText(form.txtHomeNextOfKin.value)){
		alert('Please enter next of kin');
		form.txtHomeNextOfKin.focus();
		return false;
	}
	if(!checkInputText(form.txtHomePhone.value)){
		alert('Please enter phone');
		form.txtHomePhone.focus();
		return false;
	}


	/*if(!checkInputText(form.tareaWorkplaceAddress.value)){
		alert('Please enter work place address');
		form.tareaWorkplaceAddress.focus();
		return false;
	}
	/* if(!checkInputText(form.txtWorkplaceSuburb.value)){
		alert('Please enter work place suburb');
		form.txtWorkplaceSuburb.focus();
		return false;
	} */
	/*if(!checkInputText(form.txtWorkplaceTownCity.value)){
		alert('Please enter work place Town/City');
		form.txtWorkplaceTownCity.focus();
		return false;
	}
	if(!checkInputText(form.txtWorkplacePhone.value)){
		alert('Please enter work place phone');
		form.txtWorkplacePhone.focus();
		return false;
	}
	if(!checkInputText(form.txtWorkplaceOccupation.value)){
		alert('Please enter work place occupation');
		form.txtWorkplaceOccupation.focus();
		return false;
	}
	*/




	/*if(!checkInputText(form.txtPostalStreet.value)){
		alert('Please enter street address');
		form.txtPostalStreet.focus();
		return false;
	}
	if(!checkInputText(form.txtPostalSuburb.value)){
		alert('Please enter suburb');
		form.txtPostalSuburb.focus();
		return false;
	}
	if(!checkInputText(form.txtPostalTownOrCity.value)){
		alert('Please enter town / city');
		form.txtPostalTownOrCity.focus();
		return false;
	}
	if(!checkInputText(form.txtPostalPostCode.value)){
		alert('Please enter post code');
		form.txtPostalPostCode.focus();
		return false;
	} */
	var selDelAdd = checkRadio(form.radDeliveryAddress);
	if(selDelAdd == false){
		alert('Please select where to deliver course materials and correspondence.');
		document.getElementById('radDeliveryAddress').focus();
		return false;
	}
	if(form.radDeliveryAddress[selDelAdd-1].value==3){
		if(!checkInputText(form.tareaAlternateDeliveryAddress.value)){
			alert('Please specify alternative address.');
			form.tareaAlternateDeliveryAddress.focus();
			return false;
		}
	}


/*	if(form.radDeliveryAddress[selDelAdd-1].value==2){

		if(!checkInputText(form.txtPostalStreet.value)){
		alert('Please enter street address');
		form.txtPostalStreet.focus();
		return false;
	}
	if(!checkInputText(form.txtPostalSuburb.value)){
		alert('Please enter suburb');
		form.txtPostalSuburb.focus();
		return false;
	}
	if(!checkInputText(form.txtPostalTownOrCity.value)){
		alert('Please enter town / city');
		form.txtPostalTownOrCity.focus();
		return false;
	}
	if(!checkInputText(form.txtPostalPostCode.value)){
		alert('Please enter post code');
		form.txtPostalPostCode.focus();
		return false;
	}

	} */
	return true;
}
validateForm5 = function(){
	form = document.onlineEnrolment;
	var stLoan = checkRadio(form.radStudentLoan);
	if(stLoan == false){
		alert('Please specify you currently have or will you have a student loan this year.');
		document.getElementById('radStudentLoan').focus();
		return false;
	}
	if(form.radStudentLoan[stLoan-1].value=='y'){
		if(!checkInputText(form.txtIrdNo.value)){
			alert('Please enter your IRD number.');
			form.txtIrdNo.focus();
			return false;
		}
	}


	var selPayOpt = checkRadio(form.radPaymentOptions);
	if(selPayOpt == false){
		alert('Please select fee payment option.');
		document.getElementById('radPaymentOptions').focus();
		return false;
	}
	if(form.radPaymentOptions[selPayOpt-1].value==7){
		if(!checkInputText(form.txtOtherPaymentOption.value)){
			alert('Please specify fee payment option.');
			form.txtOtherPaymentOption.focus();
			return false;
		}
	}
	var stID = checkRadio(form.radStudentID);
	if(stID == false){
		alert('Please specify whether you require a student ID card.');
		document.getElementById('radStudentID').focus();
		return false;
	}
/*	if(form.passportPhoto.value==''){
		alert('Please upload passport photo.');
		return false;
	} */
	if(!checkFile(form.passportPhoto.value)){
		return false;
	}


	/* if(!checkRadio(form.radCirculateContact)){
		alert('Please specify if you are giving permission for NCNZ to circulate your contact details');
		document.getElementById('radCirculateContact').focus();
		return false;
	}
 */

	return true;
}
validateForm6 = function(){

	form = document.onlineEnrolment;
	/*var selPayOpt = checkRadio(form.radPaymentOptions);
	if(selPayOpt == false){
		alert('Please select fee payment option.');
		return false;
	}
	if(form.radPaymentOptions[selPayOpt-1].value==7){
		if(!checkInputText(form.txtOtherPaymentOption.value)){
			alert('Please specify fee payment option.');
			form.txtOtherPaymentOption.focus();
			return false;
		}
	}

	if(!checkFile(form.passportPhoto.value)){
		return false;
	}
	; *//*	if(form.passportPhoto.value==''){
		alert('Please upload passport photo.');
		return false;
	} */


	if(document.getElementById('chkTerms').checked==false){
		alert("Please Accept Terms and Conditions");
		return false;
	}

	return true
}




enrollmentFormSave = function(formNo){
	//if (eval('validateForm'+formNo)()) {
		document.onlineEnrolment.hidValEnrol.value = eval('"enrollmentForm'+formNo+'Write"');
		document.onlineEnrolment.action = 'savenexit.html?form='+formNo
		document.onlineEnrolment.submit();
	//} else {
	//	return;
	//}
}


function EnrolEmailSent(){
	var form = document.onlineEnrolmentSavenExit;
	if(!checkEmail(form.txtSaveExitEmail.value)){
		alert('Please enter valid Email id');
		form.txtSaveExitEmail.focus();
		return false;
	}
	form.hidValEnrol.value = "saveNExitSentEmail";
	form.action = 'savenexitconfirmation.html';
	form.submit();
}


function checkEnterKey(e,fn)
{
    var key;
    if (window.event){
        e = window.event;
		key = e.keyCode;
    }else if(e.which){
		key = e.which;
	}
	if ( key == '13' ){
		eval(fn)();
	}
	return;
}

function disableEnterKey(e)
{
     var key;
     if(window.event)
          key = window.event.keyCode;
     else
          key = e.which;
     if(key == 13)
          return false;
     else
          return true;
}

function underConstruction(){

	alert("Page under construction, please fill out the Postal Enrolment");

}


function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   }
   return this
}

function isDate(dtStr){
	var dtCh= "/";
	var minYear=1900;
	var maxYear=2100;

	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : dd/mm/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}

function StartEnrolment(){
	 window.location.assign("online_enrolment.html")
}

 function showEntrolment(id){

	 var url="viewenrolment_details.html?hidValEnrol=selectedEnrolment&enroledID="+id;
	 win = window.open( url, 'details', 'scrollbars=yes, resizable=no, left=300, top= 200, height=440, width=520' );
	 win.focus();

 }

 function printReport(){
	window.print();
}

function buildUrl(){
var url;
url = window.location.href;
newurl = (url.slice(-8));
orginal = url.lastIndexOf('?');
url = url.substring(0,orginal);
if(newurl=='cookie=1'){
	alert ('Your browser cookie is disabled. Please re-enable the cookie and try again');
	window.location.href=url;
}

}

function test(){
	alert ('This part is under construction');
}

