// 080617 - 5:00pm || SBS - add extra padding if the popup is below the body height
function chkBrows(sInp) {
var sUA = navigator.userAgent.toLowerCase();
var bFound = sUA.indexOf(sInp) + 1;
return bFound;
}
/* css positioning functions for popups */
function FindDocW() {
return document.body.scrollWidth > document.body.offsetWidth ? document.body.scrollWidth : document.body.offsetWidth;
}
function FindDocH() {
return document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight;
}
function FindWinW() {
return self.innerWidth ? self.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body ? document.body.clientWidth : 0;
}
function FindWinH() {
return self.innerHeight ? self.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body ? document.body.clientHeight : 0;
}
function FindWinScrX() {
return self.pageXOffset ? self.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body ? document.body.scrollLeft : 0;
}
function FindWinScrY() {
return self.pageYOffset ? self.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body ? document.body.scrollTop : 0;
}
function FindPosX(oEl,iAdd) {
var x = String(iAdd) == 'undefined' ? 0 : iAdd;
if (oEl.offsetWidth) x += oEl.offsetWidth;
if (oEl.offsetParent) {
while (oEl.offsetParent) {
x += oEl.offsetLeft
oEl = oEl.offsetParent;
}
} else if (oEl.x) x += oEl.x;
return x;
}
function FindPosY(oEl,iAdd) {
var y = String(iAdd) == 'undefined' ? 0 : iAdd;
if (oEl.offsetHeight) y += oEl.offsetHeight;
if (oEl.offsetParent) {
while (oEl.offsetParent) {
y += oEl.offsetTop
oEl = oEl.offsetParent;
}
} else if (oEl.y) y += oEl.y;
return y;
}
function ShowDiv(soPos,soDiv,bShow,iXAdd,iYAdd,bXAddAbs,bYAddAbs) {
var adjXHid=0;
if (/tooltip/.test(soDiv) && document.getElementById(soDiv).parentNode.parentNode.parentNode.style.display=='none') {
adjXHid = 1;
soDiv = soDiv.substring(7,soDiv.length);
soDiv = parseInt(soDiv)+2000;
}
var xsDiv = null;
var ysDiv = null;
if (String(bShow) == 'undefined') bShow = true;
if (String(bXAddAbs) == 'undefined') bXAddAbs = false;
if (String(bYAddAbs) == 'undefined') bYAddAbs = false;
var oPos = typeof soPos == 'object' ? soPos : document.getElementById(soPos);
var oDiv = typeof soDiv == 'object' ? soDiv : document.getElementById(soDiv);
if (oDiv.className=='ptP' || oDiv.className=='plT') {
if (this.chkBrows('msie') && this.chkBrows('windows')) {
iYAdd=-47;
}
if (this.chkBrows('msie') && this.chkBrows('mac')) {
iYAdd=-346;
iXAdd=iXAdd-20;
}
}
var iBottom = FindWinScrY() + FindWinH();
var xsDiv = bXAddAbs ? iXAdd : FindPosX(oPos,iXAdd);
var ysDiv = bYAddAbs ? iYAdd : FindPosY(oPos,iYAdd);
if (/tooltip/.test(soDiv)) {
xsDiv=xsDiv-49;
if (this.chkBrows('msie') && this.chkBrows('mac')) {
xsDiv=xsDiv-1;
}
}
// jfy: prctlt1 & prctlt2 was the blue bar on top of the flight selection but it is being removed on 3.6
/*if (this.chkBrows('msie') && this.chkBrows('mac')) {
if (oDiv.id=='prctlt1' || oDiv.id=='prctlt2') {
ysDiv = ysDiv-50;
}
}
if (this.chkBrows('opera')) {
if (oDiv.id=='prctlt1' || oDiv.id=='prctlt2') {
ysDiv = ysDiv-5;
}
}*/
if (adjXHid==1) {
xsDiv = xsDiv-49;
}
oDiv.style.left = xsDiv + 'px';
oDiv.style.top = ysDiv + 'px';
$('.nochange').css('left', (xsDiv+127));
//BEGIN
if (bShow == false) {
if (document.getElementById('IframeTip0')) {
document.getElementById('IframeTip0').style.display = 'none';
}
if (document.getElementById('IframeTip1')) {
document.getElementById('IframeTip1').style.display = 'none';
}
} else {
if (chkBrows('msie') && chkBrows('windows')) {
if (chkBrows('opera')) {
// Nothing
} else {
for(iFlt=0;iFlt<2;iFlt++){
if (document.getElementById('IframeTip'+iFlt)) {
IfrRef=document.getElementById('IframeTip'+iFlt);
IfrRef.style.width = '147px';
IfrRef.style.top = oDiv.style.top;
IfrRef.style.left = oDiv.style.left
IfrRef.style.zIndex = '98';
IfrRef.style.display = "block";
}
}
}
}
}
// END
oDiv.style.display = bShow ? "block" : "none";
var iPopH = oDiv.offsetHeight ? oDiv.offsetHeight : 0;
if (document.getElementById('IframeTip0')) {
document.getElementById('IframeTip0').style.height=iPopH;
}
if (document.getElementById('IframeTip1')) {
document.getElementById('IframeTip1').style.height=iPopH;
}
if (this.chkBrows('msie') && this.chkBrows('mac_')) {
ysDiv = ysDiv-5;
oDiv.style.left = xsDiv + 'px';
oDiv.style.top = ysDiv + 'px';
}
if (ysDiv + iPopH > iBottom) {
ysDiv += (iBottom - ysDiv - iPopH);
oDiv.style.top = ysDiv + 'px';
}
if (document.getElementById('prctip')) {
if (oDiv.className=='ptP') {
//document.getElementById('prctip').innerHTML = "
"+sbstitl+"
"+prcPopVal+"
"+btnCode; // jfy: moved to shop.js in the uFare() because we took out the ShowDiv() from the radio button.
/* JFY: prctlt1 & prctlt2 was the blue bar on top of the flight selection but it is being removed on 3.6
document.getElementById('prctlt1').innerHTML = ""+sbstitl+""+prcPopVal+"";
document.getElementById('prctlt2').innerHTML = ""+sbstitl+""+prcPopVal+"";*/
}
}
// IE6- IFRAME - gFloatyPos is just on sbs - 080527
var oDivH = $("#"+oDiv.id+" .fiPopup").height();
if (typeof gFloatyPos != "undefined" && $.browser.msie && $.browser.version <= 6) {
var $oDiv = $("#"+oDiv.id+"");
var oDivW = $("#"+oDiv.id+" .fiPopup").width();
if (bShow == true) { // mouseover
$oDiv.append('');
} else { // mouseout
$("#"+oDiv.id+" .iframeBg").remove();
}
}
// SBS - add extra padding if the popup is below the body height
if (typeof gFloatyPos != "undefined") {
var bodyH = $("body").height();
var oDivY = getCoords(oDiv.id, 'y');
oDivY = oDivY + oDivH;
if (bodyH < oDivY) {
var bodyPadBAdd = oDivY - bodyH;
var bodyPadB = document.body.style.paddingBottom;
var bodyPadB = parseFloat(bodyPadB.replace("px",""));
if (typeof gBodyPadBAdd != "undefined") {
if (bodyPadBAdd > gBodyPadBAdd) {
gBodyPadBAdd = bodyPadBAdd;
document.body.style.paddingBottom = bodyPadBAdd + "px";
}
} else {
document.body.style.paddingBottom = bodyPadBAdd + "px";
gBodyPadBAdd = bodyPadBAdd;
}
}
}
}
//set a global variable to store all timeouts for all tooltips
iTimeout = false;
function ShowTooltip(sPos,sDiv) {
var sCode = "ShowDiv('" + sPos + "','" + sDiv + "',true,625,0,1,0);";
// store the timeout so you can cancel it later
iTimeout = window.setTimeout(sCode,250);
}
function HideTooltip(sPos,sDiv) {
// clear any lingering timeouts and reset iTimeout;
if (iTimeout) {
window.clearTimeout(iTimeout);
iTimeout = false;
}
ShowDiv(sPos,sDiv,false);
}
/* objects for Detailed Farefinder Calendar */
function oMonth_obj(iM,iY,iSta,iEnd) {
this.iM = iM;
this.iY = iY;
this.aDAll = GetArrD(iM,iY);
this.aDUse = GetArrDBln(iM,iY,iSta,iEnd);
this.aDofW = GetArrDofW(iM,iY);
this.iDMax = this.aDAll[this.aDAll.length - 1];
this.iDUseMin = this.aDAll[this.aDUse.firstIndexOf(true)];
this.iDUseMax = this.aDAll[this.aDUse.lastIndexOf(true)];
}
function oCal_obj(sName,sDiv,sSelM,sSelD,sStaMY,sStaD,sCurMY,sCurD) {
this.sName = sName;
this.oDiv = document.getElementById(sDiv);
this.oSelM = document.getElementById(sSelM);
this.oSelD = document.getElementById(sSelD);
/*new fix*/
cltVal=new Date();
cltD=cltVal.getDate();
cltD=parseFloat(cltD);
chgToPrev=false;
if (cltD==31) {
chgToPrev=true;
}
if (cltD <10) {
cltD='0'+cltD;
}
cltM=cltVal.getMonth()+1;
cltY=cltVal.getFullYear();
chkCalYVal=sStaMY.substring(0,4);
chkValMVal=sStaMY.substring(5,sStaMY.length);
chkCalYVal=parseFloat(chkCalYVal);
chkValMVal=parseFloat(chkValMVal);
if (cltM==chkValMVal-1 && chgToPrev==true) {
sStaMY=cltY+'-'+cltM;
sStaD=cltD;
}
/*end new fix*/
this.dSta = SetDt(FmtDtArr(sStaMY,sStaD));
this.iStaD = this.dSta.getDate();
this.iStaY = this.dSta.getFullYear();
this.iStaM = this.dSta.getMonth();
this.dEnd = AddDays(this.dSta, this.iDaysOut);
this.iEndD = this.dEnd.getDate();
this.iEndY = this.dEnd.getFullYear();
this.iEndM = this.dEnd.getMonth();
var aM = GetArrM(this.iStaM,this.iStaY,this.iEndM,this.iEndY);
this.aM = [];
var iY = this.iStaY;
for (var i = 0; i < aM.length; i++) {
var iStaD = aM[i] == this.iStaM ? this.iStaD : 0;
var iEndD = aM[i] == this.iEndM ? this.iEndD : 0;
this.aM[i] = new oMonth_obj(aM[i], iY, iStaD, iEndD);
if (aM[i] == 11) iY++;/*move to the next year after December*/
}
this.dCur = SetDt(FmtDtArr(sCurMY,sCurD));
this.iCurD = this.dCur.getDate();
/*this.iCurM = this.dCur.getMonth();*/
this.iCurM = Number((sCurMY.substr(5,2)));
if (this.iCurM >0) {
this.iCurM =this.iCurM-1
}
this.iCurY = this.dCur.getFullYear();
this.oCurM = GetObjFromArrByVal(this.aM, this.iCurM, "iM");
this.iMDis = this.iCurM;
this.iYDis = this.iCurY;
this.oMDis = this.oCurM;
}
function oCal_obj_SetM(sCurM, sCurY) {
this.iCurM = TransMFrom(sCurM);
this.iCurY = Number(sCurY);
this.oCurM = GetObjFromArrByVal(this.aM, this.iCurM, "iM");
}
function oCal_obj_Init() {
this.PopM();
this.PopD();
document.write(this.DrawCal());
this.MoveCalD();
}
function oCal_obj_PopM(iM) {
var aOpt = this.oSelM.options;
aOpt.length = 0;
for (var i = 0; i < this.aM.length; i++) {
var oM = this.aM[i];
var bSel = oM.iM == this.iCurM;
aOpt[i] = new Option(this.aMthAbbr[oM.iM] + " " + oM.iY, oM.iY + "-" + TransMTo(oM.iM));
aOpt[i].defaultSelected = bSel;
aOpt[i].selected = bSel;
}
}
function oCal_obj_PopD() {
var aOpt = this.oSelD.options;
aOpt.length = 0;
for (var i = 0; i < this.oCurM.aDAll.length; i++) {
var sVal = this.oCurM.aDAll[i];
var sVal2 = FmtTwoDigits(sVal);
var bSel = sVal == this.iCurD;
if (this.oCurM.aDUse[i]) {
aOpt[aOpt.length] = new Option(sVal2,sVal2);
aOpt[aOpt.length - 1].defaultSelected = bSel;
aOpt[aOpt.length - 1].selected = bSel;
}
}
}
function oCal_obj_DisM(iM,iY,bLink) {
if (String(bLink) == 'undefined') bLink = true;
this.iMDis = iM;
this.iYDis = iY;
this.oMDis = GetObjFromArrByVal(this.aM,this.iMDis,"iM");
this.MoveCalM(false);
if (!this.bIsPopup && bLink && this.oCalFw && !CompMs(this.iMDis,this.iYDis,this.oCalFw.iMDis,this.oCalFw.iYDis)) this.oCalFw.DisM(iM,iY);
if (!this.bIsPopup && bLink && this.oCalBk && CompMs(this.iMDis,this.iYDis,this.oCalBk.iMDis,this.oCalBk.iYDis)) this.oCalBk.DisM(iM,iY);
}
function oCal_obj_ChgM(sVal,bFromFwOrBack) {
if (String(bFromFwOrBack) == 'undefined') bFromFwOrBack = false;
//passed a value by calendar interface but no value by select onchange event
var bFromSel = (String(sVal) == 'undefined');
if (bFromSel) sVal = this.oSelM[this.oSelM.selectedIndex].value;
var aVals = sVal.split("-");
this.SetM(aVals[1], aVals[0]);
this.DisM(TransMFrom(aVals[1]), Number(aVals[0]),false);
if (this.bPrevDate) {
this.iCurD = this.bPrevDate;
this.bPrevDate = false;
}
if (this.iCurD > this.oCurM.iDUseMax) {
this.bPrevDate = this.iCurD;
this.iCurD = this.oCurM.iDUseMax;
}
if (this.iCurD < this.oCurM.iDUseMin) {
this.bPrevDate = this.iCurD;
this.iCurD = this.oCurM.iDUseMin;
}
this.PopD();
if (!bFromSel) this.MoveSelM();
this.MoveCalM(true);
//sync linked calendar
if (!bFromFwOrBack) {
if (this.oCalFw) {
//if Trip Template, maintain Trip Template span between depart and return cals until return cal is moved.
if (this.iTTDays > 0) {
var dTT = new Date(this.iCurY,this.iCurM,this.iCurD);
dTT = AddDays(dTT,this.iTTDays);
this.oCalFw.ChgD(dTT.getDate(),dTT.getMonth(),dTT.getFullYear(),true);
} else if (!CompDs(this.iCurD,this.iCurM,this.iCurY,this.oCalFw.iCurD,this.oCalFw.iCurM,this.oCalFw.iCurY)) {
this.oCalFw.ChgD(this.iCurD,this.iCurM,this.iCurY,true);
}
}
if (this.oCalBk) {
if (this.oCalBk) this.oCalBk.iTTDays = 0;//once back calendar is moved, kill trip template linking
if (CompDs(this.iCurD,this.iCurM,this.iCurY,this.oCalBk.iCurD,this.oCalBk.iCurM,this.oCalBk.iCurY)) {
this.oCalBk.ChgD(this.iCurD,this.iCurM,this.iCurY,true);
}
}
}
if (this.bIsPopup) this.ShowCal(false);
}
function oCal_obj_ChgD(iD,iM,iY,bFromFwOrBack) {
if (String(bFromFwOrBack) == 'undefined') bFromFwOrBack = false;
//passed value by calendar interface but no values by dropdowns
if (String(iM) == 'undefined') iM = this.iCurM;
if (String(iY) == 'undefined') iY = this.iCurY;
if (String(iD) == 'undefined') iD = Number(this.oSelD[this.oSelD.selectedIndex].value);
this.SetM(TransMTo(iM),String(iY));
this.iCurD = iD;
this.bPrevDate = false;
this.ChgM(iY + "-" + TransMTo(iM),bFromFwOrBack);
this.MoveCalD();
this.MoveSelD();
if (this.bIsPopup) this.ShowCal(false);
}
function oCal_obj_MoveSelM() {
var sVal = this.iCurY + "-" + TransMTo(this.iCurM);
var oS = this.oSelM;
oS.selectedIndex = GetSelIndByVal(oS, sVal);
}
function oCal_obj_MoveSelD() {
var oS = this.oSelD;
oS.selectedIndex = GetSelIndByVal(oS, FmtTwoDigits(this.iCurD));
}
function oCal_obj_MoveCalM(bMoveDay) {
this.oDiv.innerHTML = this.DrawCal();
if (bMoveDay || this.iCurM == this.iMDis) this.MoveCalD();
}
function oCal_obj_MoveCalD() {
for (var i = 1; i <= this.oCurM.iDMax; i++) {
var oTD = document.getElementById(this.sName + "day_" + i);
oTD.className = i == this.iCurD ? "act" : "on";
}
}
function oCal_obj_DrawCal() {
var iDateThis = 1;
var iDofWThis = 0;
var i = 0;
var iD = 42;
var bWhitespace = false;
var sWr = "";
sWr += '\n';
sWr += '\n\t\t';
if (CompMs(this.iStaM,this.iStaY,this.iMDis,this.iYDis)) {
var iMBk = this.iMDis == 0 ? 11 : this.iMDis - 1;
var iYBk = this.iMDis == 0 ? this.iYDis - 1 : this.iYDis;
sWr += ' ';
} else {
sWr += ' ';
}
sWr += ' | ';
sWr += '\n\t\t';
sWr += this.aMthFull[this.iMDis] + ", " + this.iYDis;
sWr += ' | ';
sWr += '\n\t\t';
if (CompMs(this.iMDis,this.iYDis,this.iEndM,this.iEndY)) {
var iMFw = this.iMDis == 11 ? 0 : this.iMDis + 1;
var iYFw = this.iMDis == 11 ? this.iYDis + 1 : this.iYDis;
sWr += ' ';
} else {
sWr += ' ';
}
sWr += ' | ';
sWr += '\n\t';
sWr += '\n
';
sWr += '\n';
sWr += '\n\t';
for (var x = 0; x < this.aDayAbbr.length; x++) {
sWr += '\n\t\t' + this.aDayAbbr[x] + ' | ';
}
sWr += '\n\t
';
sWr += '\n\t';
while (iD > 0 || i < this.oMDis.aDAll.length) {
if (iDofWThis == this.oMDis.aDofW[i]) {
sWr += '\n\t\t| ' : '';
iDateThis++
i++;
} else {
if (bWhitespace) {
sWr += '\n\t\t | ';
} else {
sWr += '\n\t\t | ';
}
}
sWr += ' | ';
if (iDofWThis == 6) {
if (i >= this.oMDis.aDAll.length) bWhitespace = true;
sWr += '\n\t
';
sWr += '\n\t';
iDofWThis = 0;
} else {
iDofWThis++;
}
iD--;
}
sWr += '\n\t
';
if (this.bIsPopup) sWr += '| close |
';
sWr += '\n
';
return sWr;
}
function oCal_obj_ShowCal(bShow) {
sdForm=document.getElementById('sideform');
if (String(bShow) == 'undefined'){
var iEnble, numEls = sdForm.elements.length;
for(iEnble=0; iEnble this.dSta.getFullYear()) || ((this.dDis.getMonth() > this.dSta.getMonth()) && (this.dDis.getFullYear() >= this.dSta.getFullYear())));
if (this.sType == "return" && this.oLinkCal.dSel) {
var dComp1 = GetDateMY(this.dDis);
var dComp2 = GetDateMY(this.oLinkCal.dSel);
//we cannot go by the actual date object. as it takes into account time also I think as I am getting invalid behavior
bPrev = bPrev && ((dComp1.getFullYear() > dComp2.getFullYear()) || ((dComp1.getMonth() > dComp2.getMonth()) && (dComp1.getFullYear() >= dComp2.getFullYear())));
}
//test to see whether to show next link. compare only month and year. day and time should not affect display of those links
var bNext = ((this.dDis.getFullYear() < this.dEnd.getFullYear()) || ((this.dDis.getMonth() < this.dEnd.getMonth()) && (this.dDis.getFullYear() <= this.dEnd.getFullYear())));
if (this.sType == "depart" && this.oLinkCal.dSel) {
var dComp1 = GetDateMY(this.dDis);
var dComp2 = GetDateMY(this.oLinkCal.dSel);
bNext = bNext && ((dComp1.getFullYear() < dComp2.getFullYear()) || ((dComp1.getMonth() < dComp2.getMonth()) && (dComp1.getFullYear() <= dComp2.getFullYear())));
}
sW = '';
sW += '';
sW += '';
sW += '| ';
sW += !bPrev ? ' ' : 'Previous';
sW += ' | ';
sW += '';
sW += this.aMthFull[this.dDis.getMonth()] + ", " + this.dDis.getFullYear();
sW += ' | ';
sW += '';
sW += !bNext ? ' ' : 'Next';
sW += ' | ';
sW += '
';
sW += '
';
sW += '';
sW += '';
for (var i = 0; i < this.aDayAbbr.length; i++) {
sW += '| ' + this.aDayAbbr[i] + ' | ';
}
sW += '
';
var aDates = GetArrD(this.dDis.getMonth(),this.dDis.getFullYear());
var aDofWs = GetArrDofW(this.dDis.getMonth(),this.dDis.getFullYear())
var iDateThis = 1;
var iDofWThis = 0;
var i = 0;
var iD = 42;
var iDSel = this.dSel ? this.dSel.getDate() : 0;
//actual dates
sW += '\n';
while (iD > 0 || i < aDates.length) {
sW += iDofWThis == 0 ? '\n| ' : '\n | ';
if (iDofWThis == aDofWs[i]) {
var bActive = aDates[i] == iDSel;
var bLink;
if (this.sType == "depart") {
bLink = this.oLinkCal.dSel ? this.oLinkCal.dSel.valueOf() >= this.dDis.setDate(aDates[i]) : true;
} else {
bLink = this.oLinkCal.dSel ? this.oLinkCal.dSel.valueOf() <= this.dDis.setDate(aDates[i]) : true;
}
//active / avail / unavail / blnk
var bAvail = eval(this.aBln[i]);
var sClass = bActive ? 'active' : bAvail ? 'avail' : 'unavail';
sW += '';
iDateThis++
i++;
} else {
sW += ' ';
}
sW += ' | ';
if (iDofWThis == 6) {
sW += '\n
\n';
iDofWThis = 0;
} else {
iDofWThis++;
}
iD--;
}
sW += '\n
';
sW += '\n
';
this.oDiv.innerHTML = sW;
//now show selected @ bottom of page
sW = '';
sW += !this.dSel
? '[not yet selected]'
: this.aDayAbbr[this.dSel.getDay()] + ', ' + this.aMthFull[this.dSel.getMonth()] + ' ' + this.dSel.getDate() + ', ' + this.dSel.getFullYear();
;
this.oSpan.innerHTML = sW;
}
//properties
oAwCal_obj.prototype.aMthFull = ['January','February','March','April','May','June','July','August','September','October','November','December'];
oAwCal_obj.prototype.aMthAbbr = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
oAwCal_obj.prototype.aDayAbbr = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
//methods
oAwCal_obj.prototype.ConvM = oAwCal_ConvM;
oAwCal_obj.prototype.Draw = oAwCal_Draw;
oAwCal_obj.prototype.Move = oAwCal_Move;
oAwCal_obj.prototype.Set = oAwCal_Set;
//submit function
function NextStep(bFinal) {
//grab form reference
var oF = document.getElementById(oD.sFormID);
//stuff selected departure date, if any, into hidden form fields
if (oD.dSel) {
oF.seldepMY.value = ConvDateToMYStr(oD.dSel);
oF.seldepD.value = ConvDateToDStr(oD.dSel);
}
//stuff selected return date, if any, into hidden form fields
if (oR.dSel) {
oF.selretMY.value = ConvDateToMYStr(oR.dSel);
oF.selretD.value = ConvDateToDStr(oR.dSel);
}
if (!bFinal) {
//if just switching months, set form action, stuff display months into hidden form fields, and submit
oF.action = oD.sChgMthURL;
oF.disdepMY.value = ConvDateToMYStr(oD.dDis);
oF.disretMY.value = ConvDateToMYStr(oR.dDis);
oF.waiting.value = 'true';
oF.submit();
} else {
//otherwise, make sure both dates selected and then either submit or display an error alert
if (oD.dSel && oR.dSel) {
oF.action = oD.sSubmitURL;
oF.waiting.value = 'true';
oF.submit();
} else {
alert(oD.sErrMsg);
}
}
}
/* date and calendar utility functions */
function GetObjFromArrByVal(aObj,uVal,sProp) {
var oRet = false;
for (var i = 0; i < aObj.length; i++) {
if (aObj[i][sProp] == uVal) {
oRet = aObj[i];
break;
}
}
return oRet;
}
function GetArrIndByVal(aArr,uVal) {
var iRet = -1
for (var i = 0; i < aArr.length; i++) {
if (aArr[i] == uVal) {
iRet = i;
break;
}
}
return iRet;
}
function GetSelIndByVal(oSel,uVal) {
var aArr = [];
for (var i = 0; i < oSel.options.length; i++) { aArr[i] = oSel.options[i].value; }
return GetArrIndByVal(aArr,uVal);
}
function GetDinM(iM,iY) {
//takes actual number of month and returns number of days
var a = [31,28,31,30,31,30,31,31,30,31,30,31];
if (iY % 4 == 0) a[1] = 29;
return a[iM];
}
function AddDays(dD,iDays) {
/*
1000 = 1 second
60000 = 1 minute
3600000 = 1 hour
86400000 = 1 day
*/
var sD = dD.toString();
var iD = Date.parse(sD);
iD += (86400000 * iDays);
return new Date(iD);
}
function GetArrM(iStaM,iStaY,iEndM,iEndY) {
var a = [];
var iM = iStaM;
var iY = iStaY;
var dEnd = new Date(iEndY,iEndM);
var dNow = new Date(iY,iM);
while (dEnd.valueOf() >= dNow.valueOf()) {
a[a.length] = iM;
if (iM == 11) {
iY++;
iM = 0;
} else {
iM++;
}
dNow = new Date(iY,iM);
}
return a;
}
function GetArrD(iM,iY) {
var a = [];
for (var i = 1; i <= GetDinM(iM,iY); i++) {
a[a.length] = i;
}
return a;
}
function GetArrDBln(iM,iY,iSta,iEnd) {
var a = [];
for (var i = 1; i <= GetDinM(iM,iY); i++) {
a[a.length] = iEnd && i > iEnd ? false : iSta && i < iSta ? false : true;
}
return a;
}
function GetArrDofW(iM,iY) {
var a = [];
for (var i = 1; i <= GetDinM(iM,iY); i++) {
a[a.length] = new Date(iY,iM,i).getDay();
}
return a;
}
function SetDt(aYMD) {
var oD = new Date();
oD.setFullYear(aYMD[0]);
oD.setMonth(aYMD[1]);
oD.setDate(aYMD[2]);
return oD;
}
function CompMsFlex(iM1,iY1,sSign,iM2,iY2) {
var iD1 = new Date(iY1,iM1);
var iD2 = new Date(iY2,iM2);
var sEval = "iD1.valueOf() " + sSign + " iD2.valueOf()";
return eval(sEval);
}
function CompMs(iM1,iY1,iM2,iY2) {
var iD1 = new Date(iY1,iM1);
var iD2 = new Date(iY2,iM2);
return iD2.valueOf() > iD1.valueOf();
}
function CompDs(iD1,iM1,iY1,iD2,iM2,iY2) {
var iD1 = new Date(iY1,iM1,iD1).valueOf();
var iD2 = new Date(iY2,iM2,iD2).valueOf();
return iD2 > iD1
}
function FmtDtArr(sYM,sD) {
return [Number(sYM.substr(0,4)), TransMFrom(sYM.substr(5,2)),Number(sD)];
}
function FmtTwoDigits(inp) {
var sRet = String(inp);
return sRet.length == 1 ? "0" + sRet : sRet;
}
function TransMTo(inp) {
inp = Number(inp);
inp++;
return FmtTwoDigits(inp);
}
function TransMFrom(inp) {
inp = Number(inp);
inp--;
return inp;
}
function GetDateMY(d,iM) {
if (String(iM) == 'undefined') iM = 0;
var dR = new Date(d.getFullYear(),d.getMonth());
if (iM < 0) dR.DecrMth();
if (iM > 0) dR.IncrMth();
return dR;
}
function ConvMYStrToDate(s) {
var aR = s.split("-");
for (var i = 0; i < aR.length; i++) {
i == 1 ?
aR[i] = TransMFrom(aR[i]) /*convert 1-based month strung to 0-based number*/
: aR[i] = Number(aR[i]) /*convert year and date strings to numbers*/
;
}
var dR = new Date(aR[0],aR[1]);
if (aR.length > 2) dR.setDate(aR[2]);
return dR;
}
function ConvDateToMYStr(d) {
return String(d.getFullYear() + "-" + (TransMTo(d.getMonth())));
}
function ConvDateToDStr(d) {
return String(FmtTwoDigits(d.getDate()));
}
//JS API
function array_indexof(inp) {
var iRet = -1;
for (var i = 0; i < this.length; i++) {
if (this[i] == inp) {
iRet = i;
break;
}
}
return iRet;
}
function array_lastindexof(inp) {
var iRet = -1;
for (var i = 0; i < this.length; i++) {
if (this[i] == inp) {
iRet = i;
}
}
return iRet;
}
function array_firstindexof(inp) {
var iRet = -1;
for (var i = 0; i < this.length; i++) {
if (this[i] == inp) {
iRet = i;
break
}
}
return iRet;
}
function array_indexofdate(inp) {
var iRet = -1;
for (var i = 0; i < this.length; i++) {
if (this[i].valueOf() == inp.valueOf()) {
iRet = i;
break;
}
}
return iRet;
}
function array_indexofdateprop(inp,sProp) {
var iRet = -1;
for (var i = 0; i < this.length; i++) {
var o = this[i];
if (o[sProp].valueOf() == inp.valueOf()) {
iRet = i;
break;
}
}
return iRet;
}
Array.prototype.indexOf = array_indexof;
Array.prototype.lastIndexOf = array_lastindexof;
Array.prototype.firstIndexOf = array_firstindexof;
Array.prototype.indexOfDate = array_indexofdate;
Array.prototype.indexOfDateProp = array_indexofdateprop;
function Date_DecrMth() {
if (this.getMonth() == 0) {
this.setMonth(11);
this.setFullYear(this.getFullYear() - 1);
} else {
this.setMonth(this.getMonth() - 1);
}
}
function Date_IncrMth() {
if (this.getMonth() == 11) {
this.setMonth(0);
this.setFullYear(this.getFullYear() + 1);
} else {
this.setMonth(this.getMonth() + 1);
}
}
Date.prototype.DecrMth = Date_DecrMth;
Date.prototype.IncrMth = Date_IncrMth;