// JavaScript Document

// Opens a new email message when user forwards the home page or current page to a friend
// Obtained from Hoover Web Design
function mailpage()
{
mail_str = "mailto:?subject=Check out " + document.title;
mail_str += "&body=Hi. I thought you might be interested in this article: " + document.title;
mail_str += ". You can view it at, " + location.href; 
mail_str += ". It comes from a web site called http://www.ShopWithTrust.com.  They offer good articles on using the internet and advice on shopping.  They also have links to all of the major retailers in one location, including information on current sales and special offers.  Take Care, ";
location.href = mail_str;
}

function mailsite()
{
mail_str = "mailto:?subject=Check out Shop With Trust " ;
mail_str += "&body=Hi. I thought you might like this web site: http://www.ShopWithTrust.com.  ";
mail_str += "It has links to all of the major retailers in one location and includes information on current sales.  They also offer easy-to-understand articles on using the internet and advice on shopping. " ; 
mail_str += "Take Care, ";
location.href = mail_str;
}

// Open New Browser Window for external web sites
// Obtained from Sitepoint's Simply Javascript book.
var externalLinks =
{
  init: function()
  {
    var extLinks = Core.getElementsByClass("external");

    for (var i = 0; i < extLinks.length; i++)
    {
      extLinks[i].onclick = externalLinks.clickHandler;
    }
  },

  clickHandler: function()
  {
    open(this.href);
    return false;
  }
};

Core.start(externalLinks);

// Ensures that the proper number of characters are entered for the user's ZIP Code.
// Obtained from sears web site and adjusted
function checkZip() {
  zip = document.forms["zipForm"].elements["zip"].value; 
  var lv_pattern = /^\d{5}$|^\d{5}\-?\d{4}$/;
  var passed = lv_pattern.test(zip); 
  if (!passed) {
  	alert("Please re-enter your ZIP Code.  There should be 5 digits in your ZIP Code.  Thank you.");
  	return false;
  }
  else {
  	return true;
  }
}

