/********************************************************************************************** ** ** File name: functions.js ** Creation date: 24th May, 2001 ** Last update: 7th January, 2002 ** ** ** ** Functions: ** ** Image functions - ** void MM_swapImgRestore() // from Dreamweaver4 ** void MM_preloadImages(String, String, ......, String) // from Dreamweaver4 ** void MM_preloadimagenew(String, String, ......, String) // from Dreamweaver4 ** void MM_findObj() // from Dreamweaver4 ** void MM_swapImage(String,null,String,) // from Dreamweaver4 ** ** Layers functions - ** void MM_showHideLayers() // from Dreamweaver4 ** void showMenu(String) ** void hideMenu(String) ** ** String functions - ** boolean isWhitespace(String) ** boolean isAlphaNumeric(String) ** boolean isAlphabets(String) ** boolean isInteger(String) ** boolean isFloat(String) ** boolean isEmail(String) ** ** Cookie functions - ** function setCookie(String, String, int) ** function getCookie(String) ** ** Other functions - ** void loadTop(String, String) ** void switchlang() ** String getParameter() ** boolean checkBrowser(int,int,int,int,int,int,int) ** boolean orangeOnLoad() ** **************************************************************************** ** Modified History ** ================ ** HKL 05/10/2001 add functions getSectionL1() and getSectionL2(), ** modify switchlang() ** Alex 24/10/2001 add function checkBrowser(int,int,int,int,int,int,int) ** Alex 07/01/2002 add function orangeOnLoad() **********************************************************************************************/ /////////////////////////////////////////////////////////////////////////////////////////////// // function name: MM_swapImgRestore // return value: void // parameter(s): void // description: // This function restores the images that was swapped by the function MM_swapImage // Note: this function is copied from Macromedia Dreamweaver 4. P.s. reference DW4 for detail // it is always used as counter part with function MM_swapImg() /////////////////////////////////////////////////////////////////////////////////////////////// function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i='A' && c<='Z') || (c>='a' && c<='z') || (c>='0' && c<='9')) ) return false; } return true; } /////////////////////////////////////////////////////////////////////////////////////////////// // function name: isAlphabets // return value: boolean, i.e. true or flase // parameter(s): a String // description: // This function will return true only if the string contains alphabets(a-z, A-Z) /////////////////////////////////////////////////////////////////////////////////////////////// function isAlphabets(str) { for(var i=0; i='A' && c<='Z') || (c>='a' && c<='z')) ) return false; } return true; } /////////////////////////////////////////////////////////////////////////////////////////////// // function name: isInteger // return value: boolean, i.e. true or flase // parameter(s): a String // description: // This function will return true only if the string contains digit characters(0-9) /////////////////////////////////////////////////////////////////////////////////////////////// function isInteger(str) { for(var i=0; i='0' && c<='9') ) return false; } return true; } /////////////////////////////////////////////////////////////////////////////////////////////// // function name: isFloat // return value: boolean, i.e. true or flase // parameter(s): a String // description: // This function will return true only if the string contains digit characters(0-9) or point(.) once /////////////////////////////////////////////////////////////////////////////////////////////// function isFloat(str) { var intCount = 0; for(var i=0; i 0 ) return false; else intCount++; else if( !(c>='0' && c<='9') ) return false; } return true; } /////////////////////////////////////////////////////////////////////////////////////////////// // function name: isEmail // return value: boolean, i.e. true or flase // parameter(s): a String // description: // This function will return false only the string is not in the pattern // "string@string[.string]" where string here is composed of alphanumeric characters or underscore(_) only. /////////////////////////////////////////////////////////////////////////////////////////////// function isEmail(strEmail) { invalidChars ="/:,?#;"; if (strEmail==null || isWhitespace(strEmail)) return false; for (ai=0;ai -1) return false; } atPos = strEmail.indexOf("@",1); if (atPos ==-1) return false; if (strEmail.indexOf("@",atPos+1) > -1) return false; periodPos = strEmail.indexOf(".",atPos); if (periodPos == -1) return false; if (periodPos+3 > strEmail.length) return false; return true; } /////////////////////////////////////////////////////////////////////////////////////////////// // function name: setCookie // return value: none // parameter(s): // name - the name string of the cookie // value - the corresponding value string of the cookie with the name above // expire - the number of minutes after the current time for the cookie to expire // description: // This function will set the cookie of the page /////////////////////////////////////////////////////////////////////////////////////////////// function setCookie(name, value, expMin) { var expire = new Date(); expire.setTime(expire.getTime()+expMin*60*1000); document.cookie = name + "=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString())); } /////////////////////////////////////////////////////////////////////////////////////////////// // function name: getCookie // return value: the corresponding value string of the cookie value specified by the name parameter // parameter(s): // name - the name string of the cookie // description: // This function will set the cookie of the page /////////////////////////////////////////////////////////////////////////////////////////////// function getCookie(Name) { var search = Name + "=" ; if (document.cookie.length > 0) { // if there are any cookies offset = document.cookie.indexOf(search); if (offset != -1) { // if cookie exists offset += search.length ; // set index of beginning of value end = document.cookie.indexOf(";", offset); // set index of end of cookie value if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(offset, end)) } } return null; } /////////////////////////////////////////////////////////////////////////////////////////////// // function name: loadTop // return value: none // parameter(s): // frame - the framem object at where top banner page is loaded // url - the url to be loaded at the frame // description: // This function is used to load the top frame with new url. /////////////////////////////////////////////////////////////////////////////////////////////// function loadTop(frame, url) { if( frame==null ) frame = parent.frames["orangetop"]; if( url==null ) frame.location.reload(); else frame.location.href = url; } /////////////////////////////////////////////////////////////////// // function name: switchlang // return value: none // parameter(s): none // description: // This function is used to change the language of a page by // replacing "/eng" to "/chi/" or // vice versa. // HKL - take care of the case if switch need to be done by // pass language=?? variables //////////////////////////////////////////////////////////////////// //function switchlang() { // return switchlang(""); //} //function switchlang(tolan) { // var path = top.location.href; // if (path.indexOf("/eng/") >=0 || path.indexOf("/chi/") >=0) { // /* case: use chi and eng to switch langauge */ // if( top.location.href.indexOf("/eng/")==-1 ) // top.location.href = top.location.href.replace(/\/chi\//gi,"\/eng\/"); // else // top.location.href = top.location.href.replace(/\/eng\//gi,"\/chi\/"); // } else { // var nextLanguage=tolan // /* pass language parameter */ // var pathname=window.location.pathname; // var end = pathname.indexOf('.'); // var temp= pathname.substring(0,end); // var begin = temp.lastIndexOf('/')+1; // var filename=temp.substring(begin,end)+pathname.substring(end); // alert("language="+nextLanguage); // document.location.href="MFL040.jsp?language="+ // nextLanguage+"&filename="+filename; // } //} // /////////////////////////////////////////////////////////////////////////////////////////////// // function name: popup // /////////////////////////////////////////////////////////////////////////////////////////////// // first time set the pop-up window does not exist var popupWin = null; function openWindow(url,name,widthpw,heightpw) { var dimension = 'scrollbars,width=' + widthpw + ',height=' + heightpw + ',top=0,left=0,resizable=yes'; var chkNS = 'n'; if (checkBrowser(0,1,0,0,0,0,0) && (url.indexOf('.html') < 0) && (url.indexOf('.htm') < 0) && (url.indexOf('.jsp') < 0)) chkNS = "y"; // if pop-up window exists, kill it if (popupWin != null) { if (popupWin.closed) { if (chkNS == 'y') { window.location.href = url; } else { popupWin = window.open(url,name,dimension); } } else { popupWin.close(); } } if (chkNS == 'y') { window.location.href = url; } else { popupWin = window.open(url,name,dimension); } if (self.focus) { popupWin.focus(); } } function clearUp() { if (popupWin != null) { popupWin.close(); } } /********************************************************************/ /* HKL -- section for usage of getParameter(String) */ /********************************************************************/ function getParameter(a) { var st = this.location.search; if (st != null && st != "") { st = st.substring(1,st.length); var pp = st.split("&"); for (ii=0; ii= 0) { var bb = pp[ii].split("="); return bb[1]; } } } return ""; } /////////////////////////////////////////////////////////////////////////////////////////////// // function name: checkBrowser // return value: boolean // parameter(s): // NSvers - the version of the Netscape(NS) browser to be checked against. // NSpass - a flag to indicate that NS pass the check // NSnoPass - a flag to indicate that NS version is ignored for the check // IEvers - the version of the Internet Explorer(IE) browser to be checked against. // IEpass - a flag to indicate that IE pass the check // IEnoPass - a flag to indicate that IE version is ignored for the check // OBpass - a flag indicate that browsers other than IE & Netscape pass the check // description: // This function check for the version of the browser which load the page // Note: This function is modified from Macromedia Dreamweaver 4. P.s. reference DW4 for detail; // For all the arguments that is a flag, 1 means 'on', otherwise, 'off' /////////////////////////////////////////////////////////////////////////////////////////////// function checkBrowser(NSvers,NSpass,NSnoPass,IEvers,IEpass,IEnoPass,OBpass) { //v4.0 var result=false, verStr=navigator.appVersion, app=navigator.appName, version = parseFloat(verStr); if (app.indexOf('Netscape') != -1) { if (version >= NSvers) {if (NSpass>0) result=(NSpass==1)?true:false;} else {if (NSnoPass>0) result=(NSnoPass==1)?true:false;} } else if (app.indexOf('Microsoft') != -1) { if (version >= IEvers || verStr.indexOf(IEvers) != -1) {if (IEpass>0) result=(IEpass==1)?true:false;} else {if (IEnoPass>0) result=(IEnoPass==1)?true:false;} } else if (OBpass>0) result=(OBpass==1)?true:false; return result; } // HKL - 22112001 function checkLogin() { var ii = document.switchform.logintype.value; if (ii == "Orange" || ii == "SVA") { return confirm("By Confirm, you will be logged out from your " + ii + " session"); } else return true; } function popupSMSCharge(lang) { window.open('http://www.orangehk.com/common/jsp/popupCharge.jsp?lang='+lang, 'popupCharge', 'width=300,height=150,toolbar=no,menubar=no,scrollbars=no,resizable=yes,location=no,status=no'); } /////////////////////////////////////////////////////////////////////////////////////////////// // function name: orangeExecuteWorklist // return value: boolean // parameter(s): // aryStatments - an string array that contains Javascript statement to be executed. // description: // This function retrieve statements from a predefined array and exectue them when called // Note: This function is initailly created for the purpose about onLoad event. /////////////////////////////////////////////////////////////////////////////////////////////// function orangeExecuteWorklist(worklist) { if( worklist==null || worklist[0]==null ) return false; for(var i=0; i