473,770 Members | 5,976 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

crossobj has no properties error in mozilla


var fixedX = -1 // x position (-1 if to appear below control)
var fixedY = -1 // y position (-1 if to appear below control)
var startAt = 0 // 0 - sunday ; 1 - monday
var showWeekNumber = 0 // 0 - don't show; 1 - show
var showToday = 1 // 0 - don't show; 1 - show
var imgDir = "images/" // directory for images ... e.g. var
imgDir="/img/"

var gotoString = "Go To Current Month"
var todayString = "Today is"
var weekString = "Wk"
var scrollLeftMessa ge = "Click to scroll to previous month. Hold mouse
button to scroll automatically."
var scrollRightMess age = "Click to scroll to next month. Hold mouse
button to scroll automatically."
var selectMonthMess age = "Click to select a month."
var selectYearMessa ge = "Click to select a year."
var selectDateMessa ge = "Select [date] as date." // do not replace
[date], it will be replaced by date.

var crossobj, crossMonthObj, crossYearObj, monthSelected, yearSelected,
dateSelected, omonthSelected, oyearSelected, odateSelected,
monthConstructe d, yearConstructed , intervalID1, intervalID2, timeoutID1,
timeoutID2, ctlToPlaceValue , ctlNow, dateFormat, nStartingYear

var bPageLoaded=fal se
var ie=document.all
var dom=document.ge tElementById
var ns4=document.la yers
var today = new Date()
var dateNow = today.getDate()
var monthNow = today.getMonth( )
var yearNow = today.getYear()
var imgsrc = new
Array("drop1.gi f","drop2.gif", "left1.gif","le ft2.gif","right 1.gif","righ
t2.gif")
var img = new Array()
var bShow = false;
function hideElement( elmID, overDiv )
{
if( ie )
{
for( i = 0; i < document.all.ta gs( elmID ).length; i++ )
{
obj = document.all.ta gs( elmID )[i];
if( !obj || !obj.offsetPare nt )
{
continue;
}

objLeft = obj.offsetLeft;
objTop = obj.offsetTop;
objParent = obj.offsetParen t;

while( objParent.tagNa me.toUpperCase( ) != "BODY" )
{
objLeft += objParent.offse tLeft;
objTop += objParent.offse tTop;
objParent = objParent.offse tParent;
}

objHeight = obj.offsetHeigh t;
objWidth = obj.offsetWidth ;

if(( overDiv.offsetL eft + overDiv.offsetW idth ) <= objLeft );
else if(( overDiv.offsetT op + overDiv.offsetH eight ) <=
objTop );
else if( overDiv.offsetT op >= ( objTop + objHeight ));
else if( overDiv.offsetL eft >= ( objLeft + objWidth ));
else
{
obj.style.visib ility = "hidden";
}
}
}
}

function showElement( elmID )
{
if( ie )
{
for( i = 0; i < document.all.ta gs( elmID ).length; i++ )
{
obj = document.all.ta gs( elmID )[i];
if( !obj || !obj.offsetPare nt )
{
continue;
}
obj.style.visib ility = "";
}
}
}
function HolidayRec (d, m, y, desc)
{
this.d = d
this.m = m
this.y = y
this.desc = desc
}

function addHoliday (d, m, y, desc)
{
Holidays[HolidaysCounter ++] = new HolidayRec ( d, m, y, desc )
}
var HolidaysCounter = 0
var Holidays = new Array()

if (dom)
{
for(i=0;i<imgsr c.length;i++)
{
img[i] = new Image
img[i].src = imgDir + imgsrc[i]

}

document.write ("<div onclick='bShow= true' name='calendar'
id='calendar'
style='z-index:+999;posi tion:absolute;v isibility:hidde n;'><table width="
+((showWeekNumb er==1)?250:220) +"
style='font-family:arial;fo nt-size:11px;borde r-width:1;border-style:soli
d;border-color:#a0a0a0;f ont-family:arial; font-size:11px}'
bgcolor='#fffff f'><tr bgcolor='#B5BEC 5'><td><table
width='"+((show WeekNumber==1)? 248:218)+"'><tr ><td
style='padding: 2px;font-family:arial; font-size:11px;'><fo nt
color='#000000' ><B><span id='caption'></span></B></font></td><td
align=right><a href='javascrip t:hideCalendar( )'><IMG
SRC='"+imgDir+" close.gif' WIDTH='15' HEIGHT='13' BORDER='0' ALT='Close
the Calendar'></a></td></tr></table></td></tr><tr><td
style='padding: 5px' bgcolor=#ffffff ><span
id='content'></span></td></tr>")

if (showToday==1)
{
document.write ("<tr bgcolor=#f0f0f0 ><td style='padding: 5px'
align=center><s pan id='lblToday'></span></td></tr>")
}
document.write ("</table></div><div id='selectMonth ' name='selectMon th'
style='z-index:+999;posi tion:absolute;v isibility:hidde n;'></div><div
id='selectYear'
style='z-index:+999;posi tion:absolute;v isibility:hidde n;'></div>");

}
var monthName =new
Array("JAN","FE B","MAR","APR", "MAY","JUN","JU L","AUG","SEP", "OCT","NOV" ,
"DEC")

if (startAt==0)
{
dayName = new Array ("Sun","Mon","T ue","Wed","Thu" ,"Fri","Sat" )
}
else
{
dayName = new Array ("Mon","Tue","W ed","Thu","Fri" ,"Sat","Sun" )
}
var styleAnchor="te xt-decoration:none ;color:green;"
var
styleLightBorde r="border-style:solid;bor der-width:1px;borde r-color:black
;"

function swapImage(srcIm g, destImg)
{
if (ie)
{
document.getEle mentById(srcImg ).setAttribute( "src",imgDi r +
destImg)
}
}
function init()
{

if (!ns4)
{

if (!ie)
{
yearNow += 1900
}

crossobj=(dom)? document.getEle mentsByName("ca lendar").style:
ie?document.all .calendar:docum ent.calendar

hideCalendar()
crossMonthObj=( dom)?document.g etElementsByNam e("selectMonth" ).style :
ie? document.all.se lectMonth : document.select Month
crossYearObj=(d om)?document.ge tElementsByName ("selectYear"). style :
ie? document.all.se lectYear : document.select Year

monthConstructe d=false;
yearConstructed =false;

if (showToday==1)
{
document.getEle mentsByName("lb lToday").innerH TML = todayString + "
<a onmousemove='wi ndow.status=\"" +gotoString+"\" '
onmouseout='win dow.status=\"\" ' title='"+gotoSt ring+"'
style='"+styleA nchor+"'
href='javascrip t:monthSelected =monthNow;yearS elected=yearNow ;constructCa
lendar();'>"+da yName[(today.getDay()-startAt==-1)?6:(today.get Day()-star
tAt)]+", " + dateNow + " " + monthName[monthNow].substring(0,3) + " "
+ yearNow + "</a>"
}

sHTML1="<span
id='spanLeft' style='border-style:solid;bor der-width:1;border-color:#B5B
EC5;cursor:poin ter'
onmouseover='sw apImage(\"chang eLeft\",\"left2 .gif\");this.st yle.borderCo
lor=\"#B5BEC5\" ;window.status= \""+scrollLeftM essage+"\"'
onclick='javasc ript:decMonth() '
onmouseout='cle arInterval(inte rvalID1);swapIm age(\"changeLef t\",\"left1.
gif\");this.sty le.borderColor= \"#B5BEC5\";win dow.status=\"\" '
onmousedown='cl earTimeout(time outID1);timeout ID1=setTimeout( \"StartDecMo
nth()\",500)' onmouseup='clea rTimeout(timeou tID1);clearInte rval(interval
ID1)'>&nbsp<IMG id='changeLeft' SRC='"+imgDir+" left1.gif' width=10
height=11 BORDER=0>&nbsp</span>&nbsp;"
sHTML1+="<span id='spanRight'
style='border-style:solid;bor der-width:1;border-color:#B5BEC5;c ursor:poi
nter' onmouseover='sw apImage(\"chang eRight\",\"righ t2.gif\");this. style.
borderColor=\"# B5BEC5\";window .status=\""+scr ollRightMessage +"\"'
onmouseout='cle arInterval(inte rvalID1);swapIm age(\"changeRig ht\",\"right
1.gif\");this.s tyle.borderColo r=\"#B5BEC5\";w indow.status=\" \"'
onclick='incMon th()'
onmousedown='cl earTimeout(time outID1);timeout ID1=setTimeout( \"StartIncMo
nth()\",500)' onmouseup='clea rTimeout(timeou tID1);clearInte rval(interval
ID1)'>&nbsp<IMG id='changeRight ' SRC='"+imgDir+" right1.gif' width=10
height=11 BORDER=0>&nbsp</span>&nbsp"
sHTML1+="<span id='spanMonth'
style='border-style:solid;bor der-width:1;border-color:#B5BEC5;c ursor:poi
nter' onmouseover='sw apImage(\"chang eMonth\",\"drop 2.gif\");this.s tyle.b
orderColor=\"#B 5BEC5\";window. status=\""+sele ctMonthMessage+ "\"'
onmouseout='swa pImage(\"change Month\",\"drop1 .gif\");this.st yle.borderCo
lor=\"#B5BEC5\" ;window.status= \"\"'
onclick='popUpM onth()'></span>&nbsp;"
sHTML1+="<span id='spanYear'
style='border-style:solid;bor der-width:1;border-color:#B5BEC5;c ursor:poi
nter'
onmouseover='sw apImage(\"chang eYear\",\"drop2 .gif\");this.st yle.borderCo
lor=\"#B5BEC5\" ;window.status= \""+selectYearM essage+"\"' onmouseout='swa
pImage(\"change Year\",\"drop1. gif\");this.sty le.borderColor= \"#B5BEC5\";
window.status=\ "\"' onclick='popUpY ear()'></span>&nbsp;"

document.getEle mentsByName("ca ption").innerHT ML = sHTML1

bPageLoaded=tru e
}
}
function hideCalendar()
{

crossobj.visibi lity="hidden"
if (crossMonthObj != null)
{
crossMonthObj.v isibility="hidd en"
}
if (crossYearObj != null)
{
crossYearObj.vi sibility="hidde n"
}

showElement( 'SELECT' );
showElement( 'APPLET' );
}
function padZero(num)
{
return (num < 10)? '0' + num : num ;
}

function constructDate(d ,m,y)
{
sTmp = dateFormat
sTmp = sTmp.replace ("dd","<e>")
sTmp = sTmp.replace ("d","<d>")
sTmp = sTmp.replace ("<e>",padZero( d))
sTmp = sTmp.replace ("<d>",d)
sTmp = sTmp.replace ("mmm","<o>" )
sTmp = sTmp.replace ("mm","<n>")
sTmp = sTmp.replace ("m","<m>")
sTmp = sTmp.replace ("<m>",m+1)
sTmp = sTmp.replace ("<n>",padZero( m+1))
sTmp = sTmp.replace ("<o>",monthNam e[m])
return sTmp.replace ("yyyy",y)
}
function closeCalendar()
{
var sTmp
hideCalendar();
ctlToPlaceValue .value
= constructDate(d ateSelected,mon thSelected,year Selected)
}
function StartDecMonth()
{
intervalID1=set Interval("decMo nth()",80)
}

function StartIncMonth()
{
intervalID1=set Interval("incMo nth()",80)
}

function incMonth ()
{
monthSelected++
if (monthSelected> 11)
{
monthSelected=0
yearSelected++
}
constructCalend ar()
}

function decMonth ()
{
monthSelected--
if (monthSelected< 0)
{
monthSelected=1 1
yearSelected--
}
constructCalend ar()
}

function constructMonth( )
{
popDownYear()

if (!monthConstruc ted)
{
sHTML = ""
for(i=0; i<12; i++)
{
sName = monthName[i];
if (i==monthSelect ed)
{
sName = "<B>" + sName + "</B>"
}
sHTML += "<tr><td id='m" + i + "'
onmouseover='th is.style.backgr oundColor=\"lav ender\"'
onmouseout='thi s.style.backgro undColor=\"\"' style='cursor:p ointer'
onclick='monthC onstructed=fals e;monthSelected =" + i +
";constructCale ndar();popDownM onth();event.ca ncelBubble=true '>&nbsp;" +
sName + "&nbsp;</td></tr>"
}

document.getEle mentById("selec tMonth").innerH TML = "<table
width=70 style='font-family:arial; font-size:11px; border-width:1;
border-style:solid; border-color:#a0a0a0;' bgcolor='#FFFFD D'
cellspacing=0
onmouseover='cl earTimeout(time outID1)' onmouseout='cle arTimeout(timeo utI
D1);timeoutID1= setTimeout(\"po pDownMonth()\", 100);event.canc elBubble=tru
e'>" + sHTML + "</table>"

monthConstructe d=true
}
}

function popUpMonth()
{
constructMonth( )
crossMonthObj.v isibility = (dom||ie)? "visible" : "show"
crossMonthObj.l eft = parseInt(crosso bj.left) + 50
crossMonthObj.t op = parseInt(crosso bj.top) + 26

hideElement( 'SELECT', document.getEle mentById("selec tMonth") );
hideElement( 'APPLET', document.getEle mentById("selec tMonth") );
}

function popDownMonth()
{
crossMonthObj.v isibility= "hidden"
}
function incYear()
{
for(i=0; i<7; i++)
{
newYear = (i+nStartingYea r)+1
if (newYear==yearS elected)
{
txtYear = "&nbsp;<B>" + newYear + "</B>&nbsp;"
}
else
{
txtYear = "&nbsp;" + newYear + "&nbsp;"
}
document.getEle mentById("y"+i) .innerHTML = txtYear
}

nStartingYear ++;
bShow=true
}
function decYear()
{
for(i=0; i<7; i++)
{
newYear = (i+nStartingYea r)-1
if (newYear==yearS elected)
{
txtYear = "&nbsp;<B>" + newYear + "</B>&nbsp;"
}
else
{
txtYear = "&nbsp;" + newYear + "&nbsp;"
}
document.getEle mentById("y"+i) .innerHTML = txtYear
}

nStartingYear --;
bShow=true
}
function selectYear(nYea r)
{
yearSelected=pa rseInt(nYear+nS tartingYear);
yearConstructed =false;
constructCalend ar();
popDownYear();
}

function constructYear()
{
popDownMonth()
sHTML = ""
if (!yearConstruct ed)
{

sHTML = "<tr><td
align='center' onmouseover='th is.style.backgr oundColor=\"#FF CC99\"'
onmouseout='cle arInterval(inte rvalID1);this.s tyle.background Color=\"\"'
style='cursor:p ointer' onmousedown='cl earInterval(int ervalID1);inter valI
D1=setInterval( \"decYear()\",3 0)'
onmouseup='clea rInterval(inter valID1)'>-</td></tr>"

j = 0
nStartingYear = yearSelected-3
for (i=(yearSelecte d-3); i<=(yearSelecte d+6); i++)
{
sName = i;
if (i==yearSelecte d)
{
sName = "<B>" + sName + "</B>"
}

sHTML += "<tr><td id='y" + j + "'
onmouseover='th is.style.backgr oundColor=\"#FF CC99\"'
onmouseout='thi s.style.backgro undColor=\"\"' style='cursor:p ointer'
onclick='select Year("+j+");eve nt.cancelBubble =true'>&nbsp;" + sName +
"&nbsp;</td></tr>"
j ++;
}

sHTML += "<tr><td align='center'
onmouseover='th is.style.backgr oundColor=\"#FF CC99\"'
onmouseout='cle arInterval(inte rvalID2);this.s tyle.background Color=\"\"'
style='cursor:p ointer'
onmousedown='cl earInterval(int ervalID2);inter valID2=setInter val(\"incYea
r()\",30)' onmouseup='clea rInterval(inter valID2)'>+</td></tr>"

document.getEle mentById("selec tYear").innerHT ML = "<table width=44
style='font-family:arial; font-size:11px; border-width:1;
border-style:solid; border-color:#a0a0a0;' bgcolor='#FFFFD D'
onmouseover='cl earTimeout(time outID2)'
onmouseout='cle arTimeout(timeo utID2);timeoutI D2=setTimeout(\ "popDownYea r
()\",100)' cellspacing=0>" + sHTML + "</table>"

yearConstructed = true
}
}

function popDownYear()
{
clearInterval(i ntervalID1)
clearTimeout(ti meoutID1)
clearInterval(i ntervalID2)
clearTimeout(ti meoutID2)
crossYearObj.vi sibility= "hidden"
}

function popUpYear()
{
var leftOffset

constructYear()
crossYearObj.vi sibility= (dom||ie)? "visible" : "show"
leftOffset = parseInt(crosso bj.left) +
document.getEle mentById("spanY ear").offsetLef t

if (ie)
{
leftOffset += 6
}

crossYearObj.le ft = leftOffset
crossYearObj.to p = parseInt(crosso bj.top) + 26
}
function WeekNbr(n)
{

year = n.getFullYear() ;
month = n.getMonth() + 1;
if (startAt == 0)
{
day = n.getDate() + 1;
}
else
{
day = n.getDate();
}

a = Math.floor((14-month) / 12);
y = year + 4800 - a;
m = month + 12 * a - 3;
b = Math.floor(y/4) - Math.floor(y/100) + Math.floor(y/400);
J = day + Math.floor((153 * m + 2) / 5) + 365 * y + b - 32045;
d4 = (((J + 31741 - (J % 7)) % 146097) % 36524) % 1461;
L = Math.floor(d4 / 1460);
d1 = ((d4 - L) % 365) + L;
week = Math.floor(d1/7) + 1;

return week;
}
function constructCalend ar ()
{
var aNumDays = Array (31,0,31,30,31, 30,31,31,30,31, 30,31)

var dateMessage
var startDate = new Date (yearSelected,m onthSelected,1)
var endDate

if (monthSelected= =1)
{
endDate = new Date (yearSelected,m onthSelected+1, 1);
endDate = new Date (endDate - (24*60*60*1000) );
numDaysInMonth = endDate.getDate ()
}
else
{
numDaysInMonth = aNumDays[monthSelected];
}

datePointer = 0
dayPointer = startDate.getDa y() - startAt

if (dayPointer<0)
{
dayPointer = 6
}

sHTML ="<table border=0
style='font-family:verdana; font-size:10px;'><tr >"

if (showWeekNumber ==1)
{
sHTML += "<td width=27><b>" + weekString + "</b></td><td width=1
rowspan=7 bgcolor='#d0d0d 0' style='padding: 0px'><img
src='"+imgDir+" divider.gif' width=1></td>"
}

for(i=0; i<7; i++)
{
sHTML += "<td width='27' align='right'>< B>"+ dayName[i]+"</B></td>"
}
sHTML +="</tr><tr>"

if (showWeekNumber ==1)
{
sHTML += "<td align=right>" + WeekNbr(startDa te) + "&nbsp;</td>"
}

for( var i=1; i<=dayPointer;i ++ )
{
sHTML += "<td>&nbsp; </td>"
}

for( datePointer=1; datePointer<=nu mDaysInMonth; datePointer++ )
{
dayPointer++;
sHTML += "<td align=right>"
sStyle=styleAnc hor
if ((datePointer== odateSelected)
&& (monthSelected= =omonthSelected ) && (yearSelected== oyearSelected))
{
sStyle+=styleLi ghtBorder
}

sHint = ""
for (k=0;k<Holidays Counter;k++)
{
if
((parseInt(Holi days[k].d)==datePointe r)&&(parseInt(H olidays[k].m)==(mont
hSelected+1)))
{
if
((parseInt(Holi days[k].y)==0)||((pars eInt(Holidays[k].y)==yearSelect ed)&
&(parseInt(Holi days[k].y)!=0)))
{
sStyle+="backgr ound-color:#FFDDDD;"
sHint+=sHint==" "?Holidays[k].desc:"\n"+Holi days[k].desc
}
}
}

var regexp= /\"/g
sHint=sHint.rep lace(regexp,"&q uot;")

dateMessage =
"onmousemove='w indow.status=\" "+selectDateMes sage.replace("[date]",const
ructDate(datePo inter,monthSele cted,yearSelect ed))+"\"'
onmouseout='win dow.status=\"\" ' "

if
((datePointer== dateNow)&&(mont hSelected==mont hNow)&&(yearSel ected==yearN
ow))
{ sHTML += "<b><a "+dateMessa ge+" title=\"" + sHint + "\"
style='"+sStyle +"'
href='javascrip t:dateSelected= "+datePointer+" ;closeCalendar( );'><font
color=#ff0000>& nbsp;" + datePointer + "</font>&nbsp;</a></b>"}
else if (dayPointer % 7 == (startAt * -1)+1)
{ sHTML += "<a "+dateMessa ge+" title=\"" + sHint + "\"
style='"+sStyle +"' href='javascrip t:dateSelected= "+datePoint er +
";closeCalendar ();'>&nbsp;<fon t color=#909090>" + datePointer +
"</font>&nbsp;</a>" }
else
{ sHTML += "<a "+dateMessa ge+" title=\"" + sHint + "\"
style='"+sStyle +"' href='javascrip t:dateSelected= "+datePoint er +
";closeCalendar ();'>&nbsp;" + datePointer + "&nbsp;</a>" }

sHTML += ""

if ((dayPointer+st artAt) % 7 == startAt)
{
sHTML += "</tr><tr>"
if ((showWeekNumbe r==1)&&(datePoi nter<numDaysInM onth))
{
sHTML += "<td align=right>" + (WeekNbr(new
Date(yearSelect ed,monthSelecte d,datePointer+1 ))) + "&nbsp;</td>"
}
}
}

document.getEle mentById("conte nt").innerHTM L = sHTML
document.getEle mentById("spanM onth").innerHTM L = "&nbsp;"
+ monthName[monthSelected] + "&nbsp;<IMG id='changeMonth '
SRC='"+imgDir+" drop1.gif' WIDTH='12' HEIGHT='10' BORDER=0>"
document.getEle mentById("spanY ear").innerHTM L = "&nbsp;" +
yearSelected + "&nbsp;<IMG id='changeYear' SRC='"+imgDir+" drop1.gif'
WIDTH='12' HEIGHT='10' BORDER=0>"
}
function popUpCalendar(c tl,ctl2,format)
{

var leftpos=-50;
var toppos=-120;

if (bPageLoaded)
{
if ( crossobj.visibi lity == "hidden" )
{
ctlToPlaceValue = ctl2
dateFormat=form at;

formatChar = " "
aFormat = dateFormat.spli t(formatChar)
if (aFormat.length <3)
{
formatChar = "/"
aFormat = dateFormat.spli t(formatChar)
if (aFormat.length <3)
{
formatChar = "."
aFormat = dateFormat.spli t(formatChar)
if (aFormat.length <3)
{
formatChar = "-"
aFormat = dateFormat.spli t(formatChar)
if (aFormat.length <3)
{
// invalid date format
formatChar=""
}
}
}
}

tokensChanged = 0
if ( formatChar != "" )
{
// use user's date
aData = ctl2.value.spli t(formatChar)
for (i=0;i<3;i++)
{
if ((aFormat[i]=="d") || (aFormat[i]=="dd"))
{
dateSelected = parseInt(aData[i], 10)
tokensChanged ++
}
else if ((aFormat[i]=="m") || (aFormat[i]=="mm"))
{
monthSelected = parseInt(aData[i], 10) - 1
tokensChanged ++
}
else if (aFormat[i]=="yyyy")
{
yearSelected = parseInt(aData[i], 10)
tokensChanged ++
}
else if (aFormat[i]=="mmm")
{
for (j=0; j<12; j++)
{
if (aData[i]==monthName[j])
{
monthSelected=j
tokensChanged ++
}
}
}
}
}

if
((tokensChanged !=3)||isNaN(dat eSelected)||isN aN(monthSelecte d)||isNaN(ye
arSelected))
{
dateSelected = dateNow
monthSelected = monthNow
yearSelected = yearNow
}

odateSelected=d ateSelected
omonthSelected= monthSelected
oyearSelected=y earSelected

aTag = ctl
do {
aTag = aTag.offsetPare nt;
leftpos += aTag.offsetLeft ;
toppos += aTag.offsetTop;
}
while(aTag.tagN ame!="BODY");

crossobj.left = fixedX==-1 ? ctl.offsetLeft + leftpos + 52 : fixedX
+ 52
crossobj.top = fixedY==-1 ? ctl.offsetTop + toppos +
ctl.offsetHeigh t + 105 : fixedY + 105
constructCalend ar (1, monthSelected, yearSelected);
crossobj.visibi lity=(dom||ie)? "visible" : "show"

hideElement( 'SELECT', document.getEle mentById("calen dar") );
hideElement( 'APPLET', document.getEle mentById("calen dar") );

bShow = true;
}
else
{
hideCalendar()
if (ctlNow!=ctl) {popUpCalendar( ctl, ctl2, format)}
}
ctlNow = ctl
}
}

document.onkeyp ress = function hidecal1 () {
if (event.keyCode= =27)
{
hideCalendar()
}
}
document.onclic k = function hidecal2 () {
if (!bShow)
{
hideCalendar()
}
bShow = false

}
function popUpCalendar_t op(ctl, ctl2, format,toppos)
{

var leftpos=-250;
var toppos=-toppos;

if (bPageLoaded)
{
if ( crossobj.visibi lity == "hidden" ) {
ctlToPlaceValue = ctl2
dateFormat=form at;

formatChar = " "
aFormat = dateFormat.spli t(formatChar)
if (aFormat.length <3)
{
formatChar = "/"
aFormat = dateFormat.spli t(formatChar)
if (aFormat.length <3)
{
formatChar = "."
aFormat = dateFormat.spli t(formatChar)
if (aFormat.length <3)
{
formatChar = "-"
aFormat = dateFormat.spli t(formatChar)
if (aFormat.length <3)
{
// invalid date format
formatChar=""
}
}
}
}

tokensChanged = 0
if ( formatChar != "" )
{
// use user's date
aData = ctl2.value.spli t(formatChar)

for (i=0;i<3;i++)
{
if ((aFormat[i]=="d") || (aFormat[i]=="dd"))
{
dateSelected = parseInt(aData[i], 10)
tokensChanged ++
}
else if ((aFormat[i]=="m") || (aFormat[i]=="mm"))
{
monthSelected = parseInt(aData[i], 10) - 1
tokensChanged ++
}
else if (aFormat[i]=="yyyy")
{
yearSelected = parseInt(aData[i], 10)
tokensChanged ++
}
else if (aFormat[i]=="mmm")
{
for (j=0; j<12; j++)
{
if (aData[i]==monthName[j])
{
monthSelected=j
tokensChanged ++
}
}
}
}
}

if
((tokensChanged !=3)||isNaN(dat eSelected)||isN aN(monthSelecte d)||isNaN(ye
arSelected))
{
dateSelected = dateNow
monthSelected = monthNow
yearSelected = yearNow
}

odateSelected=d ateSelected
omonthSelected= monthSelected
oyearSelected=y earSelected

aTag = ctl
do {
aTag = aTag.offsetPare nt;
leftpos += aTag.offsetLeft ;
toppos += aTag.offsetTop;
} while(aTag.tagN ame!="BODY");

crossobj.left = fixedX==-1 ? ctl.offsetLeft + leftpos : fixedX
crossobj.top = fixedY==-1 ? ctl.offsetTop + toppos +
ctl.offsetHeigh t + 2 : fixedY
constructCalend ar (1, monthSelected, yearSelected);
crossobj.visibi lity=(dom||ie)? "visible" : "show"

hideElement( 'SELECT', document.getEle mentById("calen dar") );
hideElement( 'APPLET', document.getEle mentById("calen dar") );

bShow = true;
}
else
{
hideCalendar()
if (ctlNow!=ctl) {popUpCalendar( ctl, ctl2, format)}
}
ctlNow = ctl
}
}

document.onkeyp ress = function hidecal1 () {
if (this.keyCode== 27)
{
hideCalendar()
}
}
document.onclic k = function hidecal2 () {
if (!bShow)
{
hideCalendar()
}
bShow = false
}
init()





*** Sent via Developersdex http://www.developersdex.com ***
Jan 12 '06 #1
1 2311
JRS: In article <WW************ *@news.uswest.n et>, dated Thu, 12 Jan
2006 11:19:18 local, seen in news:comp.lang. javascript, rajesh
<ja*****@yahoo. co.in> posted :
Lines: 966
Unreasonably long. You need to simplify and neaten it if you want it to
be widely read.

<FAQENTRY> Code posted needs to be executable as transmitted. The
sending agent must not be allowed to wrap lines. </FAQENTRY>

It's helpful to use two spaces per indent level, rather than a tab; an
editor can easily make the change.
if (startAt==0)
{
dayName = new Array ("Sun","Mon","T ue","Wed","Thu" ,"Fri","Sat" )
}
else
{
dayName = new Array ("Mon","Tue","W ed","Thu","Fri" ,"Sat","Sun" )
}
Simpler to use an 8-entry array of Sun..Sun, have startAt 0 or 1, and
add or subtract startAt when indexing?

function init()
{

if (!ns4)
{

if (!ie)
{
yearNow += 1900
}
ISTM dangerous to assume that all bar NS4 & IE need +1900. There are
better ways of dealing with that. Read the FAQ; see below.

function WeekNbr(n)
{

year = n.getFullYear() ;
month = n.getMonth() + 1;
if (startAt == 0)
{
day = n.getDate() + 1;
}
else
{
day = n.getDate();
}

a = Math.floor((14-month) / 12);
y = year + 4800 - a;
m = month + 12 * a - 3;
b = Math.floor(y/4) - Math.floor(y/100) + Math.floor(y/400);
J = day + Math.floor((153 * m + 2) / 5) + 365 * y + b - 32045;
d4 = (((J + 31741 - (J % 7)) % 146097) % 36524) % 1461;
L = Math.floor(d4 / 1460);
d1 = ((d4 - L) % 365) + L;
week = Math.floor(d1/7) + 1;

return week;
}
You don't need all that to get Week Number, whether absolute ISO or
American. A method giving ISO week number should also return the Year.
The 4800 should not be needed for dates after 0000-02-29.

In general, secular Gregorian calendar algorithms are liable to be
simplified by starting with Year %= 400.

endDate = new Date (endDate - (24*60*60*1000) );
I suspect India has no Summer Time. Your code may fail elsewhere.
If your code needs to be faster, try using UTC methods rather than local
ones.

*** Sent via Developersdex http://www.developersdex.com ***


--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jan 13 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2090
by: kj | last post by:
This problem is driving me nuts. The code at the end of this post below works fine with IE, but fails with Mozilla. You can see it in action at http://tinyurl.com/2jvo3 With Mozilla 1.4 and 1.6, the function msg works fine if it's installed as an onclick handler for the button, but fails as an onload handler for the page. The error is "console has no properties", and is triggered by the line.
9
12429
by: kj | last post by:
Is there any way to programmatically discover and inspect *all* the properties of an object, even those that are not enumerable through a for/in loop? Thanks! kj -- NOTE: In my address everything before the period is backwards.
3
3035
by: ytrewq | last post by:
Should dynamic ("expando") properties be restricted to native and user-defined objects? Or should host objects - such as references to the browser or a plug-in or to the document and its elements - also allow them? Adding (and removing) object properties dynamically is an acceptable and common practice in JavaScript, and greatly adds to the power and character of the language. Essentially, an object in JavaScript can be considered to...
4
3767
by: susanlimsg lim | last post by:
I have tried to resolved this problem but I dunno how to resolved it can anyone help me?? It cannot be successfully displayed at the mozilla environment // written by Tan Ling Wee on 2 Dec 2001 // last updated 23 June 2002 // email : fuushikaden@yahoo.com
6
13378
by: Luke Dalessandro | last post by:
I'm not sure if this is the correct forum for platform specific (Mozilla/Firefox) javascript problems, so just shout and point me to the correct newsgroup if I'm being bad. Here's the deal... html file (generated using .NET 2.0 beta2): <form method="post" action="Test2.aspx" id="form1">
1
1712
by: jayaram n | last post by:
how to correct the crossobj has no property error in mozilla *** Sent via Developersdex http://www.developersdex.com ***
1
1508
by: rajesh | last post by:
Hi all; For me also the same error "crossobj has no properties" is occuring while running in mozilla browser for the same calender.Plz help me to solve this problem with coding as soon as possible. Thanks u in advance by N.Jayaram
1
2098
by: rajesh | last post by:
URL: *** http://www.webdeveloping.nl/forum/showthread.php?s=0cfd9dadcad70f5454595 879ad73140b&threadid=2037&goto=nextoldest *** Sent via Developersdex http://www.developersdex.com ***
3
3487
by: droesler | last post by:
I have a function that receives a form name and field name. someFunc(formName, fieldName) { var fieldVal = document.forms.elements.value; } This triggers the 'has no properties error. An alert message shows the correct values are being passed in. If I hardcode var fieldVal = document.realFormName.realFieldName.value;
0
9592
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10230
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10058
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10004
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9870
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8886
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.