var dtCh= "/"; var minYear=1900; var maxYear=2100; 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++){ var c = s.charAt(i); if (bag.indexOf(c) == -1) returnString += c; } return returnString; } 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 DaysArray(n) { for (var i = 1; i <= n; i++) { this[i] = 31 if (i==4 || i==6 || i==9 || i==11) {this[i] = 30} if (i==2) {this[i] = 29} } return this } function regValidate(newsletter, formname, fieldnames, fieldtypes, validatetypes) { //var isnews = false; //var a_newsletter = newsletter.split(","); //for (var x=0; x 2) { oFormEl = document.getElementById("ermsg_" + array_cbox[0] + "_" + array_cbox[1]); }else{ oFormEl = document.getElementById("ermsg_" + array_fieldnames[x]); } oFormEl.style.display = "none"; if (array_fieldtypes[x] == "radio" && array_validatetypes[x] == "required") { if (! valRadio(eval("document." + formname + "." + array_fieldnames[x]))) { isvalid = 0; elvalid = 0; oFormEl.style.display = "block"; } } if (array_fieldtypes[x] == "select" && (array_validatetypes[x] == "required" || array_validatetypes[x] == "all|required")) { if (! valSelectBox(array_fieldnames[x],formname)) { isvalid = 0; elvalid = 0; oFormEl.style.display = "block"; } } if (array_fieldtypes[x] == "checkbox" && array_validatetypes[x] == "required") { var array_cbox = array_fieldnames[x].split("_"); var namecbox = ""; if (array_cbox.length > 2) { namecbox = array_cbox[0] + "_" + array_cbox[1]; numcbox = array_cbox[2]; }else{ namecbox = array_cbox[0]; numcbox = array_cbox[1]; } var oneischecked = 0; for (var cb=0; cb 0) { if (! valEmail(eval("document." + formname + "." + array_fieldnames[x] + ".value"))) { isvalid = 0; elvalid = 0; oFormEl.style.display = "block"; } } if((array_validation[i] == "alpha" || array_validation[i] == "alphanumeric" || array_validation[i] == "numeric") && eval("document." + formname + "." + array_fieldnames[x] + ".value.length") > 0) { if (! valAlphaNumeric(eval("document." + formname + "." + array_fieldnames[x] + ".value"),array_fieldnames[x],eval("document." + formname + "." + array_fieldnames[x] + ".value.length"),array_validation[i])) { isvalid = 0; elvalid = 0; oFormEl.style.display = "block"; } } if(array_validation[i] == "date" && eval("document." + formname + "." + array_fieldnames[x] + ".value.length") > 0) { if (! isDate(eval("document." + formname + "." + array_fieldnames[x] + ".value"))) { isvalid = 0; elvalid = 0; oFormEl.style.display = "block"; } } if(array_validation[i].indexOf("length>") > -1 && eval("document." + formname + "." + array_fieldnames[x] + ".value.length") > 0) { if (! valLength(eval("document." + formname + "." + array_fieldnames[x] + ".value.length"),array_validation[i].substring(array_validation[i].indexOf(">")+1,array_validation[i].length),'gt')) { isvalid = 0; elvalid = 0; oFormEl.style.display = "block"; } } if(array_validation[i].indexOf("length<") > -1 && eval("document." + formname + "." + array_fieldnames[x] + ".value.length") > 0) { if (! valLength(eval("document." + formname + "." + array_fieldnames[x] + ".value.length"),array_validation[i].substring(array_validation[i].indexOf("<")+1,array_validation[i].length),'lt')) { isvalid = 0; elvalid = 0; oFormEl.style.display = "block"; } } } // check if field match required name with _confirm if(array_fieldnames[x].indexOf("_confirm") > -1) { if (eval("document." + formname + "." + array_fieldnames[x] + ".value") != eval("document." + formname + "." + array_fieldnames[x].substring(0,array_fieldnames[x].indexOf("_confirm")) + ".value")) { isvalid = 0; elvalid = 0; var oConfirm = document.getElementById(oFormEl.id); oConfirm.style.display = "block"; } } } if (elvalid == 0) { if (array_fieldtypes[x] == "radio") { for (var i=0; i= limit) { isvalid = 0; } } if(isvalid == 0){ return false; }else{ return true; } } function valAlphaNumeric(fieldValue, fieldName, fieldLength, valType) { var validChars = ""; var invalid = 0; if (valType == "alphanumeric" || valType == "numeric" || valType == "alphanumeric_") { validChars += "0123456789"; } if (valType == "alphanumeric" || valType == "alpha" || valType == "alphanumeric_" || valType == "alpha_") { validChars += "abcdefghijklmnopqrstuvwxyz"; validChars += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; } if (valType == "alphanumeric_" || valType == "alpha_") { validChars += "_"; } for(var i=0;i1) strDay=strDay.substring(1) if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1) for (var i = 1; i <= 3; i++) { if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1) } month=parseInt(strMonth) day=parseInt(strDay) year=parseInt(strYr) if (pos1==-1 || pos2==-1){ return false } if (strMonth.length<1 || month<1 || month>12){ return false } if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){ return false } if (strYear.length != 4 || year==0 || yearmaxYear){ return false } if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){ return false } return true } function isTime(str) { if (str.indexOf(":") == -1) return false; var bits = str.split(":"); if (bits.length > 2) return false; if (!isInteger(bits[0])) return false; if ( (bits[0] < 0) || (bits[0] > 23) ) return false; if (!isInteger(bits[1])) return false; if ( (bits[1] < 0) || (bits[1] > 59) ) return false; return true; } function validateEvent() { var valid = true; var msg = ""; if (document.events.contact.value == "") { valid = false; ermsg_contact.style.display = "block"; //msg += "Please enter your name\n"; }else{ ermsg_contact.style.display = "none"; } if (!valEmail(document.events.email.value)) { valid = false; ermsg_email.style.display = "block"; }else{ ermsg_email.style.display = "none"; } if (document.events.phone.value == "") { valid = false; ermsg_phone.style.display = "block"; //msg += "Please enter your name\n"; }else{ ermsg_phone.style.display = "none"; } if (document.events.category.value == "-1") { valid = false; ermsg_category.style.display = "block"; }else{ ermsg_category.style.display = "none"; } if (document.events.subject.value == "") { valid = false; ermsg_subject.style.display = "block"; }else{ ermsg_subject.style.display = "none"; } if (document.events.description.value == "") { valid = false; ermsg_description.style.display = "block"; }else{ ermsg_description.style.display = "none"; } ermsg_startdate.style.display = "none"; ermsg_enddate.style.display = "none"; if (!isDate(document.events.startdate.value)) { valid = false; ermsg_startdate.style.display = "block"; } if ( (!document.events.allday.checked) && (!isTime(document.events.starttime.value)) ) { valid = false; ermsg_startdate.style.display = "block"; } if ( (!document.events.allday.checked) && (!isDate(document.events.enddate.value)) ) { valid = false; ermsg_enddate.style.display = "block"; } if ( (!document.events.allday.checked) && (!isTime(document.events.endtime.value)) ) { valid = false; ermsg_enddate.style.display = "block"; } if (valid) { var sdbits = document.events.startdate.value.split("/"); var sd = new Date(Date.parse(sdbits[1]+"/"+sdbits[0]+"/"+sdbits[2] + " " + document.events.starttime.value)); edbits = document.events.enddate.value.split("/"); var ed = new Date(Date.parse(edbits[1]+"/"+edbits[0]+"/"+edbits[2] + " " + document.events.endtime.value)); if (ed < sd) { alert("The end date you have added is before the start date"); document.events.enddate.value = document.events.startdate.value; valid = false; }else{ document.events.startdate.value = sd.getFullYear() + "-" + (sd.getMonth()+1) + "-" + sd.getDate(); document.events.enddate.value = ed.getFullYear() + "-" + (ed.getMonth()+1) + "-" + ed.getDate(); } if (document.events.allday.checked) { document.events.starttime.value = "00:00"; document.events.endtime.value = "00:00"; document.events.enddate.value = document.events.startdate.value; } } //if (!valid) alert(msg) if (valid) document.events.verified.value = '1'; return valid; //return false; } function jump(){} function clearSearchMask(fieldname) { var field = document.getElementById(fieldname); if (field != null) field.value = ""; } var searchtype = "site"; function checkSearch(search) { if (searchtype == "web") { search.action = "http://www.google.co.uk/search"; search.target = "_blank"; }else{ search.removeAttribute("target"); search.action = "/search.jsp"; } } function clearSearch(field) { if (field.value == "Site Search") { field.value = ""; } } function checkSearchReset(field) { if (field.value == "") { field.value = "Site Search"; } } var isFlashPresent = 0; var FlashVersion = 0; var isIE = "false"; if (navigator.plugins && navigator.plugins.length) { var isNavigator = navigator.plugins["Shockwave Flash"]; if (isNavigator) { isFlashPresent = 2; if (isNavigator.description) { var navDesc = isNavigator.description; FlashVersion = navDesc.charAt(navDesc.indexOf('.')-1); } }else{ isFlashPresent = 1; } }else if (navigator.mimeTypes && navigator.mimeTypes.length){ var isNavigator = navigator.mimeTypes['application/x-shockwave-flash']; if (isNavigator && isNavigator.enabledPlugin) { isFlashPresent = 2; }else{ isFlashPresent = 1; } }else{ isIE = "true"; } if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('Opera') == -1)) { document.writeln('