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", "light_blue_bold");
					objHref[i].setAttribute("className", "light_blue_bold");
				}
				else
				{
					objHref[i].setAttribute("class", "blue_bold");
					objHref[i].setAttribute("className", "blue_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 validate_frm_recruitment(theForm) {
  var reason = "";
  reason += validateEmpty(theForm.txtfullname);
  reason += validateEmail(theForm.txtemail);
  reason += validateNumber(theForm.txtcontactno);
 
  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_freetangle(theForm) {
var reason = "";
  reason += validateFirstName(theForm.txtFirstName);
  reason += validateLastName(theForm.txtLastName);
  reason += validateCompanyName(theForm.txtCompanyName);
  reason += validateJobTitle(theForm.txtJobTitle);
  reason += validateAddress(theForm.txtaddress);
  reason += validateCity(theForm.txtCity);
  reason += validatePC(theForm.txtPostCode);
  reason += validateCountry(theForm.txtCountry);
  reason += validateEmail(theForm.txtEmail);
  reason += validatePhone(theForm.txtPhone);
  reason += validateSecurity(theForm.security_code);
  //reason += validateTerms(theForm.chkterms);

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

  return true;
}

function checkfrm_send_ipod(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_money(theForm) {
var reason = "";
  reason += validateFullName(theForm.txtFullName);
  reason += validateCompanyName(theForm.txtCompanyName);
  reason += validateEmail(theForm.txtEmail);
  reason += validatePhone(theForm.txtPhone);
 
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}
function validateCompanyName(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.borderColor = '#FF0000'; 
        error = "You must enter a company name.\n"
		
    } else {
        fld.style.borderColor = '#000000';
    }
    return error;  
}
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 validateFullName(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.borderColor = '#FF0000'; 
        error = "You must enter a full name.\n"
		
    } else {
        fld.style.borderColor = '#000000';
    }
    return error;  
}
function validateEmpty(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.borderColor = '#FF0000'; 
        error = "The required field has not been filled in.\n"
		
    } else {
        fld.style.borderColor = '#000000';
    }
    return error;  
}
function validateFirstName(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.borderColor = '#FF0000'; 
        error = "You must enter a first name.\n"
		
    } else {
        fld.style.borderColor = '#000000';
    }
    return error;  
}
function validateLastName(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.borderColor = '#FF0000'; 
        error = "You must enter a last name.\n"
		
    } else {
        fld.style.borderColor = '#000000';
    }
    return error;  
}

function validateJobTitle(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.borderColor = '#FF0000'; 
        error = "You must enter a job title.\n"
		
    } else {
        fld.style.borderColor = '#000000';
    }
    return error;  
}

function validateAddress(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.borderColor = '#FF0000'; 
        error = "You must enter an address.\n"
		
    } else {
        fld.style.borderColor = '#000000';
    }
    return error;  
}
function validateCity(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.borderColor = '#FF0000'; 
        error = "You must enter a city.\n"
		
    } else {
        fld.style.borderColor = '#000000';
    }
    return error;  
}
function validatePC(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.borderColor = '#FF0000'; 
        error = "You must enter a post code.\n"
		
    } else {
        fld.style.borderColor = '#000000';
    }
    return error;  
}
function validateCountry(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.borderColor = '#FF0000'; 
        error = "You must enter a country.\n"
		
    } else {
        fld.style.borderColor = '#000000';
    }
    return error;  
}
function validateSecurity(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.borderColor = '#FF0000'; 
        error = "You must enter the Security Code.\n"
		
    } else {
        fld.style.borderColor = '#000000';
    }
    return error;  
}

function validateUsername(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.borderColor = '#FF0000'; 
        error = "You must enter a username.\n";
		
    } else if ((fld.value.length < 5) || (fld.value.length > 15)) {
        fld.style.borderColor = '#FF0000'; 
        error = "The username is the wrong length.\n";
		
    } else if (illegalChars.test(fld.value)) {
        fld.style.borderColor = '#FF0000'; 
        error = "The username contains illegal characters.\n";
		
    } else {
        fld.style.borderColor = '#000000';
    }
    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.borderColor = '#FF0000'; 
        error = "You must enter an email address.\n";
		
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.borderColor = '#FF0000';
        error = "Please enter a valid email address.\n";
		
    } else if (fld.value.match(illegalChars)) {
        fld.style.borderColor = '#FF0000';
        error = "The email address contains illegal characters.\n";
		
    } else {
        fld.style.borderColor = '#000000';
    }
    return error;
}
function validatePhone(fld) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');    

   if (fld.value == "") {
        error = "You must enter a phone number.\n";
		
        fld.style.borderColor = '#FF0000';
    } else if (isNaN(parseInt(stripped))) {
        error = "The phone number contains illegal characters.\n";
		
        fld.style.borderColor = '#FF0000';
    } else {
        fld.style.borderColor = '#000000';
    }
    return error;
}
function validateNumber(fld) {
    var error = "";
	if (fld.value.length == 0) {
        fld.style.borderColor = '#FF0000'; 
        error = "The required field has not been filled in.\n"
		
    } 
    else if (isNaN(fld.value))
	{
	 	error = "You must enter your quantity as a number.\n";
		
        fld.style.borderColor = '#FF0000';
	}
	else
	{
		fld.style.borderColor = '#000000';
	}
    return error;
}
function validateTerms(fld) {
    var error = "";
	if (fld.checked == 1)
	{
		fld.style.borderColor = '#000000';
	}
	else
	{
        fld.style.borderColor = '#FF0000'; 
        error = "You must agree to the Privacy Policy for this website.\n";
		
    } 
    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();
}