function navMouseover(tdid) {
	var colID = tdid.replace('navtext','');
	var prev_class = next_class = prev_mid_class = next_mid_class = '';
	if(document.getElementById('navtext'+(parseInt(colID) - 1))) prev_class = document.getElementById('navtext'+(parseInt(colID) - 1)).className;
	if(document.getElementById('navtext'+(parseInt(colID) + 1))) next_class = document.getElementById('navtext'+(parseInt(colID) + 1)).className;
	if(prev_class=='nav_text_active') prev_mid_class = 'nav_mid_yell';
	else prev_mid_class = 'nav_mid_yell_right';
	if(next_class=='nav_text_active') next_mid_class = 'nav_mid_yell';
	else next_mid_class = 'nav_mid_yell_left';
	if(document.getElementById('navmid'+(parseInt(colID) - 1)+colID)) document.getElementById('navmid'+(parseInt(colID) - 1)+colID).className = prev_mid_class;
	if(document.getElementById('navmid'+colID+(parseInt(colID) + 1))) document.getElementById('navmid'+colID+(parseInt(colID) + 1)).className = next_mid_class;
	document.getElementById('navtext'+colID).className = 'nav_text_active';
}
function navMouseout(tdid,dropdown) {
    if(document.getElementById(dropdown)) {
		if(document.getElementById(dropdown).style.display!='block') {
			var colID = tdid.replace('navtext','');
			document.getElementById('navtext'+colID).className = 'nav_text';
			var prev_class = next_class = prev_mid_class = next_mid_class = '';
			if(document.getElementById('navtext'+(parseInt(colID) - 1))) prev_class = document.getElementById('navtext'+(parseInt(colID) - 1)).className;
			if(document.getElementById('navtext'+(parseInt(colID) + 1))) next_class = document.getElementById('navtext'+(parseInt(colID) + 1)).className;
			if(prev_class=='nav_text_active') prev_mid_class = 'nav_mid_yell_left';
			else prev_mid_class = 'nav_mid_grey';
			if(next_class=='nav_text_active') next_mid_class = 'nav_mid_yell_right';
			else next_mid_class = 'nav_mid_grey';
			if(document.getElementById('navmid'+(parseInt(colID) - 1)+colID)) document.getElementById('navmid'+(parseInt(colID) - 1)+colID).className = prev_mid_class;
			if(document.getElementById('navmid'+colID+(parseInt(colID) + 1))) document.getElementById('navmid'+colID+(parseInt(colID) + 1)).className = next_mid_class;
		}
	} else {
		var colID = tdid.replace('navtext','');
		document.getElementById('navtext'+colID).className = 'nav_text';
		var prev_class = next_class = prev_mid_class = next_mid_class = '';
		if(document.getElementById('navtext'+(parseInt(colID) - 1))) prev_class = document.getElementById('navtext'+(parseInt(colID) - 1)).className;
		if(document.getElementById('navtext'+(parseInt(colID) + 1))) next_class = document.getElementById('navtext'+(parseInt(colID) + 1)).className;
		if(prev_class=='nav_text_active') prev_mid_class = 'nav_mid_yell_left';
		else prev_mid_class = 'nav_mid_grey';
		if(next_class=='nav_text_active') next_mid_class = 'nav_mid_yell_right';
		else next_mid_class = 'nav_mid_grey';
		if(document.getElementById('navmid'+(parseInt(colID) - 1)+colID)) document.getElementById('navmid'+(parseInt(colID) - 1)+colID).className = prev_mid_class;
		if(document.getElementById('navmid'+colID+(parseInt(colID) + 1))) document.getElementById('navmid'+colID+(parseInt(colID) + 1)).className = next_mid_class;
	}
}
function show_tests(id) {
	var nextid = parseInt(id);
	nextid++;
	$('test'+id).style.top = '190px';
   	$('test'+id).set('morph', {duration: 800, transition: 'quad:in:out'});
	$('test'+id).morph({'top': '0px'});
	if(document.getElementById('test'+nextid)) {
		setTimeout("show_tests("+nextid+");",9200);
		setTimeout("$('test"+id+"').morph({'top': '-190px'});",9000);
	} else {
		setTimeout("show_tests(1);",9200);
		setTimeout("$('test"+id+"').morph({'top': '-190px'});",9000);
	}
}
var timer = new Array();
var delay = 400;
var menu_opacity = 100; //ranging from 0 to 100;
var original_bgd = '';
var original_text = '';
var highlight_bgd = '';
var highlight_text = '#FFED2D';
function dropDown(id,action,options,links,orig,cntr,tdid) {
	if(action=='show') {
		if(!document.getElementById(id)) {
			var options = options.split("#");
			var links = links.split("#");
            var newdiv = document.createElement('div');
			newdiv.id = id;
			newdiv.style.position = 'absolute';
			newdiv.style.display = 'none';
			newdiv.style.paddingTop = '4px';
			for(var i = 0;i<options.length;i++) {
				var div = document.createElement("div");
				div.className = 'dropdowns';
				div.cntr = cntr;
				div.links_id = id;
				div.linkto = links[i];
				div.tdid = tdid;
				div.onmouseover = function(highlight_bgd,highlight_text) {
					dropDown(this.links_id,'clear','','','',this.cntr,this.tdid);
					navMouseover(tdid);
					this.className = 'dropdowns_active';
				}
				div.onmouseout = function() {
					dropDown(this.links_id,'set','','','',this.cntr,this.tdid);
					this.className = 'dropdowns';
				}
				if(links[i].indexOf("www")>=0||links[i].indexOf("http")>=0)
					{
					div.onclick = function() { window.open(this.linkto); }
					}
				else div.onclick = function() { window.location.href = this.linkto; }
				div.innerHTML = options[i];
				newdiv.appendChild(div);
			}
			document.body.appendChild(newdiv);
		}
		var all_fields = document.getElementById('all_fields').value;
		var all_fields = all_fields.split(",");
		for(var i=0;i<all_fields.length;i++) {
			var content = all_fields[i].split("#");
			if(content[0]!=id) {
				if(document.getElementById(content[0])) {
					navMouseout(content[1]);
					document.getElementById(content[0]).style.display = 'none';
				}
			}
		}
		var target = document.getElementById(id);
		var top = parseInt(orig.offsetHeight);
		var curleft = curtop = 0;
		if(orig.offsetParent) {
			do {
				curleft += orig.offsetLeft;
				curtop += orig.offsetTop;
			} while (orig = orig.offsetParent);
		}
		var top = top + curtop;
		top = top;
		var top = top+'px';
		var left = curleft;
		left = left;
		var left = left+'px';
        target.style.top = top;
        target.style.left = left;
        target.style.display = 'block';
		target.style.opacity=(menu_opacity/100); //Opera
		target.style.MozOpacity=(menu_opacity/100); //Mozilla+Firefox
		target.style.KhtmlOpacity=(menu_opacity/100); //Konqueror
		target.style.filter="alpha(opacity="+menu_opacity+")"; //IE
		window.clearTimeout(timer[cntr]);
	}
	if(action=='clear') {
		window.clearTimeout(timer[cntr]);
	}
	if(action=='set') {
		timer[cntr] = window.setTimeout("dropDown('"+id+"','hide','','','','"+cntr+"','"+tdid+"');", delay);
	}
	if(action=='hide') {
		var target = document.getElementById(id);
	    target.style.display = 'none';
		navMouseout(tdid);
	}
	if(action=='hideall') {
		var all_fields = document.getElementById('all_fields').value;
		var all_fields = all_fields.split(",");
		for(var i=0;i<all_fields.length;i++) {
			var content = all_fields[i].split("#");
			if(content[0]!=id) {
				if(document.getElementById(content[0])) {
					navMouseout(content[1]);
					document.getElementById(content[0]).style.display = 'none';
				}
			}
		}
	}
}
function loadGallery(width,height) {
	var page_width = parseInt(document.body.clientWidth);
	var page_length = parseInt(document.body.scrollHeight);
	var page_height = parseInt(document.body.clientHeight);
    if(page_length<page_height) page_length = page_height;

	var scroll = document.body.scrollTop;

	var obj = document.getElementById('image_div');
	var div_width = parseInt(obj.style.width);
	var div_height = parseInt(obj.style.height);

	var prevleftOff = Math.round((page_width - div_width)/2);
	var newleftOff = Math.round((page_width - width)/2);
	var prevtopOff = Math.round((page_height - div_height)/2) + scroll;
	var newtopOff = Math.round((page_height - height)/2) + scroll;

	$('image_div').style.display = 'block';
	$('blackout').style.display = 'block';
//added next line
	$('virt_tour').style.display = 'block';
	$('blackout').style.width = page_width+'px';
	$('blackout').style.height = page_length+'px';
	$('image_div').style.top=prevtopOff+'px';
	$('image_div').style.left=prevleftOff+'px';
	$('blackout').morph({'opacity': 0.85});
	$('image_div').morph({'opacity': 1});
	setTimeout("$('image_div').morph({'left': '"+newleftOff+"px','width': '"+width+"px'});",500);
	setTimeout("$('image_div').morph({'top': '"+newtopOff+"px','height': '"+height+"px'});",1000);
	setTimeout("$('virt_tour').morph({'opacity': 1});",1500);
}

function closeGallery(width,height) {
	$('blackout').morph({'opacity': 0,'moz-opacity': 0});
	$('image_div').morph({'opacity': 0});
	$('virt_tour').morph({'opacity': 0});
	setTimeout("$('blackout').style.display = 'none';",500);
	setTimeout("$('image_div').style.display = 'none';",500);
	setTimeout("$('virt_tour').style.display = 'none';",500);
	setTimeout("$('image_div').style.width = '"+width+"px';",500);
	setTimeout("$('image_div').style.height = '"+height+"px';",500);
}
function adjustGallery() {
	if($('image_div').style.display=='block') {
		var height = $('image_div').offsetHeight;
		var scroll = document.body.scrollTop;
		var page_height = parseInt(document.body.clientHeight);
		var newtopOff = Math.round((page_height - height)/2) + scroll;
    	$('image_div').morph({'top': newtopOff+'px'});
	}
}
function resizeGallery() {
	if($('image_div').style.display=='block') {
		var page_width = parseInt(document.body.clientWidth);
		var page_length = parseInt(document.body.scrollHeight);
		var page_height = parseInt(document.body.clientHeight);
	    if(page_length<page_height) page_length = page_height;
       	$('blackout').style.width = page_width+'px';
		$('blackout').style.height = page_length+'px';

		var height = $('image_div').offsetHeight;
		var width = $('image_div').offsetWidth;
		var scroll = document.body.scrollTop;
		var newtopOff = Math.round((page_height - height)/2) + scroll;
		var newleftOff = Math.round((page_width - width)/2);
    	$('image_div').morph({'top': newtopOff+'px','left': newleftOff+'px'});
	}
}

function playvideo(videoNum){
	if(videoNum==1){
		document.getElementById('play_img').src = 'images/playvideo-1.jpg';
		document.getElementById('play_area_1').href = 'javascript:playvideo(\'2\');';
		document.getElementById('play_area_1').alt = 'Play Video - Launch your career as a FLIGHT ATTENDANT';
		document.getElementById('play_area_1').title = 'Play Video - Launch your career as a FLIGHT ATTENDANT';
		document.getElementById('play_area_2').href = 'javascript:playvideo(\'3\');';
		document.getElementById('play_area_2').alt = 'Play Video - Find out what it takes to be an Aircraft Maintenance Engineer';
		document.getElementById('play_area_2').title = 'Play Video - Find out what it takes to be an Aircraft Maintenance Engineer';
		document.getElementById('video_div').innerHTML = '<img onClick="playvideo(\'1\');" style="cursor:hand;cursor:pointer;display:block; cursor:hand" src="images/take_virtual_tour.jpg">';
		var page_width = parseInt(document.body.clientWidth);
		var page_height = parseInt(document.body.clientHeight);
		var window_width = 800;
		var window_height = 570;
		var left = (page_width - window_width) /2;
		var top = (page_height - window_height) /2;
		window.open("http://online.aviationaustralia.aero/vtour/vtour.htm", "virtualtour",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,modal=yes,close=no,resizable=0,width='+window_width+',height='+window_height+',left='+left+',top='+top);
//		window.open("content/Flash/VT/virtualTour.html", "virtualtour",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,modal=yes,close=no,resizable=0,width='+window_width+',height='+window_height+',left='+left+',top='+top);
//		window.open("virtualtour/vtour.htm", "virtualtour",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,modal=yes,close=no,resizable=0,width='+window_width+',height='+window_height+',left='+left+',top='+top);
	} else if(videoNum==2){
		document.getElementById('play_area_1').href = 'javascript:playvideo(\'1\');';
		document.getElementById('play_area_1').alt = 'Take a Virtual Tour';
		document.getElementById('play_area_1').title = 'Take a Virtual Tour';
		document.getElementById('play_area_2').href = 'javascript:playvideo(\'3\');';
		document.getElementById('play_area_2').alt = 'Play Video - Find out what it takes to be an Aircraft Maintenance Engineer';
		document.getElementById('play_area_2').title = 'Play Video - Find out what it takes to be an Aircraft Maintenance Engineer';
		document.getElementById('play_img').src = 'images/playvideo-2.jpg';
		document.getElementById('video_div').innerHTML = '<object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="300"><param name="movie" value="video/video2.swf" /><param name="quality" value="high" /><param name="wmode" value="opaque" /><param name="swfversion" value="9.0.45.0" /><param name="allowFullScreen" value="true" /><!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. --><param name="expressinstall" value="../Scripts/expressInstall.swf" /><!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. --><!--[if !IE]>--><object type="application/x-shockwave-flash" data="video/video2.swf" width="400" height="300"><!--<![endif]--><param name="allowFullScreen" value="true" /><param name="quality" value="high" /><param name="wmode" value="opaque" /><param name="swfversion" value="9.0.45.0" /><param name="expressinstall" value="../Scripts/expressInstall.swf" /><!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. --><div><h4>Content on this page requires a newer version of Adobe Flash Player.</h4><p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p></div><!--[if !IE]>--></object><!--<![endif]--></object>';
	} else if(videoNum==3){
		document.getElementById('play_area_1').href = 'javascript:playvideo(\'2\');';
		document.getElementById('play_area_1').alt = 'Play Video - Launch your career as a FLIGHT ATTENDANT';
		document.getElementById('play_area_1').title = 'Play Video - Launch your career as a FLIGHT ATTENDANT';
		document.getElementById('play_area_2').href = 'javascript:playvideo(\'1\');';
		document.getElementById('play_area_2').alt = 'Take a Virtual Tour';
		document.getElementById('play_area_2').title = 'Take a Virtual Tour';
		document.getElementById('play_img').src = 'images/playvideo-3.jpg';
		document.getElementById('video_div').innerHTML = '<object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="300"><param name="movie" value="#" /><param name="quality" value="high" /><param name="wmode" value="opaque" /><param name="swfversion" value="9.0.45.0" /><param name="allowFullScreen" value="true" /><!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. --><param name="expressinstall" value="../Scripts/expressInstall.swf" /><!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. --><!--[if !IE]>--><object type="application/x-shockwave-flash" data="video/video1.swf" width="400" height="300"><!--<![endif]--><param name="allowFullScreen" value="true" /><param name="quality" value="high" /><param name="wmode" value="opaque" /><param name="swfversion" value="9.0.45.0" /><param name="expressinstall" value="../Scripts/expressInstall.swf" /><!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. --><div><h4>Content on this page requires a newer version of Adobe Flash Player.</h4><p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p></div><!--[if !IE]>--></object><!--<![endif]--></object>';
	}
}

function updateTCC(selectVal) {
	if(selectVal!='') {
		var splite = selectVal.split("#");
		if(splite[0]>0) {
			document.getElementById('tcc_td').innerHTML = '<b>$'+splite[0]+'.00</b>';
			document.getElementById('tcc_tr').style.display = '';
			document.getElementById('submit_enq').style.display = 'none';
			document.getElementById('enrol_enq').style.display = 'block';
		} else {
			document.getElementById('submit_enq').style.display = 'block';
			document.getElementById('enrol_enq').style.display = 'none';
		}
		document.getElementById('selected_opt').value = splite[1];
	} else {
		document.getElementById('tcc_td').innerHTML = '';
		document.getElementById('selected_opt').value = '';
		document.getElementById('tcc_tr').style.display = 'none';
		document.getElementById('submit_enq').style.display = 'block';
		document.getElementById('enrol_enq').style.display = 'none';
	}
}

function changeEnquiry(thisValue) {
	var target = document.getElementById('course_select');
	if(target.hasChildNodes()) while (target.childNodes.length>=1) target.removeChild(target.firstChild);
	if(typeof enq_cour[thisValue] != 'undefined') {
   	    var option = document.createElement('option');
   		option.text = '';
	    option.value = '';
   	  	target.appendChild(option);
		var obj = enq_cour[thisValue];
		for(var t=0;t<obj.length;t++) {
			var content = obj[t].split("#");
    	    var option = document.createElement('option');
    		option.innerHTML = content[2];
		    option.value = content[1]+'#'+content[0];
    	  	target.appendChild(option);
		}
		document.getElementById('course_tr').style.display = '';
		updateTCC('');
	} else {
		document.getElementById('course_tr').style.display = 'none';
		updateTCC('');
	}
}

function getkey(e)
{
if (window.event)
   return window.event.keyCode;
else if (e)
   return e.which;
else
   return null;
}

