<!--
// COMMON JAVASCRIPT FUNCTIONS
//   Changelog:
//      26-11-2003  MB   Added Popup window functions to specific URLs
//      21-10-2003  CW   Added currency conversion functions


/* IMAGE SWAPPING FUNCTIONS -------------------------------------------------- */
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

/* Functions that swaps images. */
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

/* OTHER COMMON FUNCTIONS ------------------------------------------------------ */

/* navigation */
function go(formname) {
    var navbox
    if (formname){
        navbox = document.forms[formname].navigate
    }
    else{
        navbox = document.forms["navMenu"].navigate;
    }
    dest = navbox.options[navbox.selectedIndex].value;

    if (dest) {
        if (dest != "In this section ..."){location.href = dest;}
        }
}

function popParent(url){
  var parent_win=this.opener;
  if(parent_win!=null){
    parent_win.navigate(url);
    parent_win.focus();
  }
}

function popupWindow(url, name, width, height, scrollbars) {
   window.open(url, name, "width=" + width + ",height=" + height + ",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=" + scrollbars + ",resizable=yes");
}

/* popup window */
function popup(url, width, height) {
    window.open(url, 'popup', "width=" +width+ ",height="+height+",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=yes");
}

function Printpopup(url, width, height,scrollbars) {
    window.open(url, 'popup', "width=" +width+ ",height="+height+",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=" + scrollbars + ",resizable=yes");
}

function writePopUpButton(url,altTag,width,height,scrollbars,overImage,offImage,imageID){
    document.write("<a onmouseout=\"MM_swapImgRestore();\" onmouseover=\"MM_swapImage('" + imageID + "','','" +overImage+"',1);\" onblur=\"MM_swapImgRestore();\" onfocus=\"MM_swapImage('" + imageID + "','','" + overImage +"',1);\" class=\"last\" href=\"javascript:Printpopup('" + url + "','" + width + "','" + height + "','" + scrollbars + "');\"><img class=\"action\" border=\"0\" alt=\"" + altTag + "\" id=\"" + imageID + "\" src=\"" + offImage + "\" /></a>");
}

function writePopUpButtonText(text,url,altTag,width,height,scrollbars,overImage,offImage,imageID){
    document.write("<a onmouseout=\"MM_swapImgRestore();\" onmouseover=\"MM_swapImage('" + imageID + "','','" +overImage+"',1);\" onblur=\"MM_swapImgRestore();\" onfocus=\"MM_swapImage('" + imageID + "','','" + overImage +"',1);\" class=\"last\" href=\"javascript:Printpopup('" + url + "','" + width + "','" + height + "','" + scrollbars + "');\"><img class=\"action\" border=\"0\" alt=\"" + altTag + "\" id=\"" + imageID + "\" src=\"" + offImage + "\" /> " + text + " </a>");
}

function writePoll(pollUrl,pollTitle,pollQuestion){
    document.write("<a href=\"javascript:popup('" + pollUrl + "',280,560);\" title=\"" + pollTitle + " (opens in a new window)\">" + pollQuestion + "</a>");
}

function writeNavigateButton(imgPath){
    document.write("<a href=\"javascript:go();\" onblur=\"MM_swapImgRestore();\" onfocus=\"MM_swapImage('doNav','','" + imgPath + "goHead_o.gif',1);\" onmouseout=\"MM_swapImgRestore();\" onmouseover=\"MM_swapImage('doNav','','" + imgPath + "goHead_o.gif',1);\"><img alt=\"Navigate to selected section\" border=\"0\" align=\"absbottom\" id=\"doNav\" src=\"" + imgPath + "goHead.gif\"></a>");
}

function writeNavigateButtonForm(imgPath, formName) {
  document.write("<a href=\"javascript:go('"+formName+"');\" onblur=\"MM_swapImgRestore();\" onfocus=\"MM_swapImage('doNav','','" + imgPath + "goHead_o.gif',1);\" onmouseout=\"MM_swapImgRestore();\" onmouseover=\"MM_swapImage('doNav','','" + imgPath + "goHead_o.gif',1);\"><img alt=\"Navigate to selected section\" border=\"0\" align=\"absbottom\" id=\"doNav\" src=\"" + imgPath + "goHead.gif\"></a>");

}

function writeForumNavigateButton(imgPath, formName){
    document.write("<a href=\"javascript:go('"+formName+"');\" onfocus=\"MM_swapImage('btnNavGo','','" + imgPath + "btn_go_over.gif',1);\" onblur=\"MM_swapImgRestore();\" onmouseover=\"MM_swapImage('btnNavGo','','" + imgPath + "btn_go_over.gif',1);\" onmouseout=\"MM_swapImgRestore();\" title=\"Go\"><img src=\"" + imgPath + "btn_go.gif\" name=\"btnNavGo\" id=\"btnNavGo\" alt=\"GO\" border=\"0\" /></a>");
}


/* currency converstion ------------------------------------------------- */

var prefix="$";
var wd;

function toCurrency(number) {
  var num = Number(number).toString();
  var retval;
  if (num.charAt(0)=="$")
    return
      wd="w";
  var tempnum = num.toString();
  for (i=0; i < tempnum.length; i++){
    if (tempnum.charAt(i)==".") {
      wd="d";
      break;
    }
  }
  if (wd=="w")
    retval=prefix+tempnum+".00";
  else {
    if (tempnum.charAt(tempnum.length-2)==".") {
      retval=prefix+tempnum+"0";
    }
    else{
      tempnum=Math.round(tempnum*100)/100;
      retval=prefix+tempnum;
    }
  }
  return retval;
} 
function toDecimal(number) {
  if (number.charAt(0)=='$') {
    return Number(number.substr(1));
  } else {
    return number;
  }
}

/* FLASH DETECTION ------------------------------------------------------------- */
var flashVersion = 0;
function getFlashVersion() {
	var agent = navigator.userAgent.toLowerCase(); 
    
	// NS3 needs flashVersion to be a local variable
	if (agent.indexOf("mozilla/3") != -1 && agent.indexOf("msie") == -1) {
		flashVersion = 0;
	}
   
    // NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Flash plugin in plugin array
    if (navigator.plugins != null && navigator.plugins.length > 0) {
        var flashPlugin = navigator.plugins['Shockwave Flash'];
        if (typeof flashPlugin == 'object') { 
            if (flashPlugin.description.indexOf('7.') != -1) flashVersion = 7;
            else if (flashPlugin.description.indexOf('6.') != -1) flashVersion = 6;
            else if (flashPlugin.description.indexOf('5.') != -1) flashVersion = 5;
            else if (flashPlugin.description.indexOf('4.') != -1) flashVersion = 4;
            else if (flashPlugin.description.indexOf('3.') != -1) flashVersion = 3;
        }
    }

    // IE4+ Win32:  attempt to create an ActiveX object using VBScript
    else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
       document.write('<scr' + 'ipt language="VBScript"\> \n');
        document.write('on error resume next \n');
        document.write('dim obFlash \n');
        document.write('set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.7") \n');
        document.write('if IsObject(obFlash) then \n');
        document.write('flashVersion = 7 \n');
        document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.6") end if \n');
        document.write('if flashVersion < 7 and IsObject(obFlash) then \n');
        document.write('flashVersion = 6 \n');
        document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.5") end if \n');
        document.write('if flashVersion < 6 and IsObject(obFlash) then \n');
        document.write('flashVersion = 5 \n');
        document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.4") end if \n');
        document.write('if flashVersion < 5 and IsObject(obFlash) then \n');
        document.write('flashVersion = 4 \n');
        document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.3") end if \n');
        document.write('if flashVersion < 4 and IsObject(obFlash) then \n');
        document.write('flashVersion = 3 \n');
        document.write('end if');
        document.write('</scr' + 'ipt\> \n');
	}
    // WebTV 2.5 supports flash 3
    else if (agent.indexOf("webtv/2.5") != -1) flashVersion = 3;
    // older WebTV supports flash 2
    else if (agent.indexOf("webtv") != -1) flashVersion = 2;
    // Can't detect in all other cases
    else {
        flashVersion = flashVersion_DONTKNOW;
    }
    return flashVersion;
}
flashVersion_DONTKNOW = -1;


// Quicktime Detection  v1.0
// documentation: http://www.dithered.com/javascript/quicktime_detect/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)
var quicktimeVersion = 0;
function getQuicktimeVersion() {
var agent = navigator.userAgent.toLowerCase(); 
// NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Quicktime plugin in plugin array
if (navigator.plugins != null && navigator.plugins.length > 0) {
	for (i=0; i < navigator.plugins.length; i++ ) {
		var plugin =navigator.plugins[i];
		if (plugin.name.indexOf("QuickTime") > -1) {
			quicktimeVersion = parseFloat(plugin.name.substring(18));
		}
	}
}
// IE4+ Win32:  attempt to create an ActiveX object using VBScript
else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
	document.write('<scr' + 'ipt language="VBScript"\> \n');
	document.write('on error resume next \n');
	document.write('dim obQuicktime \n');
	document.write('set obQuicktime = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1") \n');
	document.write('if IsObject(obQuicktime) then \n');
	document.write('   if obQuicktime.IsQuickTimeAvailable(0) then \n');
	document.write('      quicktimeVersion = CInt(Hex(obQuicktime.QuickTimeVersion) / 1000000) \n');
	document.write('   end if \n');
	document.write('end if \n');
	document.write('</scr' + 'ipt\> \n');
}

// Can't detect in all other cases
else {
	quicktimeVersion = quicktimeVersion_DONTKNOW;
}
//alert(quicktimeVersion);
return quicktimeVersion;
}
quicktimeVersion_DONTKNOW = -1;

/* POP-UP WINDOWS FUNCTIONS (NMA Specific) -------------------------------------------------- */
/* These are here due to bug #229-6757, functionality can be recoded once this has been resolved */
function JerilderiePopup() {popup("http://www.nma.gov.au/outlawed/jerilderie/home.html", 770, 540);}

function makeYourVerdictPopup() {popup("http://www.nma.gov.au/outlawed/make_your_verdict/", 679, 543);}

/* Generic delete confirmation */
function confirm_delete(label, url) {
    bPrompt = confirm('Are you sure you wish to delete ' + label + '?');
    if (bPrompt) { document.location = url; }
}

/* BOOKMARK THIS PAGE ------------------------------------------------------------- */
function addbookmark() {
    bookmarkurl=document.URL;
    bookmarktitle=document.title;
    if (document.all)
    {
        window.external.AddFavorite(bookmarkurl,bookmarktitle);
    }
}

/* double click disabler */
submitted = false;
function doubleclickCheck(submitObj) {
	if(submitted) {
		submitObj.disabled = true;
	} else {
		submitted = true;
	}
}

//-->

