function showPic (whichpic) { 
		if (document.getElementById) { 
			document.getElementById("placeholder").src = whichpic.href; 
			var objHref = document.getElementsByName("hrefimage");
			for (i=0;i < objHref.length; i++)
			{
				if (objHref[i].href == document.getElementById("placeholder").src)
				{
					objHref[i].setAttribute("class", "pink_bold");
					objHref[i].setAttribute("className", "pink_bold");
				}
				else
				{
					objHref[i].setAttribute("class", "purple_bold");
					objHref[i].setAttribute("className", "purple_bold");
				}
			}
			return false; 
		} else { 
			return true; 
		} 
}
function checkfrm(theForm) {
var reason = "";

  reason += validateEmpty(theForm.txtFullName);
  reason += validateEmpty(theForm.txtCompany);
  reason += validateNumber(theForm.txtQuantity);
  reason += validateEmail(theForm.txtEmail);
  reason += validatePhone(theForm.txtPhone);
  reason += validateEmpty(theForm.txtComment);
 
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}

function checkfrm_callback(theForm) {
var reason = "";
  reason += validateEmpty(theForm.txtProdName);
  reason += validateEmpty(theForm.txtFullName);
  reason += validateEmpty(theForm.txtCompanyName);
  reason += validateEmail(theForm.txtEmail);
  reason += validatePhone(theForm.txtPhone);
 
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}
function checkfrm_money(theForm) {
var reason = "";
  reason += validateEmpty(theForm.txtFullName);
  reason += validateEmpty(theForm.txtCompanyName);
  reason += validateEmail(theForm.txtEmail);
  reason += validatePhone(theForm.txtPhone);
 
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}
function checkfrm_services(theForm) {
var reason = "";
  reason += validateEmpty(theForm.txtProdName);
  reason += validateUpload(theForm.uploadedfile1, theForm.uploadedfile2, theForm.uploadedfile3, theForm.uploadedfile4 );
  reason += validateEmpty(theForm.txtFullName);
  reason += validateEmpty(theForm.txtCompanyName);
  reason += validateEmail(theForm.txtEmail);
  reason += validatePhone(theForm.txtPhone);

  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}

function validateUpload(fld1, fld2, fld3, fld4) {
    var error = "";
 
    if (fld1.value.length == 0 && fld2.value.length == 0 && fld3.value.length == 0 && fld4.value.length == 0) {
        fld1.style.background = 'Yellow'; 
        error = "Please upload your logo.\n"
		
    } else {
        fld1.style.background = 'White';
    }
    return error;  
}
function validateEmpty(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "The required field has not been filled in.\n"
		
    } else {
        fld.style.background = 'White';
    }
    return error;  
}
function validateUsername(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = 'Yellow'; 
        error = "You didn't enter a username.\n";
		
    } else if ((fld.value.length < 5) || (fld.value.length > 15)) {
        fld.style.background = 'Yellow'; 
        error = "The username is the wrong length.\n";
		
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = 'Yellow'; 
        error = "The username contains illegal characters.\n";
		
    } else {
        fld.style.background = 'White';
    }
    return error;
}
function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}

function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
   
    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter an email address.\n";
		
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = 'Yellow';
        error = "Please enter a valid email address.\n";
		
    } else if (fld.value.match(illegalChars)) {
        fld.style.background = 'Yellow';
        error = "The email address contains illegal characters.\n";
		
    } else {
        fld.style.background = 'White';
    }
    return error;
}
function validatePhone(fld) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');    

   if (fld.value == "") {
        error = "You didn't enter a phone number.\n";
		
        fld.style.background = 'Yellow';
    } else if (isNaN(parseInt(stripped))) {
        error = "The phone number contains illegal characters.\n";
		
        fld.style.background = 'Yellow';
    } else {
        fld.style.background = 'White';
    }
    return error;
}
function validateNumber(fld) {
    var error = "";
	if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "The required field has not been filled in.\n"
		
    } 
    else if (isNaN(fld.value))
	{
	 	error = "You didn't enter your quantity as a number.\n";
		
        fld.style.background = 'Yellow';
	}
	else
	{
		fld.style.background = 'White';
	}
    return error;
}

function ShowImage(file,wd,ht)
{
	       
	  if(wd==null) { wd = 300;}
	  if(ht==null) { ht = 400;}
	  var left = Math.floor( (screen.width - wd) / 2);
      var top = Math.floor( (screen.height - ht) / 2);
	  //prop="status=no,toolbar=no,menubar=no,top=2,left=2,width="+wd+",height="+ht;
	  prop= "top=" + top + ",left=" + left + ",height=" + ht + ",width=" + wd;
	  newWin=window.open(file,"ShowImage",prop);
	  newWin.focus();
}
function ShowProduct(sProductCode,wd,ht)
{
	  if(wd==null) { wd = 300;}
	  if(ht==null) { ht = 400;}
	  var left = Math.floor( (screen.width - wd) / 2);
      var top = Math.floor( (screen.height - ht) / 2);
	  prop= "top=" + top + ",left=" + left + ",height=" + ht + ",width=" + wd;
	  newWin=window.open("product.php?productCode="+sProductCode,"ShowImage",prop);
	  newWin.focus();
}