<!--//

function getControlID(id)   // get the root control name to know how to validate the form control
{   
    if(id.substring(0,3) == "ctl")
    {
        var controlIDs = id.split("_")
        
        return controlIDs[controlIDs.length - 1];
    }
    else
    {
        return id;
    }    
}

// form validation functions 
function validateField(id, label)
{    
    var c = document.getElementById(id);
    var controlID = getControlID(id);
            
    switch(controlID.substring(0,3))
    {
        case "txt":
        {
            if(c == null || c.value == "")   
            {   
                alert("Please enter your '" + label + "'");        
                c.focus();      
                return false;   
            }
            return true;
        }
        
        case "cbo":
        {
            if(c == null || c.options[c.selectedIndex].value == "")
            {
                alert("Please enter your '" + label + "'");        
                c.focus();
                return false;
            }
            return true;
        }
        
        case "chk":
        {
            return true;
        }
        
        default:
        {
            alert("Invalid field '" + controlID + " to validate.");
            return false;
        }
    }

    return false;    
}

// info window opener
function doInfoWin(theUrl)	{
	if (window.infoWindow && !window.infoWindow.closed)	{
		window.infoWindow.close;
		window.infoWindow= window.open(theUrl, 'infoWin', 'width=640,height=480,scrollbars,resizeable');
		window.infoWindow.focus;
		window.infoWindow.opener = self;
	} else  {
		window.infoWindow= window.open(theUrl, 'infoWin', 'width=640,height=480,scrollbars,resizeable');
		window.infoWindow.focus;
		window.infoWindow.opener = self;
	}
}
// End -->

