/////////////////////////////////////////////////////////// // Usage IEprompt("dialog descriptive text", "default starting value"); // // IEprompt will call promptCallback(val) // Where val is the user's input or null if the dialog was canceled. /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // This source code has been released into the public domain // January 14th, 2007. // You may use it and modify it freely without compensation // and without the need to tell everyone where you got it. /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // You must create a promptCallback(val) function to handle // the user input. If you don't this script will fail and // Bunnies will die. /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // These are global scope variables, they should remain global. /////////////////////////////////////////////////////////// var _dialogPromptID=null; var _blackoutPromptID=null; /////////////////////////////////////////////////////////// function IEprompt(innertxt,def) { that=this; // Check to see if this is MSIE 7. This isn't a great general purpose // detection system but it works well enough just to find MSIE 7. var _isIE7=(navigator.userAgent.indexOf('MSIE 7')>0); this.wrapupPrompt = function (cancled) { // wrapupPrompt is called when the user enters or cancels the box. // It's called only by the IE7 dialog box, not the non IE prompt box if (_isIE7) { // Make sure we're in IE7 mode and get the text box value val=document.getElementById('iepromptfield').value; // clear out the dialog box _dialogPromptID.style.display='none'; // clear out the screen _blackoutPromptID.style.display='none'; // clear out the text field document.getElementById('iepromptfield').value = ''; // if the cancel button was pushed, force value to null. if (cancled) { val = '' } // call the user's function promptCallback(val); } return false; } //if def wasn't actually passed, initialize it to null if (def==undefined) { def=''; } if (_isIE7) { // If this is MSIE 7.0 then... if (_dialogPromptID==null) { // Check to see if we've created the dialog divisions. // This block sets up the divisons // Get the body tag in the dom var tbody = document.getElementsByTagName("body")[0]; // create a new division tnode = document.createElement('div'); // name it tnode.id='IEPromptBox'; // attach the new division to the body tag tbody.appendChild(tnode); // and save the element reference in a global variable _dialogPromptID=document.getElementById('IEPromptBox'); // Create a new division (blackout) tnode = document.createElement('div'); // name it. tnode.id='promptBlackout'; // attach it to body. tbody.appendChild(tnode); // And get the element reference _blackoutPromptID=document.getElementById('promptBlackout'); // assign the styles to the blackout division. _blackoutPromptID.style.opacity='.9'; _blackoutPromptID.style.position='absolute'; _blackoutPromptID.style.top='0px'; _blackoutPromptID.style.left='0px'; _blackoutPromptID.style.backgroundColor='#555555'; _blackoutPromptID.style.filter='alpha(opacity=100)'; _blackoutPromptID.style.height=(document.body.offsetHeight
'; tmp += '
'; tmp += ''; tmp += '

'; tmp += ''; tmp += '      '; tmp += ''; tmp += ''; // Stretch the blackout division to fill the entire document // and make it visible. Because it has a high z-index it should // make all other elements on the page unclickable. _blackoutPromptID.style.height=(document.body.offsetHeight "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 testForObject(Id, Tag) { var o = document.getElementById(Id); if (o) { if (Tag) { if (o.tagName.toLowerCase() == Tag.toLowerCase()) { return o; } } else { return o; } } return null; } function isDate(dtStr){ var promptBlackOutExist = testForObject("promptBlackout", "div"); if (promptBlackOutExist) { _blackoutPromptID=document.getElementById('promptBlackout'); // assign the styles to the blackout division. _blackoutPromptID.style.opacity='.9'; _blackoutPromptID.style.filter='alpha(opacity=100)'; _blackoutPromptID.style.display='block'; } var daysInMonth = DaysArray(12) var pos1=dtStr.indexOf(dtCh) var pos2=dtStr.indexOf(dtCh,pos1+1) var strMonth=dtStr.substring(0,pos1) var strDay=dtStr.substring(pos1+1,pos2) var strYear=dtStr.substring(pos2+1) strYr=strYear if (strDay.charAt(0)=="0" && strDay.length>1) 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){ alert("The date format should be : mm/dd/yyyy") return false } if (strMonth.length<1 || month<1 || month>12){ alert("Please enter a valid month") return false } if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){ alert("Please enter a valid day") return false } if (strYear.length != 4 || year==0 || yearmaxYear){ alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear) return false } if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){ alert("Please enter a valid date") return false } return true } function readBirthDate (){ IE7 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 7.")!=-1)) ? true : false; if(IE7) { document.body.style.overflow="hidden"; IEprompt("Enter your birthday in mm/dd/yyyy format","mm/dd/yyyy"); }else { var birthDay=prompt("Enter your birthday in mm/dd/yyyy format","mm/dd/yyyy"); if(!birthDay){ alert("Redirecting to homepage\n"); window.location = "http://carolinaspurerock.com"; return false; } if (isDate(birthDay)){ return birthDay; }else{ return readBirthDate(); } } }