﻿    function ClearBox(box, defaultText)
    {
        if (box.value==defaultText)
        {
            box.value = "";
        }
    }
    
    function DefaultBox(box, defaultText)
    {
        if (box.value=="")
        {
            box.value = defaultText;
        }
    }
    
    function confirmation(pageid) {
	    var answer = confirm("Are you sure you want to delete this?")
	    if (answer){
		    window.location = "?pageid=" + pageid + "&act=delete";
	    }
    }

    function TextboxEmpty(form) {
        var textbox = document.forms.aspnetForm.q.value;
        var allow = /^[A-Za-z- &q \d\s]{3,100}$/;
        textbox = trim(textbox);
        if (textbox == ""){
            alert("Please type in a search phrase");
        }
        else if (!allow.test(textbox)) {
            alert("You may only type in letters or numbers,\nBetween 3 and 100 characters");
        }
        else {
            window.location = "Search.aspx?q=" + textbox;
        }
    }

    function trim(stringToTrim) {
        return stringToTrim.replace(/^\s+|\s+$/g, "");
    }
    
    function ShowProcessing()
    {
        var processing = getElement('processing');
        if (screen.availHeight)
        {
            processing.style.height = screen.availHeight;
            processing.style.width = screen.availWidth;
        }
        processing.style.display='block';
    }
    function HideProcessing()
    {
        getElement('processing').style.display='none';
    }
    
    function KeywordSearch()
    {
        var processing = getElement('processing');
        if (screen.availHeight)
        {
            processing.style.height = screen.availHeight;
            processing.style.width = screen.availWidth;
        }
        ShowProcessing();
        getElement('keyword').value = getElement('tkeyword').value;
        document.keywordform.submit();
    }
    
    function DoLogin(loginid)
    {
        var loginbtn = getElement(loginid);
        eval(loginbtn.href);
    }
    
    function Cancel()
    {
        HideProcessing();
        if (window.stop)
        {
            window.stop();
        }
        else
        {
            document.execCommand("Stop");
        }
    }
    
    function CheckEnter(e)
    {
        var keynum;
        var keychar;
        var numcheck;

        if(window.event) // IE
        {
            keynum = e.keyCode;
        }
        else if(e.which) // Netscape/Firefox/Opera
        {
            keynum = e.which;
        }
        if (keynum==13)
        {
            return false;
        }
        return true;
    }
    
    function getElement(itemid) {
	var theElement;
	if (document.all) {
		eval("theElement = document.all."+itemid+";");
	}
	else {
		if (navigator.userAgent.indexOf("Gecko")!=-1) {// is NS6 ?
			theElement = document.getElementById(itemid);
		}
		else {
			eval("theElement = document.layers['"+itemid+"'];");
		}
	}
	return theElement;
}