menu_status = new Array();
function showHide(obj, img){
    if (document.getElementById) {
    var switch_id = document.getElementById(obj);
	var switch_img = document.getElementById(img);
        if(menu_status[obj] != 'show'){
           switch_id.className = 'show';
           menu_status[obj] = 'show';
			switch_img.src = "images/down.gif";
			
        }else{
           switch_id.className = 'hide';
           menu_status[obj] = 'hide';
			switch_img.src = "images/left.gif";

        }
    }
} 

function checkRequired(form,required) {
  for (field in required) {
    if (!form.elements[field].value) {
      alert(required[field]+" is a required field");
      form.elements[field].focus();
      return false;
    }
  }
  return true;
}

function writeEmail(host,username,text,extra) {
  document.write("<a href=\"mailto:"+username+"@"+host+"\" "+extra+">");
  if (text) {
    document.write(text);
  } else {
    document.write(username+"@"+host);
  }
  document.write("</a>");
}

function validateEmail(email) {
  var emailFilter=/^[^@\s]+@[^@\s]+\.\w{2,4}$/;
  return emailFilter.test(email);
}

function validateDate(date,yearLength) {
  var dateFilter = yearLength == 4 ? /^\d\d\/\d\d\/\d\d\d\d$/ : /^\d\d\/\d\d\/\d\d$/;
  return dateFilter.test(date);
}

function wholesalePricing() {
  var win = wholesalePricing.pricingWin;
  if (win && !win.closed) {
    win.document.location="/pricing.php";
    win.focus();
  } else {
    wholesalePricing.pricingWin = window.open("/pricing.php","pricingWin","width=450,height=400,location=no,scrollbars=yes,toolbar=no,status=no");
    wholesalePricing.pricingWin.focus();
  }
}

function getPromptDiv() {
  return document.getElementById("prompt");;
}

function clearPrompt() {
  var prompt = getPromptDiv();
  prompt.innerHTML = "";
  prompt.style.display = "none";
}

function requestCatalogPrompt() {
  var prompt = getPromptDiv();
  var html = "<p align=center style='font-weight:bold;'>A Catalog will be sent to your billing address at no charge.\n";
  html += "<form><p align=center><input type=button value=OK style='font-weight:bold;' onClick=\"requestCatalog('Y');\"> <input type=button value=Cancel onClick=\"requestCatalog('N');\"></form>";
  prompt.innerHTML = html;
  prompt.style.display='block';
}

function requestCatalog(response) {
  if (response == "Y") {
    ajaxIFrame.document.location.replace('/request_catalog.php');
  } else {
    clearPrompt();
  }
}

function requestCatalogDone() {
  clearPrompt();
}

function requestSamplePrompt() {
  var prompt = getPromptDiv();
  var html = "<p align=center style='font-weight:bold;'>A sample will be sent to your shipping address at no charge.<p align=center style='font-weight:bold;'>Please note, new customers only.\n";
  html += "<form><p align=center><input type=button value=OK style='font-weight:bold;' onClick=\"requestSample('Y');\"> <input type=button value=Cancel onClick=\"requestSample('N');\"></form>";
  prompt.innerHTML = html;
  prompt.style.display='block';
}

function requestSample(response) {
  if (response == "Y") {
    ajaxIFrame.document.location.replace('/request_sample.php');
  } else {
    clearPrompt();
  }
}

function requestSampleError(error) {
  alert(error);
  clearPrompt();
}

function requestSampleDone() {
  clearPrompt();
}

function requestCDPrompt() {
  var prompt = getPromptDiv();
  var html = "<p align=center style='font-weight:bold;'>A CD will be sent to your billing address at no charge.\n";
  html += "<form><p align=center><input type=button value=OK style='font-weight:bold;' onClick=\"requestCD('Y');\"> <input type=button value=Cancel onClick=\"requestCD('N');\"></form>";
  prompt.innerHTML = html;
  prompt.style.display='block';
}

function requestCD(response) {
  if (response == "Y") {
    ajaxIFrame.document.location.replace('/request_cd.php');
  } else {
    clearPrompt();
  }
}

function requestCDError(error) {
  alert(error);
  clearPrompt();
}

function requestCDDone() {
  clearPrompt();
}

function displayDate() {
  var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
  var monthNames = new Array("January","February","March","April","May","June","July",
                           "August","September","October","November","December");
  var dt = new Date();
  var y  = dt.getYear();
  if (y < 1000) y +=1900;
  document.write(dayNames[dt.getDay()] + ", " + monthNames[dt.getMonth()] + " " + dt.getDate() + ", " + y);
}


