
    //*******************************************************
    //  General Purpose Functions
    //*****************************************************

    //User agent object for the current user.
    var agent=new UserAgent();


    //****************************************************
    //  USer Agent Object
    //
    //  Object used to determine the current type of browser
    //*****************************************************
	function UserAgent() {
        var b=navigator.appName;
        if (b=="Netscape") this.b="ns";
        else if (b=="Microsoft Internet Explorer") this.b="ie";
        else this.b=b;
        this.version=navigator.appVersion;
        this.v=parseInt(this.version);
        this.ns=(this.b=="ns" && this.v>=4);
        this.ns4=(this.b=="ns" && this.v==4);
        this.ns5=(this.b=="ns" && this.v==5);
        this.ie=(this.b=="ie" && this.v>=4);
        this.ie4=(this.version.indexOf('MSIE 4')>0);
        this.ie5=(this.version.indexOf('MSIE 5')>0);
        this.ie55=(this.version.indexOf('MSIE 5.5')>0);
        this.ie6=(this.version.indexOf('MSIE 6')>0);
        this.ie7=(this.version.indexOf('MSIE 7')>0);
        this.ie4up = (this.ie4 || this.ie5 || this.ie55 || this.ie6 || this.ie7);
        this.ns4up = (this.ns && this.v >= 4);
        this.ie5up = (this.ie5 || this.ie55 || this.ie6 || this.ie7 ||(this.ie && this.v >= 5));
		return this;
	}
    //------------------------------------------------------
    //  USer Agent Object End
    //------------------------------------------------------


    //****************************************************
    //  Cross Browser Stuff
    //*****************************************************

    //Find the html element for the given id in browser independent manner
	function findElementById(doc, id) {
		if (id == null || id == "") {
			return null;
		}
		if (doc.getElementById) {
			return doc.getElementById(id);
		} else if (agent.ie4up) {
			return doc.all[id];
		} else if (agent.ns4up) {
			return doc.layers[id];
		}
  	}

	function getWindowHeight() {
        if (self.innerWidth) {
            return self.innerHeight;
        }
        else if (document.documentElement && document.documentElement.clientWidth) {
            return document.documentElement.clientHeight;
        }
        else if (document.body) {
            return document.body.clientHeight;
        } else {
            return 0;
        }
	}

    //Find the html element for the given id in browser independent manner
	function findElementById(id) {
		if (document.getElementById) {
			return document.getElementById(id);
		} else if (agent.ie4up) {
			return document.all[id];
		} else if (agent.ns4up) {
			return document.layers[id];
		}
  	}

	//Find css object in browser independent manner
	function getCss(target) {
		if (document.getElementById) {
			return target.style;
		} else if (agent.ie4up) {
			return target.style;
		} else if (agent.ns4up) {
			return target;
		}
	}

	//Toggle the visibility of an element.
	function toggle(id) {
		var element = findElementById(id);
		if (element) {
			var css = getCss(element);
			if (css.display != "none") {
				css.display = "none";
			} else {
				css.display = "";
			}
		}
	}


	//**************************************************
	// General Keyboard functions
	//**************************************************

	function getEvent() {
		var e = null;
		if (agent.ie5up) {
        	e = window.event;
   	 		if (e == null && getStatusWindow() != null) {
   	 			e = getStatusWindow().getEvent();
   	 		}
   	 	}
   	 	return e;
	}

	function getKeyEventChar(e) {
		var ch = null;
		if (e != null) {
			if (e.keyCode) ch = e.keyCode;
			else if (e.charCode) ch = e.charCode;
		}
		return ch;
	}

	function enforceMaxLengthOnKeyPress(source, max) {
		var e = getEvent();
		var ch = getKeyEventChar(e);
   	 	if (e != null && ch != null && ch >=32 && ch <=127) {
   	 		var range = source.createTextRange();
	  	 	var currentValue = range.text;
			if (currentValue != null && currentValue.length >= max) {
				return e.returnValue = false;
			}
		}
		return;
	}

	//Reload the current View
    function refreshView() {
        window.location.reload();
    }

	//Go back one step in browser history
    function goBackward() {
        history.back();
    }


	//Swap an image source to the given name
    function swap(img, imageName) {
        img.src = eval(imageName + ".src");
    }

    //Opens a url in an external window
    function openUrl(url) {
        if (url.substring(0, 7).toUpperCase() == "HTTP://") {
            window.open(url,"redirect");
        } else {
            window.open("http://" + url,"redirect");
        }
    }

    //Do Nothing function ... used to create disabled links.
    function x() {
    }

    //Show a message as popup alert
    function showMessage(msg) {
    	alert(msg);
    }








