// Product title: Gurt Calendar JavaScript
// Product version details: 1.2.0, 03-01-2006 (mm-dd-yyyy)
// Product URL: http://gurtom.com/products/calendars/js
// Contact info: feedback@gurtom.com (specify product title in the subject)
// Notes: This script is free. Feel free to copy, use and change this script as
// long as this head part remains unchanged. Visit official site for details.
// Copyright: (c) 2006 by Gurtom.Com
var agC= [],ogB,oD;
function gCalendar(oSettings){
var _ = this;
_.nCId = agC.length;
agC[_.nCId] = _;
if (!ogB) ogB = new _UserAgent();
if (!oD) oD = new _DManager();
_.sNameControl = oSettings.dataArea ? oSettings.dataArea :'dataArea'+_.nCId;
_.sIcoName = 'icoCls'+_.nCId;
_.sPosName = 'icoPos'+_.nCId;
_.sDivName = 'clsDiv'+_.nCId;
_.sBoxName = 'clsBox'+_.nCId;
_.sTitleName = 'clsTitle'+_.nCId;
_.sPmiName = 'clsPMI'+_.nCId;
_.sNmiName = 'clsNMI'+_.nCId;
_.sPyiName = 'clsPYI'+_.nCId;
_.sNyiName = 'clsNYI'+_.nCId;
_.sPmaName = 'clsPMA'+_.nCId;
_.sNmaName = 'clsNMA'+_.nCId;
_.sPyaName = 'clsPYA'+_.nCId;
_.sNyaName = 'clsNYA'+_.nCId;
_.oChiefDate = new Date();
_.sChiefFormat = !oSettings.dateFormat ? 'm/d/Y' : oSettings.dateFormat;
_.oApp = oSettings['appearance'];
gBuildControl(_);
}
function gBuildControl(_) {
var oWbuf = new writer();
myClass="ois_textfield";
myStyle="width:66px";
oWbuf.into ('
');
document.write(oWbuf.out());
gBuildCalendar(_);
gSetControl(_);
gUpdateCalendarControl(_);
}
function gBuildCalendar(_){
var oWbuf = new writer();
oWbuf.into(' | ![',_.oApp['messages']['AltPrevYear'],'](',_.oApp['PrevYear'],') | ![',_.oApp['messages']['AltPrevMonth'],'](',_.oApp['PrevMonth'],') | ',_.oApp['longmonth'][_.oChiefDate.getMonth()],' ',_.oChiefDate.getFullYear(),' | ![',_.oApp['messages']['AltNextMonth'],'](',_.oApp['NextMonth'],') | ![',_.oApp['messages']['AltNextYear'],'](',_.oApp['NextYear'],') |
|  |  | ',gUnitedGrid(_),' |  |  |
|
');
if(ogB.ie6){
oWbuf.into('');
}
document.write(oWbuf.out());
}
function gDateReset(oInDate){
var oTmpDate = oInDate ? new Date(oInDate) : new Date();
oTmpDate.setHours(0);oTmpDate.setMinutes(0);oTmpDate.setSeconds(0);oTmpDate.setMilliseconds(0);
return oTmpDate;
}
function gDateType(c,oInDate){
var nResType = 1,oTmpDate = new Date(oInDate);
oTmpDate = gDateReset(oTmpDate);
var oChiefDateTmp = c.oChiefDate;
if (gDateReset(oChiefDateTmp).valueOf() == oTmpDate.valueOf()) nResType |= 2;
if (oTmpDate.getMonth() != oChiefDateTmp.getMonth() || oTmpDate.getFullYear() != oChiefDateTmp.getFullYear()) nResType |= 8;
if (oTmpDate.getDay() == 0 || oTmpDate.getDay() == 6) nResType |= 4;
return nResType;
}
function gDisplayCalendar(_) {
var sVis = String(_.oDiv.style.visibility).toLowerCase();
if (sVis == 'visible' || sVis == 'show') {
_.oDiv.style.visibility = 'hidden';
if(ogB.ie6) {_.oDiv2.style.visibility = 'hidden';}
_.oIco.src = _.oApp['IcoCalVis'];
}
else {
gRePosition(_);
if(gVerifyDataArea(_))gUpdateCalendarData(_);
_.oDiv.style.visibility = 'visible';
if(ogB.ie6) {
_.oDiv2.style.width = _.oDiv.offsetWidth;
_.oDiv2.style.height = _.oDiv.offsetHeight;
_.oDiv2.style.visibility = 'visible';
}
_.oIco.src = _.oApp['IcoCalUnVis'];
}
}
function gUserClickHandler(_,inDa,typeClick) {
var tmpDa = inDa ? new Date(inDa) : new Date(_.oChiefDate);
_.oChiefDate = new Date(tmpDa);
if(!typeClick) {gDisplayCalendar(_);_.oDataArea.value = oD.GenerateDate(_.oChiefDate,_.sChiefFormat);}
gUpdateCalendarData(_);
}
function gUpdateCalendarData(_){
gUpdateCalendarControl(_);
_.oInfoTitle.innerHTML = _.oApp['longmonth'][_.oChiefDate.getMonth()]+' '+_.oChiefDate.getFullYear();
_.oUnitedGrid.innerHTML = '';
_.oUnitedGrid.innerHTML = gUnitedGrid(_);
}
function gSetControl(_){
var oTmpDate;
_.oDiv = gObja(_,_.sDivName);
if(ogB.ie6) _.oDiv2 = gObja(_,'IE6bug'+_.sDivName);
_.oIco = gObja(_,_.sIcoName);
_.oPos = gObja(_,_.sPosName);
_.oDataArea = gObja(_,_.sNameControl);
_.oUnitedGrid = gObja(_,_.sBoxName);
_.oInfoTitle = gObja(_,_.sTitleName);
_.oPMI = gObja(_,_.sPmiName);
_.oNMI = gObja(_,_.sNmiName);
_.oPYI = gObja(_,_.pyiName);
_.oNYI = gObja(_,_.sNyiName);
_.oPMA = gObja(_,_.sPmaName);
_.oNMA = gObja(_,_.sNmaName);
_.oPYA = gObja(_,_.sPyaName);
_.oNYA = gObja(_,_.sNyaName);
}
function gShiftDate (oInDate, sShiftYear, sShiftMonth ,sShiftHour,sShiftMinute,sShiftSecond) {
var oTmpDate = new Date(oInDate);
if (sShiftYear) oTmpDate.setFullYear(oTmpDate.getFullYear() + sShiftYear);
if (sShiftMonth) {oTmpDate.setMonth(oTmpDate.getMonth() + sShiftMonth);}
if (sShiftHour) {oTmpDate.setHours(oTmpDate.getHours() + sShiftHour);}
if (sShiftMinute) {oTmpDate.setMinutes(oTmpDate.getMinutes() + sShiftMinute);}
if (sShiftSecond) {oTmpDate.setSeconds(oTmpDate.getSeconds() + sShiftSecond);}
if(!(sShiftHour||sShiftMinute||sShiftSecond)) {
if (oTmpDate.getDate() != oInDate.getDate()) {oTmpDate.setDate(0);}
}
return oTmpDate.valueOf();
}
function gUpdateCalendarControl(_){
_.oPYA.href = "javascript: gUserClickHandler(agC["+_.nCId+"],"+gShiftDate (_.oChiefDate,-1)+",2);";
_.oNYA.href = "javascript: gUserClickHandler(agC["+_.nCId+"],"+gShiftDate (_.oChiefDate,1)+",2);";
_.oPMA.href = "javascript: gUserClickHandler(agC["+_.nCId+"],"+gShiftDate (_.oChiefDate,null,-1)+",1);";
_.oNMA.href = "javascript: gUserClickHandler(agC["+_.nCId+"],"+gShiftDate (_.oChiefDate,null,1)+",1);";
}
function gVerifyDataArea(_)
{
// RAIMO
if (_.oDataArea.value)
{
oTmpDate = oD.ParseDate(_.oDataArea.value+'',_.sChiefFormat);
if(!oTmpDate)
{
//alert(_.oApp['messages']['Warning']);
oTmpDate = new Date()
};
if(oTmpDate.valueOf() != _.oChiefDate.valueOf())
{
_.oChiefDate = new Date(oTmpDate);
return true;
}
else
{
_.oDataArea.value = oD.GenerateDate(_.oChiefDate,_.sChiefFormat);
return false;
}
}
else return false;
}
function gDayTitle (o) {
var oWbuf = new writer();
oWbuf.into('');
for (var nWD = 0; nWD < 7; nWD++) oWbuf.into('',o.oApp.weekdays[(nWD+1)%7],' | ');
oWbuf.into('
');
return(oWbuf.out());
}
function gDayGrid(a){
var oWbuf = new writer(),oFDay = new Date(a.oChiefDate);
oFDay.setDate(1);
oFDay.setDate(1 - (6 + oFDay.getDay()) % 7);
var oTDay = new Date(oFDay);
while (oTDay.getMonth() == a.oChiefDate.getMonth() || oTDay.getMonth() == oFDay.getMonth()) {
oWbuf.into('');
for (var nWD = 0; nWD < 7; nWD++) {
oWbuf.into(gDayCell(a,oTDay));
oTDay.setDate(oTDay.getDate() + 1);
}
oWbuf.into('
\n');
}
return(oWbuf.out());
}
function gUnitedGrid(_){
var oWbuf = new writer();
oWbuf.into('');
oWbuf.into(gDayTitle(_));
oWbuf.into(gDayGrid(_));
oWbuf.into('
');
return(oWbuf.out());
}
function _UserAgent() {
var _ = this,br = navigator.appName,v = _.version = navigator.appVersion,ua=_.uas = navigator.userAgent.toLowerCase(),re_num = /opera/;
_.op = re_num.exec(ua)?true:false;
_.ie = (br == "Microsoft Internet Explorer");
if(_.op) {_.ie = false;}
_.v = parseInt(v);
if (_.ie) {
_.ie4 = _.ie5 = _.ie55 = _.ie6 = false;
if (v.indexOf('MSIE 6') > 0) {_.ie6 = true; _.v = 6;}
}
_.win32 = ua.indexOf("win")>-1;
_.mac = ua.indexOf("mac")>-1;
}
function dmMakeWorkTemplate(inFormat)
{
var _=this,sCh,nKey=0,aTmp=[],aDel=["\\\\","\\/","\\.","\\+","\\*","\\?","\\$","\\^","\\|"],aDel2=["","/",".","+","*","?","$","^","|"];
//var _=this,sCh,nKey=0,aTmp=[],aDel=["\\\\","\\/","\\.","\\+","\\*","\\?","\\$","\\^","\\|"];
for(nI = 0; nI < inFormat.length; nI ++)
{
sCh = inFormat.substr(nI,1);
if(_.dmFormatChar.indexOf(sCh) != -1 && sCh != '')
{
aTmp[nKey]=sCh;
_.dmTmpFormat[nKey++]=sCh;
}
}
nKey=1;
for(nI in aDel)
{
//inFormat=inFormat.replace(eval("/"+aDel[nI]+"/g"),aDel[nI]);
//inFormat=inFormat.replace(eval("/"+aDel[nI]+"g"),aDel[nI]);
inFormat=inFormat.replace(aDel2[nI],aDel[nI]);
//window.status = inFormat;
}
for(nI=0;nI' + oInDate.getDate() + '';
if(nTD&2) stTName = 'SelectedDay';
else if(nTD&4) stTName = 'HoliDay';
else if(nTD&8) stTName = 'OtherMonthDay';
else stTName = 'WorkDay';
sCell = '' + sCell + ' | ';
return sCell;
}
function _DManager(){
var _=this;
_.dmFormatChar='dmY';
_.dmSignFormatChar='dmY';
_.dmRegFormatChar = {'d' : "([0-9]{0,2})",'m' : "([0-9]{0,2})",'Y' : "([0-9]{4})"};
_.dmCallChar={'d':['setDate',function(_v,_m){_v=_v.getDate();if(_v<10)return('0'+_v);else return _v},function(_v){return _v*1}],'m':['setMonth',function(_v){_v=_v.getMonth()+1;if(_v<10)return('0'+_v);else return _v},function(_v){return(_v*1-1)}],'Y':['setFullYear','getFullYear',function(_v){return _v*1}]};
_.dmTmpFormat =[];
_.DateReset = gDateReset;
_.MakeWorkTemplate = dmMakeWorkTemplate;
_.GenerateDate = dmGenerateDate;
_.ParseDate = dmParseDate;
}
function gRePosition (_) {
_.oDiv.style.left = gGlobalPosition(_,'Left')+'px';
_.oDiv.style.top = gGlobalPosition(_,'Top')+'px';
if(ogB.ie6){
_.oDiv2.style.left = _.oDiv.style.left;
_.oDiv2.style.top = _.oDiv.style.top;
}
}
function gGlobalPosition (_,displace) {
var nPos = 0, tPos = _.oPos;
while (tPos) {
nPos += tPos["offset" + displace];
tPos = tPos.offsetParent;
}
return nPos;
}
function gObja (_,_id) {
if (document.images && document.images[_id]) return document.images[_id];
else if (_.formName && document.forms[_.formName].elements[_id]) return document.forms[_.formName].elements[_id];
else if (document.all && document.all[_id]) return document.all[_id];
else if (document.getElementById) return document.getElementById(_id);
else return null;
}
function writer() {
var _ = this;
_.bufArray = [];
_.into = function () {
var n = arguments.length;
for (var nI = 0; nI < n; nI++)
_.bufArray[_.bufArray.length] = arguments[nI];
};
_.out = function () {
return _.bufArray.join('');
};
}