function writeDate() {
  document.write(new Date().getFullYear());
}

function r_on(i) {
  if (document.images) { 
    if (document[i].src.indexOf("down") < 0) {
      document[i].src = "/images/" + i + "_over.gif"; 
//    document[i].src = "images/" + i + "_over.gif"; 
    }
  }
}

function r_off(i) {
  if (document.images) { 
    if (document[i].src.indexOf("down") < 0) {
      document[i].src = "/images/" + i + ".gif"; 
//    document[i].src = "images/" + i + ".gif"; 
    }
  }
}

function s_on(i) {
  if (document.images) { 
    if (document[i].src.indexOf("down") < 0) {
      document[i].src = "images/" + i + "_over.gif"; 
//    document[i].src = "images/" + i + "_over.gif"; 
    }
  }
}

function s_off(i) {
  if (document.images) { 
    if (document[i].src.indexOf("down") < 0) {
      document[i].src = "images/" + i + ".gif"; 
//    document[i].src = "images/" + i + ".gif"; 
    }
  }
}

function retext(x) {
    var nextyear = new Date();
    nextyear.setFullYear(nextyear.getFullYear() + 1);
    if (x == "small") { textsize = "11px"; }
    if (x == "medium") { textsize = "13px"; }
    if (x == "large") { textsize = "15px"; }
    
    document["text_small"].src = "/images/text_small.gif";
    document["text_medium"].src = "/images/text_medium.gif";
    document["text_large"].src = "/images/text_large.gif";
    document["text_" + x].src =  "/images/text_" + x + "_down.gif";

    $("body").css({ "font-size" : textsize });
    document.cookie = "fontsize=" + x + "; expires=" + nextyear.toGMTString() + "; path=/";    
}
 
function leaveSite(site) {
  if (confirm('You are now leaving the Hampton Wealth management web site. If you do not wish to leave this site, click Cancel. Click OK to leave.') == 1) {
    window.open(site);
  }
}

$(document).ready(function(){
  var allcookies = document.cookie;
  if(allcookies.indexOf("fontsize=") != -1) {
    if (allcookies.indexOf(";") != -1) {
	current = allcookies.substring(9,allcookies.indexOf(";"));
    } else {
      current = allcookies.substring(9);
    }
    retext(current);
  } else {
    retext("medium");
  }
});

