﻿function password_focus(evt)
{
    var e = (window.event) ? window.event : evt;
     //alert(event.keyCode);
     if (e.keyCode==9) //we are about to tab into next control
     {
         jQuery('#passwordItemOn').show();
         jQuery('#passwordItemOff').hide(); 
        //    alert('attempting to focus');
        //document.getElementById('passwordItemOff').childNodes[1].focus();
        //alert('focused??');
     }
}

function password_blur(evt)
{
    //alert(evt==null);
    var e = (window.event) ? window.event : evt;
    //alert(e.keyCode);
    if (e.keyCode==9)
        if (document.getElementById('passwordItemOn').childNodes[1].value.length == 0) 
        {   
            jQuery('#passwordItemOff').show();
            jQuery('#passwordItemOn').hide(); 
            //if firefox
            //alert('attempting to blur');
            //if (!window.event)
              //  document.getElementById('passwordItemOff').childNodes[1].focus();
        }
        
}

function findChildIDFromNodeName(element, childNodeName)
{   
    var returnID="";
    if (element.childNodes==null) 
        return;
    var count = element.childNodes.length;
    if (count > 0)
    for(var elementIndex = 0 ; elementIndex < count; elementIndex ++)
    {
        var childnode = element.childNodes[elementIndex];            
        if (childnode.nodeName.toLowerCase() == childNodeName.toLowerCase()) {
            //alert ('return value' && childnode.getAttribute('id'));
            return childnode.getAttribute('id');
            }
        else if (childnode.childNodes!=null) 
            if(childnode.childNodes.length > 0)
                returnID = findChildIDFromNodeName(childnode, childNodeName);
        if (returnID!=null && returnID!="")
            return returnID;
    }         
}

function getChieldIdValue(prmdivID)
{        
    var divID = document.getElementById(prmdivID);       
    var chieldNodeValue = divID.childNodes[1].getAttribute('value');
    return chieldNodeValue;
}
       
       
function setImage(control,imagePath)
{
    if (control==null)
        return;
    //alert ('Set image alert' && control);
    document.getElementById(control).setAttribute("src", imagePath);    
}