/*  	
	Brown Paper Bag - Web Studio - Web Design - Web Creation - Web Hosting - Internet - Intranet
	Version 1.0
	Created: 4th March 2006
	By: info@brownpaperbag.com.au
	Modified: 

*/
//<![CDATA[

var current = '';
function WinLoad(func) {
	var oldonload = window.onload;
	if(typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() { 
			oldonload();
			func();
		}
	}
}

function externalLink() {
	for(i=0;i<document.links.length;i++) {
		var thisLink = document.links[i];
			if(thisLink.href.indexOf(document.domain) == -1) {
			thisLink.title += " (Opens in new window)";
			
			thisLink.onclick = function() {
			if(window.open(this.href,"newWindow")) 	return false;
			else return false;
			}
			thisLink.onkeypress = function() {
			if(window.open(this.href,"newWindow")) 	return false;
			else return false;
			}
		}
	}
}
WinLoad(externalLink);
/* Image Swapper */
function ImgSwp(oButton) {  // Image swapper
	var ext = oButton.src.substring(oButton.src.lastIndexOf("."), oButton.src.length)
	var path = oButton.src.substring(0, oButton.src.lastIndexOf("/")+1)
	var file = oButton.src.substring(oButton.src.lastIndexOf("/")+1,oButton.src.lastIndexOf("."))
	if (oButton != current){
		oButton.src = (((i = file.indexOf("_ovr")) >= 0) || ((i = file.indexOf("_on")) >= 0)) ? path + file.substring(0, file.lastIndexOf("_")) + ext : path + file + "_ovr" + ext;
	}
}



function loadPage() {

//This sets focus to the first entry field on a page that is not the search

  window.history.forward(1);

  if (document.forms.length > 0) {
    var field = document.forms[0];
    for (i = 0; i < field.length; i++) {
      if (((field.elements[i].tagName.toLowerCase() == "input") ||
          (field.elements[i].tagName.toLowerCase() == "select")) && 
          (field.elements[i].name.toLowerCase() != "search") &&
          (field.elements[i].disabled != true)) {
        if ((field.elements[i].tagName.toLowerCase() == "select") ||
            (field.elements[i].type.toLowerCase() == "text") || 
            (field.elements[i].type.toLowerCase() == "textarea") ) {
            document.forms[0].elements[i].focus();
            break;
        }
       }
     }
   }

}

function submitForm(action) {

    document.forms[0].formAction.value = action;

    if (action != 'Delete') {
        document.forms[0].SubmitPB.click();
    } 
    else {
        ask = confirm('Are you sure you wish to delete this record?');
        if (ask == true) {
            document.forms[0].SubmitPB.click();
        }
    }
}


function setAction(action) {

    if (document.forms[0].formAction) {
        document.forms[0].formAction.value = action;
    }

}

function displayBanners() {
    var bannerDiv = document.getElementById('BannerAd');
    var bannerIdx = Math.floor(Math.random() * banners.length);
    bannerDiv.innerHTML=banners[bannerIdx];
    setTimeout ('displayBanners()',25000);
}


//]]>
