function GetCookie (name )  {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen)  {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg) {
       var endstr = document.cookie.indexOf (";", j);
       if (endstr == -1) endstr = document.cookie.length;
       return unescape(document.cookie.substring(j, endstr));
    }
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}

function setDateDiv( y, m, d, h){
 m = m - 1;
 d1 = new Date();
 d2 = new Date( y, m, d);
 d2.setYear( y); d2.setMonth( m); d2.setDate( d);
 d3 = d1 - d2;
 mtg = new String(d3/86400000)    //calculate days and convert to string
 point = mtg.indexOf(".")    //find the decimal point
 days = mtg.substring(0,point)    //get just the whole days
 if( days <= 1) document.write( "<div class=\"sitemap-1day\">");
 else if( days <= 3) document.write( "<div class=\"sitemap-3day\">");
 else if( days <= 7) document.write( "<div class=\"sitemap-7day\">");
 else if( days <= 21) document.write( "<div class=\"sitemap-21day\">");
 else document.write( "<div class=\"sitemap-old\">");

 var pv =  GetCookie ( "pageVisit")
 lastVisit = new Date( pv)
 d3 = lastVisit - d2;
 mtg = new String(d3/3600000)
 point = mtg.indexOf(".")
 hours = mtg.substring(0,point)
 if( hours < 1) document.write( "<div class=\"sitemap-new\">");
 else          document.write( "<div class=\"sitemap-none\">");
}


function sitemapEntryEnd(){
	document.write( "</div></div>");
}


function setSitemapCookie()
{
 var expdate = new Date (); 
 expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));  

 d1 = new Date();
 document.cookie = "pageVisit=" + d1 + "; expires=" + expdate.toGMTString();

}

