﻿
// Genreic Input Commands

function GenDeleteOnClick(sWhat)
{
    var frm = document.forms[0];
    if ( window.confirm("Are you sure that you want to permanently delete the selected " + sWhat + "?"))
    {
        if (frm.txtAction != null)
        {
       		frm.txtAction.value = 'delete';
	    	frm.submit();   
		}
    }
}


function GenSubmitOnClick(sAction)
{
    var frm = document.forms[0];
    if (frm.txtAction != null)
    {
	    frm.txtAction.value = sAction;
	    frm.submit();   
	}
}


    function OnFocusZipInput(oObj)
    {
        oObj.className = "GrayInputOn";
        oObj.value = "";
    }
    
    function OnKeydownZipInput(event)
    {
		// The next two lines of code handle cross-browser differences
		var e = event || window.event;
		var code = e.charCode || e.keyCode;
   		if (code == 13) 
   		{
			code = 0;
			e.returnValue = false;
			e.cancelBubble = true;
			ClickDotNetFormElement("btnFindLocation");
		}
    }

    function OnKeydownZipInput2(event)
    {
		// The next two lines of code handle cross-browser differences
		var e = event || window.event;
		var code = e.charCode || e.keyCode;
   		if (code == 13) 
   		{
			code = 0;
			e.returnValue = false;
			e.cancelBubble = true;
			ClickDotNetFormElement("btnGoLocator");
		}
    }
    
    function OnKeydownSubscribe(event)
    {
		// The next two lines of code handle cross-browser differences
		var e = event || window.event;
		var code = e.charCode || e.keyCode;
   		if (code == 13) 
   		{
			code = 0;
			e.returnValue = false;
			e.cancelBubble = true;
			ClickDotNetFormElement("btnSubscribe");
		}
    }

    function ClickDotNetFormElement(sName)
    {
		// The following conditional is for cross-browser compatibility
		if (navigator.appName.indexOf("Microsoft") != -1)
			{
			var ElementArray = document.forms[0].all;
			}
		else
			{
			var ElementArray = document.getElementsByTagName("*");
			}
        var i = ElementArray.length;
        var s = "";
        while (i > 0)
        {
            --i;
            s = ElementArray[i].id;
            if ( s != "")
            {
                if (s.indexOf(sName) >= 0)
                    ElementArray[i].click();
            }        
        }
    }

    function GetIDByPartialName(sName) {
        var arr = new Array();
        arr = document.getElementsByTagName("*");
        for (var i = 0; i < arr.length; i++) {
            var obj = arr[i];
            if (obj.id.indexOf(sName) >= 0) {
                return obj.id;
            }
        }
        return "";
    }

    function GetObjByPartialName(sName) {
        var arr = new Array();
        arr = document.getElementsByTagName("*");
        for (var i = 0; i < arr.length; i++) {
            var obj = arr[i];
            if (obj.id.indexOf(sName) >= 0) {
                return obj;
            }
        }
        return "";
    }
