function confirmActionGet(msg, url)
{
    //If the user selected ok, submit the form and return true
    if (confirm(msg) != false)
    {
        self.location.href=url;
        return true;
    }

    return false;
}
function confirmActionSubmit(msg, frm)
{
    //If the user selected ok, submit the form and return true
    if (confirm(msg) != false)
    {
        frm.submit();
        return true;
    }

    return false;
}
function new_window(file, name, params)
{
    my_window = window.open(file, name, params);
}
function close_window()
{
    my_window.close();
}
function setAllCheckBoxes(fmobj, toggle, exlusivitycheck)
{
    var s=0;
    //Run through form elements
    for (var i=0;i<fmobj.elements.length;i++)
    {
        //Create object of each form element
        var e = fmobj.elements[i];
        //If the element is a checkbox and id matches exlusivitycheck, set toggle on
        if ((e.type=='checkbox') && (!e.disabled) && (e.id == exlusivitycheck) )
        {
            s++;
            e.checked = toggle;
        }
    }
}
function setAllDropdownMenuOptions(fmobj, exlusivitycheck, selectvalue)
{
    var s=0;
    //Run through form elements
    for (var i=0;i<fmobj.elements.length;i++)
    {
        //Create object of each form element
        var e = fmobj.elements[i];
        //If the element is a checkbox and id matches exlusivitycheck, set toggle on
        if ((e.type=='select-one') && (!e.disabled) && (e.id == exlusivitycheck) )
        {
            //Run through options
            for (k=0; k<e.options.length; k++)
            {
                if (e.options[k].id == selectvalue)
                {
                    e.options.selectedIndex = k;
                }
            }
            s++;
        }
    }
}
function getDropdownSelectedCount(fmobj, exlusivitycheck, selectvalue)
{
    var s=0;
    //Run through form elements
    for (var i=0;i<fmobj.elements.length;i++)
    {
        //Create object of each form element
        var e = fmobj.elements[i];
        //If the element is a checkbox and id matches exlusivitycheck, set toggle on
        if ((e.type=='select-one') && (!e.disabled) && (e.id == exlusivitycheck) )
        {
            //Check if the current select box's selected otion contains the select value
            if (strpos(e.options[e.options.selectedIndex].value, selectvalue, 0))
            {
                s++;
            }
        }
    }
    return s;
}
//This function confirms if an action must occur or not
//by prompting for the users input by displaying msg
function confirmAction(msg)
{
    if (confirm(msg)==false)
    {
        return false;
    }

    return true;
}

/**
Returns an HTTP object for the browser the user is on in order to do
GET and POST sends directly to a web page without refreshing it
*/
function getXmlHttpObject()
{
    var xmlHttp=null;
    try
    {
        //Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        //Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
                //IceBrowser
                xmlHttp=window.createRequest();
            }
        }
    }
    return xmlHttp;
}

/**
Make up a get string from an array e.g.
if an array is passed like array('a=1', 'b=2', 'c=3');
then this function will return it like so...
?a=1&b=2&c=3
*/
function makeGetString(array)
{
    //Ensure that the array has elements
    if (array.length > 0)
    {
        return '?'+array.join('&');
    }
    return '';
}

//Make the function name dynamic in order to use it in virtually any way
function ajaxCall(url, div, vararray)
{
    //Get HTTP object. Function defined in javascript/functions.js
    xmlHttp=getXmlHttpObject()
    //Browser does not support an HTTP request if the object returneed is null
    if (xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request");
        return;
    }
    //Write url pages response to element if the page has completed
    //all its tasks and gets to the complete state
    xmlHttp.onreadystatechange=function()
    {
        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
        {
            setInnerHTML(div, xmlHttp.responseText);
        }
    }
    //Build up the URL get parameters if they exists
    var getparameters = makeGetString(vararray);
    //Open the url through a GET request
    xmlHttp.open("GET",url+getparameters,true);
    //Call the url
    xmlHttp.send(null);
}

/**
This function sets the inner html of an object
*/
function setInnerHTML(objectname, value)
{
    document.getElementById(objectname).innerHTML=value;
}

/**
This function gets the inner html of an object
*/
function getInnerHTML(objectname)
{
    return document.getElementById(objectname).innerHTML;
}

/**
Find the position in a string
*/
function strpos(haystack, needle, offset)
{
    var i = (haystack+'').indexOf( needle, offset );
    return i===-1 ? false : i;
}

/**
Format a number into user-readable format e.g.
456789 will convert to 456,789
*/
function formatNumber(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

//--------------------------------------------------------------------------------//
//Disable mouse right click on the web site
var message="Dear client. This function has been disabled for use on this site.";

///////////////////////////////////
function clickIE4()
{
    if (event.button==2)
    {
        alert(message);
        return false;
    }
}

function clickNS4(e)
{
    if (document.layers||document.getElementById&&!document.all)
    {
        if (e.which==2||e.which==3)
        {
            alert(message);
            return false;
        }
    }
}

if (document.layers)
{
    document.captureEvents(Event.MOUSEDOWN);
    document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById)
{
    document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")
//--------------------------------------------------------------------------------//