var scwDateNow = new Date(Date.parse(new Date().toDateString())); var scwBaseYear = scwDateNow.getFullYear()-10; var scwDropDownYears = 20; var scwLanguage; function scwSetDefaultLanguage() {try {scwSetLanguage();} catch (exception) {// English scwToday = 'Today:'; scwClear = 'Clear'; scwDrag = 'click here to drag'; scwArrMonthNames = ['Jan','Feb','Mar','Apr','May','Jun', 'Jul','Aug','Sep','Oct','Nov','Dec']; scwArrWeekInits = ['S','M','T','W','T','F','S']; scwInvalidDateMsg = 'The entered date is invalid.\n'; scwOutOfRangeMsg = 'The entered date is out of range.'; scwDoesNotExistMsg = 'The entered date does not exist.'; scwInvalidAlert = ['Invalid date (',') ignored.']; scwDateDisablingError = ['Error ',' is not a Date object.']; scwRangeDisablingError = ['Error ', ' should consist of two elements.']; } }; var scwWeekStart = 0; var scwWeekNumberDisplay = false; var scwWeekNumberBaseDay = 4; var scwShowInvalidDateMsg = true, scwShowOutOfRangeMsg = true, scwShowDoesNotExistMsg = true, scwShowInvalidAlert = true, scwShowDateDisablingError = true, scwShowRangeDisablingError = true; var scwArrDelimiters = ['/','-','.',',',' ']; function scwDateOutput(dateOut) { if (document.forms["chkAvailabilityForm"].dateFlag != null ) { if (document.forms["chkAvailabilityForm"].dateFlag.value == 1) { var scwDateOutputFormat = 'DD/MM/YYYY'; return scwDateOutputFormat; } else { var scwDateOutputFormat = 'MM/DD/YYYY'; return scwDateOutputFormat; } } }; var scwZindex = 10000; var scwBlnStrict = false; var scwClearButton = false; var scwAutoPosition = true; var scwEnabledDay = [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]; var scwDisabledDates = new Array(); var scwActiveToday = true; var scwOutOfMonthDisable = false; var scwOutOfMonthHide = false; var scwOutOfRangeDisable = true; var scwFormatTodayCell = true; var scwTodayCellBorderColour = '#ffc000'; var scwAllowDrag = false; var scwClickToHide = false; document.writeln( '' ); document.writeln( '' ); var scwTargetEle, scwTriggerEle, scwMonthSum = 0, scwBlnFullInputDate = false, scwPassEnabledDay = new Array(), scwSeedDate = new Date(), scwParmActiveToday = true, scwWeekStart = scwWeekStart%7, scwToday, scwClear, scwDrag, scwArrMonthNames, scwArrWeekInits, scwInvalidDateMsg, scwOutOfRangeMsg, scwDoesNotExistMsg, scwInvalidAlert, scwDateDisablingError, scwRangeDisablingError; Date.prototype.scwFormat = function(scwFormat) {var charCount = 0, codeChar = '', result = ''; for (var i=0;i<=scwFormat.length;i++) {if (i 0) {result += codeChar;} } if (i1) { alert( 'SCW' + ' \nCannot uniquely identify element named: ' + id + '.\nMore than one identical NAME attribute defined' + '.\nSolution: Assign the required element a unique ID attribute value.'); } } } }; var scwNextActionReturn, scwNextAction; function showCal(scwEle,scwSource) {scwShow(scwEle,scwSource);}; function scwShow(scwEle,scwSource) {if (!scwSource) {scwSource = window.event;} if (scwSource.tagName) // Second parameter isn't an event it's an element {var scwSourceEle = scwSource; if (scwID('scwIE')) {window.event.cancelBubble = true;} else {scwSourceEle.parentNode.addEventListener('click',scwStopPropagation,false);} } else // Second parameter is an event {var scwSourceEle = (scwSource.target) ?scwSource.target :scwSource.srcElement; if (scwSource.stopPropagation) {scwSource.stopPropagation();} else {scwSource.cancelBubble = true;} } scwTriggerEle = scwSourceEle; scwParmActiveToday = true; for (var i=0;i<7;i++) {scwPassEnabledDay[(i+7-scwWeekStart)%7] = true; for (var j=2;j 0) {scwTriggerEle.scwTextNode = scwChildNodes[i]; scwTriggerEle.scwLength = scwChildNodes[i].nodeValue.length; break; } } } } } scwSetDefaultLanguage(); scwID('scwDragText').innerHTML = scwDrag; scwID('scwMonths').options.length = 0; for (var i=0;i scwDateNow && (new Date(scwBaseYear, 0, 0)) < scwDateNow) || (scwClearButton && (scwEle.readOnly || scwEle.disabled)) ) {scwID('scwFoot').style.display = ''; scwID('scwNow').innerHTML = scwToday + ' ' + scwDateNow.scwFormat(scwDateOutput()); scwID('scwClearButton').value = scwClear; if ((new Date(scwBaseYear + scwDropDownYears, 0, 0)) > scwDateNow && (new Date(scwBaseYear, 0, 0)) < scwDateNow ) {scwID('scwNow').style.display = ''; if (scwClearButton && (scwEle.readOnly || scwEle.disabled)) {scwID('scwClear').style.display = ''; scwID('scwClear').style.textAlign = 'left'; scwID('scwNow').style.textAlign = 'right'; } else {scwID('scwClear').style.display = 'none'; scwID('scwNow').style.textAlign = 'center'; } } else {scwID('scwClear').style.textAlign = 'center'; scwID('scwClear').style.display = ''; scwID('scwNow').style.display = 'none'; } } else {scwID('scwFoot').style.display = 'none';} if (scwDateValue.length==0) { scwBlnFullInputDate=false; if ((new Date(scwBaseYear+scwDropDownYears,0,0))scwSeedDate ) {scwSeedDate = new Date(scwBaseYear + Math.floor(scwDropDownYears / 2), 5, 1);} } else {function scwInputFormat() {var scwArrSeed = new Array(), scwArrInput = scwDateValue.split(new RegExp('[\\'+scwArrDelimiters.join('\\')+']+','g')); if (scwArrInput[0]!=null) {if (scwArrInput[0].length==0) {scwArrInput.splice(0,1);} if (scwArrInput[scwArrInput.length-1].length==0) {scwArrInput.splice(scwArrInput.length-1,1);} } scwBlnFullInputDate = false; scwDateOutputFormat = scwDateOutput().toUpperCase(); var template = ['D','M','Y']; var result = new Array(); for (var i=0;i-1) {result[scwDateOutputFormat.search(template[i])] = template[i];} } var scwDateSequence = result.join(''); switch (scwArrInput.length) {case 1: {if (scwDateOutputFormat.indexOf('Y')>-1 && scwArrInput[0].length>scwDateOutputFormat.lastIndexOf('Y')) {scwArrSeed[0] = parseInt(scwArrInput[0].substring(scwDateOutputFormat.indexOf('Y'), scwDateOutputFormat.lastIndexOf('Y')+1),10); } else {scwArrSeed[0] = 0;} if (scwDateOutputFormat.indexOf('M')>-1 && scwArrInput[0].length>scwDateOutputFormat.lastIndexOf('M')) {scwArrSeed[1] = scwArrInput[0].substring(scwDateOutputFormat.indexOf('M'), scwDateOutputFormat.lastIndexOf('M')+1); } else {scwArrSeed[1] = '6';} if (scwDateOutputFormat.indexOf('D')>-1 && scwArrInput[0].length>scwDateOutputFormat.lastIndexOf('D')) {scwArrSeed[2] = parseInt(scwArrInput[0].substring(scwDateOutputFormat.indexOf('D'), scwDateOutputFormat.lastIndexOf('D')+1),10); } else {scwArrSeed[2] = 1;} if (scwArrInput[0].length==scwDateOutputFormat.length) {scwBlnFullInputDate = true;} break; } case 2: { scwArrSeed[0] = parseInt(scwArrInput[scwDateSequence. replace(/D/i,''). search(/Y/i)],10); // Year scwArrSeed[1] = scwArrInput[scwDateSequence. replace(/D/i,''). search(/M/i)]; // Month scwArrSeed[2] = 1; // Day break; } case 3: { scwArrSeed[0] = parseInt(scwArrInput[scwDateSequence. search(/Y/i)],10); // Year scwArrSeed[1] = scwArrInput[scwDateSequence. search(/M/i)]; // Month scwArrSeed[2] = parseInt(scwArrInput[scwDateSequence. search(/D/i)],10); // Day scwBlnFullInputDate = true; break; } default: { scwArrSeed[0] = 0; // Year scwArrSeed[1] = 0; // Month scwArrSeed[2] = 0; // Day } } var scwExpValDay = new RegExp('^(0?[1-9]|[1-2][0-9]|3[0-1])$'), scwExpValMonth = new RegExp('^(0?[1-9]|1[0-2]|' + scwArrMonthNames.join('|') + ')$','i'), scwExpValYear = new RegExp('^([0-9]{1,2}|[0-9]{4})$'); if (scwExpValYear.exec(scwArrSeed[0]) == null || scwExpValMonth.exec(scwArrSeed[1]) == null || scwExpValDay.exec(scwArrSeed[2]) == null ) {if (scwShowInvalidDateMsg) {alert(scwInvalidDateMsg + scwInvalidAlert[0] + scwDateValue + scwInvalidAlert[1]);} scwBlnFullInputDate = false; scwArrSeed[0] = scwBaseYear + Math.floor(scwDropDownYears/2); // Year scwArrSeed[1] = '6'; // Month scwArrSeed[2] = 1; // Day } return scwArrSeed; }; scwArrSeedDate = scwInputFormat(); if (scwArrSeedDate[0]<100) {scwArrSeedDate[0] += (scwArrSeedDate[0]>50)?1900:2000;} if (scwArrSeedDate[1].search(/\d+/)<0) {for (i=0;i scwSeedDate) {if (scwBlnStrict && scwShowOutOfRangeMsg) {alert(scwOutOfRangeMsg);} scwSeedDate = new Date(scwBaseYear,0,1); scwBlnFullInputDate=false; } else {if ((new Date(scwBaseYear+scwDropDownYears,0,0)) scwDisabledDates[i][1])) {scwDisabledDates[i].reverse();} } else {if (scwShowRangeDisablingError) {alert(scwDateDisablingError[0] + scwDisabledDates[i] + scwDateDisablingError[1]);}} } } scwMonthSum = 12*(scwSeedDate.getFullYear()-scwBaseYear)+scwSeedDate.getMonth(); scwID('scwYears' ).options.selectedIndex = Math.floor(scwMonthSum/12); scwID('scwMonths').options.selectedIndex = (scwMonthSum%12); scwID('scwDrag').style.display=(scwAllowDrag)?'':'none'; scwShowMonth(0); scwTargetEle=scwEle; var offsetTop =parseInt(scwEle.offsetTop ,10) + parseInt(scwEle.offsetHeight,10), offsetLeft=parseInt(scwEle.offsetLeft,10); if (!window.opera) {while (scwEle.tagName!='BODY' && scwEle.tagName!='HTML') {offsetTop -=parseInt(scwEle.scrollTop, 10); offsetLeft-=parseInt(scwEle.scrollLeft,10); scwEle=scwEle.parentNode; } scwEle=scwTargetEle; } do {scwEle=scwEle.offsetParent; offsetTop +=parseInt(scwEle.offsetTop, 10); offsetLeft+=parseInt(scwEle.offsetLeft,10); } while (scwEle.tagName!='BODY' && scwEle.tagName!='HTML'); if (scwAutoPosition) {var scwWidth = parseInt(scwID('scw').offsetWidth, 10), scwHeight = parseInt(scwID('scw').offsetHeight,10), scwWindowLeft = (document.body && document.body.scrollLeft) ?document.body.scrollLeft //DOM compliant :(document.documentElement && document.documentElement.scrollLeft) ?document.documentElement.scrollLeft //IE6+ standards compliant :0, //Failed scwWindowWidth = (typeof(innerWidth) == 'number') ?innerWidth //DOM compliant :(document.documentElement && document.documentElement.clientWidth) ?document.documentElement.clientWidth //IE6+ standards compliant :(document.body && document.body.clientWidth) ?document.body.clientWidth //IE non-compliant :0, //Failed scwWindowTop = (document.body && document.body.scrollTop) ?document.body.scrollTop //DOM compliant :(document.documentElement && document.documentElement.scrollTop) ?document.documentElement.scrollTop //IE6+ standards compliant :0, //Failed scwWindowHeight = (typeof(innerHeight) == 'number') ?innerHeight //DOM compliant :(document.documentElement && document.documentElement.clientHeight) ?document.documentElement.clientHeight //IE6+ standards compliant :(document.body && document.body.clientHeight) ?document.body.clientHeight //IE non-compliant :0; //Failed offsetLeft -= (offsetLeft - scwWidth + parseInt(scwTargetEle.offsetWidth,10) >= scwWindowLeft && offsetLeft + scwWidth > scwWindowLeft + scwWindowWidth )?(scwWidth - parseInt(scwTargetEle.offsetWidth,10)):0; offsetTop -= (offsetTop - scwHeight - parseInt(scwTargetEle.offsetHeight,10) >= scwWindowTop && offsetTop + scwHeight > scwWindowTop + scwWindowHeight )?(scwHeight + parseInt(scwTargetEle.offsetHeight,10)):0; } scwID('scw').style.top = offsetTop+'px'; scwID('scw').style.left = offsetLeft+'px'; scwID('scwIframe').style.top = offsetTop+'px'; scwID('scwIframe').style.left = offsetLeft+'px'; scwID('scwIframe').style.width =(scwID('scw').offsetWidth-(scwID('scwIE')?2:4))+'px'; scwID('scwIframe').style.height=(scwID('scw').offsetHeight-(scwID('scwIE')?2:4))+'px'; scwID('scwIframe').style.visibility='inherit'; // Show it on the page scwID('scw').style.visibility='inherit'; }; function scwHide() {scwID('scw').style.visibility='hidden'; scwID('scwIframe').style.visibility='hidden'; if (typeof scwNextAction!='undefined' && scwNextAction!=null) {scwNextActionReturn = scwNextAction(); // Explicit null set to prevent closure causing memory leak scwNextAction = null; } }; function scwCancel(scwEvt) {if (scwClickToHide) {scwHide();} scwStopPropagation(scwEvt); }; function scwStopPropagation(scwEvt) {if (scwEvt.stopPropagation) {scwEvt.stopPropagation();} // Capture phase else {scwEvt.cancelBubble = true;} // Bubbling phase }; function scwBeginDrag(event) {var elementToDrag = scwID('scw'); var deltaX = event.clientX, deltaY = event.clientY, offsetEle = elementToDrag; do {deltaX -= parseInt(offsetEle.offsetLeft,10); deltaY -= parseInt(offsetEle.offsetTop ,10); offsetEle = offsetEle.offsetParent; } while (offsetEle.tagName!='BODY' && offsetEle.tagName!='HTML'); if (document.addEventListener) {document.addEventListener('mousemove',moveHandler,true); // Capture phase document.addEventListener('mouseup', upHandler, true); // Capture phase } else {elementToDrag.attachEvent('onmousemove',moveHandler); // Bubbling phase elementToDrag.attachEvent('onmouseup', upHandler); // Bubbling phase elementToDrag.setCapture(); } scwStopPropagation(event); function moveHandler(scwEvt) {if (!scwEvt) scwEvt = window.event; elementToDrag.style.left = (scwEvt.clientX - deltaX) + 'px'; elementToDrag.style.top = (scwEvt.clientY - deltaY) + 'px'; scwID('scwIframe').style.left = (scwEvt.clientX - deltaX) + 'px'; scwID('scwIframe').style.top = (scwEvt.clientY - deltaY) + 'px'; scwStopPropagation(scwEvt); }; function upHandler(scwEvt) {if (!scwEvt) scwEvt = window.event; if (document.removeEventListener) {document.removeEventListener('mousemove',moveHandler,true); // Capture phase document.removeEventListener('mouseup', upHandler, true); // Capture phase } else {elementToDrag.detachEvent('onmouseup', upHandler); // Bubbling phase elementToDrag.detachEvent('onmousemove',moveHandler); // Bubbling phase elementToDrag.releaseCapture(); } scwStopPropagation(scwEvt); }; }; function scwShowMonth(scwBias) { var scwShowDate = new Date(Date.parse(new Date().toDateString())), scwStartDate = new Date(); scwShowDate.setHours(12); scwSelYears = scwID('scwYears'); scwSelMonths = scwID('scwMonths'); if (scwSelYears.options.selectedIndex>-1) {scwMonthSum=12*(scwSelYears.options.selectedIndex)+scwBias; if (scwSelMonths.options.selectedIndex>-1) {scwMonthSum+=scwSelMonths.options.selectedIndex;} } else {if (scwSelMonths.options.selectedIndex>-1) {scwMonthSum+=scwSelMonths.options.selectedIndex;}} scwShowDate.setFullYear(scwBaseYear + Math.floor(scwMonthSum/12),(scwMonthSum%12),1); scwID('scwWeek_').style.display=(scwWeekNumberDisplay)?'':'none'; if (window.opera) {scwID('scwMonths').style.display = 'inherit'; scwID('scwYears' ).style.display = 'inherit'; } scwTemp = (12*parseInt((scwShowDate.getFullYear()-scwBaseYear),10)) + parseInt(scwShowDate.getMonth(),10); if (scwTemp > -1 && scwTemp < (12*scwDropDownYears)) {scwSelYears.options.selectedIndex=Math.floor(scwMonthSum/12); scwSelMonths.options.selectedIndex=(scwMonthSum%12); scwCurMonth = scwShowDate.getMonth(); scwShowDate.setDate((((scwShowDate. getDay()-scwWeekStart)<0)?-6:1)+ scwWeekStart-scwShowDate.getDay()); // This statement moved by Michael Cerveny to make version 3.55 var scwCompareDateValue = new Date(scwShowDate.getFullYear(), scwShowDate.getMonth(), scwShowDate.getDate()).valueOf(); scwStartDate = new Date(scwShowDate); if ((new Date(scwBaseYear + scwDropDownYears, 0, 0)) > scwDateNow && (new Date(scwBaseYear, 0, 0)) < scwDateNow) {var scwNow = scwID('scwNow'); function scwNowOutput() {scwSetOutput(scwDateNow);}; if (scwDisabledDates.length==0) {if (scwActiveToday && scwParmActiveToday) {scwNow.onclick = scwNowOutput; scwNow.className = 'scwNow'; if (scwID('scwIE')) {scwNow.onmouseover = scwChangeClass; scwNow.onmouseout = scwChangeClass; } } else {scwNow.onclick = null; scwNow.className = 'scwNowDisabled'; if (scwID('scwIE')) {scwNow.onmouseover = null; scwNow.onmouseout = null; } if (document.addEventListener) {scwNow.addEventListener('click',scwStopPropagation,false);} else {scwNow.attachEvent('onclick',scwStopPropagation);} } } else {for (var k=0;k= scwDisabledDates[k][0].valueOf() && scwDateNow.valueOf() <= scwDisabledDates[k][1].valueOf() ) ) ) ) {scwNow.onclick = null; scwNow.className = 'scwNowDisabled'; if (scwID('scwIE')) {scwNow.onmouseover = null; scwNow.onmouseout = null; } if (document.addEventListener) {scwNow.addEventListener('click',scwStopPropagation,false);} else {scwNow.attachEvent('onclick',scwStopPropagation);} break; } else {scwNow.onclick=scwNowOutput; scwNow.className='scwNow'; if (scwID('scwIE')) {scwNow.onmouseover = scwChangeClass; scwNow.onmouseout = scwChangeClass; } } } } } function scwSetOutput(scwOutputDate) { if (typeof scwTargetEle.value == 'undefined') { scwTriggerEle.scwTextNode.replaceData(0,scwTriggerEle.scwLength,scwOutputDate.scwFormat(scwDateOutputFormat)); } else { scwTargetEle.value = scwOutputDate.scwFormat(scwDateOutputFormat); } scwHide(); setNights(); }; function scwCellOutput(scwEvt) {var scwEle = scwEventTrigger(scwEvt), scwOutputDate = new Date(scwStartDate); if (scwEle.nodeType==3) scwEle=scwEle.parentNode; scwOutputDate.setDate(scwStartDate.getDate() + parseInt(scwEle.id.substr(8),10)); scwSetOutput(scwOutputDate); }; function scwChangeClass(scwEvt) {var scwEle = scwEventTrigger(scwEvt); if (scwEle.nodeType==3) {scwEle=scwEle.parentNode;} switch (scwEle.className) {case 'scwCells': scwEle.className = 'scwCellsHover'; break; case 'scwCellsHover': scwEle.className = 'scwCells'; break; case 'scwCellsExMonth': scwEle.className = 'scwCellsExMonthHover'; break; case 'scwCellsExMonthHover': scwEle.className = 'scwCellsExMonth'; break; case 'scwCellsWeekend': scwEle.className = 'scwCellsWeekendHover'; break; case 'scwCellsWeekendHover': scwEle.className = 'scwCellsWeekend'; break; case 'scwNow': scwEle.className = 'scwNowHover'; break; case 'scwNowHover': scwEle.className = 'scwNow'; break; case 'scwInputDate': scwEle.className = 'scwInputDateHover'; break; case 'scwInputDateHover': scwEle.className = 'scwInputDate'; } return true; } function scwEventTrigger(scwEvt) {if (!scwEvt) {scwEvt = event;} return scwEvt.target||scwEvt.srcElement; }; function scwWeekNumber(scwInDate) {// The base day in the week of the input date var scwInDateWeekBase = new Date(scwInDate); scwInDateWeekBase.setDate(scwInDateWeekBase.getDate() - scwInDateWeekBase.getDay() + scwWeekNumberBaseDay + ((scwInDate.getDay()> scwWeekNumberBaseDay)?7:0)); // The first Base Day in the year var scwFirstBaseDay = new Date(scwInDateWeekBase.getFullYear(),0,1); scwFirstBaseDay.setDate(scwFirstBaseDay.getDate() - scwFirstBaseDay.getDay() + scwWeekNumberBaseDay ); if (scwFirstBaseDay < new Date(scwInDateWeekBase.getFullYear(),0,1)) {scwFirstBaseDay.setDate(scwFirstBaseDay.getDate()+7);} // Start of Week 01 var scwStartWeekOne = new Date(scwFirstBaseDay - scwWeekNumberBaseDay + scwInDate.getDay()); if (scwStartWeekOne > scwFirstBaseDay) {scwStartWeekOne.setDate(scwStartWeekOne.getDate()-7);} var scwWeekNo = '0' + (Math.round((scwInDateWeekBase - scwFirstBaseDay)/604800000,0) + 1); return scwWeekNo.substring(scwWeekNo.length-2, scwWeekNo.length); }; var scwCells = scwID('scwCells'); for (i=0;i (new Date(scwBaseYear+ scwDropDownYears,0,0, scwShowDate.getHours())) ) ) || (scwOutOfMonthDisable && (scwShowDate < (new Date(scwShowDate.getFullYear(), scwCurMonth,1, scwShowDate.getHours())) || scwShowDate > (new Date(scwShowDate.getFullYear(), scwCurMonth+1,0, scwShowDate.getHours())) ) ) )?true:false; scwCell.style.visibility = (scwOutOfMonthHide && (scwShowDate < (new Date(scwShowDate.getFullYear(), scwCurMonth,1, scwShowDate.getHours())) || scwShowDate > (new Date(scwShowDate.getFullYear(), scwCurMonth+1,0, scwShowDate.getHours())) ) )?'hidden':'inherit'; for (var k=0;k= scwDisabledDates[k][0].valueOf() && scwCompareDateValue <= scwDisabledDates[k][1].valueOf() ) {scwDisabled = true;} } } if (scwDisabled || !scwEnabledDay[j-1+(7*((i*scwCells.childNodes.length)/6))] || !scwPassEnabledDay[(j-1+(7*(i*scwCells.childNodes.length/6)))%7] ) {scwRows.childNodes[j].onclick = null; if (scwID('scwIE')) {scwRows.childNodes[j].onmouseover = null; scwRows.childNodes[j].onmouseout = null; } scwCell.className= (scwShowDate.getMonth()!=scwCurMonth) ?'scwCellsExMonthDisabled' :(scwBlnFullInputDate && scwShowDate.toDateString()== scwSeedDate.toDateString()) ?'scwInputDateDisabled' :(scwShowDate.getDay()%6==0) ?'scwCellsWeekendDisabled' :'scwCellsDisabled'; scwCell.style.borderColor = (scwFormatTodayCell && scwShowDate.toDateString()==scwDateNow.toDateString()) ?scwTodayCellBorderColour :(scwCell.currentStyle) ?scwCell.currentStyle['backgroundColor'] :(window.getComputedStyle) ?document.defaultView.getComputedStyle(scwCell,null).getPropertyValue('background-color') :''; } else {scwRows.childNodes[j].onclick=scwCellOutput; if (scwID('scwIE')) {scwRows.childNodes[j].onmouseover = scwChangeClass; scwRows.childNodes[j].onmouseout = scwChangeClass; } scwCell.className= (scwShowDate.getMonth()!=scwCurMonth) ?'scwCellsExMonth' :(scwBlnFullInputDate && scwShowDate.toDateString()== scwSeedDate.toDateString()) ?'scwInputDate' :(scwShowDate.getDay()%6==0) ?'scwCellsWeekend' :'scwCells'; scwCell.style.borderColor = (scwFormatTodayCell && scwShowDate.toDateString() == scwDateNow.toDateString()) ?scwTodayCellBorderColour :(scwCell.currentStyle) ?scwCell.currentStyle['backgroundColor'] :(window.getComputedStyle) ?document.defaultView.getComputedStyle(scwCell,null).getPropertyValue('background-color') :''; } scwShowDate.setDate(scwShowDate.getDate()+1); scwCompareDateValue = new Date(scwShowDate.getFullYear(),scwShowDate.getMonth(),scwShowDate.getDate()).valueOf(); } } } } } if (window.opera) {scwID('scwMonths').style.display = 'inline'; scwID('scwYears' ).style.display = 'inline'; scwID('scw').style.visibility='hidden'; scwID('scw').style.visibility='inherit'; } }; document.writeln(""); document.writeln(""); document.write( "" + "" + "" + "" + "" + "" + "" + "" + "
" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "
" + "" + "" + "" + ' ' + "" + ' ' + "" + "" + "" + "
" + "
" + "" + "" + ""); for (i=0;i<7;i++) {document.write( ""); } document.write("" + "" + ""); for (i=0;i<6;i++) {document.write( "" + ""); for (j=0;j<7;j++) {document.write( ""); } document.write( ""); } document.write( "" + "" + "" + "" + "" + "" + "
" + "" + "" + "" + "" + "" + "
" + "" + "
" + "
" + "
"); if (document.addEventListener) {scwID('scw' ).addEventListener('click',scwCancel,false); scwID('scwHeadLeft' ).addEventListener('click',scwStopPropagation,false); scwID('scwMonths' ).addEventListener('click',scwStopPropagation,false); scwID('scwMonths' ).addEventListener('change',scwStopPropagation,false); scwID('scwYears' ).addEventListener('click',scwStopPropagation,false); scwID('scwYears' ).addEventListener('change',scwStopPropagation,false); scwID('scwHeadRight').addEventListener('click',scwStopPropagation,false); } else {scwID('scw' ).attachEvent('onclick',scwCancel); scwID('scwHeadLeft' ).attachEvent('onclick',scwStopPropagation); scwID('scwMonths' ).attachEvent('onclick',scwStopPropagation); scwID('scwMonths' ).attachEvent('onchange',scwStopPropagation); scwID('scwYears' ).attachEvent('onclick',scwStopPropagation); scwID('scwYears' ).attachEvent('onchange',scwStopPropagation); scwID('scwHeadRight').attachEvent('onclick',scwStopPropagation); } if (document.addEventListener) {document.addEventListener('click',scwHide, false);} else {document.attachEvent('onclick',scwHide);} function clickedstartdate(event) { var mydate= new Date(); mydate.setDate(mydate.getDate()-1); var theyear=mydate.getFullYear(); var themonth=mydate.getMonth(); var theyesterday=mydate.getDate(); scwDisabledDates[0] = [new Date(2000,0,1),new Date(theyear,themonth,theyesterday)]; scwShow(document.getElementById("dateStart"),event); //scwNextAction=trivialAlert.runsAfterSCW(this); } function clickedenddate(event) { var mydate= new Date(); mydate.setDate(mydate.getDate()-1); var theyear=mydate.getFullYear(); var themonth=mydate.getMonth(); var theyesterday=mydate.getDate(); scwDisabledDates[0] = [new Date(2000,0,1),new Date(theyear,themonth,theyesterday)]; scwShow(document.getElementById("dateEnd"),event); } function ReverseUSDate(dateStr) { dateStr = dateStr.split("/"); var nwVal = dateStr[1] + '/' + dateStr[0] + '/' + dateStr[2]; return nwVal; } function sendToReservation() { if (document.forms["chkAvailabilityForm"].dateFlag.value == 1) { if ( validateForm() ) { var beFilterName = document.forms["chkAvailabilityForm"].beFilterName.value; var beFilterValue = document.forms["chkAvailabilityForm"].beFilterVal.value; if(document.forms["chkAvailabilityForm"].openInNewWindow.value == "1") { var sendStrDate = ReverseUSDate(document.forms["chkAvailabilityForm"].dateStart.value) var sendEndDate = ReverseUSDate(document.forms["chkAvailabilityForm"].dateEnd.value) if (document.forms["chkAvailabilityForm"].adults.value != null) mine = window.open("http://clients.innroad.com/"+ document.forms["chkAvailabilityForm"].clientCode.value +"/logon.aspx?adults="+document.forms["chkAvailabilityForm"].adults.value +"&children="+document.forms["chkAvailabilityForm"].children.value+"&dateStart="+sendStrDate+"&dateEnd="+sendEndDate+"&"+beFilterName+"="+beFilterValue+"&promoCode="+document.forms["chkAvailabilityForm"].promoCode.value); else mine = window.open("http://clients.innroad.com/"+ document.forms["chkAvailabilityForm"].clientCode.value); window.document.location.replace("index.html"); } else { if (document.forms["chkAvailabilityForm"].useIFrame.value == "1") { document.forms["chkAvailabilityForm"].submit(); } else { // If iFrame is not exist than opening in the same window. var mine; var sendStrDate = ReverseUSDate(document.forms["chkAvailabilityForm"].dateStart.value) var sendEndDate = ReverseUSDate(document.forms["chkAvailabilityForm"].dateEnd.value) if (document.forms["chkAvailabilityForm"].adults.value != null) window.top.location.replace("http://clients.innroad.com/"+document.forms["chkAvailabilityForm"].clientCode.value+"/logon.aspx?adults="+document.forms["chkAvailabilityForm"].adults.value +"&children="+document.forms["chkAvailabilityForm"].children.value+"&dateStart="+sendStrDate+"&dateEnd="+sendEndDate+"&"+beFilterName+"="+beFilterValue+"&promoCode="+document.forms["chkAvailabilityForm"].promoCode.value); else window.top.location.replace("http://clients.innroad.com/"+document.forms["chkAvailabilityForm"].clientCode.value); } } } } else { if ( validateForm() ) { var beFilterName = document.forms["chkAvailabilityForm"].beFilterName.value; var beFilterValue = document.forms["chkAvailabilityForm"].beFilterVal.value; if(document.forms["chkAvailabilityForm"].openInNewWindow.value == "1") { if (document.forms["chkAvailabilityForm"].adults.value != null) mine = window.open("http://clients.innroad.com/"+ document.forms["chkAvailabilityForm"].clientCode.value +"/logon.aspx?adults="+document.forms["chkAvailabilityForm"].adults.value +"&children="+document.forms["chkAvailabilityForm"].children.value+"&dateStart="+document.forms["chkAvailabilityForm"].dateStart.value+"&dateEnd="+document.forms["chkAvailabilityForm"].dateEnd.value+"&"+beFilterName+"="+beFilterValue+"&promoCode="+document.forms["chkAvailabilityForm"].promoCode.value); else mine = window.open("http://clients.innroad.com/"+ document.forms["chkAvailabilityForm"].clientCode.value); window.document.location.replace("index.html"); } else { if (document.forms["chkAvailabilityForm"].useIFrame.value == "1") { document.forms["chkAvailabilityForm"].submit(); } else { // If iFrame is not exist than opening in the same window. var mine; if (document.forms["chkAvailabilityForm"].adults.value != null) window.top.location.replace("http://clients.innroad.com/"+document.forms["chkAvailabilityForm"].clientCode.value+"/logon.aspx?adults="+document.forms["chkAvailabilityForm"].adults.value +"&children="+document.forms["chkAvailabilityForm"].children.value+"&dateStart="+document.forms["chkAvailabilityForm"].dateStart.value+"&dateEnd="+document.forms["chkAvailabilityForm"].dateEnd.value+"&"+beFilterName+"="+beFilterValue+"&promoCode="+document.forms["chkAvailabilityForm"].promoCode.value); else window.top.location.replace("http://clients.innroad.com/"+document.forms["chkAvailabilityForm"].clientCode.value); } } } try { var pageTracker = _gat._createTracker('UA-44740105-1'); pageTracker._trackEvent('Outbound Links', 'click'); } catch(err) { console.log("Exception: "+err); } var referUrl = "www.seasprayinnverobeach.com"; if(document.referrer != "") { referUrl = document.referrer.split('/')[2]; } pageTracker._trackEvent('Outbound Links', 'click'); pageTracker._link("http://clients.innroad.com/sea/logon.aspx?adults="+document.forms[0].adults.value +"&children="+document.forms[0].children.value+"&dateStart="+document.forms[0].dateStart.value+"&dateEnd="+document.forms[0].dateEnd.value+"&"+beFilterName+"="+beFilterValue + "&utm_source=" + referUrl + "&utm_medium=referral"); window.document.location.replace("http://clients.innroad.com /sea/logon.aspx?adults="+document.forms[0].adults.value +"&children="+document.forms[0].children.value+"&dateStart="+document.forms[0].dateStart.value+"&dateEnd="+document.forms[0].dateEnd.value+"&"+beFilterName+"="+beFilterValue + "&utm_source=" + referUrl + "&utm_medium=referral"); } } function validateForm() { if (document.forms["chkAvailabilityForm"].beFilterVal.value == '') { if (document.forms["chkAvailabilityForm"].beFilterConfig.value == 'town') alert("Please select a Town"); if (document.forms["chkAvailabilityForm"].beFilterConfig.value == 'property') alert("Please select a Property"); if (document.forms["chkAvailabilityForm"].beFilterConfig.value == 'roomclass') alert("Please select a Room Class"); document.forms["chkAvailabilityForm"].beFilterVal.focus(); return false; } if ( !validateNotEmpty(trim(document.forms["chkAvailabilityForm"].dateStart.value)) ) { alert("Please enter Checkin Date"); document.forms["chkAvailabilityForm"].dateStart.focus(); return false; } if ( !validateNotEmpty(trim(document.forms["chkAvailabilityForm"].dateEnd.value)) ) { alert("Please enter Checkout Date"); document.forms["chkAvailabilityForm"].dateEnd.focus(); return false; } if ( validateDateOffset() ) { if ( document.forms["chkAvailabilityForm"].adults.value == '0' ) { alert("Please select adults"); document.forms["chkAvailabilityForm"].adults.focus(); return false; } else return true; } else return false; } function validateDateOffset() { var returnVal = true; var startDateTime = new Date(FormatUSDate(document.forms["chkAvailabilityForm"].dateStart.value)).getTime(); var endDateTime = new Date(FormatUSDate(document.forms["chkAvailabilityForm"].dateEnd.value)).getTime(); if (document.forms["chkAvailabilityForm"].dateFlag.value == 1) { startDateTime = new Date(FormatUSDate(document.forms["chkAvailabilityForm"].dateStart.value)).getTime(); endDateTime = new Date(FormatUSDate(document.forms["chkAvailabilityForm"].dateEnd.value)).getTime(); } else { startDateTime = new Date(document.forms["chkAvailabilityForm"].dateStart.value).getTime(); endDateTime = new Date(document.forms["chkAvailabilityForm"].dateEnd.value).getTime(); } var curDate = new Date(); var y = curDate.getFullYear(); // if(navigator.appName=='Netscape') // { // y = y + 1900; // } curDate = new Date(y, curDate.getMonth(), parseInt(curDate.getDate()) ); var curDateTime = curDate.getTime(); var one_day = 1000*60*60*24; if (startDateTime >= endDateTime ) { alert("Please enter valid Check Out date"); returnVal = false; } else { if (document.forms["chkAvailabilityForm"].daysOffset.value > 0) { if (startDateTime > curDateTime) { if ( Math.ceil((startDateTime - curDateTime)/(one_day)) < document.forms["chkAvailabilityForm"].daysOffset.value ) { alert("Please enter Check In date which is greater than " + document.forms["chkAvailabilityForm"].daysOffset.value + " from now"); returnVal = false; } } else { alert("Please enter Check In date which is greater than " + document.forms["chkAvailabilityForm"].daysOffset.value + " from now"); returnVal = false; } } } return returnVal; } function populateDates() { var curDate = new Date(); var y = curDate.getFullYear(); // if(navigator.appName == 'Netscape') // { // y = y + 1900; // } if (document.forms["chkAvailabilityForm"].dateFlag.value == 1) { curDate = new Date(y, curDate.getMonth(), parseInt(curDate.getDate())+parseInt(document.forms["chkAvailabilityForm"].daysOffset.value) ); document.forms["chkAvailabilityForm"].dateStart.value = formatDate(curDate, "dd/MM/yyyy"); y = curDate.getFullYear(); } else { curDate = new Date(y, curDate.getMonth(), parseInt(curDate.getDate())+parseInt(document.forms["chkAvailabilityForm"].daysOffset.value) ); document.forms["chkAvailabilityForm"].dateStart.value = formatDate(curDate, "MM/dd/yyyy"); y = curDate.getFullYear(); } // if(navigator.appName == 'Netscape') // { // y = y + 1900; // } if (document.forms["chkAvailabilityForm"].dateFlag.value == 1) { curDate = new Date(y, curDate.getMonth(), parseInt(curDate.getDate() + 1) ); document.forms["chkAvailabilityForm"].dateEnd.value = formatDate(curDate, "dd/MM/yyyy"); setNights(); } else { curDate = new Date(y, curDate.getMonth(), parseInt(curDate.getDate() + 1) ); document.forms["chkAvailabilityForm"].dateEnd.value = formatDate(curDate, "MM/dd/yyyy"); setNights(); } } function calClosed() { setCheckoutDate(); } function setCheckoutDate() { setCheckoutDateParams(document.forms["chkAvailabilityForm"].dateStart,document.forms["chkAvailabilityForm"].noOfNights,document.forms["chkAvailabilityForm"].dateEnd); } function setCheckoutDateParams(checkinDate, noOfNights, checkOutDate) { if (checkinDate.value != '' && isNumericVal(noOfNights.value, 0) && noOfNights.value != '') { if (document.forms["chkAvailabilityForm"].dateFlag.value == 1) { var m_names = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); var myDate=new Date(FormatUSDate(checkinDate.value)); var nights = noOfNights.value; var datevalue; var monthsvalue=0; myDate.setDate(myDate.getDate()+parseInt(nights)) if (myDate.getDate() < 10) datevalue = "0" + myDate.getDate(); else datevalue = myDate.getDate(); if (myDate.getMonth() == 0) checkOutDate.value = datevalue + "/" + "01" + "/" + myDate.getFullYear(); else if (myDate.getMonth() < 9) checkOutDate.value = datevalue + "/" + "0" + (myDate.getMonth()+1) + "/" + myDate.getFullYear(); else checkOutDate.value = datevalue + "/" + (myDate.getMonth()+1) + "/" + myDate.getFullYear(); } else { var m_names = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); var myDate=new Date(checkinDate.value) var nights = noOfNights.value; var datevalue; var monthsvalue=0; myDate.setDate(myDate.getDate()+parseInt(nights)) if (myDate.getDate() < 10) datevalue = "0" + myDate.getDate(); else datevalue = myDate.getDate(); if (myDate.getMonth() == 0) checkOutDate.value = "01" + "/" + datevalue + "/" + myDate.getFullYear(); else if (myDate.getMonth() < 9) checkOutDate.value = "0" + (myDate.getMonth()+1) + "/" + datevalue + "/" + myDate.getFullYear(); else checkOutDate.value = (myDate.getMonth()+1) + "/" + datevalue + "/" + myDate.getFullYear(); } } } function isNumericVal(c, varTest) { //allows alhabetic and space characters var letters="-0123456789"; var LETTERS="-0123456789"; var index1 = c.indexOf("-"); var index2 = c.indexOf("-", index1 + 1); var index3 = c.indexOf("-", index2 + 1); if (varTest == 1) { if (!((index1 == 3) && (index2 == 7) && (index3 == -1))) { return false; } } if(c.length>1) { for(j=0;j=0 || LETTERS.indexOf(c)>=0) return true; return false; } } function setNights() { return setNightsParams(document.forms["chkAvailabilityForm"].dateStart,document.forms["chkAvailabilityForm"].noOfNights,document.forms["chkAvailabilityForm"].dateEnd); } function FormatUSDate(dateStr) { dateStr = dateStr.split("/"); return new Date(dateStr[2], dateStr[1] - 1, dateStr[0]); } function setNightsParams(checkinDate, noOfNights, checkOutDate) { var one_day=1000*60*60*24 if (checkinDate.value != '' && checkOutDate.value != '') { var totNights = new Number(); var zero = 0; if (document.forms["chkAvailabilityForm"].dateFlag.value == 1) { var stDate = new Date(FormatUSDate(checkinDate.value)); var endDate = new Date(FormatUSDate(checkOutDate.value)); stDate.setHours(0); stDate.setMinutes(0); stDate.setSeconds(0); stDate.setHours(0); endDate.setMinutes(0); endDate.setSeconds(0); totNights=Math.round((endDate.getTime() - stDate.getTime())/one_day); if(totNights < zero) { alert('Arrival Date must be earlier than Departure Date'); return false; } else { noOfNights.value = totNights ; return true; } } else { var stDate = new Date(checkinDate.value); var endDate = new Date(checkOutDate.value); stDate.setHours(0); stDate.setMinutes(0); stDate.setSeconds(0); stDate.setHours(0); endDate.setMinutes(0); endDate.setSeconds(0); totNights=Math.round((endDate.getTime() - stDate.getTime())/one_day); if(totNights < zero) { alert('Arrival Date must be earlier than Departure Date'); return false; } else { noOfNights.value = totNights ; return true; } } } } function fillForm() { if (document.forms["chkAvailabilityForm"].beFilterConfig.value == 'town') { document.forms["chkAvailabilityForm"].beFilterName.value="townID"; document.getElementById("beFilterLabel").innerHTML="Town:"; } if (document.forms["chkAvailabilityForm"].beFilterConfig.value == 'property') { document.forms["chkAvailabilityForm"].beFilterName.value="propertyID"; document.getElementById("beFilterLabel").innerHTML="Property:"; } if (document.forms["chkAvailabilityForm"].beFilterConfig.value == 'roomClass') { document.forms["chkAvailabilityForm"].beFilterName.value="roomClassID"; document.getElementById("beFilterLabel").innerHTML="Room Class:"; } if (document.forms["chkAvailabilityForm"].showHideBEFilter.value == 'hide') { document.getElementById("beFilterTR").style.display = 'none'; } if (document.forms["chkAvailabilityForm"].showHideBEFilter.value == 'show') { document.getElementById("beFilterTR").style.display = ''; } if (document.forms["chkAvailabilityForm"].showHideChildren.value == 'hide') { document.getElementById("beChildrenTD").style.display = 'none'; document.getElementById("beChildrenHelpTD").style.display = 'none'; } if (document.forms["chkAvailabilityForm"].showHideChildren.value == 'show') { document.getElementById("beChildrenTD").style.display = ''; document.getElementById("beChildrenHelpTD").style.display = ''; } if (document.forms["chkAvailabilityForm"].showHideNights.value == 'hide') { document.getElementById("beNightsTR").style.display = 'none'; } if (document.forms["chkAvailabilityForm"].showHideNights.value == 'show') { document.getElementById("beNightsTR").style.display = ''; } if (document.forms["chkAvailabilityForm"].showHidePromoCode.value == 'hide') { document.getElementById("bePromoCodeTR").style.display = 'none'; } if (document.forms["chkAvailabilityForm"].showHidePromoCode.value == 'show') { document.getElementById("bePromoCodeTR").style.display = ''; } } /***************************** Validation *************************/ var reSpecialChars = /[\'\"]/g; //matches any occurence of single quote or double quote var reInitialWhitespace = /^\s+/g; //matches one or more whitespace char at start of string var reTermialWhitespace = /\s+$/g; //matches one or more whitespace char at end of string var reBackSlash = /%5C/gi; var reSemiColon = /\;/gi; var reForwardSlash = /[\\]/g; var reOpenBrackets= /[\{\<]/g; var reCloseBrackets= /[\}\>]/g; // These methods below are not necessary but are included as sample library functions that are used in the example function validateNotEmpty( strValue ) { /************************************************ DESCRIPTION: Validates that a string is not all blank (whitespace) characters. PARAMETERS: strValue - String to be tested for validity RETURNS: True if not empty, otherwise false. *************************************************/ var strTemp = strValue; strTemp = trimAll(strTemp); if(strTemp.length > 0){ return true; } return false; } //Description : Removes spaces from the start and end of the string. Spaces in the middle are not removed. //Input Parameters : s - String //Output : String sOutStr function trim (s) { return stripCharacters(stripCharacters (s, reInitialWhitespace),reTermialWhitespace); } function trimAll( strValue ) { /************************************************ DESCRIPTION: Removes leading and trailing spaces. PARAMETERS: Source string from which spaces will be removed; RETURNS: Source string with whitespaces removed. *************************************************/ var objRegExp = /^(\s*)$/; //check for all spaces if(objRegExp.test(strValue)) { strValue = strValue.replace(objRegExp, ''); if( strValue.length == 0) return strValue; } //check for leading & trailing spaces objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/; if(objRegExp.test(strValue)) { //remove leading and trailing whitespace characters strValue = strValue.replace(objRegExp, '$2'); } return strValue; } //Description : Strip character in passed reBag (valid RegExp expression) from passed String // ; Note that reBag must be a valid RegExp which matches sigle characters in isolation // ; and make sure the 'g' modifier is appended for global search & replace. //Input Parameters : s - String //Output : String with designated (reBag) characters removed function stripCharacters(s, reBag) { return s.replace(reBag, '') } var testresults function checkemail(email){ var str=email var filter=/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i if (filter.test(str)) testresults=true else{ alert("Please input a valid email address!") testresults=false } return (testresults) } /****************************** Date Util *****************************/ var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat'); function LZ(x) {return(x<0||x>9?"":"0")+x} function isDate(val,format) { var date=getDateFromFormat(val,format); if (date==0) { return false; } return true; } function compareDates(date1,dateformat1,date2,dateformat2) { var d1=getDateFromFormat(date1,dateformat1); var d2=getDateFromFormat(date2,dateformat2); if (d1==0 || d2==0) { return -1; } else if (d1 > d2) { return 1; } return 0; } function formatDate(date,format) { format=format+""; var result=""; var i_format=0; var c=""; var token=""; var y=date.getFullYear()+""; var M=date.getMonth()+1; var d=date.getDate(); var E=date.getDay(); var H=date.getHours(); var m=date.getMinutes(); var s=date.getSeconds(); var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k; // Convert real date parts into formatted versions var value=new Object(); if (y.length < 4) {y=""+(y-0+1900);} value["y"]=""+y; value["yyyy"]=y; value["yy"]=y.substring(2,4); value["M"]=M; value["MM"]=LZ(M); value["MMM"]=MONTH_NAMES[M-1]; value["NNN"]=MONTH_NAMES[M+11]; value["d"]=d; value["dd"]=LZ(d); value["E"]=DAY_NAMES[E+7]; value["EE"]=DAY_NAMES[E]; value["H"]=H; value["HH"]=LZ(H); if (H==0){value["h"]=12;} else if (H>12){value["h"]=H-12;} else {value["h"]=H;} value["hh"]=LZ(value["h"]); if (H>11){value["K"]=H-12;} else {value["K"]=H;} value["k"]=H+1; value["KK"]=LZ(value["K"]); value["kk"]=LZ(value["k"]); if (H > 11) { value["a"]="PM"; } else { value["a"]="AM"; } value["m"]=m; value["mm"]=LZ(m); value["s"]=s; value["ss"]=LZ(s); while (i_format < format.length) { c=format.charAt(i_format); token=""; while ((format.charAt(i_format)==c) && (i_format < format.length)) { token += format.charAt(i_format++); } if (value[token] != null) { result=result + value[token]; } else { result=result + token; } } return result; } // ------------------------------------------------------------------ // Utility functions for parsing in getDateFromFormat() // ------------------------------------------------------------------ function _isInteger(val) { var digits="1234567890"; for (var i=0; i < val.length; i++) { if (digits.indexOf(val.charAt(i))==-1) { return false; } } return true; } function _getInt(str,i,minlength,maxlength) { for (var x=maxlength; x>=minlength; x--) { var token=str.substring(i,i+x); if (token.length < minlength) { return null; } if (_isInteger(token)) { return token; } } return null; } // ------------------------------------------------------------------ // getDateFromFormat( date_string , format_string ) // // This function takes a date string and a format string. It matches // If the date string matches the format string, it returns the // getTime() of the date. If it does not match, it returns 0. // ------------------------------------------------------------------ function getDateFromFormat(val,format) { val=val+""; format=format+""; var i_val=0; var i_format=0; var c=""; var token=""; var token2=""; var x,y; var now=new Date(); var year=now.getFullYear(); var month=now.getMonth()+1; var date=1; var hh=now.getHours(); var mm=now.getMinutes(); var ss=now.getSeconds(); var ampm=""; while (i_format < format.length) { // Get next token from format string c=format.charAt(i_format); token=""; while ((format.charAt(i_format)==c) && (i_format < format.length)) { token += format.charAt(i_format++); } // Extract contents of value based on format token if (token=="yyyy" || token=="yy" || token=="y") { if (token=="yyyy") { x=4;y=4; } if (token=="yy") { x=2;y=2; } if (token=="y") { x=2;y=4; } year=_getInt(val,i_val,x,y); if (year==null) { return 0; } i_val += year.length; if (year.length==2) { if (year > 70) { year=1900+(year-0); } else { year=2000+(year-0); } } } else if (token=="MMM"||token=="NNN"){ month=0; for (var i=0; i11)) { month=i+1; if (month>12) { month -= 12; } i_val += month_name.length; break; } } } if ((month < 1)||(month>12)){return 0;} } else if (token=="EE"||token=="E"){ for (var i=0; i12)){return 0;} i_val+=month.length;} else if (token=="dd"||token=="d") { date=_getInt(val,i_val,token.length,2); if(date==null||(date<1)||(date>31)){return 0;} i_val+=date.length;} else if (token=="hh"||token=="h") { hh=_getInt(val,i_val,token.length,2); if(hh==null||(hh<1)||(hh>12)){return 0;} i_val+=hh.length;} else if (token=="HH"||token=="H") { hh=_getInt(val,i_val,token.length,2); if(hh==null||(hh<0)||(hh>23)){return 0;} i_val+=hh.length;} else if (token=="KK"||token=="K") { hh=_getInt(val,i_val,token.length,2); if(hh==null||(hh<0)||(hh>11)){return 0;} i_val+=hh.length;} else if (token=="kk"||token=="k") { hh=_getInt(val,i_val,token.length,2); if(hh==null||(hh<1)||(hh>24)){return 0;} i_val+=hh.length;hh--;} else if (token=="mm"||token=="m") { mm=_getInt(val,i_val,token.length,2); if(mm==null||(mm<0)||(mm>59)){return 0;} i_val+=mm.length;} else if (token=="ss"||token=="s") { ss=_getInt(val,i_val,token.length,2); if(ss==null||(ss<0)||(ss>59)){return 0;} i_val+=ss.length;} else if (token=="a") { if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";} else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";} else {return 0;} i_val+=2;} else { if (val.substring(i_val,i_val+token.length)!=token) {return 0;} else {i_val+=token.length;} } } // If there are any trailing characters left in the value, it doesn't match if (i_val != val.length) { return 0; } // Is date valid for month? if (month==2) { // Check for leap year if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year if (date > 29){ return 0; } } else { if (date > 28) { return 0; } } } if ((month==4)||(month==6)||(month==9)||(month==11)) { if (date > 30) { return 0; } } // Correct hours value if (hh<12 && ampm=="PM") { hh=hh-0+12; } else if (hh>11 && ampm=="AM") { hh-=12; } var newdate=new Date(year,month-1,date,hh,mm,ss); return newdate.getTime(); } // ------------------------------------------------------------------ // parseDate( date_string [, prefer_euro_format] ) // // This function takes a date string and tries to match it to a // number of possible date formats to get the value. It will try to // match against the following international formats, in this order: // y-M-d MMM d, y MMM d,y y-MMM-d d-MMM-y MMM d // M/d/y M-d-y M.d.y MMM-d M/d M-d // d/M/y d-M-y d.M.y d-MMM d/M d-M // A second argument may be passed to instruct the method to search // for formats like d/M/y (european format) before M/d/y (American). // Returns a Date object or null if no patterns match. // ------------------------------------------------------------------ function parseDate(val) { var preferEuro=(arguments.length==2)?arguments[1]:false; generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d'); monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d'); dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M'); var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst'); var d=null; for (var i=0; i