function getBanner(inNumOfChoices)
{
    var imgElement = document.getElementById("bannerImg");

    // Get a random number between 0 and inNumOfChoices

    id = Math.floor(Math.random() * inNumOfChoices);
    imgElement.src = imgElement.src + "banner" + id + ".gif";
}



function addBookmark()
{
    var browser	       = navigator.appName;
    var browserVersion = parseInt(navigator.appVersion);

    if ((browser == "Microsoft Internet Explorer") && (browserVersion >= 4))
    {
	window.external.AddFavorite("http://www.calypso.net.au/", "My CalypsoNet");
    }
    else
    {
       alert("Press Ctrl+D to bookmark us, after clicking OK below.");
    }
}



function setWindowStatus(inStatusMsg)
{
    if (inStatusMsg == null)
	window.status = "";
    else
	window.status = inStatusMsg;

    return(true);
}



function openWholesaler(inUrl)
{
    var width	= 776;
    var height	= 558;
    var left	= (screen.width	 - width)  / 2;
    var top	= (screen.height - height) / 2;
    var params	= "toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, menubar=no, resizable=yes," +
		  "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width;

    window.open(inUrl, "", params);

    return(false);
}



function reloadParent()
{
    // Get the (parent) window that opened this window.

    var parentWindow = window.opener;

    // If the parent window exists and the URL its currently at begins with "http://www.calypso.net.au/",
    // then reload the parent window.

    if ((parentWindow != null) && !parentWindow.closed)
    {
	try
	{
	    var parentUrl = new String(parentWindow.location);
	    parentUrl	  = parentUrl.toLowerCase();

	    var matches = parentUrl.match("^http://www.calypso.net.au/");

	    if (matches)
		parentWindow.location.reload();
	}
	catch (exception)
	{
	    // Access denied on parentWindow.location property. Just close current window.
	    // The function returns straight after executing the catch block.

	    window.close();
	}
    }

    // Close the current (child) window.

    window.close();
}



function submitQuickLaunch(inSelectElem)
{
    var quickLaunchForm = document.getElementById("quickLaunchForm");

    // Open the selected wholesaler.
    openWholesaler(quickLaunchForm.action + "?wholesalerId=" + inSelectElem.options[inSelectElem.selectedIndex].value);

    // Reset the select list to the first item.
    inSelectElem.options[0].selected = true;
}



function newWindow(inURL)
{
    var newWindow = window.open(inURL);

    if ((navigator.userAgent.toLowerCase().indexOf("msie") == -1) || (parseInt(navigator.appVersion) >= 5))
	newWindow.focus();

    return(false);
}



function openWindow(inClient, inAgSu, inAuNz, inType)
{
    var width	= 776;
    var height	= 558;
    var left	= (screen.width - width) / 2;
    var top	= (screen.height - height) / 2;
    var params1	= "toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, menubar=no, resizable=yes," +
		  "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width;
    var params2 = "toolbar=yes, location=yes, directories=yes, status=yes, scrollbars=yes, menubar=yes, resizable=yes," +
		  "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width;
    var url;

    if (inAuNz == "au")
	url = "https://www.calypso.net.au/" + inAgSu + "/" + inClient + "?o=p";
    else
    if (inAuNz == "nz")
	url = "https://calypsoweb.co.nz/" + inAgSu + "/" + inClient + "?o=p";
    else
	url = inClient;

    if (inType == 1)
	window.open(url, "", params1);
    else
	window.open(url, "", params2);
}



function openWindowUrl(inUrl)
{
    var width	= 776;
    var height	= 558;
    var left	= (screen.width - width) / 2;
    var top	= (screen.height - height) / 2;
    var params1 = "toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, menubar=no, resizable=yes," +
		  "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width;

    window.open(inUrl, "", params1);
}



function openPrintableDisclaimer()
{
    /* ------------------------------------------------------------------------------------------------------------------------- */
    /* Obtain disclaimer from text area of create user form.									 */
    /* ------------------------------------------------------------------------------------------------------------------------- */

    var disclaimer = document.getElementById("disclaimer").innerHTML;

    /* ------------------------------------------------------------------------------------------------------------------------- */
    /* Open new window and populate the page with a title and heading.								 */
    /* ------------------------------------------------------------------------------------------------------------------------- */

    var disclaimerWindow = open("","","toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes," +
				 "resizable=yes,width=600,height=700");

    disclaimerWindow.document.write("<html>");
    disclaimerWindow.document.write("<head>");
    disclaimerWindow.document.write("<title>CalypsoNet - Disclaimer and Privacy</title>");
    disclaimerWindow.document.write("</head>");
    disclaimerWindow.document.write("<body>");
    disclaimerWindow.document.write("<h2>CalypsoNet - Disclaimer and Privacy</h2><br/>");

    /* ------------------------------------------------------------------------------------------------------------------------- */
    /* For every new line character found ('\n'), write the characters up to and including the new line character to the page,	 */
    /* and then write an additional <br/> tag.											 */
    /* ------------------------------------------------------------------------------------------------------------------------- */

    var newLineIndex = disclaimer.indexOf('\n');

    while (newLineIndex >= 0)
    {
	disclaimerWindow.document.write(disclaimer.substring(0, newLineIndex + 1));
	disclaimerWindow.document.write("<br/>");

	disclaimer = disclaimer.substring(newLineIndex + 1, disclaimer.length);
	newLineIndex = disclaimer.indexOf('\n');
    }

    disclaimerWindow.document.write(disclaimer);

    disclaimerWindow.document.write("</body>");
    disclaimerWindow.document.write("</html>");
    disclaimerWindow.document.close();
}



function checkSelections(inFieldIds)
{
    for (index in inFieldIds)
    {
	checkSelection(inFieldIds[index]);
    }
}



function checkSelection(inFieldId)
{
    var field		  = document.getElementById(inFieldId);
    var fieldOtherHeading = document.getElementById(inFieldId + "OtherHeading");
    var fieldOther	  = document.getElementById(inFieldId + "Other");

    if (field.options[field.selectedIndex].innerHTML == "Other")
    {
	showVisibility(fieldOtherHeading);
	showVisibility(fieldOther);
	enableField(fieldOther);
    }
    else
    {
	hideVisibility(fieldOtherHeading);
	hideVisibility(fieldOther);
	disableField(fieldOther);
	clearContent(fieldOther);
    }
}



function focusOnField(inFieldId)
{
    anchor(inFieldId);
    cursorOnField(inFieldId);
}



function showAddWholesaler(inClickedButton)
{
    var addForm	  = document.getElementById("wholesalerAddForm");
    var addDiv	  = document.getElementById("wholesalerAddDiv");
    var addButton = document.getElementById("wholesalerAddButton");

    noneDisplay(addButton);
    blockDisplay(addDiv);
    location.hash = "#wholesalerAddDiv";

    // Hide status and/or error messages when the user manually clicked the "Add wholesaler" button.

    if (inClickedButton)
	hideStatusErrorMsg();

    focusFirstElement(addForm);
}



function showChangeWholesaler(inWholesalerName, inWholesalerId)
{
    var changeForm = document.getElementById("wholesalerChangeForm");
    var changeDiv  = document.getElementById("wholesalerChangeDiv");
    var nameCell   = document.getElementById("wholesalerChangeName");
    var idHidden   = document.getElementById("wholesalerChangeIdHidden");
    var addDiv	   = document.getElementById("wholesalerAddDiv");
    var addButton  = document.getElementById("wholesalerAddButton");

    var errorChangeLogin    = document.getElementById("errorChangeLogin");
    var errorChangePassword = document.getElementById("errorChangePassword");

    /* ------------------------------------------------------------------------------------------------------------------------- */
    /* "Change Wholesaler" is currently hidden											 */
    /* ------------------------------------------------------------------------------------------------------------------------- */

    if (changeDiv.style.display == "none")
    {
	if (addDiv)
	{
	    if (addDiv.style.display == "block")
	    {
		noneDisplay(errorChangeLogin);
		noneDisplay(errorChangePassword);
	    }

	    noneDisplay(addButton);
	    noneDisplay(addDiv);
	}

	if (inWholesalerName != null) nameCell.innerHTML = inWholesalerName;
	if (inWholesalerId   != null) idHidden.value	 = inWholesalerId;

	blockDisplay(changeDiv);

	location.hash = "#wholesalerChangeDiv";
    }

    /* ------------------------------------------------------------------------------------------------------------------------- */
    /* "Change Wholesaler" is already displaying but the wholesaler to change is different					 */
    /* ------------------------------------------------------------------------------------------------------------------------- */

    else if (idHidden.value != inWholesalerId)
    {
	nameCell.innerHTML = inWholesalerName;
	location.hash = "#wholesalerChangeDiv";

	resetForm(document.getElementById("wholesalerChangeForm"));
	noneDisplay(errorChangeLogin);
	noneDisplay(errorChangePassword);

	idHidden.value = inWholesalerId;
    }

    hideStatusErrorMsg();
    focusFirstElement(changeForm);

    return(false);
}



function showMyWholesaler()
{
    var addDiv	   = document.getElementById("wholesalerAddDiv");
    var changeDiv  = document.getElementById("wholesalerChangeDiv");
    var addButton  = document.getElementById("wholesalerAddButton");
    var addForm	   = document.getElementById("wholesalerAddForm");
    var changeForm = document.getElementById("wholesalerChangeForm");

    var errorAddWholesalerId = document.getElementById("errorAddWholesalerId");
    var errorAddLogin	     = document.getElementById("errorAddLogin");
    var errorAddPassword     = document.getElementById("errorAddPassword");

    var errorChangeLogin    = document.getElementById("errorChangeLogin");
    var errorChangePassword = document.getElementById("errorChangePassword");

    noneDisplay(addDiv);
    noneDisplay(changeDiv);
    blockDisplay(addButton);

    location.hash = "#";

    /* ------------------------------------------------------------------------------------------------------------------------- */
    /* Reset the "Add wholesaler" form and hide any error messages associated with the previous form submission.		 */
    /* ------------------------------------------------------------------------------------------------------------------------- */

    resetForm(addForm);
    noneDisplay(errorAddWholesalerId);
    noneDisplay(errorAddLogin);
    noneDisplay(errorAddPassword);

    /* ------------------------------------------------------------------------------------------------------------------------- */
    /* Reset the "Edit wholesaler" form and hide any error messages associated with the previous form submission.		 */
    /* ------------------------------------------------------------------------------------------------------------------------- */

    resetForm(changeForm);
    noneDisplay(errorChangeLogin);
    noneDisplay(errorChangePassword);
}



function hideStatusErrorMsg()
{
    var statusMsg = document.getElementById("statusMsg");
    var errorMsg  = document.getElementById("errorMsg");

    noneDisplay(statusMsg);
    noneDisplay(errorMsg);
}



function resetForm(inForm)
{
    for (var elemIdx = 0; elemIdx < inForm.elements.length; elemIdx++)
    {
	var elem = inForm[elemIdx];

	if (elem.type == "text")
	    clearContent(elem);
	else if (elem.type == "select-one")
	    elem.options[0].selected = true;
    }
}



function focusFirstElement(inForm)
{
    for (i = 0; i < inForm.length; i++)
    {
	var element = inForm.elements[i];

	if (element.type == "text" || element.type == "select-one" || element.type == "radio" || element.type == "password")
	{
	    cursorOnField(element.id);
	    return;
	}
    }
}



function removeWholesaler(inWholesalerName)
{
    if (confirm("Are you sure you want to remove " + inWholesalerName + "?"))
	return(true);

    return(false);
}



function cursorOnField(inFieldId)
{
    var element = document.getElementById(inFieldId);
    if (element != null) element.focus();
}



function anchor(inAnchor)
{
    window.location.hash = inAnchor;
}



function showVisibility(inElement)
{
    if (inElement != null)
	inElement.style.visibility = "visible";
}



function hideVisibility(inElement)
{
    if (inElement != null)
	inElement.style.visibility = "hidden";
}



function blockDisplay(inElement)
{
    if (inElement != null)
	inElement.style.display = "block";
}



function noneDisplay(inElement)
{
    if (inElement != null)
	inElement.style.display = "none";
}



function disableField(inField)
{
    if (inField != null)
	inField.disabled = true;
}



function enableField(inField)
{
    if (inField != null)
	inField.disabled = false;
}



function clearContent(inField)
{
    if (inField != null)
	inField.value = "";
}



function highlightRow(inRow)
{
    inRow.bgColor = "#c0cfec";
}



function unhighlightRow(inRow)
{
    inRow.bgColor = "#dde6f7";
}



// START OF SmartSource Data Collector TAG
// Copyright 1999-2003 NetIQ Corporation. All rights reserved.
// V6.1
// $DateTime: 2003/09/30 11:23:29 $

var gVersion="1.2";
var gImages=new Array;
var gIndex=0;
var DCS=new Object();
var WT=new Object();
var DCSext=new Object();

var gDomain="statse.webtrendslive.com";
var gDcsId="dcsk8khaa21e5hivl8507hjvp_3l1d";

function doWebTrends()
{
    dcsVar();
    dcsMeta();
    dcsTag();
}

function dcsVar(){
    var dCurrent=new Date();
    WT.tz=dCurrent.getTimezoneOffset()/60*-1;
    if (WT.tz==0){
	WT.tz="0";
    }
    WT.bh=dCurrent.getHours();
    WT.ul=navigator.appName=="Netscape"?navigator.language:navigator.userLanguage;
    if (typeof(screen)=="object"){
	WT.cd=navigator.appName=="Netscape"?screen.pixelDepth:screen.colorDepth;
	WT.sr=screen.width+"x"+screen.height;
    }
    if (typeof(navigator.javaEnabled())=="boolean"){
	WT.jo=navigator.javaEnabled()?"Yes":"No";
    }
    if (document.title){
	WT.ti=document.title;
    }
    WT.js="Yes";
    if (typeof(gVersion)!="undefined"){
	WT.jv=gVersion;
    }
    WT.sp="46022";
    DCS.dcsdat=dCurrent.getTime();
    DCS.dcssip=window.location.hostname;
    DCS.dcsuri=window.location.pathname;
    if (window.location.search){
	DCS.dcsqry=window.location.search;
    }
    if ((window.document.referrer!="")&&(window.document.referrer!="-")){
	if (!(navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)<4)){
	    DCS.dcsref=window.document.referrer;
	}
    }
}

function A(N,V){
    return "&"+N+"="+dcsEscape(V);
}

function dcsEscape(S){
    if (typeof(RE)!="undefined"){
	var retStr = new String(S);
	for (R in RE){
		retStr = retStr.replace(RE[R],R);
	}
	return retStr;
    }
    else{
	return escape(S);
    }
}

function dcsCreateImage(dcsSrc){
    if (document.images){
	gImages[gIndex]=new Image;
	gImages[gIndex].src=dcsSrc;
	gIndex++;
    }
    else{
	document.write('<IMG BORDER="0" NAME="DCSIMG" WIDTH="1" HEIGHT="1" SRC="'+dcsSrc+'">');
    }
}

function dcsMeta(){
    var myDocumentElements;
    if (document.all){
	myDocumentElements=document.all.tags("meta");
    }
    else if (document.documentElement){
	myDocumentElements=document.getElementsByTagName("meta");
    }
    if (typeof(myDocumentElements)!="undefined"){
	for (var i=1;i<=myDocumentElements.length;i++){
	    myMeta=myDocumentElements.item(i-1);
	    if (myMeta.name){
		if (myMeta.name.indexOf('WT.')==0){
		    WT[myMeta.name.substring(3)]=myMeta.content;
		}
		else if (myMeta.name.indexOf('DCSext.')==0){
		    DCSext[myMeta.name.substring(7)]=myMeta.content;
		}
		else if (myMeta.name.indexOf('DCS.')==0){
		    DCS[myMeta.name.substring(4)]=myMeta.content;
		}
	    }
	}
    }
}

function dcsTag(){
    var P="http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+gDomain+(gDcsId==""?'':'/'+gDcsId)+"/dcs.gif?";
    for (N in DCS){
	if (DCS[N]) {
	    P+=A(N,DCS[N]);
	}
    }
    for (N in WT){
	if (WT[N]) {
	    P+=A("WT."+N,WT[N]);
	}
    }
    for (N in DCSext){
	if (DCSext[N]) {
	    P+=A(N,DCSext[N]);
	}
    }
    if (P.length>2048&&navigator.userAgent.indexOf('MSIE')>=0){
	P=P.substring(0,2040)+"&WT.tu=1";
    }
    dcsCreateImage(P);
}

// END OF Data Collection Server TAG
