//=====================================================
//	Module:		ObjectFinder.js

//REQUIRES myProfile.js

//implements functions that can be used to access 
//objects uniformly in Navigator and IE.

//This implementation finds objects only 2 levels deep.
//It is possible to extend function so that search can be
//done for unlimited levels.
//=====================================================

// return reference to object that are at top level in document 
	function getObject(objName)
	{
		var obj = null;
		if (myProfile.browserName == "ie")
		{
			obj = document.all[objName];
		}
		else
		{
 			if ( myProfile.browserNameVersion == "NS5" || myProfile.browserNameVersion == "NS7" || myProfile.browserNameVersion == "FIREFOX" )
 			{
 				obj = document.getElementById(objName);
 			}
 			else
 			{
				obj = document.layers[objName];
				if (!obj)
					obj = document.images[objName];
				if (!obj)
					obj = document.forms[objName];
				if (!obj)
					obj = document.plugins[objName];
				if (!obj)
					obj = document.links[objName];				
			}
		}
		return obj;
	}


// return reference to object that are child to a top level object in document 
	function getChildObject(parentName, objName)
	{
		var obj = null;
		if (myProfile.browserName == "ie")
		{
			obj = document.all[objName];
		}
		else
		{		
 			if ( myProfile.browserNameVersion == "NS5" || myProfile.browserNameVersion == "NS7" || myProfile.browserNameVersion == "FIREFOX")
 			{
 				obj = document.getElementById(objName);
 			}
 			else
 			{
 				var objParent = getObject(parentName);
				obj = objParent.document.layers[objName];
				if (!obj)
					obj = objParent.document.images[objName];
				if (!obj)
					obj = objParent.document.forms[objName];
				if (!obj)
					obj = objParent.document.plugins[objName];
				if (!obj)
					obj = objParent.document.links[objName];
			}
		}
		return obj;
	}
	
	function getHrefLink(LayerName,hrefLink)
	{
		var obj = null;
		if (myProfile.browserName == "ie")
		{
			obj = document.all[hrefLink];
		}
		else
		{		
 			if ( myProfile.browserNameVersion == "NS5" || myProfile.browserNameVersion == "NS7" || myProfile.browserNameVersion == "FIREFOX")
 			{
 				obj = document.getElementById(hrefLink);
 			}
 			else
 			{
 				var objParent = getObject(LayerName);
				var linkHref = null;
				for (var i=0; i < objParent.document.links.length; i++)
				{
					linkHref = objParent.document.links[i].href;
					if(linkHref != '' && hrefLink == "QALink" && linkHref.indexOf("QuestionFullViewFrameSet") != -1)
					{
						obj = objParent.document.links[i];
						break;
					}
					if(linkHref != '' && hrefLink == "TAFLink" && linkHref.indexOf("TellAFriendView") != -1)
					{
						obj = objParent.document.links[i];
						break;												
					}
				}
										
			}
		}
		return obj;	
	}

// make object visible
	function showObject(obj)
	{
		if (obj)
		{
			if (myProfile.browserName == "ie")
			{
				obj.style.visibility = "visible";
			}
			else if(myProfile.browserNameVersion == "NS5" || myProfile.browserNameVersion == "NS7" || myProfile.browserNameVersion == "FIREFOX")
			{
				obj.style.display = "block";
			}			
			else
			{		
				obj.visibility = "show";
			}
		}
	}
	
// make object hidden
	function hideObject(obj)
	{
		if (obj)
		{
			if (myProfile.browserName == "ie")
			{
				obj.style.visibility = "hidden";
			}
			else if(myProfile.browserNameVersion == "NS5" || myProfile.browserNameVersion == "NS7" || myProfile.browserNameVersion == "FIREFOX")
			{
				obj.style.display = "none";
			}
			else
			{		
				obj.visibility = "hide";
			}
		}
	}

// check if object is hidden
	function isHidden(obj)
	{
		if (obj)
		{
			if (myProfile.browserName == "ie")
			{
				return (obj.style.visibility == "hidden");
			}		
			else
			{		
				return (obj.visibility == "hide");
			}
		}
	}
