1// JavaScript Document
2var winH,winW;
3
4function winW_H(){
5	if(parseInt(navigator.appVersion) > 3){
6		winW = document.documentElement.scrollWidth;
7		if(document.documentElement.clientHeight > document.documentElement.scrollHeight)
8			winH = document.documentElement.clientHeight;
9		else
10			winH = document.documentElement.scrollHeight;
11	}
12}
13
14function LoadingTime(seconds, flag){
15	showtext(document.getElementById("proceeding_main_txt"), "<#Main_alert_proceeding_desc1#>...");
16	document.getElementById("Loading").style.visibility = "visible";
17
18	y = y+progress;
19	if(typeof(seconds) == "number" && seconds >= 0){
20		if(seconds != 0){
21			/* trigger IE8 counter */
22			if(navigator.appName.indexOf("Microsoft") >= 0){
23				var childsel=document.createElement("span");
24				document.body.appendChild(childsel);
25   			document.body.removeChild(document.body.lastChild);
26			}
27
28			showtext(document.getElementById("proceeding_main_txt"), "<#Main_alert_proceeding_desc4#>");
29			showtext(document.getElementById("proceeding_txt"), Math.round(y)+"% <#Main_alert_proceeding_desc1#>");
30			--seconds;
31			setTimeout("LoadingTime("+seconds+", '"+flag+"');", 1000);
32		}
33		else{
34			showtext(document.getElementById("proceeding_main_txt"), translate("<#Main_alert_proceeding_desc3#>"));
35			showtext(document.getElementById("proceeding_txt"), "");
36			y = 0;
37
38			if(flag != "waiting")
39				setTimeout("hideLoading();",1000);
40		}
41	}
42}
43
44function LoadingProgress(seconds){
45	document.getElementById("LoadingBar").style.visibility = "visible";
46
47	y = y + progress;
48	if(typeof(seconds) == "number" && seconds >= 0){
49		if(seconds != 0){
50			document.getElementById("proceeding_img").style.width = Math.round(y) + "%";
51			document.getElementById("proceeding_img_text").innerHTML = Math.round(y) + "%";
52
53			if(document.getElementById("loading_block1")){
54				document.getElementById("proceeding_img_text").style.width = document.getElementById("loading_block1").clientWidth;
55				document.getElementById("proceeding_img_text").style.marginLeft = "175px";
56			}
57			--seconds;
58			setTimeout("LoadingProgress("+seconds+");", 1000);
59		}
60		else{
61			document.getElementById("proceeding_img_text").innerHTML = "<#Main_alert_proceeding_desc3#>";
62			y = 0;
63			if(location.pathname.indexOf("Advanced_MobileBroadband_Content") > 0){
64				setTimeout("hideLoadingBar();",1000);
65				htmlbodyforIE = document.getElementsByTagName("html");
66				htmlbodyforIE[0].style.overflow = "";
67			}
68			else if(location.pathname.indexOf("QIS_wizard.htm") < 0 && location.pathname.indexOf("Advanced_FirmwareUpgrade_Content") < 0 && location.pathname.indexOf("Advanced_SettingBackup_Content") < 0){
69				setTimeout("hideLoadingBar();",1000);
70				location.href = "index.asp";
71			}
72		}
73	}
74}
75
76function showLoading(seconds, flag){
77	if(window.scrollTo)
78		window.scrollTo(0,0);
79
80	disableCheckChangedStatus();
81
82	htmlbodyforIE = document.getElementsByTagName("html");  //this both for IE&FF, use "html" but not "body" because <!DOCTYPE html PUBLIC.......>
83	htmlbodyforIE[0].style.overflow = "hidden";	  //hidden the Y-scrollbar for preventing from user scroll it.
84
85	winW_H();
86
87	var blockmarginTop;
88	var blockmarginLeft;
89	if (window.innerWidth)
90		winWidth = window.innerWidth;
91	else if ((document.body) && (document.body.clientWidth))
92		winWidth = document.body.clientWidth;
93
94	if (window.innerHeight)
95		winHeight = window.innerHeight;
96	else if ((document.body) && (document.body.clientHeight))
97		winHeight = document.body.clientHeight;
98
99	if (document.documentElement  && document.documentElement.clientHeight && document.documentElement.clientWidth){
100		winHeight = document.documentElement.clientHeight;
101		winWidth = document.documentElement.clientWidth;
102	}
103
104	if(winWidth >1050){
105
106		winPadding = (winWidth-1050)/2;
107		winWidth = 1105;
108		blockmarginLeft= (winWidth*0.35)+winPadding;
109	}
110	else if(winWidth <=1050){
111		blockmarginLeft= (winWidth)*0.35+document.body.scrollLeft;
112
113	}
114
115	if(winHeight >660)
116		winHeight = 660;
117
118	blockmarginTop= winHeight*0.3
119
120	document.getElementById("loadingBlock").style.marginTop = blockmarginTop+"px";
121	document.getElementById("loadingBlock").style.marginLeft = blockmarginLeft+"px";
122
123	document.getElementById("Loading").style.width = winW+"px";
124	document.getElementById("Loading").style.height = winH+"px";
125
126	loadingSeconds = seconds;
127	progress = 100/loadingSeconds;
128	y = 0;
129
130	LoadingTime(seconds, flag);
131}
132
133function showLoadingBar(seconds){
134	if(window.scrollTo)
135		window.scrollTo(0,0);
136
137	disableCheckChangedStatus();
138
139	htmlbodyforIE = document.getElementsByTagName("html");  //this both for IE&FF, use "html" but not "body" because <!DOCTYPE html PUBLIC.......>
140	htmlbodyforIE[0].style.overflow = "hidden";	  //hidden the Y-scrollbar for preventing from user scroll it.
141
142	winW_H();
143
144	var blockmarginTop;
145	var blockmarginLeft;
146	if (window.innerWidth)
147		winWidth = window.innerWidth;
148	else if ((document.body) && (document.body.clientWidth))
149		winWidth = document.body.clientWidth;
150
151	if (window.innerHeight)
152		winHeight = window.innerHeight;
153	else if ((document.body) && (document.body.clientHeight))
154		winHeight = document.body.clientHeight;
155
156	if (document.documentElement  && document.documentElement.clientHeight && document.documentElement.clientWidth){
157		winHeight = document.documentElement.clientHeight;
158		winWidth = document.documentElement.clientWidth;
159	}
160
161	if(winWidth >1050){
162
163		winPadding = (winWidth-1050)/2;
164		winWidth = 1105;
165		blockmarginLeft= (winWidth*0.3)+winPadding;
166	}
167	else if(winWidth <=1050){
168		blockmarginLeft= (winWidth)*0.3+document.body.scrollLeft;
169
170	}
171
172	if(winHeight >660)
173		winHeight = 660;
174
175	blockmarginTop= winHeight*0.3
176
177	document.getElementById("loadingBarBlock").style.marginTop = blockmarginTop+"px";
178	// marked by Jerry 2012.11.14 using CSS to decide the margin
179	document.getElementById("loadingBarBlock").style.marginLeft = blockmarginLeft+"px";
180
181
182	/*blockmarginTop = document.documentElement.scrollTop + 200;
183	document.getElementById("loadingBarBlock").style.marginTop = blockmarginTop+"px";*/
184
185	document.getElementById("LoadingBar").style.width = winW+"px";
186	document.getElementById("LoadingBar").style.height = winH+"px";
187
188	loadingSeconds = seconds;
189	progress = 100/loadingSeconds;
190	y = 0;
191	LoadingProgress(seconds);
192}
193
194function hideLoadingBar(){
195	document.getElementById("LoadingBar").style.visibility = "hidden";
196}
197
198function hideLoading(flag){
199	document.getElementById("Loading").style.visibility = "hidden";
200	htmlbodyforIE = document.getElementsByTagName("html");  //this both for IE&FF, use "html" but not "body" because <!DOCTYPE html PUBLIC.......>
201	htmlbodyforIE[0].style.overflow = "";	  //hidden the Y-scrollbar for preventing from user scroll it.
202}
203
204function simpleSSID(obj){
205	var SSID = document.loginform.wl_ssid.value;
206
207	if(SSID.length < 16)
208		showtext(obj, SSID);
209	else{
210		obj.title = SSID;
211		showtext(obj, SSID.substring(0, 16)+"...");
212	}
213}
214
215function dr_advise(){
216	disableCheckChangedStatus();
217
218	htmlbodyforIE = document.getElementsByTagName("html");  //this both for IE&FF, use "html" but not "body" because <!DOCTYPE html PUBLIC.......>
219	htmlbodyforIE[0].style.overflow = "hidden";	  //hidden the Y-scrollbar for preventing from user scroll it.
220
221	winW_H();
222	var blockmarginTop;
223	blockmarginTop = document.documentElement.scrollTop + 200;
224	document.getElementById("dr_sweet_advise").style.marginTop = blockmarginTop+"px"
225	document.getElementById("hiddenMask").style.width = winW+"px";
226	document.getElementById("hiddenMask").style.height = winH+"px";
227	document.getElementById("hiddenMask").style.visibility = "visible";
228}
229