

var prop = new Object() ;
var dbtable = prop ;



var pagename= document.location;
pagenamestring = pagename.toString();
pagecode = new String( pagename );
var marker1 = pagecode.indexOf(".htm");
var marker2 = pagecode.lastIndexOf("/");
pagefinal = pagecode.substring( (marker2 + 1), marker1 );
pagefinalUP = pagefinal.toUpperCase();
var unitvalue1 = pagefinalUP ;
var unitvalue = new String( unitvalue1 );
evalunit = eval(unitvalue);
// alert(  "unitvalue... " + unitvalue  );


//var v1= 'prop' + unitvalue + '=new Object();    ';
//var v2= 'prop' + unitvalue + '["bkarray"]="";   ';
//var v3= 'prop' + unitvalue + '["avarray"]="";   ';
// sample of whats created
//prop19HL=new Object();
//prop19HL["bkarray"]="";
//prop19HL["avarray"]="";
//document.writeln( "<script language=JavaScript>" );
//document.writeln( v1 );
//document.writeln( v2 );
//document.writeln( v3 );
//document.writeln( "</script>" );




// calls just the data portion
//document.write("<script src='../cgi/cal2.js' language='JavaScript'><!-- nada --></script>");
//alert(  "unitvalue... " + unitvalue  );
// document.write("<script src='../jsdata/" + unitvalue + ".JS' language='JavaScript'><!-- nada --></script>");

document.write("<script src='cal2.js' language='JavaScript'><!-- nada --></script>");

var calendaractive = 1;

function  writePick( unitcode ) {
// alert ( "unitcode is.. " + unitcode );
// unitprop = new String( unitcode );
//unitprop = eval(unitcode)
//alert ( "lockoffs are.. " + lockoff1 + " ... " + lockoff2 );
if ( calendaractive == 1 )
{


unitvalue=unitcode;
//alert ( "unitvalue is.. " + unitvalue );

var avunit =  "prop" + unitcode + ".avarray" ; 
var bkunit =  "prop" + unitcode + ".bkarray" ; 


var propstring = "Property" + unitcode + ".Shown";
//alert ( "avunit is.. " + avunit );
//alert ( "bkunit is.. " + bkunit );

// var avunit = "prop[" + unitcode + "].prop_avarray" ; 
// document.write(" unitcode is... " + unitcode );
// document.write(" avunit is... " + avunit );
// document.write(" bkunit is... " + bkunit );
// document.write(" dbtable.doty... " + dbtable.doty );


 todayDate = new Date();
 todayDOM = "<OPTION selected>" +  todayDate.getDate();
  todayDate.getMonth() == 0  ?  textMonth0 = "SELECTED" : textMonth0 = " ";
  todayDate.getMonth() == 1  ? textMonth1 = "SELECTED" : textMonth1 = " ";
  todayDate.getMonth() == 2  ? textMonth2 = "SELECTED" : textMonth2 = " ";
  todayDate.getMonth() == 3  ? textMonth3 = "SELECTED" : textMonth3 = " ";
  todayDate.getMonth() == 4  ? textMonth4 = "SELECTED" : textMonth4 = " ";
  todayDate.getMonth() == 5  ? textMonth5 = "SELECTED" : textMonth5 = " ";
  todayDate.getMonth() == 6  ? textMonth6 = "SELECTED" : textMonth6 = " ";
  todayDate.getMonth() == 7  ? textMonth7 = "SELECTED" : textMonth7 = " ";
  todayDate.getMonth() == 8  ? textMonth8 = "SELECTED" : textMonth8 = " ";
  todayDate.getMonth() == 9  ? textMonth9 = "SELECTED" : textMonth9 = " ";
  todayDate.getMonth() == 10 ? textMonth10 = "SELECTED" : textMonth10 = " ";
  todayDate.getMonth() == 11 ? textMonth11 = "SELECTED" : textMonth11 = " ";




document.write(" <script language='JavaScript'> ");
document.write(" function computeMonth() ");
document.write("{ formdatevalue = document.formdate.pickmonth.selectedIndex; }</script> ");   
document.write("<table border=0 width=520 cellpadding=2 cellspacing=0 bgcolor=#ffffff>");
document.write("<tr bgcolor=cdcdcd><td align=right>View Available Dates For This Home In: </td>");
document.write("<td align=left><form name='formdate'>");
document.write("<SELECT name='pickmonth'>");
document.write("<OPTION value=0 " + textMonth0 + ">January");
document.write("<OPTION value=1 " + textMonth1 + ">February");
document.write("<OPTION value=2 " + textMonth2 + ">March");
document.write("<OPTION value=3 " + textMonth3 + ">April");
document.write("<OPTION value=4 " + textMonth4 + ">May");
document.write("<OPTION value=5 " + textMonth5 + ">June");
document.write("<OPTION value=6 " + textMonth6 + ">July");
document.write("<OPTION value=7 " + textMonth7 + ">August");
document.write("<OPTION value=8 " + textMonth8 + ">September");
document.write("<OPTION value=9 " + textMonth9 + ">October");
document.write("<OPTION value=10 " + textMonth10 + ">November");
document.write("<OPTION value=11 " + textMonth11 + ">December");
document.write("</select>");
document.write("<Input type=button onClick='computeMonth(); calendar(formdatevalue, ");
// document.write(" avunit , bkunit, unitvalue  "); 
document.write(  avunit + "," + bkunit + ", " );
document.write("  dbtable.doty ); ' value='click'></td></form></tr></table>");
document.write("</center>");
}
else
{
document.write("   ");
}

}


function testForWindow()
{
      if ( newwin.location != null )   
                {
                //alert("newwin... " + newwin.location );
                ID=window.setTimeout("",1000);   // have to set 'ID' here so can kill later
                }
      else
                {
                ID=window.setTimeout("testForWindow();",1000);
                }
}




function calendar( smon,  savarray, sbkarray,  sbaseday ){   

newwin = window.open( "","calendarwindow","width=420,height=280,toolbar=0,status=0,scrollbars=no");
testForWindow();
window.clearTimeout(ID);

// var imonth = 0;
// var iyear = 1997;

thisday = new Date();

var imonth = smon;
var iday = 1;
var iyear = thisday.getYear();  //syear;

// Y2K fix    
if(  iyear > 1000 ){  var icentury = 0 } else { var icentury = 1900 }
var iyear = iyear + icentury ;   
var yeardays = 365;	 
if   (((iyear % 4 == 0) && (iyear % 100 != 0)) || (iyear % 400 == 0))
{
//alert(" iyear here " + iyear );
       var yeardays = 366;
}



today = new Date();
var runmonth = today.getMonth();   // = 11
// Y2K fix
if ( today.getYear() > 1000 )
	{     var runyear = today.getYear() ; }   // = 2000 or above 	
else
	{     var runyear = today.getYear() + 1900;  } // = 97 + 1900 
	

if ( imonth < runmonth ) { iyear = iyear + 1 } else { iyear = iyear  }
var offset = 1;
var prop_avarray = "01234xxxxxx1234x6789x1234567890xx          xxxxxxxxxxxxx      xxxx                  xxxxxxxxxxxxxxxxxxxx                     xxxxx          xxxxxxxxxxxxxxxxxxxxx                                                                         xxxxxx                         xxxxxxxxxxxxxxxxxxxx                                                  xxxx";  // A104     
prop_avarray = savarray;
prop_bkarray = sbkarray;
var baseday = sbaseday;
// alert(" baseday... " + baseday + "  " + sbaseday);




var monthNames = "JanFebMarAprMayJunJulAugSepOctNovDec";   
var monthDays =  "312831303130313130313031";      
var monthDoy  =  "  0 31 59 90120151181212243273304334";  
//alert(" iyear... " + iyear );
var rundate = new Date( iyear, imonth, iday, 8, 0, 0 );


// Y2K fix    
var testyear = rundate.getYear();
if( testyear > 1000 ){  var century = 0 } else { var century = 1900 }
var year = rundate.getYear() + century ;   



//////// determine leapyear adjustment for calendars after Feb-Dec
var ly = 0;
var leapyear = parseInt( ly );

//var yeardays = 365;
if   (((runyear % 4 == 0) && (runyear % 100 != 0)) || (runyear % 400 == 0))
{
//var yeardays = 366;
}


if   (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
{
     if ( rundate.getMonth() > 1 )
     {
       var ly = 1;
       var leapyear = parseInt( ly );
    //   var yeardays = 366;
// alert(" yeardays... " + yeardays );
	     }
}


nDays = (monthDays.substring( rundate.getMonth() * 2,( rundate.getMonth() + 1) * 2));   
     if ( rundate.getMonth() == 1 && ly == 1)
     {
	   var nDays = 29;
     }

//alert(" nDays... " + nDays );
var nDaysInt = parseInt( nDays );
var nDoystring =  (monthDoy.substring(  rundate.getMonth() * 3,( rundate.getMonth() + 1) * 3)  );   
var nDoy = parseInt( nDoystring ) + leapyear  ;
var nDoynext =   nDoy  + nDaysInt ;
var thisDay;   
thisDay = rundate.getDate();      




// reads   e.g.  Dec 15 1997
firstDay = rundate;   
// sets a date equal to 1st day of month  e.g.   Dec 1 1997
firstDay.setDate(1);   
// figure out what day of the week to start at e.g.  0-6
var startDay = firstDay.getDay();        


// newwin.document.writeln( "<br>startday = " + startDay );   
//  newwin.document.writeln( "<br>nDays = " + nDays );   
//  newwin.document.writeln( "<br>nDoy = " + nDoy );   
//  newwin.document.writeln( "<br>nDoynext = " + nDoynext );   
//  newwin.document.writeln( "<br>baseday = " + baseday );   

// document.writeln("<CENTER>");   

if ( imonth < runmonth ) { var showyear = runyear + 1 } else { var showyear = runyear }
if ( imonth < runmonth ) { var yr = 365 } else { var yr = 0 };  // need to read file dates month I think


// newwin.document.writeln( "y onLoad( 'this.window.focus()';>" );
 newwin.document.write("<body bgcolor=#efefef ; xonBlur='window.close(self)'; ><center>");   
// newwin.document.write("<b> Property # " + sunitcode + "</b>" );
// newwin.document.write("<font size=2 face=arial><a href='bookit.html?" +unitvalue+ "'>- book it now- </a></font><br>" );
// newwin.document.write("<a href='bookit.html?" +unitvalue+ "'><img src='bookit3.jpg' width=274 height=40 alt='CLICK HERE to book it now' border=0></a><br>" );
 newwin.document.write("<b>Unit Code:  " + unitvalue + "</b>" );
 newwin.document.write("<TABLE border=0 width=400 cellpadding=2><tr valign=top><td align=center>");
 newwin.document.write("<TABLE BORDER=0 bgcolor=black width=180 cellpadding=2 cellspacing=1><TR bgcolor=efefef><TH COLSPAN=7><font size=2 face=arial>");   
 
 var shortmonth = monthNames.substring( rundate.getMonth() * 3,( rundate.getMonth() + 1) * 3) ;
if ( shortmonth   == "Jan" )  { var longmonth = "January" };
if ( shortmonth   == "Feb" )  { var longmonth = "February" };
if ( shortmonth   == "Mar" )  { var longmonth = "March" };
if ( shortmonth   == "Apr" )  { var longmonth = "April" };
if ( shortmonth   == "May" )  { var longmonth = "May" };
if ( shortmonth   == "Jun" )  { var longmonth = "June" };
if ( shortmonth   == "Jul" )  { var longmonth = "July" };
if ( shortmonth   == "Aug" )  { var longmonth = "August" };
if ( shortmonth   == "Sep" )  { var longmonth = "September" };
if ( shortmonth   == "Oct" )  { var longmonth = "October" };
if ( shortmonth   == "Nov" )  { var longmonth = "November" };
if ( shortmonth   == "Dec" )  { var longmonth = "December" };


 newwin.document.write( longmonth );

 
// newwin.document.write(monthNames.substring( rundate.getMonth() * 3,( rundate.getMonth() + 1) * 3));   
 newwin.document.write(" ~ ");   
 newwin.document.write(showyear);   
// testing document.write(" ~ ");   
// testing document.write(rundate);


   
 newwin.document.write("<TR bgcolor=#efffef valign=bottom>");   
 newwin.document.write("<TH width=22><font size=1 face=arial>Sun</TH><TH width=22><font size=1 face=arial>Mon</TH><TH width=22><font size=1 face=arial>Tue</TH><TH width=22><font size=1 face=arial>Wed</TH><TH width=22><font size=1 face=arial>Thu</TH><TH width=22><font size=1 face=arial>Fri</TH><TH width=22><font size=1 face=arial>Sat</TH>");      
 newwin.document.write("</TR><TR>");
column = 0;
for (i=0; i<startDay; i++)   {
 newwin.document.write("<TD>");      
column++;      
}
for (i=1; i<=nDays; i++)   {      
var occup = "black";





if ( ( nDoy <=  baseday)  &&  ( baseday <= nDoynext )   )
{                
startoffset = (  nDoy - baseday );
}
else        // 344       121 
{       if  ( baseday > nDoynext) 
		{  
		startoffset = (  nDoy +  ( yeardays  - baseday) );
//		startoffset = (  nDoy +  ( 365  - baseday) );
		} 
        else
		{   startoffset = (  nDoy -  baseday  ) ;  
//		alert("using this");
		}
}



locat =  ( startoffset ) + i ;

if
 ( prop_avarray.charAt( locat ) == "x" || prop_bkarray.charAt( locat ) == "b"
 )
{
     var occup = "red"  ;
}
else
{              //  show black for period of no data
//if ( locat <= 0 ) {var occup = "black" } else {var occup = "pink"} ;
if ( locat <= 0 ) {var occup = "gray" } else {var occup = "pink"} ;

}
if ( locat < 0 ) {var occup = "black" } ;
if ( locat < todayDate.getDate() ) {var occup = "gray" } ;

 newwin.document.write("</td><TD bgcolor=" + occup + "><font size=1 face=arial>");      

// testing document.write( locat + "~" +  runyear + "~" + showyear + "~" +  runmonth + "~" +imonth + "~");
//if (i == thisDay)         
// document.write("<FONT COLOR=\"#FF0000\" SIZE+=4>")      

 newwin.document.write(i);      
// if (i == thisDay)        
// document.write("</FONT>")      
column++;      
if (column == 7)      {         
 newwin.document.write("<TR>"); 
      
column = 0;      
}   
}   
 newwin.document.write("</TABLE>");   
 newwin.document.writeln("</CENTER>");

 newwin.document.writeln("</td><td align=center>");

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ////////////////////   2nd calendar here
 
 
thisday = new Date();

var imonth = eval(smon) + 1;
// var imonth = smon;
var iday = 1;
var iyear = thisday.getYear();  //syear;

// Y2K fix    
if(  iyear > 1000 ){  var icentury = 0 } else { var icentury = 1900 }
var iyear = iyear + icentury ;   
var yeardays = 365;	 
if   (((iyear % 4 == 0) && (iyear % 100 != 0)) || (iyear % 400 == 0))
{
//alert(" iyear here " + iyear );
       var yeardays = 366;
}



today = new Date();
var runmonth = today.getMonth();   // = 11
// Y2K fix
if ( today.getYear() > 1000 )
	{     var runyear = today.getYear() ; }   // = 2000 or above 	
else
	{     var runyear = today.getYear() + 1900;  } // = 97 + 1900 
	

if ( imonth < runmonth ) { iyear = iyear + 1 } else { iyear = iyear  }
var offset = 1;
var prop_avarray = "01234xxxxxx1234x6789x1234567890xx          xxxxxxxxxxxxx      xxxx                  xxxxxxxxxxxxxxxxxxxx                     xxxxx          xxxxxxxxxxxxxxxxxxxxx                                                                         xxxxxx                         xxxxxxxxxxxxxxxxxxxx                                                  xxxx";  // A104     
prop_avarray = savarray;
prop_bkarray = sbkarray;
var baseday = sbaseday;
// alert(" baseday... " + baseday + "  " + sbaseday);




var monthNames = "JanFebMarAprMayJunJulAugSepOctNovDec";   
var monthDays =  "312831303130313130313031";      
var monthDoy  =  "  0 31 59 90120151181212243273304334";  
//alert(" iyear... " + iyear );
var rundate = new Date( iyear, imonth, iday, 8, 0, 0 );


// Y2K fix    
var testyear = rundate.getYear();
if( testyear > 1000 ){  var century = 0 } else { var century = 1900 }
var year = rundate.getYear() + century ;   



//////// determine leapyear adjustment for calendars after Feb-Dec
var ly = 0;
var leapyear = parseInt( ly );

//var yeardays = 365;
if   (((runyear % 4 == 0) && (runyear % 100 != 0)) || (runyear % 400 == 0))
{
//var yeardays = 366;
}


if   (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
{
     if ( rundate.getMonth() > 1 )
     {
       var ly = 1;
       var leapyear = parseInt( ly );
    //   var yeardays = 366;
// alert(" yeardays... " + yeardays );
	     }
}


nDays = (monthDays.substring( rundate.getMonth() * 2,( rundate.getMonth() + 1) * 2));   
     if ( rundate.getMonth() == 1 && ly == 1)
     {
	   var nDays = 29;
     }

//alert(" nDays... " + nDays );
var nDaysInt = parseInt( nDays );
var nDoystring =  (monthDoy.substring(  rundate.getMonth() * 3,( rundate.getMonth() + 1) * 3)  );   
var nDoy = parseInt( nDoystring ) + leapyear  ;
var nDoynext =   nDoy  + nDaysInt ;
var thisDay;   
thisDay = rundate.getDate();      




// reads   e.g.  Dec 15 1997
firstDay = rundate;   
// sets a date equal to 1st day of month  e.g.   Dec 1 1997
firstDay.setDate(1);   
// figure out what day of the week to start at e.g.  0-6
var startDay = firstDay.getDay();        


// newwin.document.writeln( "<br>startday = " + startDay );   
//  newwin.document.writeln( "<br>nDays = " + nDays );   
//  newwin.document.writeln( "<br>nDoy = " + nDoy );   
//  newwin.document.writeln( "<br>nDoynext = " + nDoynext );   
//  newwin.document.writeln( "<br>baseday = " + baseday );   

// document.writeln("<CENTER>");   

if ( imonth < runmonth ) { var showyear = runyear + 1 } else { var showyear = runyear }
if ( imonth < runmonth ) { var yr = 365 } else { var yr = 0 };  // need to read file dates month I think


 newwin.document.write("<TABLE BORDER=0 bgcolor=black width=180 cellpadding=2 cellspacing=1><TR bgcolor=efefef><TH COLSPAN=7><font size=2 face=arial>");   
// newwin.document.write("<TABLE BORDER=1 width=180 cellpadding=2 cellspacing=0><TR bgcolor=efefef><TH COLSPAN=7><font size=2 face=arial>");   
 
 var shortmonth = monthNames.substring( rundate.getMonth() * 3,( rundate.getMonth() + 1) * 3) ;
if ( shortmonth   == "Jan" )  { var longmonth = "January" };
if ( shortmonth   == "Feb" )  { var longmonth = "February" };
if ( shortmonth   == "Mar" )  { var longmonth = "March" };
if ( shortmonth   == "Apr" )  { var longmonth = "April" };
if ( shortmonth   == "May" )  { var longmonth = "May" };
if ( shortmonth   == "Jun" )  { var longmonth = "June" };
if ( shortmonth   == "Jul" )  { var longmonth = "July" };
if ( shortmonth   == "Aug" )  { var longmonth = "August" };
if ( shortmonth   == "Sep" )  { var longmonth = "September" };
if ( shortmonth   == "Oct" )  { var longmonth = "October" };
if ( shortmonth   == "Nov" )  { var longmonth = "November" };
if ( shortmonth   == "Dec" )  { var longmonth = "December" };


 newwin.document.write( longmonth );

 
// newwin.document.write(monthNames.substring( rundate.getMonth() * 3,( rundate.getMonth() + 1) * 3));   
 newwin.document.write(" ~ ");   
 newwin.document.write(showyear);   
// testing document.write(" ~ ");   
// testing document.write(rundate);


   
 newwin.document.write("</TH></TR><TR bgcolor=#efffef valign=bottom>");   
 newwin.document.write("<TH width=22><font size=1 face=arial>Sun</TH><TH width=22><font size=1 face=arial>Mon</TH><TH width=22><font size=1 face=arial>Tue</TH><TH width=22><font size=1 face=arial>Wed</TH><TH width=22><font size=1 face=arial>Thu</TH><TH width=22><font size=1 face=arial>Fri</TH><TH width=22><font size=1 face=arial>Sat</TH>");      
 newwin.document.write("</TR><TR>");
column = 0;
for (i=0; i<startDay; i++)   {
 newwin.document.write("<TD>");      
column++;      
}
for (i=1; i<=nDays; i++)   {      
var occup = "black";





if ( ( nDoy <=  baseday)  &&  ( baseday <= nDoynext )   )
{                
startoffset = (  nDoy - baseday );
}
else        // 344       121 
{       if  ( baseday > nDoynext) 
		{  
		startoffset = (  nDoy +  ( yeardays  - baseday) );
//		startoffset = (  nDoy +  ( 365  - baseday) );
		} 
        else
		{   startoffset = (  nDoy -  baseday  ) ;  
//		alert("using this");
		}
}



locat =  ( startoffset ) + i ;

if
 ( prop_avarray.charAt( locat ) == "x" || prop_bkarray.charAt( locat ) == "b"
 )
{
     var occup = "red"  ;
}
else
{              //  show black for period of no data
//if ( locat <= 0 ) {var occup = "black" } else {var occup = "pink"} ;
if ( locat <= 0 ) {var occup = "gray" } else {var occup = "pink"} ;
}

 newwin.document.write("</td><TD bgcolor=" + occup + "><font size=1 face=arial>");      

// testing document.write( locat + "~" +  runyear + "~" + showyear + "~" +  runmonth + "~" +imonth + "~");
//if (i == thisDay)         
// document.write("<FONT COLOR=\"#FF0000\" SIZE+=4>")      

 newwin.document.write(i);      
// if (i == thisDay)        
// document.write("</FONT>")      
column++;      
if (column == 7)      {         
 newwin.document.write("<TR>"); 
      
column = 0;      
}   
}   
 
 
 ////////////// end 2nd calendar here

 
 newwin.document.write("</TABLE>");   
 newwin.document.write("</td></tr></table>");     /////  end left-right table


 newwin.document.writeln("</CENTER>");

 
 
 newwin.document.write("<br><center><table border=0 cellpadding=1><tr><th bgcolor=pink>Available</th><th bgcolor=red>Not Available</th></tr></table></center>");


// newwin.document.writeln("<br><center><FORM name='junkhere'><input name='foo' type=text></form>");

// newwin.document.writeln("<script language='javascript'> focus();</script>");
 newwin.document.writeln("<br><center><FORM name='closehere'><INPUT type='button'  onClick='window.close(self)'; value='Close'></FORM>");
 newwin.document.writeln("<!-- testing here -->");


// newwin.document.writeln("<script src='calendar.js' language='JavaScript'>");
// newwin.document.writeln("<script >");
// newwin.document.writeln(" opener.writePick( 4 ); ");
// newwin.document.writeln("</script>");


      newwin.document.focus;      ///  this works for MSIE
      newwin.focus();                   ///  this works for Netscape
	                                          ///   use BOTH, they don''t seem to 'hurt' the opposite browser


 newwin.document.close();

}



// -->


