
function ShowDetail(imgPath)
{
    var img = document.getElementById('imgDetail');
    img.src = imgPath;
}

function KeyDownHandler(e, btn)	
{		
	var keycode;
	
	keycode = e.keyCode ? e.keyCode: e.charCode;
	
	if (keycode == 13)
	{			 
		document.getElementById(btn).click();		
		return false;
	}
}


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);
      
    // check for url input
    if(c.value.toLowerCase().indexOf("http://") > 0)
    {
        alert("Invalid User Input");
        c.focus();
        return false;   
    }

    // check for url input
    if(c.value.toLowerCase().indexOf("http://") > 0)
    {
        alert("Invalid User Input");
        c.focus();
        return false;   
    }
      
    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;
        }
        
        case "rdo":
        {
            var cs = document.getElementsByName(id);
                        
            // see if any of them have been selected
            for(var i=0, c;c=cs[i];i++)   
            {  
                if(c.checked) return true; 
            }
            
            alert("Please enter your '" + label + "'");
            return false;
        }
        
        default:
        {
            alert("Invalid field '" + controlID + " to validate.");
            return false;
        }
    }

    return false;    
}
