// Used for getting accurated date for cookie
var expdate = new Date ();
FixCookieDate (expdate); // Correct for Mac date bug - call only once for given Date object!
expdate.setTime (expdate.getTime() + (30*24 * 60 * 60 * 1000)); // 30 days from now 
function colClick(inpName) {
  var arr = showModalDialog( "diary_selcolour.htm",
                             "",
                             "font-family:Verdana; font-size:12; dialogWidth:30em; dialogHeight:30em; status:no; help:no" );
    if (arr != null){
	  window.event.srcElement.style.backgroundColor = arr;
	  window.event.srcElement.style.borderColor = arr;
	  inpName.value=arr;
	}
}	
function TcolClick(inpName) {
  var bg;
  var arr = showModalDialog( "diary_selcolour.htm",
                             "",
                             "font-family:Verdana; font-size:12; dialogWidth:30em; dialogHeight:30em; status:no; help:no" );
    if (arr != null){
	  window.event.srcElement.style.color = arr;
	  eval('frmColors.' + inpName.name + 'BG.style.color = arr;');
	  inpName.value=arr;
	}
}
function UpdateColors(flg) {
  var i=0;
  var j;
  var eln;
  for (i=0;i<=5;i++){
    for (j=1;j<=7;j++){
		eln = eval('document.getElementById("'+i+j+'").name;');
		switch (eval('String("'+eln+'").substring(0,1)')) {
			case 'w':
//      			frmColors.txtWeekendBG.style.backgroundColor = frmColors.txtWeekendBG.value;
//	  			eval('document.getElementById("'+i+j+'").style.backgroundColor = frmColors.txtWeekendBG.value;');
//	  			eval('document.getElementById("'+i+j+'").style.color = frmColors.txtWeekend.value;');

			  if (GetCookie("txtWeekendBG") == null || flg) { 
      			frmColors.txtWeekendBG.style.backgroundColor = frmColors.txtWeekendBG.value;
	  			eval('document.getElementById("'+i+j+'").style.backgroundColor = frmColors.txtWeekendBG.value;');
			  } else {
      			frmColors.txtWeekendBG.value = GetCookie("txtWeekendBG");
	  			eval('document.getElementById("'+i+j+'").style.backgroundColor = frmColors.txtWeekendBG.value;');
      			frmColors.txtWeekendBG.style.backgroundColor = frmColors.txtWeekendBG.value;
			  }
			  if (GetCookie("txtWeekend") == null || flg) { 
	  			eval('document.getElementById("'+i+j+'").style.color = frmColors.txtWeekend.value;');
			  } else {
      			frmColors.txtWeekend.value = GetCookie("txtWeekend");
      			frmColors.txtWeekend.style.color = GetCookie("txtWeekend");
      			frmColors.txtWeekendBG.style.color = GetCookie("txtWeekend");
	  			eval('document.getElementById("'+i+j+'").style.color = GetCookie("txtWeekend");');
			  }

			break;
			case 'd':
			  if (GetCookie("txtWeekdayBG") == null || flg) { 
      			frmColors.txtWeekdayBG.style.backgroundColor = frmColors.txtWeekdayBG.value;
	  			eval('document.getElementById("'+i+j+'").style.backgroundColor = frmColors.txtWeekdayBG.value;');
			  } else {
      			frmColors.txtWeekdayBG.value = GetCookie("txtWeekdayBG");
	  			eval('document.getElementById("'+i+j+'").style.backgroundColor = frmColors.txtWeekdayBG.value;');
      			frmColors.txtWeekdayBG.style.backgroundColor = frmColors.txtWeekdayBG.value;
			  }
			  if (GetCookie("txtWeekend") == null || flg) { 
	  			eval('document.getElementById("'+i+j+'").style.color = frmColors.txtWeekday.value;');
			  } else {
      			frmColors.txtWeekday.value = GetCookie("txtWeekday");
      			frmColors.txtWeekday.style.color = GetCookie("txtWeekday");
      			frmColors.txtWeekdayBG.style.color = GetCookie("txtWeekday");
				eval('document.getElementById("'+i+j+'").style.color = GetCookie("txtWeekday");');
			  }
//      			frmColors.txtWeekdayBG.style.backgroundColor = frmColors.txtWeekdayBG.value;
//	  			eval('document.getElementById("'+i+j+'").style.backgroundColor = frmColors.txtWeekdayBG.value;');
//	  			eval('document.getElementById("'+i+j+'").style.color = frmColors.txtWeekday.value;');
			break;
			case 't':
			  if (GetCookie("txtTodayBG") == null || flg) { 
      			frmColors.txtTodayBG.style.backgroundColor = frmColors.txtTodayBG.value;
	  			eval('document.getElementById("'+i+j+'").style.backgroundColor = frmColors.txtTodayBG.value;');
			  } else {
      			frmColors.txtTodayBG.value = GetCookie("txtTodayBG");
	  			eval('document.getElementById("'+i+j+'").style.backgroundColor = frmColors.txtTodayBG.value;');
      			frmColors.txtTodayBG.style.backgroundColor = frmColors.txtTodayBG.value;
			  }
			  if (GetCookie("txtWeekend") == null || flg) { 
	  			eval('document.getElementById("'+i+j+'").style.color = frmColors.txtToday.value;');
			  } else {
      			frmColors.txtToday.value = GetCookie("txtToday");
      			frmColors.txtToday.style.color = GetCookie("txtToday");
      			frmColors.txtToday.style.color = GetCookie("txtToday");
				eval('document.getElementById("'+i+j+'").style.color = GetCookie("txtToday");');
			  }
//      			frmColors.txtTodayBG.style.backgroundColor = frmColors.txtTodayBG.value;
//	  			eval('document.getElementById("'+i+j+'").style.backgroundColor = frmColors.txtTodayBG.value;');
//	  			eval('document.getElementById("'+i+j+'").style.color = frmColors.txtToday.value;');
			break;
		}
    }
  }
}
function savecolors() {
	SetCookie ("txtWeekendBG", frmColors.txtWeekendBG.value, expdate);
	SetCookie ("txtWeekend", frmColors.txtWeekend.value, expdate);
	SetCookie ("txtWeekdayBG", frmColors.txtWeekdayBG.value, expdate);
	SetCookie ("txtWeekday", frmColors.txtWeekday.value, expdate);
	SetCookie ("txtTodayBG", frmColors.txtTodayBG.value, expdate);
	SetCookie ("txtToday", frmColors.txtToday.value, expdate);
}
function defaultC() {
	DeleteCookie ("txtWeekendBG");
	DeleteCookie ("txtWeekend");
	DeleteCookie ("txtWeekdayBG");
	DeleteCookie ("txtWeekday");
	DeleteCookie ("txtTodayBG");
	DeleteCookie ("txtToday");
}

