function $(element) {
  if (arguments.length > 1) {
    for (var i = 0, elements = [], length = arguments.length; i < length; i++)
      elements.push($(arguments[i]));
    return elements;
  }
  if (typeof element == "string")
    element = document.getElementById(element);
  return element;
}

	function SearchKeyPress(searchtext,e)
		{
		var key;
		if(window.event)
			{
			key = window.event.keyCode;     //IE
			}
		else
			{
			key = e.which;     //firefox
			}
    	if(key == 13)
    		{
			DisplaySearch(searchtext);
			return false;
			}
		else
			{
			return true;
			}
		}


	function DisplaySearch(stext, sPageName)
		{
		//attempt to get the search text from the current document
		//var searchtext = $("txtsearch").value
		//pass the search text to _search.htm
		if (sPageName == "" || sPageName == null)
			{
			//This is the global search
			var sSearchPage="_search.htm";
			}
		else
			{
			//If a pagename was passed then this is a child search
			var sSearchPage="_search_"+sPageName+".htm";
			}

		//if the fra_contents frame doesn't exist then display the search results on the current page
		if ($("fra_contents") != null)
			{
			//window.open("_search.htm?searchTxt="+stext+sPageParm, "fra_contents");
			window.open(sSearchPage+"?searchTxt="+stext, "fra_contents");
			$("fra_contents").style.display="";
			}
		else if ($("basefrm") != null)
			{
			window.open(sSearchPage+"?searchTxt="+stext, "basefrm");
			}
		else
			{
			//location.href = "_search.htm?searchTxt="+stext+"&type=noframes"+sPageParm;
			location.href = sSearchPage+"?searchTxt="+stext+"&type=noframes";
			}
   	        if($('imgtabs')!=null)
   	            $('imgtabs').src='images/skins/tabs_tabs_search.gif';
            if($('tdSearch')!=null)
                tabtoggle($('tdSearch'));  			
	}

	function DisplayIndex()
	{
		if ($("fra_contents") != null)
			{
			window.open("_keywordindex.htm", "fra_contents");
			}
		else if ($("basefrm") != null)
			{
			window.open("_keywordindex.htm", "basefrm");
			}
		else if ($("div_javascript_contents") != null)
			{
			$("div_javascript_index").style.display="";
			$("div_javascript_contents").style.display="none";
			}
	    else
	        {
			location.href = "_index.htm";
	        }
        if($('imgtabs')!=null)
            $('imgtabs').src='images/skins/tabs_tabs_index.gif';
        if($('tdIndex')!=null)
         tabtoggle($('tdIndex'));
	}


	function DisplayContents()
		{
		if ($("fra_contents") != null)
			{
			window.open("contents.htm", "fra_contents");
			}
		else if ($("basefrm") != null)
			{
			window.open("contents.htm", "basefrm");
			}
		else if ($("div_javascript_contents") != null)
			{
			$("div_javascript_index").style.display="none";
			$("div_javascript_contents").style.display="";
			}
	    else
	        {
			location.href = "contents.htm";
	        }
        if($('imgtabs')!=null)
            $('imgtabs').src='images/skins/tabs_tabs_contents.gif';
        if($('tdContents')!=null)
            tabtoggle($('tdContents')); 	        
	}

	function addtofav()
		{
		if (document.all)
			{
			//if there is a basefrm frame then get the URL from there, otherwise get the url for this page.
			if ($("basefrm") == null)
				{
				//FLAT - Get URL from this page
				var sFavURL=String(location.href);
				var sPageName = sFavURL.substr(sFavURL.lastIndexOf("/")+1)
				}
			else
				{
				//FRAMES - get URL from the frame
				var sPageURL=String(window.basefrm.location);
				var sPageName = sPageURL.substr(sPageURL.lastIndexOf("/")+1)
				var sFavURL = window.location.href
				}

			//Remove any parameters from the url (eg. page.aspx?search=X)
			if (sFavURL.indexOf("?") != -1)
				{
				sFavURL=sFavURL.substr(0,sFavURL.lastIndexOf("?"))
				}

			//Remove any parameters from the pagename (eg. page.aspx?search=X)
			if (sPageName.indexOf("?") != -1)
				{
				sPageName=sPageName.substr(0,sPageName.lastIndexOf("?"))
				}

			//remove any %20 codes (space codes)
			sPageName = sPageName.replace(/%20/g, " ");
			var sTitle=sPageName;
			
			if ($("basefrm") == null)
                {
                // --FLAT--
    			window.external.AddFavorite(sFavURL,sTitle);
                }
            else
                {
                // --FRAMES--
    			window.external.AddFavorite(sFavURL + "?" + sPageName,sTitle);
                }
                

			}
		}
	


	function printpage()
		{
		//if the basefrm frame exists then print the contents
		if ($("basefrm") != null)
			{
			printframe();
			}
		else
			{
			//If this is IE then print the cell containing the page HTML. If this is another browser then print the entire page.
			if (navigator.userAgent.toLowerCase().indexOf("ie") == -1)
				{
				//Current browser is not IE
				window.print();
				}
			else
				{
				//Current browser is IE
				print_noframes();
				}
			}
		}


	function printframe()
		{
		//print the basefrm frame
		window.frames['basefrm'].focus(); 
		window.frames['basefrm'].print();
		}


	function print_noframes()
		{
		var printIframe = document.createElement("IFRAME");
		document.body.appendChild(printIframe);
		var printDocument = printIframe.contentWindow.document;
		printDocument.designMode = "on";
		printDocument.open();
		var currentLocation = document.location.href;
		currentLocation = currentLocation.substring(0, currentLocation.lastIndexOf("/") + 1);
		var htmlcontent = $("td_noframes_main")
		printDocument.write("<html><head></head><body>" + htmlcontent.innerHTML + "</body></html>");
		printDocument.close();

		try
			{
			if (document.all)
				{
				var oLink = printDocument.createElement("link");
				oLink.setAttribute("href", currentLocation + "pgstyles.css", 0);
				oLink.setAttribute("type", "text/css");
				oLink.setAttribute("rel", "stylesheet", 0);
				printDocument.getElementsByTagName("head")[0].appendChild(oLink);
				printDocument.execCommand("Print");
				}
			else
				{
				printDocument.body.innerHTML = "<link rel='stylesheet' type='text/css' href='" + currentLocation + "pgstyles.css'></link>" + printDocument.body.innerHTML;
				printIframe.contentWindow.print();
				}
			}
		catch(ex)
			{
			}
		document.body.removeChild(printIframe);
		}


	function showpageurl()
		{
		//alert("showpageurl")
		//if there is a basefrm frame then get the URL from there, otherwise get the url for this page.
		if ($("basefrm") == null)
			{
			//FLAT - get URL from this page
			var sPageURL=String(location.href);
			var sPageName = sPageURL.substr(sPageURL.lastIndexOf("/")+1)
			var sRelativeURL = "help/" + sPageName;
			}
		else
			{
			//FRAMES - Get URL from basefrm frame
			var sPageURL=String(window.basefrm.location.href);
			//alert("sPageURL = " + sPageURL)
			//Remove any parameters (eg. page.aspx?parm1=X)
			if (sPageURL.toLowerCase().indexOf("?") != -1)
				{
				sPageURL=sPageURL.substr(0,sPageURL.lastIndexOf("?"))
				}
			//alert("sPageURL = " + sPageURL)
			var sPageName = sPageURL.substr(sPageURL.lastIndexOf("/")+1)
			//alert("sPageName = " + sPageName)
			//Remove the page name
  			sPageURL=sPageURL.substr(0,sPageURL.lastIndexOf("/"))

			var sPageURL =  sPageURL + "/default.htm?" + sPageName;
			var sRelativeURL = "help/default.htm?" + sPageName;
			}

		//Set the table cell innerHTML
		var sHTML = ""		
		sHTML = sHTML + "<table style='width:400px;height:165px;background-image:url(images/pageurl_back.gif);cellpadding:24px'><tr style='height:35px'><td align=right><img src='images/close_mover.gif' style='cursor:pointer;' onclick='closepagelinkform()'><tr><td valigh='top'>&nbsp;<textarea style='width:98%'  rows=4>"+sPageURL+"</textarea></td></tr><tr ><td align=right valign=top ><input type=button class='btnstyle' onclick=\"clip('"+sPageURL+"')\" value='Copy'>&nbsp;</td></tr></table>";

		$("tdpageurl").innerHTML=sHTML;
		$("tblpageurl").style.display="";
		}

    function closepagelinkform()
        {
        $("tblpageurl").style.display="none";
        }

	function loadpage()
		{
		//if a page was passed in the url,load it now
		//alert("href = "+top.location.href);
		if (top.location.href.lastIndexOf("?") > 0)
			{
			//attempt to get the file name that was passed
			var sPage=top.location.href.substring(top.location.href.lastIndexOf("?")+1,top.location.href.length);
			//alert("last four chars = "+sPage.toLowerCase().substring(sPage.length-4, sPage.length));
			//if the prefix is .htm then load the page, otherwise don't do anything
			if (sPage.toLowerCase().substring(sPage.length-4, sPage.length) == ".htm")
				{
				var myframe=$("basefrm");
				//if the 'basefrm' frame is not found then assume that this is a "no-frames" help system
				if (myframe == null)
					{
					location.href=sPage;
					}
				else
					{
					$("basefrm").src=sPage;
					}
				}
			else if (sPage.toLowerCase() == "index")
				{
				ShowIndex();
				}

			}
		}


			
		function previouspage()
			{
				onclick = history.back()
			}
			
		function nextpage()
			{
				onclick = history.forward()
			}

		function showhomepage(homepage)
			{
			if ($("basefrm") != null)
				{
				window.open(homepage, "basefrm");
				}
			else
				{
				location.href = homepage;
				}
			}
			
		function browse()
			{
			if ($("basefrm") != null)
				{
				window.open("contents.htm", "basefrm");
				}
			else
				{
				location.href = "contents.htm";
				}
			}

		function showaskpage()
			{
			if ($("basefrm") != null)
				{
				window.open("ask.htm", "basefrm");
				}
			else
				{
				location.href = "ask.htm";
				}
			}


		function showoptions()
			{
			//if the options form is already displayed then hide it
			if ($("tbloptions").style.display=="")
				{
				$("tbloptions").style.display="none";
				}
			else
				{
				$("tbloptions").style.display="";
				$("tbloptions").focus();
				//position the options list below the options button
				$("tbloptions").style.top=$("imgoptions").offsetTop+$("imgoptions").offsetHeight;
				$("tbloptions").style.left=$("imgoptions").offsetLeft+$("imgoptions").offsetWidth-198;
				}
			}
function clip(tocopy)
{
    window.clipboardData.setData("Text",tocopy);
    //window.close();
}			