rnd.today=new Date(); rnd.seed=rnd.today.getTime(); function msg(sBuf) { alert(sBuf); } function rnd() { rnd.seed = (rnd.seed * 9301 + 49297) % 233280; return rnd.seed / (233280.0); } function rand(number) { return Math.ceil(rnd() * number); } function GetQueryStringParam(sName,bTop) { var sSearch; if (bTop) { sSearch = top.location.search; } else { sSearch = location.search; } var p1; p1 = sSearch.indexOf('?' + sName + '='); if (p1 < 0) { p1 = sSearch.indexOf('&' + sName + '='); } if (p1 < 0) { return ""; } p1 += sName.length + 2; var p2 = sSearch.indexOf('&',p1); if (p2 >= 0) { return sSearch.substring(p1,p2); } else { return sSearch.substring(p1); } } function Set_Cookie(name, value, expires, path, domain, secure) { document.cookie = name + '=' + escape(value) + ((expires) ? ';expires=' + expires.toGMTString() : '') + ((path) ? ';path=' + path : '') + ((domain) ? ';domain=' + domain : '') + ((secure) ? ';secure' : ''); } function Get_Cookie(name) { var start = document.cookie.indexOf(name+"="); var len = start+name.length+1; if ((!start) && (name != document.cookie.substring(0, name.length))) return ''; if (start == -1) return ''; var end = document.cookie.indexOf(";",len); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(len,end)); } function Delete_Cookie(name, path, domain) { if (Get_Cookie(name)) document.cookie = name + "=" + ((path) ? ";path=" + path : "") + ((domain) ? ";domain=" + domain : "") + ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; } function Set_Sub_Cookie(bigCookieName, subCookieName, value, expires, path, domain, secure) { sBuf = Get_Cookie(bigCookieName); iLoc = sBuf.indexOf(subCookieName + '='); if (iLoc > -1) { iEnd = sBuf.indexOf(';', iLoc) + 1; sBuf = sBuf.substr(0, iLoc) + sBuf.substr(iEnd); } sBuf += subCookieName + '=' + escape(value) + ';'; Set_Cookie(bigCookieName, sBuf, expires, path, domain, secure); } function Set_Main_Cookie(name, value, expires, path, domain, secure) { Set_Sub_Cookie('main', name, value, '', '/', '', ''); } function Delete_Main_Cookie(name, expires, path, domain, source) { Delete_Sub_Cookie('main', name, expires, path, domain, source); } function Delete_Sub_Cookie(bigCookieName, subCookieName, expires, path, domain, secure) { sBuf = Get_Cookie(bigCookieName); iLoc = sBuf.indexOf(subCookieName + '='); if (iLoc > -1) // find cookie and delete it { iEnd = sBuf.indexOf(';', iLoc) + 1; sBuf = sBuf.substr(0, iLoc) + sBuf.substr(iEnd); if (sBuf.length > 0) { Set_Cookie(bigCookieName, sBuf, expires, path, domain, secure); } else { Delete_Cookie(bigCookieName, path, domain); } } } function Get_Sub_Cookie(bigCookieName, subCookieName) { sBuf = Get_Cookie(bigCookieName); iLoc = sBuf.indexOf(subCookieName + '='); if (iLoc > -1) { iLoc = iLoc + subCookieName.length + 1; return unescape(sBuf.substr(iLoc, sBuf.indexOf(';', iLoc) - iLoc)); } return ''; } function Get_Main_Cookie(name) { return Get_Sub_Cookie('main', name); } function makeArray() { for (i=0; i < makeArray.arguments.length; i++) this[i + 1] = makeArray.arguments[i]; } /* commented out * commented out function WriteDate() { var months = new makeArray('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); var date = new Date(); var day = date.getDate(); var month = date.getMonth() + 1; var yy = date.getYear(); var year = (yy < 1000) ? yy + 1900 : yy; return (months[month] + " " + day + ", " + year); } */ function SetDebug(val) { Set_Cookie('debug', val, '', '/', '', ''); } function SetPartner(name) { Set_Cookie('partner', name, '', '/', '', ''); } function DebugMsg(msg) { alert('Debug Level: ' + Get_Cookie('debug') + '\n\n' + msg); } function StripSpaces(buf) { while (buf.substring(0,1) == ' ') buf = buf.substring(1); while (buf.substring(buf.length-1, buf.length) == ' ') buf = buf.substring(0, buf.length-1); return buf; } function WriteMapButton(load) { document.write(''); if (Get_Cookie('map') == '1') { document.write('Map Off'); } else { document.write('Map On'); } document.write(''); } function NotAvailableMsg() { alert('Not available.'); } function UrlCheck(url) { if ((url.indexOf('http://') == 0) || (url.indexOf('https://') == 0) || (url.indexOf('ftp://') == 0)|| (url.indexOf('mailto:') == 0)) { return url; } else { return 'http://' + url; } } function isValidURLDirectoryName(string) { if (string.search(/^\w+((-\w+)|(\.\w+))*$/) != -1) return true; else return false; } function MailToCheck(url) { if (url.indexOf('mailto:') == 0) { return url; } else { return 'mailto:' + url; } } function IsValidFileExt(file, ext) { return ((file.indexOf(ext) != -1) && !(file.indexOf(ext) == 0) && (file.indexOf(ext) == strTest.length - ext.length)); } function IsValidFileName(file) { //chars = ' \\/:*?"<>|'; chars = ' !"#$%&\'()*+,/:;<=>?@[\\]^`{|}~'; if (file.indexOf('.') == 0) return false; for (i=0; i < chars.length; i++) { if (file.indexOf(chars.charAt(i)) > -1) { return false; } } return true; } function getErrorMessageInvalidFileName() { return "Please enter a valid file name. The following characters are not valid !\"#$%&'()*+,/:;<=>?@[\\]^`{|}~ and spaces. A period '.' cannot be used as a first character."; } function isInteger(buf) { var i; for (i=0; i < buf.length; i++) { var c = buf.charAt(i); if (!isDigit(c)) return false; } return true; } function isDigit(c) { return ((c >= "0") && (c <= "9")); } function isLetter(c) { return (((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z"))); } function isNotExtChar(c) { return (((c >= ' ') && (c <= '~'))); } function isURLPathChar(c) { var ci = c.charCodeAt(0); if (((c > ' ') && (c <= '~'))) { if (ci == 34 || // double quote ci == 35 || // hash ci == 60 || // less than ci == 62 || // greater than ci == 63 || // query ci == 91 || // square bracket ci == 92 || // backslash ci == 93 || // square bracket ci == 94 || // caret ci == 96 || // backquote ci == 123 || // curly brace ci == 124 || // pipe ci == 125 // curly brace ) return false; return true; } return false; } function isURLPath(s) { var i; for (i = 0; i < s.length; i++) { var c = s.charAt(i); if (c == '#') return true; if (c == '?') return true; if (! (isURLPathChar(c))) return false; } return true; } function isLatin1(s) { var i; for (i = 0; i < s.length; i++) { var c = s.charAt(i); if (! (isLatin1Char(c))) return false; } return true; } function isLatin1Char(c) { var ci = c.charCodeAt(0); return (ci <= 255 && (ci >= 32 || (ci == 10) || (ci == 13) || (ci == 9))); } function getLatin1OnlyString(s) { var i; var str = ''; for (i = 0; i < s.length; i++) { var c = s.charAt(i); if (isLatin1Char(c)) str = str + c; } return str; } function getAsciiOnlyString(s) { var i; var str = ''; for (i = 0; i < s.length; i++) { var c = s.charAt(i); if (isNotExtChar(c)) str = str + c; } return str; } function isXML(s) { var i; for (i = 0; i < s.length; i++) { var c = s.charAt(i); if (! (isXMLChar(c))) return false; } return true; } function isXMLChar(c) { var ci = c.charCodeAt(0); return ((ci >= 32) || (ci == 10) || (ci == 13) || (ci == 9)); } function getXMLString(s) { var i; var str = ''; for( i = 0; i < s.length; i++) { var c = s.charAt(i); if (isLatin1Char(c)) str = str + c; else if (c.charCodeAt(0) > 255) str = str + "&#" + c.charCodeAt(0) + ";"; } return str; } function isAlphanumeric(s) { var i; for (i = 0; i < s.length; i++) { var c = s.charAt(i); if (! (isLetter(c) || isDigit(c) || c == ' ')) return false; } return true; } function isStrictAlphanumeric(s) { var i; for (i = 0; i < s.length; i++) { var c = s.charAt(i); if (! (isLetter(c) || isDigit(c))) return false; } return true; } function isNotExt(s) { var i; for (i = 0; i < s.length; i++) { var c = s.charAt(i); if (! (isNotExtChar(c))) return false; } return true; } function replace(string,text,by) { // Replaces text with by in string var strLength = string.length, txtLength = text.length; if ((strLength == 0) || (txtLength == 0)) return string; var i = string.indexOf(text); if ((!i) && (text != string.substring(0,txtLength))) return string; if (i == -1) return string; var newstr = string.substring(0,i) + by; if (i+txtLength < strLength) newstr += replace(string.substring(i+txtLength,strLength),text,by); return newstr; } function myEscape(buf) { buf = escape ( buf ); return replace (buf, "+", "%2B"); //buf.replace(/\+/, "%2B"); } function isNameAllLowercase(str) { for (i = 0; i < str.length; i++) { var c = str.charAt(i); if (isUppercase(c)) return false; } return true; } function isUppercase(c){ return ('A' <= c && c <= 'Z'); } function isSiteExist(sites, publishName, index){ for (i = 0; i < index; i++) { if (sites[i] == publishName) { return true; } } return false; } function isDirExist(dirs, publishName, dircount){ for (i = 0; i < dircount; i++) { if (dirs[i] == publishName) { return true; } } return false; } function OpenNewWin(loc, wd, ht, winname, resizeable) { var xloc = (screen.width - wd) / 2; var yloc = (screen.height - ht) / 2; if (winname == null || winname == '') winname = 'popUp'; var winHelp; if (resizeable != "resizeable"){ winHelp = window.open(loc, winname,'width='+wd+',height='+ht+',innerwidth='+wd+',innerheight='+ht+',left='+xloc+',top='+yloc+',resizeable=no'); } else{ // resizeable winHelp = window.open(loc, winname,'width='+wd+',height='+ht+',innerwidth='+wd+',innerheight='+ht+',left='+xloc+',top='+yloc+',resizeable=yes'); } if (!winHelp.focus()) { winHelp.focus(); } } /* This function checks for a valid HTTP URL with no query string */ function isValidURL(str) { var pos = 0; var c = 0; /* check for http scheme */ if (str.indexOf('http://') == 0) { pos = 6; } else if (str.indexOf('https://') == 0) { pos = 7; } else if (str.indexOf('ftp://') == 0) { pos = 5; } /* -- leave out mailto for now -- */ else if (str.indexOf('mailto:') == 0) { pos = str.indexOf('@'); if (pos < 0) { return false; } } /**/ else { return false; } /* check for empty address */ if (str.length <= pos + 1) { return false; } /* check for valid hostname */ do { if ( !isStrictAlphanumeric(str.charAt(++pos)) && !(str.charAt(pos) == '@') && !(str.charAt(pos) == '_') ) { return false; } while (pos < str.length) { if (!isStrictAlphanumeric(str.charAt(pos)) && !(str.charAt(pos) == '-') && !(str.charAt(pos) == '@') && !(str.charAt(pos) == '_') ) { break; } pos++; } if (pos >= str.length) return true; if (str.charAt(pos-1) == '-') return false; if (str.charAt(pos-1) == '@') return false; if (str.charAt(pos-1) == '_') return false; if (str.charAt(pos) == ':') break; if (str.charAt(pos) == '/') break; if (!(str.charAt(pos) == '.')) return false; } while (pos < str.length) /* check for optional port number */ if (str.charAt(pos) == ':') { c = 0; while (pos < str.length && isDigit(str.charAt(++pos))) { if (++c > 5) return false; } if (c < 1) { return false; } } /* check for valid path */ if (str.charAt(pos) == '/') { if (!isURLPath(str.substring(pos))) return false; } else if (pos < str.length) { return false; } return true; }