﻿// JScript File

//------------------------------------------------------------------------------------------------------------
//this is to delete or display keyword 

function deleteOrDisplayKeyword(obj,sKeyWord,sWhenCalled,normalCss,watermarkCss)
{
    if (sWhenCalled.toLowerCase() == 'onfocus')
    {    
        if (trim(obj.value) == sKeyWord)
        {   
            obj.value = '';
        }
        if(normalCss != '')
        {
            obj.className = normalCss;
        }
    }
    else if (sWhenCalled.toLowerCase() == 'onblur')
    {    
        if (trim(obj.value) == '')
        {
            obj.value = sKeyWord;
            if(watermarkCss != '')
            {
                obj.className = watermarkCss;
            }
        }
        else if(trim(obj.value) == sKeyWord)
        {
            if(watermarkCss != '')
            {
                obj.className = watermarkCss;
            }
        }
        else
        {
            if(normalCss != '')
            {
                obj.className = normalCss;
            }
        }
    }
        
}

/* This function remove trailing spaces around a given string */
function trim(str) { 
    return( ("" + str).replace(/^\s+/,'').replace(/[\s]+/g,' ').replace(/\s+$/,'') ); 
}

/* This function is used to visible false of particular object. But u need to pass 
client Id of that object like:- 'ctl00_ContentPlaceHolder1_lblUsrNm' */
function VisibleFalse(objId)
{   
    if (document.getElementById(objId))
    {
        document.getElementById(objId).style.display = 'none'                
    }
}

//This method is used to set focus on particular object (control)
function setFocus(objId)
{            
    document.getElementById(objId).focus();
}
//This function toggles image border on hover
function changeBorder(imgObj,action)
{
    if (imgObj != null)
    {
        if (action=='over')
            imgObj.style.border = "solid 4px #386EB9";
        else if (action=='out')
            imgObj.style.border = "solid 4px #E5E6E8";
    }   
}
//-------------------------------------------------------------------------------------------------------------
