//functions used for discounts pages function showD1() { showSection('d1-on','none'); hideSection('d1-off'); } function hideD1() { showSection('d1-off','none'); hideSection('d1-on'); } function showD2() { showSection('d2-on','none'); hideSection('d2-off'); } function hideD2() { showSection('d2-off','none'); hideSection('d2-on'); } function showD3() { showSection('d3-on','none'); hideSection('d3-off'); } function hideD3() { showSection('d3-off','none'); hideSection('d3-on'); } function showD4() { showSection('d4-on','none'); hideSection('d4-off'); } function hideD4() { showSection('d4-off','none'); hideSection('d4-on'); } function isValidDayMonth(day, month) { var intMonth = parseInt(month,10); var intDay = parseInt(day,10); // catch invalid days, except for February if ((intDay > daysInMonth[intMonth])) { return false; } else { return true; } } 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 ); } daysInMonth = new Array(12); daysInMonth[1] = 31; daysInMonth[2] = 29 ; // must programmatically check this 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; function changeCSS(theClass,element,value) { //documentation for this script at http://www.shawnolson.net/a/503/ var cssRules; if (document.all) { cssRules = 'rules'; } else if (document.getElementById) { cssRules = 'cssRules'; } for (var S = 0; S < document.styleSheets.length; S++){ for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) { if (document.styleSheets[S][cssRules][R].selectorText == theClass) { document.styleSheets[S][cssRules][R].style[element] = value; } } } } function showSection(s_name,s_class){ var section = document.getElementById(s_name); section.className = s_class; } function hideSection(s_name){ var section = document.getElementById(s_name); section.className = 'form-hide'; } function errorText(id, state){ var id = document.getElementById(id); if(state=='on'){ id.className = 'errorColour'; }else{ id.className = ''; } } /*============================================================================================' '============================== STANDARD INCLUDE OBJECTS =================================' '=============================================================================================' '== Installation: ==' ' Place this file in an INCLUDE directory, then copy the code below (on line 10) and paste ' ' it in the header of your HTML page. Remember to have it directing to the appropriate ' ' directory, i.e. the directory where you placed this script. ' ' ' ' ' ' ' '=============================================================================================' '== Versioning Notes: ==' ' v1.0.0: 12/01/2007 ' ' * Created object fileLoader. ' ' v1.0.1: 15/01/2007 ' ' * Created object brower. ' ' v1.0.2: 16/01/2007 ' ' * Created object validator. ' ' v1.0.2: 17/01/2007 ' ' * Created object varType. ' '=============================================================================================' '============================================================================================*/ /*============================================================================================' '=================================== fileLoader Object =====================================' '=============================================================================================' '== Description: ==' ' This Object loads files by writing out thier HTML tags via scripted JavaScript. ' '=============================================================================================' '== Creating Object: ==' ' var fl=new fileLoader(); ' '=============================================================================================' '== Methods: ==' ' fileLoader.css(href[[[,media],rel],title]) ' ' + Description ' ' Loads a CSS file to the HTML page by writing out its HTML tags. ' ' ' ' + Parameters ' ' ~ href:String [Required] - A valid CSS file location and file name. ' ' ~ media:String [Optional] - What media the CSS file relates to (valid HTML only). ' ' ~ rel:String [Optional] - The relationship the StyleSheet has to the page (valid HTML ' ' only). ' ' ~ title:String [Optional] - The title of the CSS Include. ' ' ' ' + Returns ' ' Returns true if it was successfully created, false if it was not. ' ' ' ' + Example ' ' var fl=new fileLoader(); ' ' if(fl.css("style.css","all","stylesheet","Default Styles")){ ' ' alert("CSS File Successfully Loaded."); ' ' } ' '============================================================================================*/ function fileLoader(){ var _t=this; _t.css=function(href,media,rel,title){ if(href==null){ return(false); }else{ media='media="'+((media==null)?"all":media)+'"'; rel='rel="'+((rel==null)?"stylesheet":rel)+'"'; title=(title==null)?'':' title="'+title+'"'; document.write(''); return(true); } } } /*============================================================================================' '===================================== browser Object ======================================' '=============================================================================================' '== Description: ==' ' This Object contains a bunch of Browser related properties and methods. ' '=============================================================================================' '== Creating Object: ==' ' var _b=new browser(); ' '=============================================================================================' '== Methods: ==' ' browser.popUp(href[,name[,options[,center]]]) ' ' + Description ' ' Pops open a window, with additional options to the basic window.open method. ' ' ' ' + Parameters ' ' ~ href:String [Required] - The URL of the page to be loaded in the PopUp. ' ' ~ name:String [Optional] - The reference/name of the popup window. ' ' ~ options:String [Optional] - Standard window.open options with added options centerX ' ' and centerY. These are Boolean values (1,0,true,false) to indicate if centering is ' ' required. If it is, a Width and Height option (respectively) must also be included. ' ' ' ' + Returns ' ' Returns true if it was successfully poped up, false if it was not. ' ' ' ' + Example ' ' var _b=new browser(); ' ' if(_b.popUp('myPopUp.php','myPopUp','width=450,height=350,centerX=1,centerY=1')){ ' ' alert("Popup window successfully opened."); ' ' } ' '============================================================================================*/ function browser(){ var _t=this; _t.popUp=function(href,name,options){ var width=0,height=0,centerX=0,centerY=0,topC=-1,leftC=-1,cXc=0,cYc=0,opts=""; var ar=[]; if(href==null||href==''){ return(false); }else{ if(options!=null&&options!=''){ ar=options.toLowerCase().split(","); for(var c=0;c0)?",":""; opts+=ar[c][0]+"="+ar[c][1]; } opts=opts.replace(/(center[xy]{1}=[\da-z]+)/gi,''); opts=opts.replace(/,{2,}/gi,','); opts=opts.replace(/(,$)|(^,)/gi,''); }else{ opts=null; } window.open(href,name,opts); return(true); } } } /*============================================================================================' '===================================== varType Object ======================================' '=============================================================================================' '== Description: ==' ' This Object performs various variable checking functions/methods. ' '=============================================================================================' '== Creating Object: ==' ' var _v=new v(); ' '=============================================================================================' '== Methods: ==' ' browser.popUp(href[,name[,options[,center]]]) ' ' + Description ' ' Pops open a window, with additional options to the basic window.open method. ' ' ' ' + Parameters ' ' ~ href:String [Required] - The URL of the page to be loaded in the PopUp. ' ' ~ name:String [Optional] - The reference/name of the popup window. ' ' ~ options:String [Optional] - Standard window.open options with added options centerX ' ' and centerY. These are Boolean values (1,0,true,false) to indicate if centering is ' ' required. If it is, a Width and Height option (respectively) must also be included. ' ' ' ' + Returns ' ' Returns true if it was successfully poped up, false if it was not. ' ' ' ' + Example ' ' var _b=new validator(); ' ' if(_b.popUp('myPopUp.php','myPopUp','width=450,height=350,centerX=1,centerY=1')){ ' ' alert("Popup window successfully opened."); ' ' } ' '============================================================================================*/ function varType(variant){ this.isFunction=function(a){return(typeof a=='function');} this.isObject=function(a){return(a&&typeof a=='object')||this.isFunction(a);} this.isArray=function(a){return(this.isObject(a)&&a.constructor==Array);} this.isString=function(a){return(typeof a=='string');} this.isBoolean=function(a){return(typeof a=='boolean');} this.isUndefined=function(a){return(typeof a=='undefined');} this.isNull=function(a){return(typeof a=='object'&&!a);} this.isEmpty=function(o){ var i,v; if(this.isObject(o)){ for(i in o){ v=o[i]; if(this.isUndefined(v)&&this.isFunction(v)){return(false);} } } return(true); } if(variant!=null){ } } /*============================================================================================' '==================================== validator Object =====================================' '=============================================================================================' '== Description: ==' ' This Object contains a bunch of properties and methods to aid in Form Validation. ' '=============================================================================================' '== Creating Object: ==' ' var _v=new v(); ' '=============================================================================================' '== Methods: ==' ' browser.popUp(href[,name[,options[,center]]]) ' ' + Description ' ' Pops open a window, with additional options to the basic window.open method. ' ' ' ' + Parameters ' ' ~ href:String [Required] - The URL of the page to be loaded in the PopUp. ' ' ~ name:String [Optional] - The reference/name of the popup window. ' ' ~ options:String [Optional] - Standard window.open options with added options centerX ' ' and centerY. These are Boolean values (1,0,true,false) to indicate if centering is ' ' required. If it is, a Width and Height option (respectively) must also be included. ' ' ' ' + Returns ' ' Returns true if it was successfully poped up, false if it was not. ' ' ' ' + Example ' ' var _b=new validator(); ' ' if(_b.popUp('myPopUp.php','myPopUp','width=450,height=350,centerX=1,centerY=1')){ ' ' alert("Popup window successfully opened."); ' ' } ' '============================================================================================*/ function validator(){ status='validator initiating...' this.fields=0; this.errors=0; this.init='The following errors must be corrected before continuing:\n\n'; this.msg=''; this.vt=new varType(); this.output = function (){ status='' //return(this.init+this.msg); } this.clean = function (){ this.fields=0; this.errors=0; this.init='The following errors must be corrected before continuing:\n\n'; this.msg=''; status='' } this.addError = function (erMsg){ this.errors++; this.msg+=' '+this.errors+'. '+erMsg+'.\n'; } //Number Validation this.round=function (num,dec){ } //String Validation this.str = function (field,fieldName,required,minLen,maxLen,altVal) { status='Validating '+fieldName+'.'; required=(required==null)?true:required; minLen=(minLen==null)?-1:minLen; maxLen=(maxLen==null)?-1:maxLen; altVal=(altVal==null)?'':altVal; var isErr=false; if(this.vt.isObject(field)){ fieldName=(fieldName==null)?field.name:fieldName; this.fields++; if(required&&field.value.length<1){ this.errors++; //this.msg+=' '+this.errors+'. Please enter a value in the field: '+fieldName+'.\n'; isErr=true; }else if(required&&field.value.length-1){ this.errors++; //this.msg+=' '+this.errors+'. The value in the field "'+fieldName+'" must be at least '+minLen+' characters.\n'; isErr=true; }else if(required&&field.value.length>maxLen&&maxLen>-1){ this.errors++; //this.msg+=' '+this.errors+'. The value in the field "'+fieldName+'" must not exceed '+maxLen+' characters.\n'; isErr=true; } if(this.errors==1){ field.focus(); } if(isErr){ return(false); } status=''; return(true); }else{ status=''; return(false); } } //String match validation this.strMatch = function (field, fieldName, textMatch){ var isErr=false; if(this.vt.isObject(field)){ fieldName=(fieldName==null)?field.name:fieldName; if(field.value == textMatch){ this.errors++; isErr=true; } if(this.errors==1){ field.focus(); } if(isErr){ return(false); } return(true); }else{ status=''; return(false); } } /** * DHTML phone number validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/) */ // Declaring required variables var digits = "0123456789"; // non-digit characters which are allowed in phone numbers var phoneNumberDelimiters = "()-. "; // characters which are allowed in international phone numbers // (a leading + is OK) var validWorldPhoneChars = phoneNumberDelimiters + "+"; // Minimum no of digits in an international phone no. var minDigitsInIPhoneNumber = 1; function isInteger(s) { var i; for (i = 0; i < s.length; i++) { // Check that current character is number. var c = s.charAt(i); if (((c < "0") || (c > "9"))) return false; } // All characters are numbers. return true; } function stripCharsInBag(s, bag) { var i; var returnString = ""; // Search through string's characters one by one. // If character is not in bag, append to returnString. for (i = 0; i < s.length; i++) { // Check that current character isn't whitespace. var c = s.charAt(i); if (bag.indexOf(c) == -1) returnString += c; } return returnString; } function checkInternationalPhone(strPhone){ s=stripCharsInBag(strPhone,validWorldPhoneChars); return (isInteger(s) && s.length >= minDigitsInIPhoneNumber); } this.num = function (field, fieldName, required){ if ((field.value==null)||(field.value=="")){ this.errors++; isErr=true; if(this.errors==1){ field.focus(); } if(isErr){ return(false); } } if (checkInternationalPhone(field.value)==false){ //alert("Please Enter a Valid Phone Number") this.errors++; isErr=true; if(this.errors==1){ field.focus(); } if(isErr){ return(false); } } return(true); } //Number Validation /*this.num = function (field,fieldName,required,isIn,format,altVal,minNum,maxNum){ status='Validating '+fieldName+'.'; required=(required==null)?true:required; isIn=(isIn==null)?'[^01234567890\.\-]':isIn; format=(format==null)?'':format; altVal=(altVal==null)?'':altVal; var isErr=false; var re=new RegExp().compile(isIn,'gi'); if(this.vt.isObject(field)){ fieldName=(fieldName==null)?field.name:fieldName; this.fields++; if(required&&field.value.length<1){ this.errors++; //this.msg+=' '+this.errors+'. Please enter a valid Number in the field: '+fieldName+'.\n'; isErr=true; }else if(re.test(field.value)){ if(required){ this.errors++; //this.msg+=' '+this.errors+'. The value in the field "'+fieldName+'" must only contain numbers.\n'; isErr=true; }else{ field.value=field.value.replace(re,''); } } if(Number(field.value)Number(maxNum)&&required&&maxNum!=null){ this.errors++; //this.msg+=' '+this.errors+'. The value in the field "'+fieldName+'" is not valid (must be less than '+(maxNum+1)+').\n'; isErr=true; } if(!isErr&&format.length>0){ //get the DP's requested if there are any. var dps=parseInt(format.substr(format.indexOf(".")+1)); if(!isNaN(dps)&&dps>0){ } for(c=0;c-1&&!isRadioOk){ field[defaultIndex].checked=true; } status=''; return(true); }else{ status=''; return(false); } } //Basic Dropmenu Validation this.dateDrop = function (fieldY,fieldM,fieldD,fieldName,required,altVal){ status='Validating '+fieldName+'.'; required=(required==null)?true:required; altVal=(altVal==null)?'altVal':altVal; var isErr=false; if(this.vt.isObject(fieldY)&&this.vt.isObject(fieldM)&&this.vt.isObject(fieldD)){ fieldName=(fieldName==null)?fieldD.name:fieldName; this.fields++; if(required&&fieldD.value.length<1){ this.errors++; this.msg+=' '+this.errors+'. Please select a Day from the drop-menu: '+fieldName+'.\n'; isErr=true; } if(required&&fieldM.value.length<1){ this.errors++; this.msg+=' '+this.errors+'. Please select a Month from the drop-menu: '+fieldName+'.\n'; isErr=true; } if(required&&fieldY.value.length<1){ this.errors++; this.msg+=' '+this.errors+'. Please select a Year from the drop-menu: '+fieldName+'.\n'; isErr=true; } if(!isErr){ date=fieldD.value+"/"+fieldM.value+"/"+fieldY.value test1=(/^\d{1,2}[\-/]\d{1,2}[\-/]\d{4}$/.test(date)) date=date.replace(/[\-/]/g,','); date=date.split(','); d=new Date(date[2],date[1]-1,date[0]); test2=(1*date[0]==d.getDate()&&1*date[1]==(d.getMonth()+1)&&1*date[2]==d.getFullYear()); if(test1&&test2){ return(true); } else if(required){ this.errors++; this.msg+=' '+this.errors+'. The date you entered in the field: '+fieldName+' was invalid.\n'; isErr=true; }else{ fieldY.selectedIndex=0; fieldM.selectedIndex=0; fieldD.selectedIndex=0; } } if(this.errors==1){ field.focus(); } if(isErr){ return(false); } status=''; return(true); }else{ status=''; return(false); } } //Basic Date Validation this.date = function (field,fieldName,required,format,altVal){ status='Validating '+fieldName+'.'; required=(required==null)?true:required; altVal=(altVal==null)?'altVal':altVal; var isErr=false; if(this.vt.isObject(field)){ fieldName=(fieldName==null)?field.name:fieldName; this.fields++; if(required&&(field.value.length<1||field.value.indexOf("/")<0)){ this.errors++; this.msg+=' '+this.errors+'. Please enter in a valid date in the field: '+fieldName+'.\n'; isErr=true; } if(!isErr){ date=field.value test1=(/^\d{1,2}[\-/]\d{1,2}[\-/]\d{4}$/.test(date)) date=date.replace(/[\-/]/g,','); date=date.split(','); d=new Date(date[2],date[1]-1,date[0]); test2=(1*date[0]==d.getDate()&&1*date[1]==(d.getMonth()+1)&&1*date[2]==d.getFullYear()); if(test1&&test2){ return(true); } else if(required){ this.errors++; this.msg+=' '+this.errors+'. The date you entered in the field: '+fieldName+' was invalid.\n'; isErr=true; }else if(altVal!='altVal'){ field.value=altVal; } } if(this.errors==1){ field.focus(); } if(isErr){ return(false); } status=''; return(true); }else{ status=''; return(false); } } status='validator initiated.'; }