<!--
// ---------------------------------------------------------------------------
// $RCSfile: ns.js,v $
// $Revision: 1.5 $
// $Name: annual_report_version_1 $
// $Date: 2002/11/11 03:07:13 $
// $Author: raymondb $
// ---------------------------------------------------------------------------

var	origWidth = innerWidth;
var	origHeight = innerHeight;
var widthFix = origWidth-20;
//var	origWidth = 0;
//var	origHeight = 0;
//var widthFix = '100%';
var subNavTextHeight = 12;
var subNavTextWrapLength = 40;

var sCalSection = '<ilayer ID="CalendarFrame" width="320" height="360"  src="'+project_root+'/Calendar/event_search.asp'+sEventSearchParams+'"></ilayer>';
var sSearchSection = '<ilayer ID="SearchFrame" width="285" height="250" frameborder="no" src="'+project_root+'/search_page/search.asp'+sSearchParams+'" scrolling="yes"></ilayer>';
var sSBSearchSection = '<ilayer ID="SearchFrame" width="170" height="350" frameborder="no" src="'+project_root+'/search_page/search.asp'+sSBSearchParams+'" scrolling="yes"></ilayer>';
var sPressSection = '<ilayer ID="PressFrame" width="290" height="350" frameborder="no" src="'+project_root+'/press/press_search.asp?d=form'+sPressParams+'" scrolling="yes"></ilayer>';
var sJobSection = '<ilayer ID="JobFrame" width="160" height="250" frameborder="no" src="'+project_root+'/careers/job_search.asp'+sJobSearchParams+'" scrolling="yes"></ilayer>';
var sAustSection = '<ilayer ID="AustFrame" width="285" height="70" frameborder="no" src="'+project_root+'/regions.asp" scrolling="yes"></ilayer>';

// page onload initialization function
function init() {
	if (subNav.length > 0) {
		makeSubnav2();
	}
	if (section != "Graduate Recruitment" && !isGrad && section != "Annual Report" && section != 'Alumni') {
		makeRightLinks();
	}
	if (FlashOff) {
		makeVis('menu_nav',1);
		makeVis('bodyLay',1);
	} else {
		showFlash();
		createLay('ctryLay',10,10,67,25,'<img id="ctry_logo" border="0" height="13" width="100" src="'+project_root+'/images/hed_australia.gif">',33,1,'');
	}
	trackerPos = -20;

	var tempSection;
	tempSection = section;
	if (section == 'Graduate Recruitment')  { section = 'Careers'; }
	if (section == 'Corporate Recovery') { section = 'Services'; }
	if (section == 'Annual Report') { section = 'About'; }

	if (section == 'search' || section == 'index' || section == 'Help' || section == 'Events' || section == 'Graduate Recruitment' || section == 'Corporate Recovery') {
		swapImg(section,'submenu_nav',1);
	} else if (section != 'errors'){
		swapImg(section,'menu_nav',1);
		if (section != 'home' && section != 'Help' && document.layers['menu_nav'].document.images[section+'_menu_nav'] != '') {
			if (section != 'Search')
			trackerPos = document.layers['menu_nav'].document.images[section+'_menu_nav'].x+(document.layers['menu_nav'].document.images[section+'_menu_nav'].width/2-14);
		}
	}
	if (cid != '' && section != 'Alumni')
	{
	    if (TopTierGraphicOn != '0') {
			document.layers['menu_nav'].document.src = project_root + '/images/buttons/' + TopTierGraphicOn;
		}
	}

	section = tempSection;

	lnd = trackerPos;
	chaseTracker();
	rollBrandImage()
}

//create layers function
function createLay(nme,x,y,h,w,content,z,v,c) {
	if (v) {
		vis = 'show';
	} else {
		vis = 'hide';
	}

	layerStr = '<layer id="'+nme+'" scroll=auto top="'+x+'" left="'+y+'"';
	if (h != 0) {
		layerStr = layerStr + ' height="'+h+'"';
	}
	if (w != 0) {
		layerStr = layerStr + ' width="'+w+'"';
	}
	if (c != '') {
		layerStr = layerStr + ' bgcolor="'+c+'"';
	}
	layerStr = layerStr + ' z-index="'+z+'" visibility="'+vis+'">'+content;
	layerStr = layerStr + '</layer>\n';
	document.write(layerStr);
}


function showFlash() {
	checkFlash();
	if (!FlashOff) {
		document.write('<layer id="intro" top="0" left="0" height="600" width="800" bgcolor="#ffffff"><OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" WIDTH="100%" HEIGHT="100%" CODEBASE="http://active.macromedia.com/flash3/cabs/" ID=flashintro>');
		document.write('<PARAM NAME="MOVIE" VALUE="intro15.swf"><PARAM NAME="PLAY" VALUE="true"><PARAM NAME="LOOP" VALUE="false"><PARAM NAME="QUALITY" VALUE="high"><PARAM NAME="SCALE" VALUE="SHOWALL">');
		document.write('<EMBED NAME="flashintro" SRC="intro15.swf" WIDTH="100%" HEIGHT="100%" PLAY="true" LOOP="false" QUALITY="high" SCALE="SHOWALL" swLiveConnect="true"  PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>');
		document.write('</OBJECT>');
	//	document.write('<font class="bodytext"><a href="index.asp">skip intro</a></font>');
		document.write('</layer>');
	} else {
		resetFlash();
	}
}

function checkFlash() {
	FlashOff = 1;
      if (navigator.appName == "Netscape" && navigator.plugins) {
         numPlugins = navigator.plugins.length;
         if (numPlugins > 0)
          {

            for (i = 0; i < numPlugins; i++)
            {
				plugin = navigator.plugins[i];
				if (plugin.description.indexOf("Flash 4") != -1)
				{
                  numTypes = plugin.length;
                  for (j = 0; j < numTypes; j++)
                  {
                     mimetype = plugin[j];

                     if (mimetype)
                     {
                        if (mimetype.enabledPlugin && (mimetype.suffixes.indexOf("swf") != -1))
                           FlashOff = 0;
                        // Mac wierdness
                        if (navigator.mimeTypes["application/x-shockwave-flash"] == null)
                           FlashOff = 1;
                     }
                  }
               }
            }
         }
      }
	return FlashOff;
}


function makeSubnav2() {
	var wayfindingset = 0;
	var imagename;
	var nextXpad = 0;

	// RB - 20020301 - Replace spaces in Image filename with %20's
	imagename = secondsection.replace(/\s/g,"%20");

	xPad = 154;
	xPad = xPad + sectionImageHeight;

	if (l1id == subNav[0].id)
		subNav[0].imgoff = subNav[0].imgon;

	subnav_str = '<table cellpadding="0" cellspacing="0" border="0" width="208"><tr><td width="202" align="right"><img src="'+project_root+'/images/clear.gif" height="50" width="1"><br>';
	subnav_str = subnav_str + '<img src="'+project_root+'/images/nav_hd_'+imagename+'.gif"><br><img src="'+project_root+'/images/clear.gif" height="22" width="1"><br>'
	for (x=0; x < subNav.length; x++) {
		if ((x < subNav.length-1) && (subNav[x+1].parNav != 0))	{
			pop = 1
		} else {
			pop = 0
		}
		dir = '';
		//alert(subNav[x].parNav);
		if (subNav[x].parNav == 0)	{
			if (subNav[x].path != '') {
				pathStr = subNav[x].path;
			} else {
				pathStr = project_root + '/content.asp?cid='+subNav[x].id;
			}
			if (l1id == subNav[x].id) {
				dir = subNav[x].imgon;
			} else {
				dir = subNav[x].imgoff;
			}

				subnav_str = subnav_str + '<a href="'+pathStr+'" onMouseOver="popup2(\''+section+'_'+subNav[x].id+'\',\'sub_nav\','+pop+')" onMouseOut="popup2(\''+section+'_'+subNav[x].id+'\',\'sub_nav\','+pop+',\''+subNav[x].imgoff+'\')"><img name="'+section+'_'+subNav[x].id+'_sub_nav" onClick="this.blur()" src="'+project_root+subNav[x].imgoff+'" border="0"></a><br>';
				if ((pid == subNav[x].id) && (hiddensection != '') && !wayfindingset)
				{
					wayfindingset = 1;
					xPad += subNavTextHeight + 3;
					if ( hiddensection.length > subNavTextWrapLength) {
						xPad += subNavTextHeight;
					}
					if (section!="Alumni" && hiddensection!=subNav[x].title) {
	//					alert(hiddensection+"**");

						subnav_str += '<img src="'+project_root+'/images/clear.gif" height="3" width="1"><br>';
						subnav_str += '<table cellpadding="0" cellspacing="0" border="0"><tr><td align="right">';
						subnav_str += '<a href="'+project_root+'/content.asp?cid='+hiddensectionid+'">';
						subnav_str += '<font class="rightSubNS" color="'+subNav[x].hc+'">';
						subnav_str += (hiddensection).replace(/BoldMenuHeading/i,""); 
						subnav_str += '</font></a></td><td width="10" nowrap>'
						subnav_str += '</td></tr></table>';
						
					}
				}
				xPad += nextXpad;
				nextXpad = subNav[x].xPadding;
		} else {
			dropDownStr = '<layer id="'+section+'_'+subNav[x].parNav+'_subnav" top="'+xPad+'" left="202" width="310" bgcolor="'+subNav[x-1].bc+'" z-index="51" visibility="hide"><table cellpadding="0" cellspacing="6" border="0"><tr><td width="298" bgcolor="#ffffff">'
			// dropDownStr += '<a href="#" onClick="document.location.href=\''+pathStr+'\'"><font class="popupMenu" color="'+subNav[x].hc+'">&nbsp;&nbsp;&nbsp;&nbsp;Overview</font></a><br>';
			while (x < subNav.length && subNav[x].parNav != 0) {
				if (l1id == subNav[x].id && !wayfindingset) {
					wayfindingset = 1;
					xPad += subNavTextHeight + 3;
					titleStr = subNav[x].title
					titleStr = titleStr.toUpperCase();
					if (section!="Alumni") {
						subnav_str = subnav_str + '<img src="'+project_root+'/images/clear.gif" height="3" width="1"><br><a href="'+project_root+'/content.asp?cid='+subNav[x].id+'"><table cellpadding="0" cellspacing="0" border="0"><tr><td align="right"><font class="rightSubNS" color="'+subNav[x].hc+'">'+titleStr.replace(/BoldMenuHeading/i,"") + '</font></a></td><td width="10" nowrap></td></table>'
					}
				}else if ((hiddensection != '') && (subNav[x].id == pid)  && !wayfindingset) {
					wayfindingset = 1;
					xPad += subNavTextHeight + 3;
					if ( hiddensection.length > subNavTextWrapLength) {
						xPad += subNavTextHeight;
					}
					if (section!="Alumni") {
						subnav_str = subnav_str + '<img src="'+project_root+'/images/clear.gif" height="3" width="1"><br><table cellpadding="0" cellspacing="0" border="0"><tr><td align="right"><a href="'+project_root+'/content.asp?cid='+hiddensectionid+'"><font class="rightSubNS" color="'+subNav[x].hc+'">'+hiddensection+ '</font></a></td><td width="10" nowrap></td></tr></table>';
					}
				}
				dropDownStr += '<a href="javascript:document.location.href=\''+project_root+'/content.asp?cid='+subNav[x].id+'\'"><font class="popupMenu" color="'+subNav[x].hc+'">&nbsp;&nbsp;&nbsp;&nbsp;'+subNav[x].title+'</font></a><br>';
				x++;
			}

			dropDownStr += '</table></layer>'
			document.write(dropDownStr);
			x--;
		}
	}
	//subnav_str = subnav_str + '<img src="'+project_root+'/images/clear.gif" height="16" width="1"><br></td><td width="6" nowrap bgcolor="'+subNav[0].bc+'"><img src="'+project_root+'/images/clear.gif" height="1" width="6"></td></tr><tr><td colspan="2" nowrap bgcolor="'+secTierboxColour+'"><img src="'+project_root+'/images/clear.gif" height="6" width="1"></td></tr></table>';
	subnav_str = subnav_str + '<img src="images/clear.gif" height="16" width="1"><br></td><td width="6" nowrap bgcolor="'+secTierboxColour+'"><img src="images/clear.gif" height="1" width="6"></td></tr><tr><td colspan="2" nowrap bgcolor="'+secTierboxColour+'"><img src="images/clear.gif" height="6" width="1"></td>';
	if (section == "Graduate Recruitment" || isGrad) {
		subnav_str = subnav_str + '</tr><tr><td><p align=right><a href="/grad_recruit/"><img vspace=6 hspace=10 border=0 src="/images/gradrecruit/kpmg_grad_recruit_button.gif"></a><br><a href="/grad_recruit/members/my_brochures.asp?cid='+ cid +'"><img vspace=6 hspace=10 border=0 src="/images/gradrecruit/kpmg_online_broch_button.gif"></a></p></td>';
	}
	if (section == "Corporate Recovery") {
		subnav_str = subnav_str + '</tr><tr><td><p ALIGN=RIGHT><a href="/corporaterecovery/"><img vspace=6 hspace=10 border=0 src="/images/corp_recovery/kpmg_corp_recov_button.gif"></a></p></td>';
	}
	if (section == "Annual Report") {
		subnav_str = subnav_str + '</tr><tr><td><p ALIGN=RIGHT><a href="/AnnualReport/index.asp?action=intro"><img vspace=6 hspace=4 border=0 src="/AnnualReport/20021023_kpmg_annual_button.gif"></a></p></td>';
	}
	if (section == "Alumni") {
		subnav_str = subnav_str + '</tr><tr><td><p ALIGN=RIGHT><a href="/Alumni/splash/index.asp?action=intro"><img vspace=6 hspace=4 border=0 src="/Alumni/Splash/alumni_introbutton.gif"></a></p></td>';
	}
	subnav_str = subnav_str + '</tr></table>';

	createLay('sub_nav',90,0,0,205,subnav_str,50,1,'');
}



//capture window resize
window.captureEvents(Event.RESIZE);
window.onresize = resizeHandler;

//reload page on window resize
function resizeHandler() {
	if (innerWidth != origWidth || innerHeight != origHeight) {
		origWidth = innerWidth;
		origHeight = innerHeight;
		window.top.location.href = document.location.href;
		}
}

//capture mouse movement
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = trackIt;

//track cursor position
function trackIt(evt) {
	if (evt.pageY > 60 && evt.pageY < 90 && evt.pageX < 750) {
		lnd = evt.pageX-14;
		chaseTracker();
	} else if (lnd != trackerPos) {
		lnd = trackerPos;
		chaseTracker();
	}
}

//make tracker chase cursor
function chaseTracker() {
	if (document.layers['trackerLay'].left != lnd) {
		if (document.layers['trackerLay'].left < (lnd-10)) {
			document.layers['trackerLay'].left +=10;
		} else if (document.layers['trackerLay'].left > (lnd+10)) {
			document.layers['trackerLay'].left -=10;
		} else if (document.layers['trackerLay'].left != lnd+10) {
			document.layers['trackerLay'].left = lnd;
		}
	setTimeout('chaseTracker()',1);
	}
}

var imgState = 0;

function swapImg(tar,par,imgState) {
	nme = tar+'_'+par;
	if (nme == "home_menu_nav") {
		nme = "Home_menu_nav"
	}

	if (nme != "Search_menu_nav" && nme != "Events_submenu_nav" && nme != "Graduate Recruitment_menu_nav" && nme != "Graduate Recruitment_submenu_nav") {
		if (imgState == 1){
			document.layers[par].document.images[nme].src = project_root+'/images/buttons/but_'+tar+'_on.gif';
		} else if (imgState == 0) {
			if ((tar.toLowerCase() != section.toLowerCase()) && (tar != rollStatus)) {
				document.layers[par].document.images[nme].src = project_root+'/images/buttons/but_'+tar+'_off.gif';
			}
		}
	}
}

function swapImg2(tar,par,imgPath) {
	nme = tar+'_'+par;
	//alert(document.layers[par].document.images[nme].src);

	document.layers[par].document.images[nme].src = project_root+imgPath;
}


function swapImg3(tar,par,imgState) {
	nme = tar+'_'+par;
	switch (tar) {
		case 'search':
			if (imgState == 1){
				imageOnOff(nme, par, tar, 'calendar', 'contact', 'aust','country');
			} else if (imgState == 0) {
				if ((tar != section) && (tar != rollStatus)) {
					document.layers[par].document.images[nme].src = ''+project_root+'/images/buttons/but_'+tar+'_off.gif';
				}
			}
			break;
		case 'calendar':
			if (imgState == 1){
				imageOnOff(nme, par, tar, 'search', 'contact', 'aust', 'country');
			} else if (imgState == 0) {
				if ((tar != section) && (tar != rollStatus)) {
					document.layers[par].document.images[nme].src = ''+project_root+'/images/buttons/but_'+tar+'_off.gif';
				}
			}
			break;
		case 'contact':
			if (imgState == 1){
				imageOnOff(nme, par, tar, 'calendar', 'search', 'aust', 'country');
			} else if (imgState == 0) {
				if ((tar != section) && (tar != rollStatus)) {
					document.layers[par].document.images[nme].src = ''+project_root+'/images/buttons/but_'+tar+'_off.gif';
				}
			}
			break;
		case 'aust':
			if (imgState == 1){
				imageOnOff(nme, par, tar, 'calendar', 'contact', 'search', 'country');
			} else if (imgState == 0) {
				if ((tar != section) && (tar != rollStatus)) {
					document.layers[par].document.images[nme].src = ''+project_root+'/images/buttons/but_'+tar+'_off.gif';
				}
			}
			break;
		case 'country':
			if (imgState == 1){
				imageOnOff(nme, par, tar, 'calendar', 'contact', 'search','aust');
			} else if (imgState == 0) {
				if ((tar != section) && (tar != rollStatus)) {
					document.layers[par].document.images[nme].src = ''+project_root+'/images/buttons/but_'+tar+'_off.gif';
				}
			}
			break;
		default :
			if (imgState == 1){
				document.all[nme].src = ''+project_root+'/images/buttons/but_'+tar+'_on.gif';
			} else if (imgState == 0) {
				if ((tar != section) && (tar != rollStatus)) {
					document.layers[par].document.images[nme].src = ''+project_root+'/images/buttons/but_'+tar+'_off.gif';
				}
			}
			break;
	}
}

function imageOnOff(nme, par, sOn, sOff1, sOff2, sOff3, sOff4) {
	document.layers[par].document.images[nme].src = ''+project_root+'/images/buttons/but_'+sOn+'_on.gif';

	var tmpSection = "";
	if (section == "Regional Sites") {
		tmpSection = "aust";
	} else if (section == "Home") {
		tmpSection = "search";
	} else {
		tmpSection = section;
	}

	if (document.layers[par].document.images[sOff1 + "_" + par] && (sOff1.indexOf(tmpSection) == -1)) {
		document.layers[par].document.images[sOff1 + "_" + par].src = project_root+'/images/buttons/but_'+sOff1+'_off.gif';
	}
	if (document.layers[par].document.images[sOff2 + "_" + par] && (sOff2.indexOf(tmpSection) == -1)) {
		document.layers[par].document.images[sOff2 + "_" + par].src = project_root+'/images/buttons/but_'+sOff2+'_off.gif';
	}
	if (document.layers[par].document.images[sOff3 + "_" + par] && (sOff3.indexOf(tmpSection) == -1)) {
		document.layers[par].document.images[sOff3 + "_" + par].src = project_root+'/images/buttons/but_'+sOff3+'_off.gif';
	}
	if (document.layers[par].document.images[sOff4 + "_" + par] && (sOff4.indexOf(tmpSection) == -1)) {
		document.layers[par].document.images[sOff4 + "_" + par].src = project_root+'/images/buttons/but_'+sOff4+'_off.gif';
	}
}



function makeVis(tar,dir) {
	if (dir) {
		document.layers[tar].visibility = 'show';
	} else {
		document.layers[tar].visibility = 'hide';
	}
}

//roll out section brand image
function rollBrandImage() {
	if ((section != 'Graduate Recruitment') && (section != 'Events') && (section != 'home') && (document.all['section_branding'].style.pixelLeft > 360)) {
		document.layers['section_branding'].left -= 10;
		var wait = setTimeout('rollBrandImage()',1);
	}
}

//sub menu rollout function
function roll(tar,dir) {
	obj = document.layers[tar+'_roll'];
	obj.top += dir*50;
	if (dir == 1) {
		if (obj.top < 100) {
			setTimeout('roll(\''+tar+'\',\''+dir+'\')',1);
		} else {
			makeVis(tar+'_form',1);
		}
	} else {
		if (obj.top > -600) {
			setTimeout('roll(\''+tar+'\',\''+dir+'\')',1);
		}
	}
}

//country redirector
function goCountry() {
	tar = document.layers['country_form'].document.forms[0].elements[0].selectedIndex;
	top.document.location.href = document.layers['country_form'].document.forms[0].elements[0].options[tar].value;
}

//preset contact pulldowns
function presetPulldowns() {
	document.layers['contact_form'].document.forms[0].reset();
	if (section == 'services') {
		for (x=0; x < document.layers['contact_form'].document.forms[0].elements['services'].length; x++) {
			if (l1id == document.layers['contact_form'].document.forms[0].elements['services'].options[x].value) {
				document.layers['contact_form'].document.forms[0].elements['services'].selectedIndex = x;
			}
		}
	} else if (section == 'industries') {
		for (x=0; x < document.layers['contact_form'].document.forms[0].elements['industry'].length; x++) {
			if (l1id == document.layers['contact_form'].document.forms[0].elements['industry'].options[x].value) {
				document.layers['contact_form'].document.forms[0].elements['industry'].selectedIndex = x;
			}
		}
	}
}

//contact submit
function submitContact(send) {
	if (send) {
	if (document.layers['contact_form'].document.forms[0].elements['about'].selectedIndex == 0) {
		alert('Please select a subject for your inquiry from the pull down menu');
	} else if ((document.layers['contact_form'].document.forms[0].elements['about'].selectedIndex == 8) && (document.layers['contact_form'].document.forms[0].elements['industry'].selectedIndex == 0)) {
			alert ('Please select your industry from the pull down menu');
	} else if ((document.layers['contact_form'].document.forms[0].elements['about'].selectedIndex == 8) && (document.layers['contact_form'].document.forms[0].elements['services'].selectedIndex == 0)) {
			alert ('Please select a service from the pull down menu');
	} else if (document.layers['contact_form'].document.forms[0].elements['comments'].value == '') {
		alert('Please enter the text of your message in the comments field');
	} else if (document.layers['contact_form'].document.forms[0].elements['firstname'].value == '') {
		alert('Please enter your first name');
	} else if (document.layers['contact_form'].document.forms[0].elements['lastname'].value == '') {
		alert('Please enter your last name');
	} else if (document.layers['contact_form'].document.forms[0].elements['email'].value == '') {
		alert('Please enter your email address');
	} else if (document.layers['contact_form'].document.forms[0].elements['email'].value != '' && (document.layers['contact_form'].document.forms[0].elements['email'].value.indexOf('@') == -1 || document.layers['contact_form'].document.forms[0].elements['email'].value.indexOf('.') == -1)) {
		alert('Your email address is invalid');
	} else if (document.layers['contact_form'].document.forms[0].elements['country'].selectedIndex == 0) {
		alert('Please select a country from the country pull down menu');
	} else {
		pullDown('contact')
		document.layers['contact_form'].document.forms[0].submit();
	}
	} else {
		document.layers['contact_form'].document.forms[0].reset();
	}
}


//search submit
function submitSearch(tar) {
	if (tar == 'A') {
		document.layers['search_form'].document.forms['searchFormA'].submit();
	} else {
		document.layers['search_nav'].document.forms['searchFormB'].submit();
	}
}

function loadCalendar() {
	//if (!(document.layers['search_form'].visibility == 'show') && !(document.layers['contact_form'].visibility == 'show')){
//		if (document.layers['calDiv'].visibility == 'hide') {
//			document.layers['rightLinksLay'].visibility = 'hide';
//			document.layers['calDiv'].visibility = 'show';
//			bDoCalendar = true;
//			if (document.layers['search_form'].visibility == 'show'){
//				pullDown('search');
//			}
//			if (document.layers['contact_form'].visibility == 'show'){
//				pullDown('contact');
//			}
//			if (document.layers['country_form'].visibility == 'show') {
//				pullDown('country');
//			}
//
//		}else {
//			document.layers['rightLinksLay'].visibility = 'show';
//			document.layers['calDiv'].visibility = 'hide';
//			bDoCalendar = false;
//		}
	//}
}

//-->