var nav=navigator.appName;
var uag=navigator.userAgent;
var brow="";
if (uag.indexOf("Netscape/7")>-1){
brow="NS7";
}else if (uag.indexOf("Firefox")>-1){
brow="Firefox";
}else if (uag.indexOf("Opera")>-1){
brow="Opera";
}else{
brow="IE";
}

var tmp_today=new Date();

var mm_today= new Date(tmp_today.getFullYear(),tmp_today.getMonth(),tmp_today.getDate(),0,0,0,0);
var mm_today_date  = mm_today.getDate();
var mm_today_month = mm_today.getMonth();
var mm_today_year  = mm_today.getFullYear();

dateTDW=23;

function chkleap(y){
if (y%4==0){return 29;}else{return 28;}
}
var TotDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var MMonths = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var Days = new Array("S","M","T","W","T","F","S");

function getMM(MM){
return MMonths[MM];
}

function getTotDays(Mm,Yy){
if (Number(Mm)==1 && Yy%4==0){
return 29;}else{
return TotDays[Mm]}
}

function getStday(Mm,Yy){
tmpDay= new Date(Yy,Mm,"01",0,0,0,0);
return Number(tmpDay.getDay());
}

function ddOv(obj,st){
obj.className="tday"+st+"";
}

function setDD(Yy,Mm,DD){
for (x=0; x<parent.document.forms["RG_frm1"].elements["cmbCheckInYear"].options.length; x++){
if (parent.document.forms["RG_frm1"].elements["cmbCheckInYear"].options[x].value==Yy){
parent.document.forms["RG_frm1"].elements["cmbCheckInYear"].selectedIndex=x;
}
}
parent.document.forms["RG_frm1"].elements["cmbCheckInMonth"].selectedIndex=Mm-1;
parent.setMonthDays('In');
parent.document.forms["RG_frm1"].elements["cmbCheckInDate"].selectedIndex=DD-1;
parent.setCheckOut();
hideCal();
}



function startHide(){
setTimeout("hideCal()",1500);
}

function hideCal(){
parent.document.getElementById("calWin").style.visibility="hidden";
parent.document.getElementById("calWin").style.height="1px"
}


function buildMonth(Mm,Yy){
stDay=getStday(Mm,Yy);
totDays=getTotDays(Mm,Yy);
reqTDs=totDays+stDay;
if (reqTDs>35){toLoop=42;}else{toLoop=35;}
dayCount=0;
tdCount=0;
tmpStr="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
tmpStr+="<tr height=\"16\" align=\"center\">\n";
tmpStr+="<td colspan=\"7\" align=\"right\" class=\"tday\"><table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">\n";
tmpStr+="<tr height=\"16\">\n";
tmpStr+="<td class=\"txt1\">"+getMM(Mm)+" - "+Yy+"</td>\n";
if (Mm==0){
tmpStr+="<td align=\"right\"><a href=\"JavaScript:buildCal(11,"+(Number(Yy)-1)+");\"><img src=\"cal_prev.gif\" width=\"13\" height=\"13\" border=\"0\"></a>";
}else{
tmpStr+="<td align=\"right\"><a href=\"JavaScript:buildCal("+(Number(Mm)-1)+","+Yy+");\"><img src=\"cal_prev.gif\" width=\"13\" height=\"13\" border=\"0\"></a>";
}
if (Mm==11){
tmpStr+="<a href=\"JavaScript:buildCal(0,"+(Number(Yy)+1)+");\"><img src=\"cal_next.gif\" width=\"13\" height=\"13\" border=\"0\"></a></td>\n";
}else{
tmpStr+="<a href=\"JavaScript:buildCal("+(Number(Mm)+1)+","+Yy+");\"><img src=\"cal_next.gif\" width=\"13\" height=\"13\" border=\"0\"></a></td>\n";
}
tmpStr+="</tr>\n";
tmpStr+="</table></td>\n";
tmpStr+="</tr>\n";
tmpStr+="<tr height=\"16\" align=\"center\">\n";
for (c=0; c<7; c++){
tmpStr+="<td width=\""+dateTDW+"\" class=\"tdays\">"+Days[c]+"</td>\n";
}
tmpStr+="</tr>\n";
tmpStr+="<tr>\n";
tmpStr+="<td colspan=\"7\"><img src=\"images/s.gif\" width=\"1\" height=\"3\" border=\"0\"></td>\n";
tmpStr+="</tr>\n";
for (a=0; a<(reqTDs/7); a++){
tmpStr+="<tr height=\"22\" align=\"center\">\n";
for (b=0; b<7; b++){
	if (tdCount<stDay){
	tmpStr+="<td width=\""+dateTDW+"\" class=\"tdot\">.</td>\n";
	}else{
	dayCount+=1;
	if (dayCount<=totDays){if (dayCount<10){
	tmpStr+="<td width=\""+dateTDW+"\" class=\"tday\" onClick=\"setDD("+Yy+","+(Number(Mm)+1)+",this.innerHTML,'-');\" onMouseOver=\"ddOv(this,'ov')\" onMouseOut=\"ddOv(this,'')\">0"+dayCount+"</td>\n";
	}else{tmpStr+="<td width=\""+dateTDW+"\" class=\"tday\" onClick=\"setDD("+Yy+","+(Number(Mm)+1)+",this.innerHTML,'-');\" onMouseOver=\"ddOv(this,'ov')\" onMouseOut=\"ddOv(this,'')\">"+dayCount+"</td>\n";}}else{
	tmpStr+="<td width=\""+dateTDW+"\" class=\"tdot\">.</td>\n";}
	}
tdCount+=1;	
}
tmpStr+="</tr>\n";
}

<!-- tmpStr+="<tr><td><img src=\"cal_close.gif\" onClick=\"hideCal();\"></td></tr></table>\n"; -->
tmpStr+="</table>\n";
return tmpStr;
}

var tmp_date="";
var chk_tmp_date="";
function getDefaults(){
tmp_date=""+parent.document.forms["RG_frm1"].elements["cmbCheckInMonth"].options[parent.document.forms["RG_frm1"].elements["cmbCheckInMonth"].selectedIndex].value+"-"+parent.document.forms["RG_frm1"].elements["cmbCheckInDate"].options[parent.document.forms["RG_frm1"].elements["cmbCheckInDate"].selectedIndex].value+"-"+parent.document.forms["RG_frm1"].elements["cmbCheckInYear"].options[parent.document.forms["RG_frm1"].elements["cmbCheckInYear"].selectedIndex].value+"";
buildCal(parent.document.forms["RG_frm1"].elements["cmbCheckInMonth"].options[parent.document.forms["RG_frm1"].elements["cmbCheckInMonth"].selectedIndex].value,parent.document.forms["RG_frm1"].elements["cmbCheckInYear"].options[parent.document.forms["RG_frm1"].elements["cmbCheckInYear"].selectedIndex].value);
setInterval("stay_alert()","300");
}

function stay_alert(){
chk_tmp_date=""+parent.document.forms["RG_frm1"].elements["cmbCheckInMonth"].options[parent.document.forms["RG_frm1"].elements["cmbCheckInMonth"].selectedIndex].value+"-"+parent.document.forms["RG_frm1"].elements["cmbCheckInDate"].options[parent.document.forms["RG_frm1"].elements["cmbCheckInDate"].selectedIndex].value+"-"+parent.document.forms["RG_frm1"].elements["cmbCheckInYear"].options[parent.document.forms["RG_frm1"].elements["cmbCheckInYear"].selectedIndex].value+"";
if (chk_tmp_date!=tmp_date){
tmp_date=chk_tmp_date;
buildCal(parent.document.forms["RG_frm1"].elements["cmbCheckInMonth"].options[parent.document.forms["RG_frm1"].elements["cmbCheckInMonth"].selectedIndex].value,parent.document.forms["RG_frm1"].elements["cmbCheckInYear"].options[parent.document.forms["RG_frm1"].elements["cmbCheckInYear"].selectedIndex].value);
}
}

function buildCal(m,y){
if (y>=mm_today_year && m>=mm_today_month && y<=(mm_today_year+4)){
document.getElementById("calWinID").innerHTML=buildMonth(m,y);
}
}


