1var Speed=50;
2
3var timer_internet=0;
4var timer_wireless=0;
5var timer_attached=0;
6var timer_parental, timer_readyshare, timer_guest;
7
8var Internet_bottom, Wireless_bottom, AttachedDevices_bottom;
9var ParentalControls_bottom, ReadyShare_bottom, GuestNetwork_bottom;
10
11var internet1, internet2;
12var wireless1, wireless2, wireless3, wireless4;
13var attached1, attached2;
14var parental1, parental2;
15var readyshare1, readyshare2;
16var guest1, guest2, guest3, guest4;
17
18var Internet_status;
19var Wireless_status1, Wireless_status2;
20var AttachedDevices_status;
21var ParentalControls_status;
22var ReadyShare_status;
23var Guest_status1, Guest_status2;
24
25function run_marquee() {
26    Marquee_init();
27    Marquee_set_timeInterval();
28    Marquee_set_event();
29}
30
31function Marquee_init()
32{
33    Speed=50;
34
35    timer_internet=0;
36    timer_wireless=0;
37    timer_attached=0;
38    timer_parental=0;
39    timer_readyshare=0;
40    timer_guest=0;
41
42    Internet_bottom = document.getElementById("Internet_bottom");
43    Wireless_bottom = document.getElementById("Wireless_bottom");
44    AttachedDevices_bottom = document.getElementById("AttachedDevices-bottom");
45    ParentalControls_bottom = document.getElementById("ParentalControls-bottom");
46    ReadyShare_bottom = document.getElementById("ReadyShare-bottom");
47    GuestNetwork_bottom = document.getElementById("GuestNetwork-bottom");
48
49    internet1= document.getElementById("internet1");
50    internet2= document.getElementById("internet2");
51    wireless1= document.getElementById("wireless1");
52    wireless2= document.getElementById("wireless2");
53    wireless3= document.getElementById("wireless3");
54    wireless4= document.getElementById("wireless4");
55    attached1= document.getElementById("attached1");
56    attached2= document.getElementById("attached2");
57    parental1= document.getElementById("parental1");
58    parental2= document.getElementById("parental2");
59    readyshare1= document.getElementById("readyshare1");
60    readyshare2= document.getElementById("readyshare2");
61    guest1= document.getElementById("guest1");
62    guest2= document.getElementById("guest2");
63    guest3= document.getElementById("guest3");
64    guest4= document.getElementById("guest4");
65
66    Internet_status= document.getElementById("Internet-status");
67    Wireless_status1= document.getElementById("Wireless-status1");
68    Wireless_status2= document.getElementById("Wireless-status2");
69    AttachedDevices_status= document.getElementById("AttachedDevices-status");
70    ParentalControls_status= document.getElementById("ParentalControls-status");
71    ReadyShare_status= document.getElementById("ReadyShare-status");
72    Guest_status1= document.getElementById("Guest-status1");
73    Guest_status2= document.getElementById("Guest-status2");
74}
75
76function Marquee_set_timeInterval()
77{
78    if(need_to_run_marquee("Internet")) {
79
80        internet2.innerHTML=internet1.innerHTML;
81
82        timer_internet=setInterval(picMarquee_interent,Speed);
83    }
84
85
86    if(need_to_run_marquee("Wireless")) {
87            $("#wireless1").css("text-align", "left");
88            $("#wireless2").css("text-align", "left");
89            $("#wireless3").css("text-align", "left");
90            $("#wireless4").css("text-align", "left");
91            wireless2.innerHTML=wireless1.innerHTML;
92            wireless4.innerHTML=wireless3.innerHTML;
93            timer_wireless=setInterval(picMarquee_wireless,Speed);
94        }
95
96    if(need_to_run_marquee("Attached")) {
97        attached2.innerHTML=attached1.innerHTML;
98        timer_attached=setInterval(picMarquee_attached,Speed);
99    }
100
101
102    if(need_to_run_marquee("Parental")) {
103        parental2.innerHTML=parental1.innerHTML;
104        timer_parental=setInterval(picMarquee_parental,Speed);
105    }
106
107    //alert(readyshare1.clientWidth + " " + ReadyShare_bottom.clientWidth);
108    //alert(document.getElementById("ReadyShare-status").scrollWidth);
109    //alert(document.getElementById("ReadyShare-condition").scrollWidth);
110
111    if(need_to_run_marquee("ReadySHARE")) {
112        readyshare2.innerHTML=readyshare1.innerHTML;
113        timer_readyshare=setInterval(picMarquee_readyshare,Speed);
114    }
115    if(need_to_run_marquee("Guest1")) {
116            $("#guest1").css("text-align", "left");
117            $("#guest2").css("text-align", "left");
118            guest2.innerHTML=guest1.innerHTML;
119            timer_guest=setInterval(picMarquee_guest,Speed);
120        }
121    if(need_to_run_marquee("Guest2")) {
122            $("#guest3").css("text-align", "left");
123            $("#guest4").css("text-align", "left");
124            guest4.innerHTML=guest3.innerHTML;
125            if(timer_guest==0)
126                timer_guest=setInterval(picMarquee_guest,Speed);
127        }
128
129}
130
131/* handle mouseover and mouseout event */
132function Marquee_set_event()
133{
134    if(timer_internet) {
135        Internet_bottom.onmouseover=function(){
136            clearInterval(timer_internet);
137        }
138        Internet_bottom.onmouseout=function(){
139            timer_internet=setInterval(picMarquee_interent,Speed);
140        }
141    }
142    if(wireless2 && wireless4 && timer_wireless) {
143        Wireless_bottom.onmouseover=function(){
144            clearInterval(timer_wireless);
145        }
146        Wireless_bottom.onmouseout=function(){
147            timer_wireless=setInterval(picMarquee_wireless,Speed);
148        }
149    }
150
151    if(timer_attached) {
152        AttachedDevices_bottom.onmouseover=function(){
153            clearInterval(timer_attached);
154        }
155        AttachedDevices_bottom.onmouseout=function(){
156            timer_attached=setInterval(picMarquee_attached,Speed);
157        }
158    }
159    if(timer_parental) {
160        ParentalControls_bottom.onmouseover=function(){
161            clearInterval(timer_parental);
162        }
163        ParentalControls_bottom.onmouseout=function(){
164            timer_parental=setInterval(picMarquee_parental,Speed);
165        }
166    }
167    if(timer_readyshare) {
168        ReadyShare_bottom.onmouseover=function(){
169            clearInterval(timer_readyshare);
170        }
171        ReadyShare_bottom.onmouseout=function(){
172            timer_readyshare=setInterval(picMarquee_readyshare,Speed);
173        }
174    }
175
176    if((guest2 || guest4) && timer_guest) {
177        GuestNetwork_bottom.onmouseover=function(){
178            clearInterval(timer_guest);
179        }
180        GuestNetwork_bottom.onmouseout=function(){
181            timer_guest=setInterval(picMarquee_guest,Speed);
182        }
183    }
184}
185
186function need_to_run_marquee(item)
187{
188    if(get_browser()=="Netscape") {
189        if(item=="Internet" && Internet_status) {
190            if (Internet_status.scrollWidth + 12 >
191                Internet_bottom.clientWidth)
192                return true;
193        } else if (item=="Wireless" && Wireless_status1) {
194            if ((Wireless_status1.scrollWidth + 12 >
195                Wireless_bottom.clientWidth) ||
196                (Wireless_status2.scrollWidth + 12 >
197                Wireless_bottom.clientWidth))
198                return true;
199        } else if (item=="Attached" && AttachedDevices_status) {
200            if (AttachedDevices_status.scrollWidth + 12 >
201                AttachedDevices_bottom.clientWidth)
202                return true;
203        } else if (item=="Parental" && ParentalControls_status) {
204            if (ParentalControls_status.scrollWidth + 12 >
205                ParentalControls_bottom.clientWidth)
206                return true;
207        } else if (item=="ReadySHARE" && ReadyShare_status) {
208            if (ReadyShare_status.scrollWidth + 12 >
209                ReadyShare_bottom.clientWidth)
210                return true;
211        } else if (item=="Guest1" && Guest_status1) {
212
213            if (Guest_status1.scrollWidth + 12 >
214                GuestNetwork_bottom.clientWidth)
215                return true;
216        } else if (item=="Guest2" && Guest_status2) {
217            if (Guest_status2.scrollWidth + 12 >
218                GuestNetwork_bottom.clientWidth)
219                return true;
220        }
221    }
222    else{
223        if(item=="Internet") {
224            if (internet1.clientWidth - Internet_bottom.clientWidth > 0)
225                return true;
226        } else if (item=="Wireless") {
227            if(wireless1 && wireless3 && wireless2 && wireless4 && Wireless_bottom &&
228                (wireless1.clientWidth - Wireless_bottom.clientWidth > 0 ||
229                wireless3.clientWidth - Wireless_bottom.clientWidth > 0)
230            )
231                return true;
232        } else if (item=="Attached") {
233            if (attached1.clientWidth - AttachedDevices_bottom.clientWidth > 0)
234                return true;
235        } else if (item=="Parental") {
236            if (parental1.clientWidth - ParentalControls_bottom.clientWidth > 0)
237                return true;
238        } else if (item=="ReadySHARE") {
239            if (readyshare1.clientWidth - ReadyShare_bottom.clientWidth > 0)
240                return true;
241        } else if (item=="Guest1") {
242            if(guest1 && guest2)
243                if(guest1.clientWidth - GuestNetwork_bottom.clientWidth > 0)
244                    return true;
245        } else if (item=="Guest2") {
246            if(guest3 && guest4)
247                if(guest3.clientWidth - GuestNetwork_bottom.clientWidth > 0)
248                    return true;
249        }
250    }
251
252    return false;
253}
254
255/* Internet */
256function picMarquee_interent(){
257    if(internet2.offsetWidth - Internet_bottom.scrollLeft <= 0){
258        Internet_bottom.scrollLeft = 0;
259    }else{
260        var temp = Internet_bottom.scrollLeft;
261        Internet_bottom.scrollLeft++;
262        if(temp==Internet_bottom.scrollLeft)
263            Internet_bottom.scrollLeft=0;
264    }
265}
266
267/* Wireless */
268function picMarquee_wireless(){
269    if(wireless2.offsetWidth - Wireless_bottom.scrollLeft <= 0){
270        Wireless_bottom.scrollLeft = 0;
271    }else{
272        var temp = Wireless_bottom.scrollLeft;
273        Wireless_bottom.scrollLeft++;
274        if(temp==Wireless_bottom.scrollLeft)
275            Wireless_bottom.scrollLeft=0;
276    }
277}
278
279
280/* Attached Devices */
281function picMarquee_attached(){
282    if(attached2.offsetWidth - AttachedDevices_bottom.scrollLeft <= 0){
283        AttachedDevices_bottom.scrollLeft = 0;
284    }else{
285        var temp = AttachedDevices_bottom.scrollLeft;
286        AttachedDevices_bottom.scrollLeft++;
287        if(temp==AttachedDevices_bottom.scrollLeft)
288            AttachedDevices_bottom.scrollLeft=0;
289    }
290}
291
292/* Parental Controls */
293function picMarquee_parental(){
294
295    if(parental2.offsetWidth - ParentalControls_bottom.scrollLeft <= 0){
296        ParentalControls_bottom.scrollLeft = 0;
297    }else{
298        var temp = ParentalControls_bottom.scrollLeft;
299        ParentalControls_bottom.scrollLeft++;
300        if(temp==ParentalControls_bottom.scrollLeft)
301            ParentalControls_bottom.scrollLeft=0;
302    }
303}
304
305/* ReadySHARE */
306function picMarquee_readyshare(){
307    if(readyshare2.offsetWidth - ReadyShare_bottom.scrollLeft <= 0){
308        ReadyShare_bottom.scrollLeft = 0;
309    }else{
310        var temp = ReadyShare_bottom.scrollLeft;
311        ReadyShare_bottom.scrollLeft++;
312        if(temp==ReadyShare_bottom.scrollLeft)
313            ReadyShare_bottom.scrollLeft=0;
314    }
315}
316
317/* Guest Network */
318function picMarquee_guest(){
319    if(guest2.offsetWidth - GuestNetwork_bottom.scrollLeft <= 0){
320        GuestNetwork_bottom.scrollLeft = 0;
321    }else{
322        var temp = GuestNetwork_bottom.scrollLeft;
323        GuestNetwork_bottom.scrollLeft++;
324        if(temp==GuestNetwork_bottom.scrollLeft)
325            GuestNetwork_bottom.scrollLeft=0;
326    }
327}
328
329function get_browser()
330{
331	if(navigator.userAgent.indexOf("Navigator") != -1)
332        return "Netscape";
333    else if(navigator.userAgent.indexOf("MSIE") != -1)
334		return "IE";
335	else if(navigator.userAgent.indexOf("Chrome") != -1 )
336		return "Chrome";//bug 21975:spec1.9-p228,[usb] the real links are different for different browsers
337	else if(navigator.userAgent.indexOf("Firefox") != -1)
338		return "Firefox";
339	else if(navigator.userAgent.indexOf("Safari") != -1 )
340		return "Safari";
341	else if(navigator.userAgent.indexOf("Camino") != -1)
342		return "Camino";
343 	else if(navigator.userAgent.indexOf("Gecko/") != -1)
344   		return "Gecko";
345	else if(navigator.userAgent.indexOf("Opera") != -1)
346		return "Opera";
347	else
348   		return "";
349}
350
351var msg_invalid_ip = "<%10%>\n";
352function isIPaddr(addr) {
353    var i;
354    var a;
355    if(addr.split) {
356        a = addr.split(".");
357    }else {
358        a = cdisplit(addr,".");
359    }
360    if(a.length != 4) {
361        return false;
362    }
363    for(i = 0; i<a.length; i++) {
364        var x = a[i];
365        if( x == null || x == "" || !_isNumeric(x) || x<0 || x>255 ) {
366            return false;
367        }
368    }
369    return true;
370}
371
372function isValidIPaddr(addr) {
373    var i;
374    var a;
375    if(addr.split) {
376        a = addr.split(".");
377    }else {
378        a = cdisplit(addr,".");
379    }
380    if(a.length != 4) {
381        return false;
382    }
383    for(i = 0; i<a.length; i++) {
384        var x = a[i];
385        if( x == null || x == "" || !_isNumeric(x) || x<0 || x>255 ) {
386            return false;
387        }
388    }
389
390    var ip1 = new String("");
391    var ip2 = new String("");
392    var ip3 = new String("");
393    var ip4 = new String("");
394    ip1.value = a[0];
395    ip2.value = a[1];
396    ip3.value = a[2];
397    ip4.value = a[3];
398
399    if(checkIP(ip1,ip2,ip3,ip4,254)||(parseInt(ip4.value,10)==0))
400        return false;
401
402    return true;
403}
404
405function isNetmask(mask1,mask2,mask3,mask4)
406{
407    var netMask;
408    var i;
409    var bit;
410    var isChanged = 0;
411
412    netMask = (mask1.value << 24) | (mask2.value << 16) | (mask3.value << 8) | (mask4.value);
413
414    /* Check most byte (must be 255) and least significant bit (must be 0) */
415    bit = (netMask & 0xFF000000) >>> 24;
416    if (bit != 255)
417        return false;
418
419    bit = netMask & 1;
420    if (bit != 0)
421        return false;
422
423    /* Now make sure the bit pattern changes from 0 to 1 only once */
424    for (i=1; i<31; i++)
425    {
426        netMask = netMask >>> 1;
427        bit = netMask & 1;
428
429        if (bit != 0)
430        {
431            if (isChanged == 0)
432                isChanged = 1;
433        }
434        else
435        {
436            if (isChanged == 1)
437                return false;
438        }
439    }
440
441    return true;
442}
443
444function trim(vString)
445{
446	var tString = vString;
447
448	//trim left spaces
449	if (tString.charAt(0) == " ")
450		tString = trim(tString.substring(1, tString.length));
451
452	//trim right spaces
453	if (tString.charAt(tString.length-1) == " ")
454		tString = trim(tString.substring(0, tString.length-1))
455
456	return(tString);
457}
458function isNumOnly(vString)
459{
460	var NUMBERS = "0123456789";
461	var valid = true;
462	for(var i=0;i<vString.length;i++)
463		if(NUMBERS.indexOf(vString.charAt(i))<0)
464			valid = false;
465
466	return(valid);
467}
468function isNull(vField) {
469	var ret = false
470	vField.value = trim(vField.value)
471
472	if (vField.value.length == 0)
473		ret = true
474	return(ret)
475}
476
477function _isNumeric(str) {
478    var i;
479
480    if(str.length == 0 || str == null || str == "" || !isDecimalNumber(str)) {
481        return false;
482    }
483
484    for(i = 0; i<str.length; i++) {
485        var c = str.substring(i, i+1);
486        if("0" <= c && c <= "9") {
487            continue;
488        }
489        return false;
490    }
491    return true;
492}
493
494function isHex(str) {
495    var i;
496    for(i = 0; i<str.length; i++) {
497        var c = str.substring(i, i+1);
498        if(("0" <= c && c <= "9") || ("a" <= c && c <= "f") || ("A" <= c && c <= "F")) {
499            continue;
500        }
501        return false;
502    }
503    return true;
504}
505
506/* Just check if MAC address is all "F", or all "0" , with  ':' in it or not weal @ Aug 14*/
507function MacStrallf(mac) {
508	var temp=mac.value;
509
510    for(i=0; i<mac.value.length;i++) {
511        var c = mac.value.substring(i, i+1)
512        if (c == "f" || c == "F" || c == "0" || c == ":" || c == "-")
513            continue;
514		else
515			break;
516	}
517	if (i == mac.value.length)
518		return true;
519	else
520		return false;
521}
522function checkMacStr(mac) {
523    if((mac.value.indexOf(':') != -1)||(mac.value.indexOf('-') != -1))
524    {
525        mac.value = mac.value.replace(/:/g,"");
526        mac.value = mac.value.replace(/-/g,"");
527    }
528    var temp=mac.value;
529    if(mac.value.length != 12) {
530        if (mac.focus)
531            mac.focus();
532        return true;
533    }
534    for(i=0; i<mac.value.length;i++) {
535        var c = mac.value.substring(i, i+1);
536        if(("0" <= c && c <= "9") || ("a" <= c && c <= "f") || ("A" <= c && c <= "F")) {
537            continue;
538        }
539        if (mac.focus)
540            mac.focus();
541        return true;
542    }
543
544    if(checkMulticastMAC(mac) || MacStrallf(mac))
545    {
546        if (mac.focus)
547            mac.focus();
548        return true;
549    }
550
551    mac.value = temp.toUpperCase();
552    return false;
553}
554/* Check Mac Address Format*/
555function checkMacMain(mac) {
556    if(mac.value.length == 0) {
557        if (mac.focus)
558            mac.focus();
559        return true;
560    }
561    for(i=0; i<mac.value.length;i++) {
562        var c = mac.value.substring(i, i+1)
563        if(("0" <= c && c <= "9") || ("a" <= c && c <= "f") || ("A" <= c && c <= "F")) {
564            continue;
565        }
566        if (mac.focus)
567            mac.focus();
568        return true;
569    }
570    if(mac.value.length == 1) {
571        mac.value = "0"+mac.value;
572    }
573    mac.value = mac.value.toUpperCase();
574    return false;
575}
576function checkMacAddress(mac1, mac2, mac3, mac4, mac5, mac6) {
577    if(checkMacMain(mac1)) return true;
578    if(checkMacMain(mac2)) return true;
579    if(checkMacMain(mac3)) return true;
580    if(checkMacMain(mac4)) return true;
581    if(checkMacMain(mac5)) return true;
582    if(checkMacMain(mac6)) return true;
583    var mac_str = new String("");
584    mac_str.value =  mac1.value + mac2.value + mac3.value
585                 + mac4.value + mac5.value + mac6.value;
586    if(checkMulticastMAC(mac_str) || MacStrallf(mac_str))
587        return true;
588
589    return false;
590}
591
592/* Check Multicast MAC */
593function checkMulticastMAC(macaddr) {
594    var mac_defined = macaddr.value;
595    var macadr_first_byte = parseInt(mac_defined.substring(0,2),16);
596    var Multicast_Flag = macadr_first_byte & 0x01;
597    if( Multicast_Flag )
598        return true;
599    return false;
600}
601
602/* Check IP Address Format*/
603function checkIPMain(ip,max) {
604    if( isNumeric(ip, max) ) {
605        if (ip.focus)
606            ip.focus();
607        return true;
608    }
609}
610
611function checkIP(ip1, ip2, ip3, ip4,max) {
612    if(checkIPMain(ip1,255)) return true;
613    if(checkIPMain(ip2,255)) return true;
614    if(checkIPMain(ip3,255)) return true;
615    if(checkIPMain(ip4,max)) return true;
616
617    if((ip1.value.charAt(0)=="0" && ip1.value.length!=1) ||
618       (ip2.value.charAt(0)=="0" && ip2.value.length!=1) ||
619       (ip3.value.charAt(0)=="0" && ip3.value.length!=1) ||
620       (ip4.value.charAt(0)=="0" && ip4.value.length!=1))
621        return true;
622
623    if((parseInt(ip1.value)==0)||
624       ((parseInt(ip1.value)==0)&&(parseInt(ip2.value)==0)&&
625        (parseInt(ip3.value)==0)&&(parseInt(ip4.value)==0)))
626        return true;
627
628    var loopback_ip_start   = (127 << 24)  |   (0 << 16)   |   (0 << 8)   |   (0);
629    var loopback_ip_end     = (127 << 24)  |  (255 << 16)  |  (255 << 8)  | (255);
630    var groupcast_ip_start  = (224 << 24)  |   (0 << 16)   |   (0 << 8)   |   (0);
631    var groupcast_ip_end    = (239 << 24)  |  (255 << 16)  |  (255 << 8)  | (255);
632    var dhcpresv_ip_start   = (169 << 24)  |  (254 << 16)  |   (0 << 8)   |   (0);
633    var dhcpresv_ip_end     = (169 << 24)  |  (254 << 16)  |  (255 << 8)  | (255);
634    var ip_addr = (ip1.value << 24) | (ip2.value << 16) | (ip3.value << 8) | (ip4.value);
635    if((ip_addr >= loopback_ip_start)&&(ip_addr <= loopback_ip_end))
636        return true;
637    if((ip_addr >= groupcast_ip_start)&&(ip_addr <= groupcast_ip_end ))
638        return true;
639    if((ip_addr >= dhcpresv_ip_start)&&(ip_addr <= dhcpresv_ip_end))
640        return true;
641
642    return false;
643}
644
645function checkIPMatchWithNetmask(mask1,mask2,mask3,mask4,ip1, ip2, ip3, ip4)
646{
647    var netMask;
648	var ipAddr;
649
650    netMask = (mask1.value << 24) | (mask2.value << 16) | (mask3.value << 8) | (mask4.value);
651    ipAddr = (ip1.value << 24) | (ip2.value << 16) | (ip3.value << 8) | (ip4.value);
652
653    if (((~netMask)&ipAddr) == 0)
654		return true;
655	if (((~netMask)&ipAddr) == (~netMask))
656		return true;
657	return false;
658}
659
660function isDecimalNumber(str)
661{
662    if ((str.charAt(0)=='0') && (str.length != 1))
663         return false;
664    for(var i=0;i<str.length;i++)
665    {
666         if(str.charAt(i)<'0'||str.charAt(i)>'9')
667         return false;
668    }
669    return true;
670}
671
672/* Check Numeric*/
673function isNumeric(str, max) {
674    if(str.value.length == 0 || str.value == null || str.value == "") {
675        if (str.focus)
676            str.focus();
677        return true;
678    }
679
680    var i = parseInt(str.value,10);
681    if(i>max) {
682        if (str.focus)
683            str.focus();
684        return true;
685    }
686    for(i=0; i<str.value.length; i++) {
687        var c = str.value.substring(i, i+1);
688        if("0" <= c && c <= "9") {
689            continue;
690        }
691        if (str.focus)
692            str.focus();
693        return true;
694    }
695    return false;
696}
697
698/* Check Blank*/
699function isBlank(str) {
700    if(str.value == "") {
701        if (str.focus)
702            str.focus();
703        return true;
704    } else
705        return false;
706}
707
708/* Check Phone Number*/
709function isPhonenum(str) {
710    var i;
711    if(str.value.length == 0) {
712        if (str.focus)
713            str.focus();
714        return true;
715    }
716    for (i = 0; i<str.value.length; i++) {
717        var c = str.value.substring(i, i+1);
718        if (c>= "0" && c <= "9")
719            continue;
720        if ( c == '-' && i !=0 && i != (str.value.length-1) )
721            continue;
722        if ( c == ',' ) continue;
723        if (c == ' ') continue;
724        if (c>= 'A' && c <= 'Z') continue;
725        if (c>= 'a' && c <= 'z') continue;
726        if (str.focus)
727            str.focus();
728        return true;
729    }
730    return false;
731}
732
733/* 0:close 1:open*/
734function openHelpWindow(filename) {
735    helpWindow = window.open(filename,"thewindow","width=300,height=400,scrollbars=yes,resizable=yes,menubar=no");
736}
737
738function alertPassword(formObj) {
739    if (formObj.focus)
740        formObj.focus();
741}
742function isEqual(cp1,cp2)
743{
744	if(parseInt(cp1.value,10) == parseInt(cp2.value,10))
745	{
746		if (cp2.focus)
747			cp2.focus();
748		return true;
749	}
750	else return false;
751}
752function setDisabled(OnOffFlag,formFields)
753{
754	for (var i = 1; i < setDisabled.arguments.length; i++)
755		setDisabled.arguments[i].disabled = OnOffFlag;
756}
757
758function cp_ip(from1,from2,from3,from4,to1,to2,to3,to4)
759//true invalid from and to ip;  false valid from and to ip;
760{
761    var total1 = 0;
762    var total2 = 0;
763
764    total1 += parseInt(from4.value,10);
765    total1 += parseInt(from3.value,10)*256;
766    total1 += parseInt(from2.value,10)*256*256;
767    total1 += parseInt(from1.value,10)*256*256*256;
768
769    total2 += parseInt(to4.value,10);
770    total2 += parseInt(to3.value,10)*256;
771    total2 += parseInt(to2.value,10)*256*256;
772    total2 += parseInt(to1.value,10)*256*256*256;
773    if(total1 > total2)
774        return true;
775    return false;
776}
777function pi(val)
778{
779    return parseInt(val,10);
780}
781function alertR(str)
782{
783    alert(str);
784    return false;
785}
786