
/-------- function for getting client Id -----------------/
function GetClientId(strid)
{
         var count=document.getElementsByTagName ('*').length; 
         var i=0;
         var eleName;
         for (i=0; i < count; i++ )
         {
           eleName=document.getElementsByTagName ('*')[i].id;
           pos=eleName.indexOf(strid);
           if(pos>=0)  break;          
         }
         return eleName;
} 
    
function Element(strid)
{
      var id = "";
      var cont =GetClientId(strid);
      if(cont!=null && cont!="")
         id=document.getElementById(GetClientId(strid));  
     return id;
}
/------------------Switch Image-------------------------/

function SwitchImage(img,path)
{
	document.getElementById(img).src=path;	
}
/------------------Number Only-------------------------/
function FilterNumber(myfield, e, dec)
{
    var key;
    var keychar;

    if (window.event)
        key = window.event.keyCode;
            else if (e)
                key = e.which;
            else
                return true;
            keychar = String.fromCharCode(key);

            // control keys
            if ((key==null) || (key==0) || (key==8) || 
                (key==9) || (key==13) || (key==27) )
            return true;

            // numbers
            else if ((("0123456789").indexOf(keychar) > -1))
                  return true;

            // decimal point jump
            else if (dec && (keychar == "."))
                {
                     myfield.form.elements[dec].focus();
                return false;
                }
            else
                return false;
}

/------------------Pop Up Window-------------------------/   
var newWindow = '';
function PopItUp(url, width, height, name) 
{
        var windowFeatures = "toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=1, resizable=0, width=" + width + "px, 			height=" + height + "px"

        if ( !newWindow.closed && newWindow.location) 
        {
            newWindow.location.href = url;
        }
        else 
        {
            newWindow = window.open(url, name, windowFeatures);
            
            if (!newWindow.opener) 
                newWindow.opener = self;
        }

        if (newWindow == null || typeof (newWindow) == "undefined") 
        {
            alert("Browser does not allow popup.")
        }
        else 
        {
            if (window.focus) 
            {
                newWindow.focus();
            }
        }
} 

/------------------Handle KeyPress-------------------------/     
function HandleKeyPress(e, form,func) 
{
        var key = e.keyCode || e.which;
        if (key == 13) {
            __doPostBack(func, "");
        }
}
/----------------Toggle Display----------------------------/
function ToggleDisplay(id,action)
{
 Element(id).style.display=action;
}



        
        
