var i_trimSelectBoxWidth = 30; var daysInMonth = new Array(12); daysInMonth[1] = 31; daysInMonth[2] = 29; daysInMonth[3] = 31; daysInMonth[4] = 30; daysInMonth[5] = 31; daysInMonth[6] = 30; daysInMonth[7] = 31; daysInMonth[8] = 31; daysInMonth[9] = 30; daysInMonth[10] = 31; daysInMonth[11] = 30; daysInMonth[12] = 31; var popupMessageText=""; var timerID = null; //window.defaultStatus=("ePartner"); // Localize is dummy function used to mark strings that need to be made // visible to GMS system for translation function Localize(str) { return(str); } //---------------------------------------------------------------- // This function traps the Enter button, so a user // can submit a form without having to use the mouse // or tab to a submit form // stick onKeyPress=checkEnter(); in the form tag, // and make sure you have a checkForm() function in the code. //----------------------------------------------------------------------------- function checkEnter() { if (window.event.keyCode == 13) { checkForm(); } } //----------------------------------------------------------------------------- function showHelp(helpURL) //----------------------------------------------------------------------------- { var win = window.open("", "win", "width=400,height=400,resizable,scrollbars,hotkeys=0"); var doc = win.document; doc.open("text/html", "replace"); doc.location = helpURL; doc.close(); } //----------------------------------------------------------------------------- // Show a div, and hide all others // Divcs must de named d_001_divname // d_ signifies a div // 001_ is the div number //----------------------------------------------------------------------------- function showDiv(thisDiv, formName) { var tmpDivs, tmpName if (formName=='') {formName='frmSubmitForm'}; tmpDivs = eval(formName+".getElementsByTagName('div')"); for (i = 0; i < tmpDivs.length; i++) { tmpName = tmpDivs(i).name; if (tmpName.charAt(0) == 'd') { if (thisDiv == tmpName.substring(1,4)) tmpDivs(i).style.display = ''; else tmpDivs(i).style.display = 'none'; } } } //----------------------------------------------------------------------------- function checkSizer(objElement) //----------------------------------------------------------------------------- { with (objElement) if (selectedIndex == 0){selectedIndex = -1}; return; } //----------------------------------------------------------------------------- // Move entries from one select to another //----------------------------------------------------------------------------- function fromListtoList(strfromList, strtoList) { var intOpenSlot, intSelectedItem for (i=eval(strfromList+".options.length")-1; i>0; i--) { //intSelectedItem = eval(strfromList+".selectedIndex"); //if (intSelectedItem != -1) if (eval(strfromList+".options[i].selected == true")) { addToSelect(strtoList, eval(strfromList+".options[i].value"), eval(strfromList+".options[i].text"),i_trimSelectBoxWidth) removeFromSelect(strfromList, i) } } } //----------------------------------------------------------------------------- // Clears a select list //----------------------------------------------------------------------------- function clearSelect(controlName) { eval(controlName + ".options.length=0;"); } //----------------------------------------------------------------------------- // remove an option from a select list //----------------------------------------------------------------------------- function removeFromSelect(controlName, optIndex) { eval(controlName + ".options[optIndex] = null;"); } //----------------------------------------------------------------------------- // Add an option to a select list //----------------------------------------------------------------------------- function addToSelect(controlName, optionValue, optionText, maxLength) { var opt = new Option() opt.value = optionValue; opt.text = optionText.substring(0,maxLength); eval(controlName + ".options[" + controlName + ".options.length] = opt;"); } //----------------------------------------------------------------------------- // Add an option to a select list //----------------------------------------------------------------------------- function addToSelect2(controlName, optionValue, optionText, maxLength, bSelected) { var opt = new Option(optionText, optionValue, 0, bSelected) eval(controlName + ".options[" + controlName + ".options.length] = opt;"); } //----------------------------------------------------------------------------- function isEmpty(s) //----------------------------------------------------------------------------- { return ((s == null) || (s.length == 0)) } //----------------------------------------------------------------------------- function daysInFebruary (year) //----------------------------------------------------------------------------- { // February has 29 days in any year evenly divisible by four, // EXCEPT for centurial years which are not also divisible by 400. return ( ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 ); } //----------------------------------------------------------------------------- function isDate (syear, smonth, sday) //----------------------------------------------------------------------------- { var daysinmonth=0; sday = (sday-0); //we need to convert this to an integer first. smonth = (smonth-0); if ((syear.length == 2) || (syear.length == 4)) { if (!((syear >= 1900) && (syear <= 2078))) {return false;} }else{ return false;} if (!((smonth >= 1) && (smonth <= 12))) {return false;} daysInMonth[2] = daysInFebruary(syear); if (!((sday >= 1) && (sday <= daysInMonth[smonth]))) {return false;} return true; } //----------------------------------------------------------------------------- function isDate2(dateStr) //----------------------------------------------------------------------------- { var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/; var matchArray = dateStr.match(datePat); // is the format ok? if (matchArray == null) { alert("Please enter date as either mm/dd/yyyy or mm-dd-yyyy."); return false; } month = matchArray[1]; // p@rse date into variables day = matchArray[3]; year = matchArray[5]; if (month < 1 || month > 12) { // check month range alert("Month must be between 1 and 12."); return false; } if (day < 1 || day > 31) { alert("Day must be between 1 and 31."); return false; } if ((month==4 || month==6 || month==9 || month==11) && day==31) { alert("Month "+month+" doesn`t have 31 days!") return false; } if (month == 2) { // check for february 29th var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); if (day > 29 || (day==29 && !isleap)) { alert("February " + year + " doesn`t have " + day + " days!"); return false; } } return true; // date is valid } //----------------------------------------------------------------------------- function roundNumber(nNumber, nDecimals) //----------------------------------------------------------------------------- { var strX = "" + nNumber var nIndex = strX.indexOf('.') if (nIndex == -1) //no decimal { strX = strX + ".00"; nIndex = strX.indexOf('.') } var sString = strX.substring(0,nIndex + nDecimals + 1) if (isNaN(sString)) return 0; else return sString; } //----------------------------------------------------------------------------- function validateNumber(oField) //----------------------------------------------------------------------------- { if (isFinite(oField.value) == true) return true; else { alert(oField.value + " is not a valid number\nPlease try again..."); oField.focus(); oField.select(); return false; } } //----------------------------------------------------------------------------- function validateNumberRange(oField, min, max) //----------------------------------------------------------------------------- { if (isFinite(oField.value) == true) { if (parseInt(oField.value) >= min && parseInt(oField.value) <= max) return true; else return false; } else return false; } //----------------------------------------------------------------------------- function validatePhoneNo(phoneno, Required) //----------------------------------------------------------------------------- { if (phoneno.length<4 && Required==true) return false; var stripped = phoneno.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters if (isNaN(parseInt(stripped))) { return false } } //----------------------------------------------------------------------------- function validateEmail(email, Required) //----------------------------------------------------------------------------- { invalidChars = " /:,;" if (email == "" && Required==false) // cannot be empty return false for (i=0; i -1) return false } atPos = email.indexOf("@",1) // there must be one "@" symbol if (atPos == -1) return false if (email.indexOf("@",atPos+1) != -1) // and only one "@" symbol return false periodPos = email.indexOf(".",atPos) if (periodPos == -1) // and at least one "." after the "@" return false if (periodPos+3 > email.length) // must be at least 2 characters after the "." return false return true } //----------------------------------------------------------------------------- function newOption(strText, strValue) //----------------------------------------------------------------------------- { var objOption = new Option(strText, strValue); return objOption; } //----------------------------------------------------------------------------- function ShowHide(objMe) //----------------------------------------------------------------------------- { if (document.all[objMe].style.display=="") document.all[objMe].style.display = "none"; else document.all[objMe].style.display = ""; } //----------------------------------------------------------------------------- // place focus on any form element you want. //----------------------------------------------------------------------------- function putFocus(formInst, elementInst) { if (document.forms.length > 0) document.forms[formInst].elements[elementInst].focus(); } //----------------------------------------------------------------------------- // this is the function in admin.js // it is to diable 'veiw source' event. //----------------------------------------------------------------------------- function rc(evnt){ //if (navigator.appName.toUpperCase().match(/NETSCAPE/) != null) { // if (evnt.which>=2) { // alert("Operation not allowed"); // return false; // } //}else{ // if (event.button>=2) // alert("Operation not allowed"); //} } document.onmousedown=rc; if (document.layers) window.captureEvents(Event.MOUSEDOWN); window.onmousedown=rc; //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- function trim(inputString) { // Removes leading and trailing spaces from the passed string. Also removes // consecutive spaces and replaces it with one space. If something besides // a string is passed in (null, custom object, etc.) then return the input. if (typeof inputString != "string") { return inputString; } var retValue = inputString; var ch = retValue.substring(0, 1); while (ch == " ") { // Check for spaces at the beginning of the string retValue = retValue.substring(1, retValue.length); ch = retValue.substring(0, 1); } ch = retValue.substring(retValue.length-1, retValue.length); while (ch == " ") { // Check for spaces at the end of the string retValue = retValue.substring(0, retValue.length-1); ch = retValue.substring(retValue.length-1, retValue.length); } while (retValue.indexOf(" ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); // Again, there are two spaces in each of the strings } return retValue; // Return the trimmed string back to the user } // Ends the "trim" function //----------------------------------------------------------------------------- // these functions are for cookies //----------------------------------------------------------------------------- function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } function SetCookie (name, value) { var argv = SetCookie.arguments; var argc = SetCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function DeleteCookie (name) { var exp = new Date(); exp.setTime (exp.getTime() - 1); var cval = GetCookie (name); document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } function getCookieVal(offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } function checkOrderLookUpAgreeMent() { var count = GetCookie('OrderAgree'); //var exp = new Date(); //var expDays = 1; // number of days the cookie should last //exp.setTime(exp.getTime() + (expDays*24*60*60*1000)); if (count == null) { document.all["agPage"].style.display=""; } else { with (document.forms[0]) { if (isReseller.value=="True") action = "order_lookup_query.asp?sess_id=" + sid.value; else if (isDistributor.value=="True") action = "order_lookup_query_disti.asp?sess_id=" + sid.value; else action = "order_lookup_reseller_search.asp?sess_id=" + sid.value; submit(); } } }