/*  Coolite Inc. 2004-2006. All rights are reserved. Unauthorized use prohibited. Visit http://www.basicdatepicker.com/ for more info. Version 1.2.2411    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A    PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR    ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR    TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF    ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */if (typeof(window["BDP"])=="undefined"){window["BDP"]={}; }BDP.TimePicker=function(hourInput,minuteInput,secondInput,designatorInput,input,is24Hour,hourNullText,minuteNullText,secondNullText,amDesignator,pmDesignator,readOnly,nullable,autoPostBack,displayType,hourIncrement,minuteIncrement,secondIncrement,nullTimeText,expandedTimeFormat){var argumentNames=new Array("hourInput","minuteInput","secondInput","designatorInput","input","is24Hour","hourNullText","minuteNullText","secondNullText","amDesignator","pmDesignator","readOnly","nullable","autopostback","displayType","hourIncrement","minuteIncrement","secondIncrement","nullTimeText","expandedTimeFormat");for(var i=0; i<arguments.length; i++) this[argumentNames[i]]=arguments[i];this._isTime=true;this.isMultiInput=(this.displayType=="MultipleTextBox"||this.displayType=="MultipleDropDownList");this.hasHourInput=(this.hourInput != null), this.hasMinuteInput=(this.minuteInput != null), this.hasSecondInput=(this.secondInput != null), this.hasDesignatorInput=(this.designatorInput != null), this.hasInput=(this.Input != null);};BDP.TimePicker.prototype.setSelectedTime=function(time){if(time==null){var useSpecificNullText=(this.nullTimeText=="{0}");if(this.isMultiInput){if(this.hasHourInput) this.setInputValue(this.hourInput, (useSpecificNullText) ? this.hourNullText : this.nullTimeText);if(this.hasMinuteInput) this.setInputValue(this.minuteInput, (useSpecificNullText) ? this.minuteNullText : this.nullTimeText);if(this.hasSecondInput) this.setInputValue(this.secondInput, (useSpecificNullText) ? this.secondNullText : this.nullTimeText);if(this.hasDesignatorInput) this.setInputValue(this.designatorInput, this.amDesignator);}else{this.setInputValue(this.input,(useSpecificNullText) ? this.expandedTimeFormat : this.nullTimeText); }return;}var tokens=this.tokenizeFormat();var hourToken=null, minuteToken=null, secondToken=null, designatorToken=null;for(var i=0; i<tokens.length; i++){var token=tokens[i];switch(token.toLowerCase()){case "h":case "hh":if(!hourToken) hourToken=token; break;case "m":case "mm":if(!minuteToken) minuteToken=token; break;case "s":case "ss":if(!secondToken) secondToken=token; break;case "t":case "tt":if(!designatorToken) designatorToken=token; break;}}if(this.isMultiInput){if(this.hasHourInput) this.setInputValue(this.hourInput, time.toString(hourToken));if(this.hasMinuteInput) this.setInputValue(this.minuteInput, time.toString(minuteToken));if(this.hasSecondInput) this.setInputValue(this.secondInput, time.toString(secondToken));if(this.hasDesignatorInput) this.setInputValue(this.designatorInput, time.toString(designatorToken, this.amDesignator, this.pmDesignator));}else{this.setInputValue(this.input, time.toString(this.expandedTimeFormat)); }};BDP.TimePicker.prototype.getSelectedTime=function(){var hourText=null, minuteText=null, secondText=null, designatorText=null;var hour=null, minute=null, second=null;if(this.isMultiInput){hourText=this.getInputValue(this.hourInput);minuteText=this.getInputValue(this.minuteInput);secondText=this.getInputValue(this.secondInput);designatorText=this.getInputValue(this.designatorInput);if(hourText==this.hourNullText && minuteText==this.minuteNullText && secondText==this.secondNullText){return null };hour=this.parseIntFromMultiInput(hourText, this.hourNullText);minute=this.parseIntFromMultiInput(minuteText, this.minuteNullText);second=this.parseIntFromMultiInput(secondText, this.secondNullText);}else{var timeText=this.getInputValue(this.input);if(timeText==this.nullTimeText||timeText==this.expandedTimeFormat){return null; };var format=this.expandedTimeFormat;var tokens=this.tokenizeFormat();var i_value=0;for(var i=0; i<tokens.length; i++){var token=tokens[i];switch(token){case "h" :case "hh" :hourText=this.getTextByToken(timeText, i_value, 1, 2);if(!hourText) {this._isTime=false; return null; }i_value+=hourText.length;hour=parseInt(hourText, 10);break;case "m" :case "mm" :minuteText=this.getTextByToken(timeText, i_value, 1, 2);if(!minuteText){this._isTime=false; return null; }i_value+=minuteText.length;minute=parseInt(minuteText, 10);break;case "s" :case "ss" :secondText=this.getTextByToken(timeText, i_value, 1, 2);if(!secondText){this._isTime=false; return null; }i_value+=secondText.length;second=parseInt(secondText, 10);break;case "t" :designatorText=timeText.substring(i_value, i_value+1);case "tt" :amDesignatorText=timeText.substring(i_value, i_value+this.amDesignator.length);pmDesignatorText=timeText.substring(i_value, i_value+this.pmDesignator.length);if(amDesignatorText.toLowerCase()==this.amDesignator.toLowerCase()){designatorText=amDesignatorText; }else if(pmDesignatorText.toLowerCase()==this.pmDesignator.toLowerCase()){designatorText=pmDesignatorText; }else designatorText=null;if(!designatorText){this._isTime=false; return null; }i_value+=designatorText.length;break;default :i_value+=token.length;}}}if(hour==null){hour=0 };if(minute==null){minute=0 };if(second==null){second=0 };if(!isNaN(hour) && !isNaN(minute) && !isNaN(second)){if((!this.is24Hour||this.isMultiInput) && designatorText != null){if(designatorText==this.amDesignator && hour==12){hour=0; }else if(designatorText==this.pmDesignator && hour != 12){hour=hour + 12; }}if(hour > 23||minute > 59||second > 59){    this._isTime=false;    return null;}else{    this._isTime=true;    return new BDP.TimeSpan(null, hour, minute, second)}}this._isTime=false;return null;};BDP.TimePicker.prototype.getSelectedTimeFormatted=function(){var time=this.getSelectedTime();return (time==null) ? "" : time.toString(this.expandedTimeFormat);};BDP.TimePicker.prototype.getTextByToken=function(str,i,minlength,maxlength){for(var x=maxlength; x>=minlength; x--){var valuePart=str.substring(i, i + x);if(valuePart.length < minlength){return null; }if(this.isNumeric(valuePart)){return valuePart; }}return null;};BDP.TimePicker.prototype.parseIntFromMultiInput=function(numberText, nullText){if(numberText != null && (numberText.length > 0||numberText != nullText)){return parseInt(numberText, 10);}return 0;};BDP.TimePicker.prototype.getInputValue=function(input){return (!input) ? null : (input.options) ? input.options[input.selectedIndex].value : input.value; };BDP.TimePicker.prototype.setInputValue=function(input, value){if(input){var options=input.options;if(options){        for(var i=0; i<options.length; i++)       {       if(options[i].value==value)       {       input.selectedIndex=i;        this.fireOnChange(input);        return;        }        }        var opt=document.createElement("OPTION");        opt.value=value;        opt.text=value;        options.add(opt, 0);input.selectedIndex=0;}else{input.value=value; }this.fireOnChange(input);}};BDP.TimePicker.prototype.fireOnChange=function(input){    if(document.createEvent)   {       var e=document.createEvent("HTMLEvents");        e.initEvent("change", true, false );        input.dispatchEvent(e);    }     else if(document.createEventObject)   {input.fireEvent("onchange"); }};BDP.TimePicker.prototype.tokenizeFormat=function(){var tokens=new Array();var format=this.expandedTimeFormat;if(format != null && format.length > 0){var i_format=0;var c;var token;while(i_format < format.length){c=format.charAt(i_format);token="";while((i_format < format.length) && (format.charAt(i_format)==c)){token+=format.charAt(i_format++);}tokens[tokens.length]=token;}}return tokens;};BDP.TimePicker.prototype.clear=function(){this.setSelectedTime(null); };BDP.TimePicker.prototype.getIsNull=function(){return (this.getSelectedTime()==null); };BDP.TimePicker.prototype.getIsTime=function(){this.getSelectedTime(); return this._isTime; };BDP.TimePicker.prototype.setEnabled=function(val){if(this.isMultiInput){    var parent;if(this.hasHourInput){this.hourInput.disabled=!val; parent=this.hourInput; };if(this.hasMinuteInput){this.minuteInput.disabled=!val; parent=this.minuteInput; };if(this.hasSecondInput){this.secondInput.disabled=!val; parent=this.secondInput; };if(this.hasDesignatorInput){this.designatorInput.disabled=!val; parent=this.designatorInput; };if(parent.parentElement){parent.parentElement.disabled=!val; }}else{this.input.disabled=!val; if(this.input.parentElement){this.input.parentElement.disabled=!val; }}};BDP.TimePicker.prototype.getEnabled=function(){    if(this.isMultiInput)   {       if(this.hasHourInput) return !this.hourInput.disabled;if(this.hasMinuteInput) return !this.minuteInput.disabled;if(this.hasSecondInput) return !this.secondInput.disabled;if(this.hasDesignatorInput) return !this.designatorInput.disabled;    }    return !this.input.disabled; };BDP.TimePicker.prototype.getHourIncrement=function(){return (this.hourIncrement==-1) ? 0 : this.hourIncrement; };BDP.TimePicker.prototype.getMinuteIncrement=function(){return (this.minuteIncrement==-1 && this.displayType=="SingleDropDownList") ? 30 : (this.minuteIncrement==-1) ? 15 : this.minuteIncrement; };BDP.TimePicker.prototype.getSecondIncrement=function(){return (this.secondIncrement==-1) ? 0 : this.secondIncrement; };BDP.TimePicker.prototype.increment=function(val, token){   var t=(this.getSelectedTime()==null) ? new BDP.TimeSpan() : this.getSelectedTime();    if(val && this.isNumeric(val))   {       if(token)       {   switch(token.toLowerCase())   {   case "d":    this.setSelectedTime(t.addDays(val));    break;        case "h":    this.setSelectedTime(t.addHours(val));    break;    case "m":    this.setSelectedTime(t.addMinutes(val));     break;    case "s":    this.setSelectedTime(t.addSeconds(val));     break;    }        }        else{this.setSelectedTime(t.addMinutes(val)); }        return;    }    this.setSelectedTime(t.addHours(this.getHourIncrement()).addMinutes(this.getMinuteIncrement()).addSeconds(this.getSecondIncrement())); };BDP.TimePicker.prototype.decrement=function(val, token){   var t=(this.getSelectedTime()==null) ? new BDP.TimeSpan() : this.getSelectedTime();    if(val && this.isNumeric(val))   {       if(token)       {   switch(token.toLowerCase())   {   case "d":    this.setSelectedTime(t.addDays(-val));    break;        case "h":    this.setSelectedTime(t.addHours(-val));    break;    case "m":    this.setSelectedTime(t.addMinutes(-val));     break;    case "s":    this.setSelectedTime(t.addSeconds(-val));     break;    }        }        else{this.setSelectedTime(t.addMinutes(-val)); }        return;    }    this.setSelectedTime(t.addHours(-this.getHourIncrement()).addMinutes(-this.getMinuteIncrement()).addSeconds(-this.getSecondIncrement())); };/* Time Span */if (typeof(window["BDP"])=="undefined"){window["BDP"]={}; }BDP.TimeSpan=function(days, hours, minutes, seconds){this.addProperty=function(name, value, createSetMethod){ this[name]=value;var functionSuffix=name.charAt(0).toUpperCase() + name.substring(1, name.length);this["get" + functionSuffix]=function(){return this[name];};if(createSetMethod != false){this["set" + functionSuffix]=function(vNewValue){ this[name]=vNewValue; };}};this.addProperty("days", (days) ? days: 0, false);this.addProperty("hours", (hours) ? hours : 0, false);this.addProperty("minutes", (minutes) ? minutes : 0, false);this.addProperty("seconds", (seconds) ? seconds : 0, false);};BDP.TimeSpan.prototype.compare=function(timeSpan){    var t1=new Date(1970,1,1, this.getHours(), this.getMinutes(), this.getSeconds()).getTime();    var t2;    if(timeSpan==null){t2=new Date(1970,1,1,0,0,0); }    else{t2=new Date(1970,1,1, timeSpan.getHours(), timeSpan.getMinutes(), timeSpan.getSeconds()).getTime(); }    return (t1 > t2) ? 1 : (t1 < t2) ? -1 : 0;};BDP.TimeSpan.prototype.add=function(timeSpan){return (timeSpan==null) ? this : this.addSeconds(timeSpan.getMilliseconds()/1000); };BDP.TimeSpan.prototype.subtract=function(timeSpan){return (timeSpan==null) ? this : this.addSeconds(-timeSpan.getMilliseconds()/1000); };BDP.TimeSpan.createFromMilliseconds=function(milliseconds){   if(this==null){return null; }    if(milliseconds < 0){milliseconds+=(24*60*60*1000); }    var diff=Math.abs(milliseconds);    var days, dMod, hours, hMod, minutes, mMod, seconds;    days=Math.floor(diff/(24*60*60*1000));    dMod=diff % (24*60*60*1000);    if(dMod && BDP.TimePicker.isNumeric(dMod))   {       hours=Math.floor(dMod/(60*60*1000));        hMod=dMod % (60*60*1000);        if(hMod && BDP.TimePicker.isNumeric(hMod))       {           minutes=Math.floor(hMod/(60*1000));            mMod=hMod % (60*1000);            if(mMod && BDP.TimePicker.isNumeric(mMod)){seconds=Math.floor(mMod/(1000)); }        }    }    return new BDP.TimeSpan(days, hours, minutes, seconds);};BDP.TimeSpan.prototype.addDays=function(number){return BDP.TimeSpan.createFromMilliseconds(this.getMilliseconds() + parseInt(number)*(24*60*60*1000)); };BDP.TimeSpan.prototype.addHours=function(number){return BDP.TimeSpan.createFromMilliseconds(this.getMilliseconds() + parseInt(number)*(60*60*1000)); };BDP.TimeSpan.prototype.addMinutes=function(number){return BDP.TimeSpan.createFromMilliseconds(this.getMilliseconds() + parseInt(number)*(60*1000)); };BDP.TimeSpan.prototype.addSeconds=function(number){return BDP.TimeSpan.createFromMilliseconds(this.getMilliseconds() + parseInt(number)*1000); };BDP.TimeSpan.prototype.addMilliseconds=function(number){return BDP.TimeSpan.createFromMilliseconds(this.getMilliseconds() + parseInt(number)); };BDP.TimeSpan.prototype.getMilliseconds=function(){return (this.getDays() * (24*60*60*1000)) + (this.getHours() * (60*60*1000)) + (this.getMinutes() * (60*1000)) + (this.getSeconds() * (1000)); };BDP.TimeSpan.prototype.get12HourHour=function(){return ((h=this.getHours() % 12) ? h : 12); };BDP.TimeSpan.prototype.getDesignator=function(amDesignator, pmDesignator){return (this.getHours() < 12) ? (amDesignator) ? amDesignator : "AM" : (pmDesignator) ? pmDesignator : "PM" };BDP.TimeSpan.prototype.toString=function(format, amDesignator, pmDesignator){var self=this;if(format){return format.replace(/(d|dd|HH|H|hh|h|mm|m|ss|s|tt|t)/gi,function($1){switch ($1){                    case "d":return self.getDays();case "dd":return self.getDays().toPaddedString(2);case "H":return self.getHours();case "HH":return self.getHours().toPaddedString(2);case "h":return self.get12HourHour();case "hh":return self.get12HourHour().toPaddedString(2);case "m":return self.getMinutes();case "mm":return self.getMinutes().toPaddedString(2);case "s":return self.getSeconds();case "ss":return self.getSeconds().toPaddedString(2);case "t":return self.getDesignator(amDesignator, pmDesignator).substring(0,1);case "tt":return self.getDesignator(amDesignator, pmDesignator);}});    }    else   {       if(self.getDays() != null && self.getDays() > 0){return self.getDays() + "." + self.getHours() + ":" + self.getMinutes().toPaddedString(2) + ":" + self.getSeconds().toPaddedString(2); }else{return self.getHours() + ":" + self.getMinutes().toPaddedString(2) + ":" + self.getSeconds().toPaddedString(2); }    }};/* Date and Time Helpers */Date.prototype.addHours=function(number){return (new Date(this.getTime() + (parseInt(number) * 60 * 60 * 1000))); };Date.prototype.addMinutes=function(number){return (new Date(this.getTime() + (parseInt(number) * 60 * 1000))); };Date.prototype.addSeconds=function(number){return (new Date(this.getTime() + (parseInt(number) * 1000))); };Date.prototype.getTimeOfDay=function(){return new BDP.TimeSpan(null,this.getHours(), this.getMinutes(), this.getSeconds()); };Number.prototype.toPaddedString=function(length, character){character=character||"0";var text=this.toString();while(text.length < length)text=character + text;return text;};BDP.TimePicker.prototype.isNumeric=function(value){var digits="1234567890";for (var i=0; i < value.length; i++){if (digits.indexOf(value.charAt(i))==-1){return false; }}return true;};if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();