function pr() {
	window.print();
}

function cl() {
	window.close();
}

function re(url)
{
	location.href = url;
}

function bk()
{
	history.go(-1);
}

function fw()
{
	history.go(1);
}

function QueryString(q) {
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
			if(this.keyValuePairs[j].split("=")[0] == s)
				return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; }	
}

function getQueryStringValue(key){
    var qs = new QueryString(window.location.search); 
    return unescape(qs.getValue(key)); 
}

function customValidateDate(source, args)
{
    //alert(Date.parse(args.Value) + " " + isNaN( Date.parse(args.Value) ) );
    if (isNaN(Date.parse(args.Value)))
        args.IsValid = false;
    else
        args.IsValid = true;                                
}

function customValidateAmount(source, args)
{
    if (args.Value < 1)
        args.IsValid = false;
    else
        args.IsValid = true;                    
}

//var currMsgShown = false;
function showCurrMsg(sel)
{
    var selCurr = sel[sel.selectedIndex].value;
    if ((selCurr == 'NZD' || selCurr == 'SGD' || selCurr == 'JPY')) // !currMsgShown && 
    {
        alert("Please note that we prefer donations in Australian Dollars (AUD) as they attract the least processing fees.\n\nThe only exception to this is if you use a currency that is stronger than the Australian Dollar.\n\nYou can use the provided link to the currency conversion website to determine the most appropriate amount to donate in Australian Dollars.\n\nThank you.");
        currMsgShown = true;
    }
}

function showHide(elemID)
{
    // code from: http://www.netlobo.com/div_hiding.html
    
    var elem, vis;  
    if( document.getElementById ) // this is the way the standards work
        elem = document.getElementById( elemID );
    else if( document.all ) // this is the way old msie versions work
        elem = document.all[elemID];
    else if( document.layers ) // this is the way nn4 works
        elem = document.layers[elemID];

    vis = elem.style;

    // if the style.display value is blank we try to figure it out here
    if(vis.display=='' && elem.offsetWidth != undefined && elem.offsetHeight != undefined)
        vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0) ? 'block' : 'none';  

    vis.display = (vis.display == '' || vis.display == 'block') ? 'none' : 'block';
}

function doPostBack(eventTarget)
{
    __doPostBack(eventTarget, null);
}


// http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html
function getClientWidth() {
    return getFilterResults(
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}

function getClientHeight() {
    return getFilterResults(
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}

function getScrollLeft() {
    return getFilterResults(
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}

function getScrollTop() {
    return getFilterResults(
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function getFilterResults(n_win, n_docel, n_body) {
    var n_result = n_win ? n_win : 0;
    if (n_docel && (!n_result || (n_result > n_docel)))
        n_result = n_docel;
    return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}