// DETERMINE CURRENT PAGE FROM QUERYSTRING
var queryString, currentPage
queryString = String(this.location).split("?");
queryString = queryString[queryString.length-1];
if (queryString.match("page=", "i"))
{
 currentPage = queryString.replace("page=","");
}
else
{
 if (String(this.location).match("/lofts/", "i"))
 {
  currentPage = "loftshome";
 }
 else
 {
  if (String(this.location).match("/plumbing/", "i"))
  {
   currentPage = "plumbinghome";
  }
 }
}

// PRELOAD THE ROLL-OVER IMAGES IF THE BROWSER IS CAPABLE
if (document.images)
{
 var loftshomeoff = new Image();
  loftshomeoff.src = "/images/b_home_off.gif";
 var loftshomeon = new Image();
  loftshomeon.src = "/images/b_home_on.gif";

 var loftsandextensionsoff = new Image();
  loftsandextensionsoff.src = "/images/b_loftsandextensions_off.gif";
 var loftsandextensionson = new Image();
  loftsandextensionson.src = "/images/b_loftsandextensions_on.gif";

 var additionalservicesoff = new Image();
  additionalservicesoff.src = "/images/b_additionalservices_off.gif";
 var additionalserviceson = new Image();
  additionalserviceson.src = "/images/b_additionalservices_on.gif";

 var faqoff = new Image();
  faqoff.src = "/images/b_faq_off.gif";
 var faqon = new Image();
  faqon.src = "/images/b_faq_on.gif";

 var referencesoff = new Image();
  referencesoff.src = "/images/b_references_off.gif";
 var referenceson = new Image();
  referenceson.src = "/images/b_references_on.gif";

 var loftscontactoff = new Image();
  loftscontactoff.src = "/images/b_contact_off.gif";
 var loftscontacton = new Image();
  loftscontacton.src = "/images/b_contact_on.gif";

 var plumbinghomeoff = new Image();
  plumbinghomeoff.src = "/images/b_home_off.gif";
 var plumbinghomeon = new Image();
  plumbinghomeon.src = "/images/b_home_on.gif";

 var plumbingcontactoff = new Image();
  plumbingcontactoff.src = "/images/b_contact_off.gif";
 var plumbingcontacton = new Image();
  plumbingcontacton.src = "/images/b_contact_on.gif";

 var linksoff = new Image();
  linksoff.src = "/images/b_links_off.gif";
 var linkson = new Image();
  linkson.src = "/images/b_links_on.gif";

 var pricelistoff = new Image();
  pricelistoff.src = "/images/b_pricelist_off.gif";
 var priceliston = new Image();
  priceliston.src = "/images/b_pricelist_on.gif";

 var specialistbuildersoff = new Image();
  specialistbuildersoff.src = "/images/b_specialistbuilders_off.gif";
 var specialistbuilderson = new Image();
  specialistbuilderson.src = "/images/b_specialistbuilders_on.gif";

 var plumbingandheatingoff = new Image();
  plumbingandheatingoff.src = "/images/b_plumbingandheating_off.gif";
 var plumbingandheatingon = new Image();
  plumbingandheatingon.src = "/images/b_plumbingandheating_on.gif";
}

// FUNCTION TO SWAP IMAGE ON MOUSE-OVER
function ButtonOn(Button)
{
 if (document.images && (Button != currentPage)){document[Button].src = eval(Button + "on.src");}
}

// FUNCTION TO REPLACE IMAGE ON MOUSE-OFF
function ButtonOff(Button)
{
 if (document.images && (Button != currentPage)){document[Button].src = eval(Button + "off.src");}
}

// FUNCTION TO SPAWN PHOTO WINDOW
function openWin(imgSource,imgWidth,imgHeight)
{
 var windowURL, windowName, windowFeatures
 windowURL = "/photos.php?imgSource=" + imgSource;
 windowName = imgSource.slice(0,-4);
 windowFeatures = "width=" + imgWidth + ",height=" + imgHeight + ",directories=no,left=20,top=20,location=no,menuBar=no,scrollBars=no,status=no,toolbar=no,resizable=no";
 return window.open(windowURL,windowName,windowFeatures);
}

