// ------------------------------- mouse wheel scrolling -----------------------------------

function scrollText(e) {
   var evt=window.event || e;
   var delta=evt.detail ?evt.detail :evt.wheelDelta*-1;
    
   if (delta>0) delta=1;
   else delta=-1;
   
   if (_el("solveEntryInputDateBoxDay").style.fontWeight=="bold") _changeInputDate(0,0,delta,0,0);
   if (_el("solveEntryInputDateBoxMonth").style.fontWeight=="bold") _changeInputDate(0,delta,0,0,0);
   if (_el("solveEntryInputDateBoxHour").style.fontWeight=="bold") _changeInputDate(0,0,0,delta,0);
   if (_el("solveEntryInputDateBoxMin").style.fontWeight=="bold") _changeInputDate(0,0,0,0,delta);
   _displayDate();
    
   if (evt.preventDefault) evt.preventDefault();
   else return false;
}

function _changeInputDate(modY,modM,modD,modHour,modMin) {
   //if (modHour!=0 || modMin!=0) alert("time");
   var dStr=inputDate.toString();
   var year=_int(dStr.slice(11,15));
   var month=_convertMonthToNumber(dStr.slice(4,7));
   var day=_int(dStr.slice(8,10));
   var hour=_int(dStr.slice(16,18));
   var min=_int(dStr.slice(19,21));
   inputDate.setFullYear(year+modY,month+modM,day+modD);
   if (modHour!=0 || modMin!=0) inputDate.setHours(hour+modHour,min+modMin);
}

function _convertMonthToNumber(monStr) {
   var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
   var month=-1;
   for (var i=0;i<12;i++) {
      if (monStr==months[i]) month=i;
   }
   return month;
}

// ----------- set up ------------
var solveDateBoxEl=_el("solveEntryInputDateBoxDay");
var mousewheelevt=(/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel";
if (solveDateBoxEl.attachEvent) solveDateBoxEl.attachEvent("on"+mousewheelevt, scrollText);
else if (solveDateBoxEl.addEventListener) solveDateBoxEl.addEventListener(mousewheelevt, scrollText, false);

solveDateBoxEl=_el("solveEntryInputDateBoxMonth");
mousewheelevt=(/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel";
if (solveDateBoxEl.attachEvent) solveDateBoxEl.attachEvent("on"+mousewheelevt, scrollText);
else if (solveDateBoxEl.addEventListener) solveDateBoxEl.addEventListener(mousewheelevt, scrollText, false);

solveDateBoxEl=_el("solveEntryInputDateBoxHour");
mousewheelevt=(/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel";
if (solveDateBoxEl.attachEvent) solveDateBoxEl.attachEvent("on"+mousewheelevt, scrollText);
else if (solveDateBoxEl.addEventListener) solveDateBoxEl.addEventListener(mousewheelevt, scrollText, false);

solveDateBoxEl=_el("solveEntryInputDateBoxMin");
mousewheelevt=(/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel";
if (solveDateBoxEl.attachEvent) solveDateBoxEl.attachEvent("on"+mousewheelevt, scrollText);
else if (solveDateBoxEl.addEventListener) solveDateBoxEl.addEventListener(mousewheelevt, scrollText, false);