/************************************************** * * * Common JavaScript Function and definitions * * * **************************************************/ var undefined; // define the undefined var..for non conforming browsers. (Darn!) var isIE; var isAdvancedBrowser=false; var countryInits=""; if(document.all){isIE=true} var winWidths = new Array(); var winHeights = new Array(); //define the widths and heights winWidths["small"] = 350; winHeights["small"] = 400; winWidths["medium"] = 600; winHeights["medium"] = 480; winWidths["large"] = 640; winHeights["large"] = 540; registerWidth = 700; registerHeight = 720; loginWidth = 400; loginHeight = 330; listWidth = 600; listHeight = 480; viewSpringWidth=640; viewSpringHeight=540; /****************************************************************/ function goWindow(url) { location.href = url; } function popWindow(URL,winSize,winName) { if (winName==null) { winName='newWin' } popUpWindow(URL,winSize,winName,true,true) } function popWindowStatic(URL,winSize,winName) { if (winName==null) { winName='newWin' } popUpWindow(URL,winSize,winName,false,false) } function popUpWindow(URL,winSize,winName,scrollable,resizalbe) { var specs=""; if (winName==null) { winName='newWin' } if (winSize==null) { winSize='small'; } else winSize = winSize.toLowerCase(); if(isIE){ if (window[winName]) {window[winName].close() } //if (window.newWin) { window.newWin.close() } } else{ //for Netscape if(window[winName]){ if(window[winName].closed==true){ } else{ window[winName].close(); } } } if (resizalbe) { specs = "resizable,"; } specs=specs + "HEIGHT=" + winHeights[winSize] + ",WIDTH=" + winWidths[winSize]; if (scrollable) { specs = specs + ",scrollbars"; } //var newWin = window.open(URL,winName,specs); newWin = window.open(URL,winName,specs); if (newWin.opener == null) newWin.opener = self; newWin.focus(); } /****************************************************************/ function swapImage(imgName,imgSrc) { if (!document.images) return true; //no images on this page document.images[imgName].src=imgSrc; } /****************************************************************/ function trim(inString) { return Trim(inString); } /****************************************************************/ function Trim(inString) { return allTrim(inString); } function allTrim(s) { if (isNull(s)) return ""; if (s=="" || s==" ") return ""; s= s+""; //force it to be a string if(s.length==1) return s; // trim from the left side first while (s.substring(0,1) == ' ') { s = s.substring(1,s.length); } // trim from the right side now while (s.substring(s.length-1,s.length) == ' ') { s = s.substring(0,s.length-1); } return s; } /****************************************************************/ function isNull(theVariable) { /* return true if the thing is null or undefined */ if (theVariable==null) return true; if (theVariable==undefined) return true; return false; } /****************************************************************/ // Check whether string s is empty. function isEmpty(s) { return ((isNull(s)) || (s.length == 0)) } /****************************************************************/ function goSubmitIt(theFormName) { // submits the form specified. if (document.forms[theFormName]!=null) { // if the form does exist..then go ahead and submit it. document.forms[theFormName].submit(); } } function selectOption(formName, selectTagName,optionValue) { /** set the selected index of the Specified Select Tag on the specified form that matches the specified optionValue */ if (isNull(document.forms[formName])) return false; //No form with specified name if (isNull(document.forms[formName][selectTagName])) return false; //that field not on form var selectObj = document.forms[formName][selectTagName]; var selValueOrText; if (selectObj.type.toLowerCase().indexOf("select")==-1) return false; //element is not a select tag var optLength = selectObj.options.length; for(var i=0;i= sLength) || (modEmailAddress.charAt(i) != "@")) return false; // did not find @ else i += 2; // look for . while ((i < sLength) && (modEmailAddress.charAt(i) != ".")) { i++ } // there must be at least one character after the . if ((i >= sLength - 1) || (modEmailAddress.charAt(i) != ".")) return false; else return true; } /** return true if this istem is a number */ function isNumeric(s) { if (isEmpty(trim(s))) return false; // no..empty if (isNaN(s)) return false; // clearly not a number..its the NaN value return (!isNaN(parseFloat(s)) || !isNaN(parseInt(s))); // if any one is true,,then it's a number } function noEntry() { this.blur(); if (countryInits.toUpperCase()=="MX") { alert('Lociento\nNo patrida es permitir en esta campo'); } else { alert('Sorry!!\nEntry into this field is not allowed'); } return false; } function billToShip(theForm,flag) { // move the fields from the bill to area to the ship to area if (flag==true){ theForm["sFirstName"].value = theForm["FirstName"].value; theForm["sSurname"].value = theForm["Surname"].value; theForm["sAddress1"].value = theForm["Address1"].value; theForm["sPostcode"].value = theForm["Postcode"].value; theForm["sCountry"].selectedIndex = theForm["Country"].selectedIndex; theForm["sPhone"].value = theForm["Phone"].value; theForm["sAddress2"].value = theForm["Address2"].value; theForm["sAddress3"].value = theForm["Address3"].value; theForm["sAddressType"].selectedIndex = theForm["AddressType"].selectedIndex; theForm["sCompany"].value = theForm["Company"].value; theForm["sCity"].value = theForm["City"].value; if (theForm["State"]!=null && theForm["State"]!=undefined) { theForm["sState"].value = theForm["State"].value; } if (theForm["County"]!=null && theForm["County"]!=undefined) { theForm["sCounty"].value = theForm["County"].value; } } } function validateEmailAddress(emailAddress) { var rtnValue = false; var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (filter.test(emailAddress)) { rtnValue = true; } else { if (countryInits.toUpperCase()=="MX") { alert('La dirección de E-mail está en un formato inválido'); } else { alert('Email address:'+emailAddress+'\nis in an invalid format.'); } } return rtnValue; }