I want to get the ID/Name of the DocumentLibrary when I Click/Select on any library from List of libraries from the Left Panel of MasterPage.
Can I call the function from MasterPage or where ? How ?
See more here http://msdn.microsoft.com/en-us/library/ff410971.aspx
I use a similar function on a Ribbon button. You might want to combine this call with ExecuteOrDelayUntilScriptLoaded (see more here http://blogs.technet.com/b/speschka/archive/2009/11/01/using-the-sharepoint-2010-client-object-model-part-1.aspx)
Still, considering that actual request and the purpose of a master page, i still fail to see a situation when you would considering adding such a constraint (or need) into your master page. May I suggest you rather consider using Delegate controls (an example here http://howtosharepoint.blogspot.ch/2010/04/how-to-use-delegate-controls-in.html)