/*==================================================*
 $Id: common.js,v 1.0 2004/01/27 16:54:31 pat Exp $
 Copyright 2004+ Mike Denman & Walnut Street Hardwoods, Inc.
 http://www.walnut-street.com/

 This program is copyrighted for use only on this website by the
 author and Walnut Street Hardwoods, Inc. from 2004 on.
 *==================================================*/

//Declare urls of each of the website versions
var baseurl='http://www.walnut-street.com';
var pdatext='/index.html';
var small='/WSH2/index2.html';
var large='/WSH/index.html';
var xlarge='/WSH3/index.html';

// This file contains functions that are called by multiple, or
// all pages within this site to properly load frames, detect browser
// support and screen size and adjust code to perform regular tasks.

//==================================================
// frametopload(src) Loads a document to top frame appropriately
//==================================================

function frametopload(url) {
 
//Detect javascript support for location.replace()
//If not supported, use location.href instead and unfortunately annoy the user
//with a back button that adds another history page unintentionally.
  if (document.images) {
	top.location.replace(url);
  }  
  else {
	top.location.href=url;
  }

//End function
}

//==================================================
// loadbysize(width,src) Loads the right size page for each user
//==================================================

function loadbysize(width,currfs,src) {

//Declare a variable to pass to the frametopload function
var addurl=baseurl;
var changetop=0;

//First we see if we're already on the right size page by testing
//the currfs value against the new value, if not then...
//Based on the width of the screen, we add the frameset to addurl
if (currfs !=0 && width < 640) {
addurl+=pdatext;
}
if (currfs !=1 && width >= 640 && width < 1024) {
addurl+=small;changetop=1;
}
if (currfs !=2 && width == 1024) {
addurl+=large;changetop=1;
}
if (currfs !=3 && width > 1024) {
addurl+=xlarge;changetop=1;
}

//Load the frametopload function to load the frameset if necessary
if (changetop==1) {
//We add the referring page as an argument to the frameset page.
 if (src != '') {
  addurl+='?'+src;
 }
frametopload(addurl);
}

//If not return to page and allow pageURL to load main frame
//End function
}

//==================================================
// statwords(message,defstat) Fills status bar with message given, or default message given
//==================================================
function statwords(message,defstatus){
//Determine if the message is given or not, if not replace with given default message.
  if (message == ' ') {
  window.setTimeout('parent.window.status="' + defstatus + '";', 1);
  }
  else {
  window.setTimeout('parent.window.status="' + message + '";', 1);
  }
  return true;

//End function
}

//End of Javascript file