www.usr.com/support/gpl/USR9113_release1.0.tar.gz
[bcm963xx.git] / userapps / broadcom / cfm / html / usr_layout.js
1 /* --------------------------------------------------------------------------
2
3         (c) 2005-2007 U.S. Robotics Corporation
4
5         -------------------------------------------------------------------------- */
6
7 /* --------------------------------------------------------------------------
8
9         RESOURCE FUNCTION
10
11         This function requires the global strings array to be defined (in a
12         separate file).
13 */
14
15 var _strings = new Array();
16
17 function getString(id)
18 {
19         var s = _strings[id];
20 /*
21         OPTIONAL FUTURE TODO ENHANCEMENT
22
23         For more complex strings, we could store a function and test the
24         type of the array element ("string" vs "function"); if it's a
25         function, we could call it, pass the id, and use the return as
26         the resource string.
27 */
28
29         if (s == undefined)
30         {
31                 alert("The string id " + id + " isn't in the resource table.");
32                 return "<ERROR>";
33         }
34         if (s.length == 0)
35         {
36                 alert("The string id " + id + " is empty.");
37                 return "<WARNING>";
38         }
39
40         return s;
41 }
42
43
44
45 /* --------------------------------------------------------------------------
46
47         PAGE HEADER AND FOOTER FUNCTIONS
48
49 */
50
51 /*
52         Set document's title.
53
54         If the <title> element is empty or doesn't exist, it uses the passed
55         string. Then it appends the product name to the title. If nothing
56         (or null) is passed, it uses the product name as the title.
57 */
58 function setPageTitle(strTitle)
59 {
60         if (strTitle == null)
61                 strTitle = document.title;
62
63         if ((document.title == null) || (document.title == ""))
64                 document.title = getString("idProdName");
65         else
66                 // N.B.: This format is used by the Diogenese Device Locator to extract the product name.
67                 document.title = document.title + " :: " + getString("idProdName");
68 }
69
70 /*
71         Write the page header
72
73         The calling page should set the <title> element to the desired header
74         text and page title. This function calls another that prepends the
75         product name to the document title.
76 */
77 function writeHeader(strTitle)
78 {
79         // This lets the calling page override the <title> element.
80         if (strTitle == null)
81                 strTitle = document.title;
82         setPageTitle(strTitle);
83
84         _writeHeader(strTitle);
85 }
86
87
88 /*
89         This writes out a page's header, including the optional menu bar.
90         The title parameter is optional. If passed, it's written out
91         as the header text.
92 */
93 function _writeHeader(strTitle)
94 {
95         document.write("<div id=\"idHeader\">");
96         document.write("<img id=\"idImgHeader\" src=\"usr_logo_rgb.gif\">");
97
98         if (strTitle == null)
99                 document.write("&nbsp;");       // to make sure header is tall enough
100         else
101                 document.write(strTitle);
102         document.write("<\/div>");
103
104         /*
105                 If this page doesn't include the menu script, don't create a menu
106         */
107         if (typeof(createMenu) != "undefined")
108                 createMenu().write();
109
110         document.write("<div id=\"idContent\">");
111 }
112
113
114 function writeFooter()
115 {
116         document.write("<\/div>");
117         document.write("<img id=\"idCopyright\" src=\"bg_color_cubes.gif\" width=\"16\" height=\"83\" \/>");
118         document.write("<p class=\"clsCopyright\">&copy; 2005-2007 <a href=\"http://www.usr.com\">U.S. Robotics Corporation<\/a><\/p>");
119 }