function WM_netscapeCssFix() {
  if (document.WM.WM_netscapeCssFix.initWindowWidth != window.innerWidth || document.WM.WM_netscapeCssFix.initWindowHeight != window.innerHeight) {
    document.location = document.location;
  }
}

function WM_netscapeCssFixCheckIn() {
  // This function checks to make sure the version of Netscape 
  // in use contains the bug; if so, it records the window's 
  // width and height and sets all resize events to be handled 
  // by the WM_netscapeCssFix() function.
  if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) {
    if (typeof document.WM == 'undefined'){
      document.WM = new Object;
    }
    if (typeof document.WM.WM_scaleFont == 'undefined') {
      document.WM.WM_netscapeCssFix = new Object;
      document.WM.WM_netscapeCssFix.initWindowWidth = window.innerWidth;
      document.WM.WM_netscapeCssFix.initWindowHeight = window.innerHeight;
    }
    window.onresize = WM_netscapeCssFix;
  }
}

WM_netscapeCssFixCheckIn()

function showItem(item){
  if (document.getElementById && document.body.style) {
    theLast = document.getElementById(lastItem);
    theItem = document.getElementById(item);
    theLast.style.visibility = "hidden";
    theItem.style.visibility = "visible";
  }
  else if (document.all) {
    theLast = document.all(lastItem).style;
    theItem = document.all(item).style;
    theLast.visibility = "hidden";
    theItem.visibility = "visible";
    } 
  else if (document.layers) {
    theLast = document.layers[lastItem];
    theItem = document.layers[item];
    theLast.visibility = "hide";
    theItem.visibility = "show";
    } 
  lastItem = item;  
}

function nav(page) {
  var str = "";
/*  str += "<a id='home'      href='index.html'>Home</a>";
  str += "<a id='about'     href='about-us.html'>About Us</a>";
  str += "<a id='wholesale' href='product-lines.html'>Wholesale Product Lines</a>";
  str += "<a id='designers' href='designers.html'>Interior Designers</a>";
  str += "<a id='reps'      href='reps.html'>Regional Reps</a>";
  str += "<a id='press'     href='press.html'>Press</a>";
  str += "<a id='community' href='community.html'>Community Outreach</a>";
  str += "<a id='dates'     href='market-dates.html'>Market Dates</a>";
  str += "<a id='contact'   href='contact.html'>Contact Us</a>";
 */
 
	str += "<ul id='main-nav'>";
	str += "<li><a id='home' href='index.html'>Home</a></li>";
	str += "<li><a id='about' href='about-us.html'>About Us</a></li>";
	str += "<li><a id='wholesale' href='product-lines.html'>Wholesale Product Lines</a></li>";
	str += "<li><a id='designers' href='designers.html'>Interior Designers</a></li>";
	str += "<li><a id='reps' href='reps.html'>Regional Reps</a></li>";
	str += "<li><a id='press' href='press.html'>Press</a></li>";
	str += "<li><a id='community' href='community.html'>Community Outreach</a></li>";
	str += "<li><a id='dates' href='market-dates.html'>Market Dates</a></li>";
	str += "<li><a id='contact' href='contact.html'>Contact Us</a></li>";
	str += "</ul>";
	document.write(str);
  
  if(document.getElementById) {
    if(page != '') {
      document.getElementById(page).className="currentpage";
    }
  }
}

/* 

 */
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

var states = new Array("AL","AK","AZ","AR","CA","CO","CT","DC","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY")

function buildStateSelect() {
  var str = "<select name='State'>";
  var thisState = "TX";
  for(var i = 0; i < states.length; i++ ) {
    if(thisState == String(states[i]))
      str += "<option value='" + states[i] + "' selected>" + states[i] + "</option>\n";    
    else
      str += "<option value='" + states[i] + "'>" + states[i] + "</option>\n";    
  }   
  str += "</select>";
  document.write(str);
}


function getStyle() {
  var n = Math.floor(Math.random() * 6);
  return(styles[n+1]);
}

function getStyles() {
  colors = new Array("mocha","aqua","celery","salmon","cobalt","rust");
  numbers = new Array(0,1,2,3,4,5); 
  newNumbers = new Array();
  i = 0;
  while (i<numbers.length){
    randomNum=Math.floor(Math.random() * numbers.length)
    if (numbers[randomNum]!="selected"){
      newNumbers[i] = randomNum;
      numbers[randomNum] = "selected";
      i++;
    }
  }
  startStr = "<td class='";
  endStr = "'><img src='images/clear.gif' height='112' width='140'></td>";
  temp = new Array();
  for( i = 0; i < newNumbers.length; i++) {
    temp[i] = startStr + colors[newNumbers[i]] + endStr; 
  }
  return(temp);
}

function getNumber(n) {
  if(n < 10) { return("0"+n); }
  return(n);
}

function makeImageArray() {
  maxNum = 68; 							// the number of product images
  numbers = new Array(); 
  for(i = 1; i <= maxNum; i++) {
    numbers[i-1] = i;
  }  
  newNumbers = new Array();
  //randomNum;
  i = 0;
  while (i<numbers.length){
    randomNum = Math.floor(Math.random() * numbers.length)
    if (numbers[randomNum] != "selected"){
      newNumbers[i] = randomNum+1;
      numbers[randomNum] = "selected";
      i++;
    }
  }
  startStr = "<img src='images/prod-";
  endStr = ".jpg' height='114' width='142'>";
  temp = new Array();
  for( i = 0; i < newNumbers.length; i++) {
    temp[i] = startStr + getNumber(newNumbers[i]) + endStr; 
  }
  return(temp);
}
