﻿//Disable the control that submits the form
function submitFormOnce(sender) {
   if (sender.disabled==false) {
        document.aspnetForm.submit();
        sender.disabled=true;
    } else {
        return false;
    }
}
//prints the contents of an iFrame and blocks the form submit
function printiFrame() {
    ifrm.focus();
    ifrm.print();
    return false;
}

//Goes back one page in the browser history
function backPage() {
    document.aspnetForm.submit=true;
    window.history.go(-1);
    return false;
}

//Confirms that the button action is t/f
function confirmClick(sMsg) {
    if (confirm(sMsg)) {
        //alert('Action confirmed!');
        document.aspnetForm.action='';
        document.aspnetForm.submit();
    } else {
        //alert('** Block Action **');
        return false;
    }
}

//Kills the enter key on a text box
function killEnter(myfield,e) {
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    if (keycode == 13) {
        return false;
    } else {
        return true;
    }
}

//Returns the key code
function getKeyCode(e) {
    if (window.event)
        return window.event.keyCode;
    else if (e)
        return e.which;
    else
    	return null;
}

//Limits the number of characters typed in to a text field
function checkLength(obj,iLen) {
	if (obj.value.length>=iLen) {
		obj.value=obj.value.substring(0, iLen);
		alert('You have reached the maximum number of characters for this field (' + obj.value.length + ')');
	}	
}

//Pops up an external help window
function popupHelpTopic(url)
{
    var newwindow;
	newwindow=window.open(url,'name','child','height=1024px,width=768px');
	if (window.focus) {newwindow.focus()}
}

function addBookmark(url,desc){
	var bookmarkurl      = url;
	var bookmarktitle    = desc;
	var nonie            = 'Sorry, only Mozilla Firefox and Internet Explorer support this method to add a bookmark/favourite\n But please feel free to visit the site\'s home page to add a bookmark manually';

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(bookmarktitle, bookmarkurl,"");
	} else if(document.all){ // IE Favourites
		window.external.AddFavorite(bookmarkurl,bookmarktitle);
	} else {
		alert(nonie);
	}
}