/*http://kelvinluck.com/assets/jquery/datePicker/v2/demo/date.js*/
Date.dayNames=['Domingo','Lunes','Martes','Miércoles','Jueves','Viernes','Sábado'];
Date.abbrDayNames=['Dom','Lun','Mar','Mie','Jue','Vie','Sab'];
Date.monthNames=['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'];
Date.abbrMonthNames=['Ene','Feb','Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic'];
Date.firstDayOfWeek=1;
Date.format='dd/mm/yyyy';
(function(){function add(a,b){if(!Date.prototype[a]){Date.prototype[a]=b}};add("isLeapYear",function(){var y=this.getFullYear();return(y%4==0&&y%100!=0)||y%400==0});add("isWeekend",function(){return this.getDay()==0||this.getDay()==6});add("isWeekDay",function(){return!this.isWeekend()});add("getDaysInMonth",function(){return[31,(this.isLeapYear()?29:28),31,30,31,30,31,31,30,31,30,31][this.getMonth()]});add("getDayName",function(a){return a?Date.abbrDayNames[this.getDay()]:Date.dayNames[this.getDay()]});add("getMonthName",function(a){return a?Date.abbrMonthNames[this.getMonth()]:Date.monthNames[this.getMonth()]});add("getDayOfYear",function(){var a=new Date("1/1/"+this.getFullYear());return Math.floor((this.getTime()-a.getTime())/86400000)});add("getWeekOfYear",function(){return Math.ceil(this.getDayOfYear()/7)});add("setDayOfYear",function(a){this.setMonth(0);this.setDate(a);return this});add("addYears",function(a){this.setFullYear(this.getFullYear()+a);return this});add("addMonths",function(a){var b=this.getDate();this.setMonth(this.getMonth()+a);if(b>this.getDate())this.addDays(-this.getDate());return this});add("addDays",function(a){this.setDate(this.getDate()+a);return this});add("addHours",function(a){this.setHours(this.getHours()+a);return this});add("addMinutes",function(a){this.setMinutes(this.getMinutes()+a);return this});add("addSeconds",function(a){this.setSeconds(this.getSeconds()+a);return this});add("zeroTime",function(){this.setMilliseconds(0);this.setSeconds(0);this.setMinutes(0);this.setHours(0);return this});add("asString",function(){var r=Date.format;return r.split('yyyy').join(this.getFullYear()).split('yy').join(this.getYear()).split('mmm').join(this.getMonthName(true)).split('mm').join(e(this.getMonth()+1)).split('dd').join(e(this.getDate()))});Date.fromString=function(s){var f=Date.format;var d=new Date('01/01/1977');var a=f.indexOf('yyyy');if(a>-1){d.setFullYear(Number(s.substr(a,4)))}else{d.setYear(Number(s.substr(f.indexOf('yy'),2)))}var b=f.indexOf('mmm');if(b>-1){var c=s.substr(b,3);for(var i=0;i<Date.abbrMonthNames.length;i++){if(Date.abbrMonthNames[i]==c)break}d.setMonth(i)}else{d.setMonth(Number(s.substr(f.indexOf('mm'),2))-1)}d.setDate(Number(s.substr(f.indexOf('dd'),2)));if(isNaN(d.getTime()))return false;return d;};var e=function(a){var s='0'+a;return s.substring(s.length-2)}})();

/* http://kelvinluck.com/assets/jquery/datePicker/v2/demo/dimensions.js */
jQuery.fn._height=jQuery.fn.height;jQuery.fn._width=jQuery.fn.width;jQuery.fn.height=function(){if(this[0]==window)return self.innerHeight||jQuery.boxModel&&document.documentElement.clientHeight||document.body.clientHeight;if(this[0]==document)return Math.max(document.body.scrollHeight,document.body.offsetHeight);return this._height(arguments[0])};jQuery.fn.width=function(){if(this[0]==window)return self.innerWidth||jQuery.boxModel&&document.documentElement.clientWidth||document.body.clientWidth;if(this[0]==document)return Math.max(document.body.scrollWidth,document.body.offsetWidth);return this._width(arguments[0])};jQuery.fn.innerHeight=function(){return this[0]==window||this[0]==document?this.height():this.css('display')!='none'?this[0].offsetHeight-(parseInt(this.css("borderTopWidth"))||0)-(parseInt(this.css("borderBottomWidth"))||0):this.height()+(parseInt(this.css("paddingTop"))||0)+(parseInt(this.css("paddingBottom"))||0)};jQuery.fn.innerWidth=function(){return this[0]==window||this[0]==document?this.width():this.css('display')!='none'?this[0].offsetWidth-(parseInt(this.css("borderLeftWidth"))||0)-(parseInt(this.css("borderRightWidth"))||0):this.height()+(parseInt(this.css("paddingLeft"))||0)+(parseInt(this.css("paddingRight"))||0)};jQuery.fn.outerHeight=function(){return this[0]==window||this[0]==document?this.height():this.css('display')!='none'?this[0].offsetHeight:this.height()+(parseInt(this.css("borderTopWidth"))||0)+(parseInt(this.css("borderBottomWidth"))||0)+(parseInt(this.css("paddingTop"))||0)+(parseInt(this.css("paddingBottom"))||0)};jQuery.fn.outerWidth=function(){return this[0]==window||this[0]==document?this.width():this.css('display')!='none'?this[0].offsetWidth:this.height()+(parseInt(this.css("borderLeftWidth"))||0)+(parseInt(this.css("borderRightWidth"))||0)+(parseInt(this.css("paddingLeft"))||0)+(parseInt(this.css("paddingRight"))||0)};jQuery.fn.scrollLeft=function(){if(this[0]==window||this[0]==document)return self.pageXOffset||jQuery.boxModel&&document.documentElement.scrollLeft||document.body.scrollLeft;return this[0].scrollLeft};jQuery.fn.scrollTop=function(){if(this[0]==window||this[0]==document)return self.pageYOffset||jQuery.boxModel&&document.documentElement.scrollTop||document.body.scrollTop;return this[0].scrollTop};jQuery.fn.offset=function(a,b){var x=0,y=0,elem=this[0],parent=this[0],absparent=false,relparent=false,op,sl=0,st=0,a=jQuery.extend({margin:true,border:true,padding:false,scroll:true},a||{});do{x+=parent.offsetLeft||0;y+=parent.offsetTop||0;if(jQuery.browser.mozilla||jQuery.browser.msie){var c=parseInt(jQuery.css(parent,'borderTopWidth'))||0;var d=parseInt(jQuery.css(parent,'borderLeftWidth'))||0;x+=d;y+=c;if(jQuery.browser.mozilla&&parent!=elem&&jQuery.css(parent,'overflow')!='visible'){x+=d;y+=c}if(jQuery.css(parent,'position')=='absolute')absparent=true;if(jQuery.css(parent,'position')=='relative')relparent=true}if(a.scroll){op=parent.offsetParent;do{sl+=parent.scrollLeft||0;st+=parent.scrollTop||0;parent=parent.parentNode;if(jQuery.browser.mozilla&&parent!=elem&&parent!=op&&jQuery.css(parent,'overflow')!='visible'){x+=parseInt(jQuery.css(parent,'borderLeftWidth'))||0;y+=parseInt(jQuery.css(parent,'borderTopWidth'))||0}}while(op&&parent!=op)}else parent=parent.offsetParent;if(parent&&(parent.tagName.toLowerCase()=='body'||parent.tagName.toLowerCase()=='html')){if((jQuery.browser.safari||(jQuery.browser.msie&&jQuery.boxModel))&&jQuery.css(elem,'position')!='absolute'){x+=parseInt(jQuery.css(parent,'marginLeft'))||0;y+=parseInt(jQuery.css(parent,'marginTop'))||0}if((jQuery.browser.mozilla&&!absparent)||(jQuery.browser.msie&&jQuery.css(elem,'position')=='static'&&(!relparent||!absparent))){x+=parseInt(jQuery.css(parent,'borderLeftWidth'))||0;y+=parseInt(jQuery.css(parent,'borderTopWidth'))||0}break}}while(parent);if(!a.margin){x-=parseInt(jQuery.css(elem,'marginLeft'))||0;y-=parseInt(jQuery.css(elem,'marginTop'))||0}if(a.border&&(jQuery.browser.safari||jQuery.browser.opera)){x+=parseInt(jQuery.css(elem,'borderLeftWidth'))||0;y+=parseInt(jQuery.css(elem,'borderTopWidth'))||0}else if(!a.border&&!(jQuery.browser.safari||jQuery.browser.opera)){x-=parseInt(jQuery.css(elem,'borderLeftWidth'))||0;y-=parseInt(jQuery.css(elem,'borderTopWidth'))||0}if(a.padding){x+=parseInt(jQuery.css(elem,'paddingLeft'))||0;y+=parseInt(jQuery.css(elem,'paddingTop'))||0}if(a.scroll&&jQuery.browser.opera&&jQuery.css(elem,'display')=='inline'){sl-=elem.scrollLeft||0;st-=elem.scrollTop||0}var e=a.scroll?{top:y-st,left:x-sl,scrollTop:st,scrollLeft:sl}:{top:y,left:x};if(b){jQuery.extend(b,e);return this}else{return e}};

/*http://kelvinluck.com/assets/jquery/datePicker/v2/jquery.datePicker.js*/
(function($){$.fn.extend({renderCalendar:function(s){var b=function(a){return document.createElement(a)};s=$.extend({month:null,year:null,renderCallback:null,showHeader:$.dpConst.SHOW_HEADER_SHORT,dpController:null,hoverClass:'dp-hover'},s);if(s.showHeader!=$.dpConst.SHOW_HEADER_NONE){var c=$(b('tr'));for(var i=Date.firstDayOfWeek;i<Date.firstDayOfWeek+7;i++){var e=i%7;var f=Date.dayNames[e];c.append(jQuery(b('th')).attr({'scope':'col','abbr':f,'title':f,'class':(e==0||e==6?'weekend':'weekday')}).html(s.showHeader==$.dpConst.SHOW_HEADER_SHORT?f.substr(0,1):f))}};var g=$(b('table')).attr({'cellspacing':2,'className':'jCalendar'}).append((s.showHeader!=$.dpConst.SHOW_HEADER_NONE?$(b('thead')).append(c):b('thead')));var h=$(b('tbody'));var j=(new Date()).zeroTime();var k=s.month==undefined?j.getMonth():s.month;var l=s.year||j.getFullYear();var m=new Date(l,k,1);var n=Date.firstDayOfWeek-m.getDay()+1;if(n>1)n-=7;m.addDays(n-1);var o=function(){if(s.hoverClass){$(this).addClass(s.hoverClass)}};var p=function(){if(s.hoverClass){$(this).removeClass(s.hoverClass)}};var w=0;while(w++<6){var r=jQuery(b('tr'));for(var i=0;i<7;i++){var q=m.getMonth()==k;var d=$(b('td')).text(m.getDate()+'').attr('className',(q?'current-month ':'other-month ')+(m.isWeekend()?'weekend ':'weekday ')+(q&&m.getTime()==j.getTime()?'today ':'')).hover(o,p);if(s.renderCallback){s.renderCallback(d,m,k,l)}r.append(d);m.addDays(1)}h.append(r)}g.append(h);return this.each(function(){$(this).empty().append(g)})},datePicker:function(s){if(!$.event._dpCache)$.event._dpCache=[];s=$.extend({month:undefined,year:undefined,startDate:undefined,endDate:undefined,renderCallback:[],createButton:true,showYearNavigation:true,closeOnSelect:true,displayClose:false,selectMultiple:false,clickInput:false,verticalPosition:$.dpConst.POS_TOP,horizontalPosition:$.dpConst.POS_LEFT,verticalOffset:0,horizontalOffset:0,hoverClass:'dp-hover'},s);return this.each(function(){var c=$(this);if(!this._dpId){this._dpId=$.event.guid++;$.event._dpCache[this._dpId]=new DatePicker(this)}var f=$.event._dpCache[this._dpId];f.init(s);if(s.createButton){f.button=$('<a href="#" class="dp-choose-date" title="'+$.dpText.TEXT_CHOOSE_DATE+'">'+$.dpText.TEXT_CHOOSE_DATE+'</a>').bind('click',function(){c.dpDisplay(this);this.blur();return false});c.after(f.button)}if(c.is(':text')){c.bind('dateSelected',function(e,a,b){this.value=a.asString()}).bind('change',function(){var d=Date.fromString(this.value);if(d){f.setSelected(d,true,true)}});if(s.clickInput){c.bind('click',function(){c.dpDisplay()})}}c.addClass('dp-applied')})},dpSetDisabled:function(s){return u.call(this,'setDisabled',s)},dpSetStartDate:function(d){return u.call(this,'setStartDate',d)},dpSetEndDate:function(d){return u.call(this,'setEndDate',d)},dpGetSelected:function(){var c=_getController(this[0]);if(c){return c.getSelected()}return null},dpSetSelected:function(d,v,m){if(v==undefined)v=true;if(m==undefined)m=true;return u.call(this,'setSelected',Date.fromString(d),v,m)},dpSetDisplayedMonth:function(m,y){return u.call(this,'setDisplayedMonth',Number(m),Number(y))},dpDisplay:function(e){return u.call(this,'display',e)},dpSetRenderCallback:function(a){return u.call(this,'setRenderCallback',a)},dpSetPosition:function(v,h){return u.call(this,'setPosition',v,h)},dpSetOffset:function(v,h){return u.call(this,'setOffset',v,h)},_dpDestroy:function(){}});var u=function(f,a,b,d){return this.each(function(){var c=_getController(this);if(c){c[f](a,b,d)}})};function DatePicker(a){this.ele=a;this.displayedMonth=null;this.displayedYear=null;this.startDate=null;this.endDate=null;this.showYearNavigation=null;this.closeOnSelect=null;this.displayClose=null;this.selectMultiple=null;this.verticalPosition=null;this.horizontalPosition=null;this.verticalOffset=null;this.horizontalOffset=null;this.button=null;this.renderCallback=[];this.selectedDates={}};$.extend(DatePicker.prototype,{init:function(s){this.setStartDate(s.startDate);this.setEndDate(s.endDate);this.setDisplayedMonth(Number(s.month),Number(s.year));this.setRenderCallback(s.renderCallback);this.showYearNavigation=s.showYearNavigation;this.closeOnSelect=s.closeOnSelect;this.displayClose=s.displayClose;this.selectMultiple=s.selectMultiple;this.verticalPosition=s.verticalPosition;this.horizontalPosition=s.horizontalPosition;this.hoverClass=s.hoverClass;this.setOffset(s.verticalOffset,s.horizontalOffset)},setStartDate:function(d){if(d){this.startDate=Date.fromString(d)}if(!this.startDate){this.startDate=(new Date()).zeroTime()}this.setDisplayedMonth(this.displayedMonth,this.displayedYear)},setEndDate:function(d){if(d){this.endDate=Date.fromString(d)}if(!this.endDate){this.endDate=(new Date('12/31/2999'))}if(this.endDate.getTime()<this.startDate.getTime()){this.endDate=this.startDate}this.setDisplayedMonth(this.displayedMonth,this.displayedYear)},setPosition:function(v,h){this.verticalPosition=v;this.horizontalPosition=h},setOffset:function(v,h){this.verticalOffset=parseInt(v)||0;this.horizontalOffset=parseInt(h)||0},setDisabled:function(s){$e=$(this.ele);$e[s?'addClass':'removeClass']('dp-disabled');if(this.button){$but=$(this.button);$but[s?'addClass':'removeClass']('dp-disabled');$but.attr('title',s?'':$.dpText.TEXT_CHOOSE_DATE)}if($e.is(':text')){$e.attr('disabled',s?'disabled':'')}},setDisplayedMonth:function(m,y){if(this.startDate==undefined||this.endDate==undefined){return}var s=new Date(this.startDate.getTime());s.setDate(1);var e=new Date(this.endDate.getTime());e.setDate(1);var t;if(isNaN(m)&&isNaN(y)){t=new Date().zeroTime();t.setDate(1)}else if(isNaN(m)){t=new Date(y,this.displayedMonth,1)}else if(isNaN(y)){t=new Date(this.displayedYear,m,1)}else{t=new Date(y,m,1)}if(t.getTime()<s.getTime()){t=s}else if(t.getTime()>e.getTime()){t=e}this.displayedMonth=t.getMonth();this.displayedYear=t.getFullYear()},setSelected:function(d,v,a){if(this.selectMultiple==false){this.selectedDates={}}if(a){this.setDisplayedMonth(d.getMonth(),d.getFullYear())}this.selectedDates[d.getTime()]=v},isSelected:function(t){return this.selectedDates[t]},getSelected:function(){var r=[];for(t in this.selectedDates){if(this.selectedDates[t]==true){r.push(new Date(Number(t)))}}return r},display:function(d){if($(this.ele).is('.dp-disabled'))return;d=d||this.ele;var c=this;var f=$(d);var g=f.offset();var h=function(e){var a=e.target;var b=$('#dp-popup')[0];while(true){if(a==b){return true}else if(a==document){c._closeCalendar();return false}else{a=$(a).parent()[0]}}};this._checkMouse=h;this._closeCalendar(true);$('body').append($('<div></div>').attr('id','dp-popup').css({'top':g.top+c.verticalOffset,'left':g.left+c.horizontalOffset}).append($('<h2></h2>'),$('<div id="dp-nav-prev"></div>').append($('<a id="dp-nav-prev-year" href="#" title="'+$.dpText.TEXT_PREV_YEAR+'">&lt;&lt;</a>').bind('click',function(){return c._displayNewMonth.call(c,this,0,-1)}),$('<a id="dp-nav-prev-month" href="#" title="'+$.dpText.TEXT_PREV_MONTH+'">&lt;</a>').bind('click',function(){return c._displayNewMonth.call(c,this,-1,0)})),$('<div id="dp-nav-next"></div>').append($('<a id="dp-nav-next-year" href="#" title="'+$.dpText.TEXT_NEXT_YEAR+'">&gt;&gt;</a>').bind('click',function(){return c._displayNewMonth.call(c,this,0,1)}),$('<a id="dp-nav-next-month" href="#" title="'+$.dpText.TEXT_NEXT_MONTH+'">&gt;</a>').bind('click',function(){return c._displayNewMonth.call(c,this,1,0)})),$('<div></div>').attr('id','dp-calendar')).bgIframe());var i=$('#dp-popup');if(this.showYearNavigation==false){$('#dp-nav-prev-year, #dp-nav-next-year').css('display','none')}if(this.displayClose){i.append($('<a href="#" id="dp-close">'+$.dpText.TEXT_CLOSE+'</a>').bind('click',function(){c._closeCalendar();return false}))}c._renderCalendar();if(this.verticalPosition==$.dpConst.POS_BOTTOM){i.css('top',g.top+f.height()-i.height()+c.verticalOffset)}if(this.horizontalPosition==$.dpConst.POS_RIGHT){i.css('left',g.left+f.width()-i.width()+c.horizontalOffset)}$(this.ele).trigger('dpDisplayed',i);$(document).bind('mousedown',this._checkMouse)},setRenderCallback:function(a){if(a&&typeof(a)=='function'){a=[a]}this.renderCallback=this.renderCallback.concat(a)},cellRender:function(b,e,f,g){var c=this.dpController;var d=new Date(e.getTime());b.bind('click',function(){var a=$(this);if(!a.is('.disabled')){c.setSelected(d,!a.is('.selected')||!c.selectMultiple);var s=c.isSelected(d.getTime());$(c.ele).trigger('dateSelected',[d,b,s]);if(c.closeOnSelect){c._closeCalendar()}else{a[s?'addClass':'removeClass']('selected')}}});if(c.isSelected(d.getTime())){b.addClass('selected')}for(var i=0;i<c.renderCallback.length;i++){c.renderCallback[i].apply(this,arguments)}},_displayNewMonth:function(a,m,y){if(!$(a).is('.disabled')){this.setDisplayedMonth(this.displayedMonth+m,this.displayedYear+y);this._clearCalendar();this._renderCalendar();$(this.ele).trigger('dpMonthChanged',[this.displayedMonth,this.displayedYear])}a.blur();return false},_renderCalendar:function(){$('#dp-popup h2').html(Date.monthNames[this.displayedMonth]+' '+this.displayedYear);$('#dp-calendar').renderCalendar({month:this.displayedMonth,year:this.displayedYear,renderCallback:this.cellRender,dpController:this,hoverClass:this.hoverClass});if(this.displayedYear==this.startDate.getFullYear()&&this.displayedMonth==this.startDate.getMonth()){$('#dp-nav-prev-year').addClass('disabled');$('#dp-nav-prev-month').addClass('disabled');$('#dp-calendar td.other-month').each(function(){var a=$(this);if(Number(a.text())>20){a.addClass('disabled')}});var d=this.startDate.getDate();$('#dp-calendar td.current-month').each(function(){var a=$(this);if(Number(a.text())<d){a.addClass('disabled')}})}else{$('#dp-nav-prev-year').removeClass('disabled');$('#dp-nav-prev-month').removeClass('disabled');var d=this.startDate.getDate();if(d>20){var b=new Date(this.startDate.getTime());b.addMonths(1);if(this.displayedYear==b.getFullYear()&&this.displayedMonth==b.getMonth()){$('#dp-calendar td.other-month').each(function(){var a=$(this);if(Number(a.text())<d){a.addClass('disabled')}})}}}if(this.displayedYear==this.endDate.getFullYear()&&this.displayedMonth==this.endDate.getMonth()){$('#dp-nav-next-year').addClass('disabled');$('#dp-nav-next-month').addClass('disabled');$('#dp-calendar td.other-month').each(function(){var a=$(this);if(Number(a.text())<14){a.addClass('disabled')}});var d=this.endDate.getDate();$('#dp-calendar td.current-month').each(function(){var a=$(this);if(Number(a.text())>d){a.addClass('disabled')}})}else{$('#dp-nav-next-year').removeClass('disabled');$('#dp-nav-next-month').removeClass('disabled');var d=this.endDate.getDate();if(d<13){var c=new Date(this.endDate.getTime());c.addMonths(-1);if(this.displayedYear==c.getFullYear()&&this.displayedMonth==c.getMonth()){$('#dp-calendar td.other-month').each(function(){var a=$(this);if(Number(a.text())>d){a.addClass('disabled')}})}}}},_closeCalendar:function(a){$(document).unbind('mousedown',this._checkMouse);this._clearCalendar();$('#dp-popup a').unbind();$('#dp-popup').empty().remove();if(!a){$(this.ele).trigger('dpClosed',[this.getSelected()])}},_clearCalendar:function(){$('#dp-calendar td').unbind();$('#dp-calendar').empty()}});$.dpConst={SHOW_HEADER_NONE:0,SHOW_HEADER_SHORT:1,SHOW_HEADER_LONG:2,POS_TOP:0,POS_BOTTOM:1,POS_LEFT:0,POS_RIGHT:1};$.dpText={TEXT_PREV_YEAR:'Previous year',TEXT_PREV_MONTH:'Previous month',TEXT_NEXT_YEAR:'Next year',TEXT_NEXT_MONTH:'Next month',TEXT_CLOSE:'Close',TEXT_CHOOSE_DATE:'Choose date'};$.dpVersion='$Id: jquery.datePicker.js 2036 2007-06-05 22:55:15Z kelvin.luck $';function _getController(a){if(a._dpId)return $.event._dpCache[a._dpId];return false};if($.fn.bgIframe==undefined){$.fn.bgIframe=function(){return this}};$(window).bind('unload',function(){var a=$.event._dpCache||[];for(var i in a){$(a[i].ele)._dpDestroy()}})})(jQuery);

$.dpText = {
	TEXT_PREV_YEAR		:	'Año anterior',
	TEXT_PREV_MONTH		:	'Mes anterior',
	TEXT_NEXT_YEAR		:	'Año siguiente',
	TEXT_NEXT_MONTH		:	'Mes siguiente',
	TEXT_CLOSE			:	'Cerrar',
	TEXT_CHOOSE_DATE	:	'Escoger fecha'
}