var sint = 5000;
var xmlr = false;
var msxmlhttp = new Array(
	'Msxml2.XMLHTTP.5.0',
	'Msxml2.XMLHTTP.4.0',
	'Msxml2.XMLHTTP.3.0',
	'Msxml2.XMLHTTP',
	'Microsoft.XMLHTTP');
for (var i = 0; i < msxmlhttp.length; i++)
{ try { xmlr = new ActiveXObject(msxmlhttp[i]); }
  catch (e) { xmlr = null; } }
if(!xmlr && typeof XMLHttpRequest != "undefined")
	xmlr = new XMLHttpRequest();
if (!xmlr) alert("Could not create connection object.");
function callServer()
{ var url = "random.php";
  xmlr.open("GET", url, true);
  xmlr.onreadystatechange = updatePage;
  xmlr.send(null); }	 
function updatePage()
{ if (xmlr.readyState == 4)
  { var resp = xmlr.responseText;
    document.getElementById("slideshow").src = "./thumbnails/" + resp; } }	 

function slider()
{ callServer();
  setTimeout("slider()",sint); }

function setslider()
{ setTimeout("slider()",sint); }

function popAlert(s)
{ var msg = s + '<p />\n';
   msg += '<a href="#" onclick="return hideapop();">';
   msg += '<img src="./lib/button_continue.png" alt="continue" /></a>';
  var newdiv = document.createElement("div");
  document.getElementById("apop").innerHTML = "";
  newdiv.innerHTML = msg;
  var container = document.getElementById("apop");
  container.appendChild(newdiv);
  popShow();
  return false; }

function popUp(txt)
{ var newdiv = document.createElement("div");
  document.getElementById("apop").innerHTML = "";
  newdiv.innerHTML = txt;
  var container = document.getElementById("apop");
  container.appendChild(newdiv);
  popShow();
  return false; }

function popShow()
{ if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
  { if (!document.body.scrollTop)
    { var y = document.documentElement.scrollTop; }
    else { var y = document.body.scrollTop; } }
  else { var y = window.pageYOffset; }
  document.getElementById("apop").style.top = "" + y + "px"; 
  document.getElementById("apop").style.display = "block"; }

function hideapop()
{ document.getElementById("apop").style.display = "none"; return false; }

function verifyPrint(s)
{ var op = document.fm.elements["itOption"];
  if (op.value == "no selection")
  { return popAlert("Please select " + s + "."); }
  var qt = document.fm.elements["itQty"];
  if (qt.value==0)
  { qt.focus(); qt.select();
    return popAlert("You must input a quantity."); }
  return true; }

function rePricePrint(f)
{ i = f.itOption.selectedIndex;
  var prices = ["0.00", "18.00", "12.00"];
  f.itPrice.value = prices[i]; }

function verifyQ()
{ var qt = document.fm.elements["itQty"];
  if (qt.value==0)
  { qt.focus(); qt.select();
    return popAlert("You must input a quantity."); }
  return true; }

function goPayPal()
{ document.payPal.submit(); }

function stripper(x)
{ return (x.replace(/^\W+/,'')).replace(/\W+$/,''); }

function verifyInfo(f)
{ f.orFirst.value = stripper(f.orFirst.value);
  f.orLast.value = stripper(f.orLast.value);
  f.orAddress.value = stripper(f.orAddress.value);
  f.orCity.value = stripper(f.orCity.value);
  f.orState.value = stripper(f.orState.value);
  f.orZip.value = stripper(f.orZip.value);
  f.orEmail.value = stripper(f.orEmail.value);
  if (f.orFirst.value == "") 
  { x = popAlert("Please enter a first name."); 
    f.orFirst.focus(); return false; }
  if (f.orLast.value == "")
  { x = popAlert("Please enter a last name."); 
    f.orLast.focus(); return false; }
  if (f.orAddress.value == "")
  { x = popAlert("Please enter an address."); 
    f.orAddress.focus(); return false; }
  if (f.orCity.value == "")
  { x = popAlert("Please enter a city."); 
  f.orCity.focus(); return false; }
  if (f.orCountry.value == "United States" || f.orCountry.value == "" || f.orCountry.value == "US" || f.orCountry.value == "USA")
  { if (f.orState.value == "")
    { x = popAlert("Please enter a state."); 
	f.orState.focus(); return false; }
    if (f.orZip.value == "")
    { x = popAlert("Please enter a zip code."); 
	f.orZip.focus(); return false; }
    if (f.orZip.value.length < 5)
    { x = popAlert("Zip code must be at least 5 characters."); 
	f.orZip.focus(); return false; }
    if (f.orEmail.value == "")
    { x = popAlert("Please enter an email address."); 
	f.orEmail.focus(); return false; } }
    return true; }

