/* generic js*/
/* output string actionscript style
trace('blah blah');
*/
var tracecount = 0;
var opener = new Object();
function trace(msg, options){
	if(! options)
	options = new Object();
	tracecount++;
	if(options){
		width = options.width ? options.width:300;
		height = options.height ? options.height:300;
		scrollbars = options.scrollbars ? options.scrollbars:1;
		resizable = options.resizable ? options.resizable:1;
		windowname = options.windowname ? options.windowname:'tracewindow';
	}
	if(! opener.document){
		opener = window.open('', windowname,'toolbar=0,scrollbars='+scrollbars+',location=0,statusbar=0,menubar=0,resizable='+resizable+',width='+width+',height='+height);
		opener.document.write('<body style="background:#ffffcc"><div id="trace" style="font:10px arial;">output</div></body>');
		opener.document.close();
		opener.onunload = function(){
			opener = new Object();
		}
	}	
	opener.document.getElementById('trace').innerHTML = opener.document.getElementById('trace').innerHTML +"\n<br/>"+tracecount+":"+msg;
}
function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
/*
* open a popup window
* usage: onclick="openWin('mypage.html', {windowname: 'mypage', width:600, height:300});
* options object is optional
*/
function openWin(url, options){

	if(! options)
	options = new Object;

	_width = options.width ? options.width:300;
	_height = options.height ? options.height:300;
	_scrollbars = options.scrollbars ? options.scrollbars:0;
	_resizable = options.resizable ? options.resizable:0;	
	_toolbar = options.toolbar ? options.toolbar:0;
	_statusbar = options.statusbar ? options.statusbar:0;
	_menubar = options.menubar ? options.menubar:0;
	_location = options.location ? options.location:0;
	_windowname = options.windowname ? options.windowname.replace( /\W+/g,'_' ):'popupwindow'; // replace all non word chars in windowname
	_left = options.left ? options.left:(screen.width - _width) / 2; // else the center of the screen
	_top = options.top ? options.top:(((screen.height - _height ) / 2) - 30); // else the center of the screen
	//window.open(url, windowname,'toolbar='+toolbar+',scrollbars='+scrollbars+',location='+location+',statusbar='+statusbar+',menubar='+menubar+',resizable='+resizable+',width='+width+',height='+height);
	_mypopup = window.open(url, _windowname,'toolbar='+_toolbar+',scrollbars='+_scrollbars+',location='+_location+',statusbar='+_statusbar+',menubar='+_menubar+',resizable='+_resizable+',width='+_width+',height='+_height+',top='+_top+',left='+_left);
	if(! _mypopup)
	alert("There was an error opening the "+_windowname+" window. If you have a popup-blocker please disable it for www.mitre10.com.au");
	else
	_mypopup.focus();
	
	return _mypopup;

}
/*
	submit keyword search forms in using /'s
*/
function submitSearch(element, url){
	if(! url)
	url = '_search/';
	searchfield = document.getElementById(element);
	window.location = url+searchfield.value;
}

function setVisible(id){
	document.getElementById(id).style.display = '';
}
function toggle(id){
	if(document.getElementById(id).style.display == 'none'){
		document.getElementById(id).style.display = '';
	}else{
		document.getElementById(id).style.display = 'none';
	}
}
/*
return the obect to after an element
*/
function nextObject (element) {
	var n = element;
	do n = n.nextSibling;
	while (n && n.nodeType != 1);
	return n;
}
function previousObject (element) {
	var n = element;
	do n = n.previousSibling;
	while (n && n.nodeType != 1);
	return n;
}
function closeFlash()
{
	$("flashhover").style.display='none';
	$("home_flash").style.display='block';
	$("home_flash2").style.display='block';
}

/* Slimbox JavaScript */
/* If the Fathers Day Promotion is over, then there is an excellent chance
/* that this crap can be removed...

/* Removed to separate file anyway */

function hidestuff()
{
	$("flashpagetitle").setStyle("display","none");
	$("bottomnav").setStyle("display","none");
}

function showstuff()
{
	$("flashpagetitle").setStyle("display","block");
	$("bottomnav").setStyle("display","block");
}

/*
function showstuff()
{
	$("flashpagetitle").setStyle("display","block");
	$("bottomnav").setStyle("display","block");
}
*/