/*
 =======================================================================*\
|| ###################################################################### ||
|| # vBulletin 6.2.3
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2026 MH Sub I, LLC dba vBulletin. All Rights Reserved.  # ||
|| # This file may not be redistributed in whole or significant part.   # ||
|| # ----------------- VBULLETIN IS NOT FREE SOFTWARE ----------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html   # ||
|| ###################################################################### ||
\*========================================================================*/
var default_weekday=0,default_day_names="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),default_month_names="January February March April May June July August September October November December".split(" ");vBulletin.events.systemInit.subscribe(function(){if(vBulletin.elements.vB_DatePicker){for(var a=0;a<vBulletin.elements.vB_DatePicker.length;a++){var b=vBulletin.elements.vB_DatePicker[a];new vB_DatePicker(b[0],b[1],b[2])}vBulletin.elements.vB_DatePicker=null}});
function vB_DatePicker(a,b,c){var d=b.match(/^(\d+),?(\w*)$/);d&&(c=d[1],b=d[2],console.log("vB_DatePicker '%s' :: Week start day '%s', Base name '%s'",b,c,b));this.button_sibling=document.getElementById(a);this.base_id=b;if(!this.button_sibling)return console.error("vB_DatePicker '%s' :: Button sibling missing",this.base_id),!1;this.datestring=document.getElementById(this.base_id+"datestring");if(!(this.datestring||(this.month_element=document.getElementById(this.base_id+"month"),this.date_element=
document.getElementById(this.base_id+"date"),this.year_element=document.getElementById(this.base_id+"year"),this.month_element&&this.date_element&&this.year_element)))return console.error("vB_DatePicker '%s' :: Form elements missing",this.base_id),!1;this.selected_date=this.read_input();this.current_month=new Date(this.selected_date);this.current_month.setFullYear(this.selected_date.getFullYear(),this.selected_date.getMonth(),1);a=new Date;this.today=new Date(0);this.today.setFullYear(a.getFullYear(),
a.getMonth(),a.getDate());this.today.setHours(0,0,0);c=(parseInt(c)-1)%7;0>c&&(c=0);for(this.userweek=[];7>this.userweek.length;)this.userweek[this.userweek.length]=c++,7<=c&&(c=default_weekday);this.daynames="undefined"!=typeof vbphrase.sunday?[vbphrase.sunday,vbphrase.monday,vbphrase.tuesday,vbphrase.wednesday,vbphrase.thursday,vbphrase.friday,vbphrase.saturday]:default_day_names;if("undefined"!=typeof vbphrase.january)this.monthnames=[vbphrase.january,vbphrase.february,vbphrase.march,vbphrase.april,
vbphrase.may,vbphrase.june,vbphrase.july,vbphrase.august,vbphrase.september,vbphrase.october,vbphrase.november,vbphrase.december];else if(!this.datestring&&this.month_element)for(this.monthnames=[],c=0;c<this.month_element.options.length;c++)1<=this.month_element.options[c].value&&12>=this.month_element.options[c].value&&(this.monthnames[this.month_element.options[c].value-1]=this.month_element.options[c].text);else this.monthnames=default_month_names;this.button_sibling&&($(document).on("click",
$.proxy(this.close_popup,this)),$(window).on("resize",$.proxy(this.close_popup,this)),this.button=this.button_sibling.parentNode.insertBefore(document.createElement("a"),this.button_sibling.nextSibling),this.button.href="#",this.buttonimg=this.button.appendChild(document.createElement("img")),this.buttonimg.src=IMGDIR_MISC+"/calendar_popup.png",this.buttonimg.style.verticalAlign="bottom",this.buttonimg.border="0",$(this.button).on("click",$.proxy(this.toggle_calendar,this)),this.popup=this.button_sibling.parentNode.appendChild(document.createElement("div")),
this.popup.style.position="absolute",this.popup.style.display="none",this.popup_state=!1,this.build_calendar());this.original_date=this.read_input();this.original_time=this.get_input_time();c=document.getElementById(this.base_id+"insert_now");$(c).on("click",$.proxy(this.handle_insert_now,this));c=document.getElementById(this.base_id+"clear");$(c).on("click",$.proxy(this.handle_clear,this));c=document.getElementById(this.base_id+"reset");$(c).on("click",$.proxy(this.handle_reset,this))}
vB_DatePicker.prototype.handle_insert_now=function(a){a.preventDefault();a.stopPropagation();this.set_today();a=new Date;this.set_input_time(a.getHours(),a.getMinutes())};vB_DatePicker.prototype.handle_clear=function(a){a.preventDefault();a.stopPropagation();this.month_element.selectedIndex=0;this.date_element.value="";this.year_element.value="";this.set_input_time("","")};
vB_DatePicker.prototype.handle_reset=function(a){a.preventDefault();a.stopPropagation();this.select_date(this.original_date);this.set_input_time(this.original_time.hour,this.original_time.minute)};vB_DatePicker.prototype.get_input_time=function(){var a=document.getElementById(this.base_id+"hour"),b=document.getElementById(this.base_id+"minute"),c={hour:0,minute:0};a&&(c.hour=a.value);b&&(c.minute=b.value);return c};
vB_DatePicker.prototype.set_input_time=function(a,b){var c=document.getElementById(this.base_id+"hour"),d=document.getElementById(this.base_id+"minute");c&&(c.value=a);d&&(""!==b&&(b=parseInt(b,10),b=10>b?"0"+b:b),d.value=b)};
vB_DatePicker.prototype.build_calendar=function(){this.table&&this.table.parentNode&&this.table.parentNode.removeChild(this.table);var a=document.createElement("span");a.className="vB_DatePicker page";a.innerHTML="&nbsp;";this.button_sibling.parentNode.appendChild(a);var b=$(a).css("backgroundColor"),c=$(a).css("color");a.parentNode.removeChild(a);this.table=document.createElement("table");this.table.cellSpacing=1;this.table.className="tborder vB_DatePicker page";this.table.style.background=b;a=this.table.appendChild(document.createElement("thead"));
b=a.appendChild(document.createElement("tr"));var d=b.appendChild(document.createElement("th"));this.tabletitle=b.appendChild(document.createElement("th"));var e=b.appendChild(document.createElement("th"));b.align="center";this.tabletitle.className="tcat smallfont";this.tabletitle.colSpan=5;this.tabletitle.innerHTML="&nbsp;";d.className="tcat smallfont";d.innerHTML="&lt;";d.style.cursor="pointer";d.increment=-1;$(d).on("click",$.proxy(this.change_month,this));e.className="tcat smallfont";e.innerHTML=
"&gt;";e.style.cursor="pointer";e.increment=1;$(e).on("click",$.proxy(this.change_month,this));b=a.appendChild(document.createElement("tr"));b.align="center";b.className="page smallfont";for(var f in this.userweek)this.userweek.hasOwnProperty(f)&&(d=b.appendChild(document.createElement("td")),d.className="smallfont",d.appendChild(document.createTextNode(this.daynames[this.userweek[f]].substring(0,1))));b=a.appendChild(document.createElement("tr"));d=b.appendChild(document.createElement("td"));d.colSpan=
7;d.className="page";f=d.appendChild(document.createElement("div"));f.style.background=c;f.appendChild(document.createElement("img")).src=getBaseUrl()+"images/clear.gif";this.tbody=this.table.appendChild(document.createElement("tbody"));this.draw_date_cells(this.selected_date.getMonth()+1,this.selected_date.getFullYear());this.popup.appendChild(this.table)};
vB_DatePicker.prototype.draw_date_cells=function(a,b){this.current_month=new Date(0);this.current_month.setFullYear(b,a-1,1);for(this.tabletitle.innerHTML=this.monthnames[this.current_month.getMonth()]+" "+this.current_month.getFullYear();this.tbody.hasChildNodes();)this.tbody.removeChild(this.tbody.firstChild);a=this.current_month.getDay();b=0;for(var c in this.userweek)if(this.userweek.hasOwnProperty(c))if(a==this.userweek[c])break;else b++;a=new Date(0);a.setFullYear(this.current_month.getFullYear(),
this.current_month.getMonth(),1-b);for(b=0;6>b;b++){var d=this.tbody.appendChild(document.createElement("tr"));d.align="center";for(c in this.userweek)if(this.userweek.hasOwnProperty(c)){var e=d.appendChild(document.createElement("td"));e.innerHTML=(10>a.getDate()?"&nbsp;":"")+a.getDate();e.dateobj=new Date(a);e.title=e.dateobj.toString();e.style.cursor="pointer";$(e).on("click",$.proxy(this.date_click,this));$(e).on("mouseover mouseout",$.proxy(this.date_mouseover,this));a.setDate(a.getDate()+1);
a.setHours(0,0,0)}}this.apply_date_classes()};vB_DatePicker.prototype.apply_date_classes=function(){for(var a=this.tbody.getElementsByTagName("td"),b=0;b<a.length;b++)a[b].dateobj.valueOf()==this.selected_date.valueOf()?a[b].className="tfoot smallfont":a[b].dateobj.getMonth()==this.current_month.getMonth()?a[b].className="smallfont":a[b].className="time smallfont",a[b].dateobj.valueOf()==this.today.valueOf()&&(a[b].className+=" today")};
vB_DatePicker.prototype.select_date=function(a){this.selected_date=new Date(a);a.getMonth()!=this.current_month.getMonth()||a.getFullYear()!=this.current_month.getFullYear()?this.draw_date_cells(this.selected_date.getMonth()+1,this.selected_date.getFullYear()):this.apply_date_classes();this.set_input()};
vB_DatePicker.prototype.read_input=function(){var a=!1;if(this.datestring)var b=Date.parse(this.datestring.value);else 100>this.year_element.value&&(b=1900+Math.abs(parseInt(this.year_element.value,10)),isNaN(b)||(this.year_element.value=b)),b=new Date(0),a=b.setFullYear(parseInt(this.year_element.value),parseInt(this.month_element.value)-1,parseInt(this.date_element.value)).valueOf(),a=!isNaN(a);return a?new Date(b):this.selected_date?this.selected_date:new Date};
vB_DatePicker.prototype.set_input=function(){if(this.datestring){var a=this.selected_date.getMonth()+1;10>a&&(a="0"+a);var b=this.selected_date.getDate();10>b&&(b="0"+b);this.datestring.value=this.selected_date.getFullYear()+"/"+a+"/"+b}else if(this.month_element.value=this.selected_date.getMonth()+1,this.date_element.value=this.selected_date.getDate(),"SELECT"==this.year_element.tagName){a=this.selected_date.getFullYear();for(b=0;b<this.year_element.options.length;b++)if(this.year_element.options[b].value==
a){this.year_element.selectedIndex=b;return}b=this.year_element.appendChild(document.createElement("option"));b.value=a;b.appendChild(document.createTextNode(a));this.year_element.selectedIndex=this.year_element.options.length-1}else this.year_element.value=this.selected_date.getFullYear()};
vB_DatePicker.prototype.open_popup=function(){this.selected_date=this.read_input();this.select_date(this.selected_date);this.popup.style.zIndex=1E3;this.popup.style.display="block";var a=$(this.button_sibling).offset(),b=a.top+this.button_sibling.offsetHeight;a="ltr"==document.getElementsByTagName("html")[0].getAttribute("dir").toLowerCase()?a.left-this.popup.offsetWidth+this.button_sibling.offsetWidth+this.button.offsetWidth:a.left-this.button.offsetWidth;$(this.popup).css({left:a,top:b});this.popup_state=
!0};vB_DatePicker.prototype.close_popup=function(){this.popup.style.display="none";this.popup_state=!1};vB_DatePicker.prototype.toggle_calendar=function(a){a.preventDefault();a.stopPropagation();this.popup_state?this.close_popup():this.open_popup()};vB_DatePicker.prototype.change_month=function(a){a.preventDefault();a.stopPropagation();this.draw_date_cells(this.current_month.getMonth()+a.target.increment+1,this.current_month.getFullYear())};
vB_DatePicker.prototype.date_click=function(a){a.preventDefault();a.stopPropagation();this.select_date(a.target.dateobj);this.close_popup();this.button_sibling.focus();try{this.button_sibling.select()}catch(b){}};vB_DatePicker.prototype.date_mouseover=function(a){var b=a.target;"mouseover"==a.type?$(b).addClass("datepicker-selected"):$(b).removeClass("datepicker-selected")};vB_DatePicker.prototype.set_today=function(a){this.select_date(this.today)};vB_DatePicker.prototype.fetch_offset=function(a){return $(a).offset()};
