function write_it(status_text) {
	window.status=status_text;
}


function toggleDivision(name)	{

	if (eval("document.all." + name + ".style.display == 'none'")) {
		eval("document.all." + name + ".style.display = ''");
		}
	else {
		eval("document.all." + name + ".style.display = 'none'");
		}
	}


function showDivision(which_division)
	{
	if (navigator.appName == "Netscape")
		{
		document.layers[which_division].display = "";
		}
	else
		{
		document.all[which_division].style.display = "";
		}
	}


function hideDivision(which_division)
	{
	if (navigator.appName == "Netscape")
		{
		document.layers[which_division].display = "none";
		}
	else
		{
		document.all[which_division].style.display = "none";
		}
	}
	
function printForm()	{
	document.all.print.style.display = 'none';
	window.print();
}

function displayDate()	{
var today = new Date();
var year  = today.getYear();
var month = today.getMonth() + 1;
var day  = today.getDate();
if (day < 10)	{
	day = "0" + day;
	}
if (month < 10)	{
	month = "0" + month;
	}
mydate = day + "/" + month + "/" + year;
window.document.forms[0].Date.value = mydate;
}

function validateForm(form) {
  for (var e = 0; e < form.elements.length; e++) {
    var el = form.elements[e];
    
    if (el.type == 'text' && el.name != "Fax" && el.name != "Cellphone") { 
      if (el.value == '') {
        alert('Please fill out all compulsory text fields');
        el.focus();
        return false;
      }
    }
    else if (el.type == 'password') { 
      if (el.value == '') {
        alert('Please supply a password');
        el.focus();
        return false;
      }
    }
    else if (el.type == 'textarea') { 
    el.value = trimString(el.value);
      if (el.value == '') {
        alert('Please enter comments');
        el.focus();
        return false;
      }
    }
    else if (el.type.indexOf('select') != -1) {
      if (el.selectedIndex == -1 || el.selectedIndex == 0) {
        alert('Please make a selection');
        el.focus();
        return false;
      }
    }
    else if (el.type == 'radio') {
      var group = form[el.name];
      var checked = false;
      if (!group.length)
        checked = el.checked;
      else
        for (var r = 0; r < group.length; r++)
          if ((checked = group[r].checked))
            break;
      if (!checked) {
        alert('Please select a radio button');
        el.focus();
        return false;
      }
    }
    else if (el.type == 'checkbox') {
      var group = form[el.name];
      if (group.length) {
        var checked = false;
        for (var r = 0; r < group.length; r++)
          if ((checked = group[r].checked))
            break;
        if (!checked) {
          alert('Please check one of the checkboxes');
          el.focus();
          return false;
        }
      }
    }
  }
  return true;
}

function validateAppFormE(form) {
  for (var e = 0; e < form.elements.length; e++) {
    var el = form.elements[e];

    if (el.type == 'text' && el.name == 'Username') {
    myUsername = el.value;
    if (el.value == '') {
      alert('Please supply a username');
      el.focus();
      return false;
    }
    var pattern = /^[a-z0-9_\s]+$/i;
    var StringMatches = myUsername.match(pattern);
    if (!StringMatches) {
      alert('Please supply a username with alphanumeric characters only');
        el.focus();
      return false;
    }
    }
    
    if (el.type == 'password' && el.name == 'Password') {
    myPassword = el.value;
    if (el.value == '') {
      alert('Please supply a password');
      el.focus();
      return false;
    }
    var pattern = /^[a-z0-9_\s]+$/i;
    var StringMatches = myPassword.match(pattern);
    if (!StringMatches) {
      alert('Please supply a password with alphanumeric characters only');
        el.focus();
      return false;
    }
    }
    
    
    
    if (el.type == 'text' && el.name == 'Email') {
    email = el.value;
    if (el.value == '') {
      alert('Please supply an e-mail address');
      el.focus();
      return false;
    }
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) {
    	alert('Please supply a valid e-mail address');
        el.focus();
    	return false;
    }
    if(splitted[1] != null) {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) {
    	alert('Please supply a valid e-mail address');
        el.focus();
    	return false;
      }
    }
    if(splitted[2] != null) {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) {
      var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) {
    	    alert('Please supply a valid e-mail address');
            el.focus();
    	    return false;
            }
      }
    }
    }
    
    if (el.type == 'text' && el.name == 'EmailN' && el.value != '') {
    email = el.value;
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) {
    	alert('Please supply a valid e-mail address');
        el.focus();
    	return false;
    }
    if(splitted[1] != null) {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) {
    	alert('Please supply a valid e-mail address');
        el.focus();
    	return false;
      }
    }
    if(splitted[2] != null) {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) {
      var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) {
    	    alert('Please supply a valid e-mail address');
            el.focus();
    	    return false;
            }
      }
    }
    }
  
    if (el.type == 'text' && el.name != 'WebsiteURL' && el.name != 'EmailN') { 
      if (el.value == '') {
        alert('Please fill out all the text fields');
        el.focus();
        return false;
      }
    }
    else if (el.type == 'textarea') { 
      if (el.value == '') {
        alert('Please complete all the text areas');
        el.focus();
        return false;
      }
    }
    else if (el.type.indexOf('select') != -1) {
      if (el.selectedIndex == -1 || el.selectedIndex == 0 && el.name != 'DepositConfirm') {
        alert('Please make a selection');
        el.focus();
        return false;
      }
    }
    else if (el.type == 'radio') {
      var group = form[el.name];
      var checked = false;
      if (!group.length)
        checked = el.checked;
      else
        for (var r = 0; r < group.length; r++)
          if ((checked = group[r].checked))
            break;
      if (!checked) {
        alert('Please select a radio button');
        el.focus();
        return false;
      }
    }
    else if (el.type == 'checkbox' && el.name != 'Notes') {
      var group = form[el.name];
      if (group.length) {
        var checked = false;
        for (var r = 0; r < group.length; r++)
          if ((checked = group[r].checked))
            break;
        if (!checked) {
          alert('Please check at least one of the checkboxes');
          el.focus();
          return false;
        }
      }
    }
  }
  return true;
}

function displaySubs(the_sub){
	if (document.getElementById(the_sub).style.display==""){
	document.getElementById(the_sub).style.display = "none";return}
for (i=0;i<subs_array.length;i++){
	var my_sub = document.getElementById(subs_array[i]);
	my_sub.style.display = "none";
	}document.getElementById(the_sub).style.display = "";
}

var subs_array = new Array("products");




