
function getCheckedRadioValue(radio) {				//nature
	for (var i=0; i < radio.length; i++) {
		if (radio[i].checked) return radio[i].value
	}
	return false
}






function checkBoxValidate1(cb) {				//jobfunc
for (j = 0; j < 8; j++) {
if (eval("document.form1.jobfunc[" + j + "].checked") == true) {
document.form1.jobfunc[j].checked = false;
if (j == cb) {
document.form1.jobfunc[j].checked = true;
document.form1.jobfunc.value="";
         }
      }
   }
}
function checkBoxValidate2(cb) {				//jobfunc
for (j = 0; j < 6; j++) {
if (eval("document.form1.role[" + j + "].checked") == true) {
document.form1.role[j].checked = false;
if (j == cb) {
document.form1.role[j].checked = true;
document.form1.role.value="";
         }
      }
   }
}

function checkBoxValidate3(cb) {				//jobfunc
for (j = 0; j < 11; j++) {
if (eval("document.form1.business[" + j + "].checked") == true) {
document.form1.business[j].checked = false;
if (j == cb) {
document.form1.business[j].checked = true;
document.form1.business.value="";
         }
      }
   }
}
function checkBoxValidate4(cb) {				//jobfunc
//for (j = 0; j < 23; j++) {
//if (eval("document.form1.products[" + j + "].checked") == true) {
//document.form1.products[j].checked = false;
//if (j == cb) {
//document.form1.products[j].checked = true;
//document.form1.products.value="";
//         }
//      }
//   }
}
function checkBoxValidate5(cb) {				//jobfunc
//for (j = 0; j < 22; j++) {
//if (eval("document.form1.Systems[" + j + "].checked") == true) {
//document.form1.Systems[j].checked = false;
//if (j == cb) {
//document.form1.Systems[j].checked = true;
//document.form1.Systems.value="";
//         }
//      }
//  }
}
function checkBoxValidate6(cb) {				//jobfunc
//for (j = 0; j < 8; j++) {
//if (eval("document.form1.Services[" + j + "].checked") == true) {
//document.form1.Services[j].checked = false;
//if (j == cb) {
//document.form1.Services[j].checked = true;
//document.form1.Services.value="";
//         }
//      }
//   }
}
function checkBoxValidate7(cb) {				//jobfunc
for (j = 0; j < 7; j++) {
if (eval("document.form1.purpose[" + j + "].checked") == true) {
document.form1.purpose[j].checked = false;
if (j == cb) {
document.form1.purpose[j].checked = true;
document.form1.purpose.value="";
         }
      }
   }
}
function checkBoxValidate8(cb) {				//jobfunc
for (j = 0; j < 8; j++) {
if (eval("document.form1.findout[" + j + "].checked") == true) {
document.form1.findout[j].checked = false;
if (j == cb) {
document.form1.findout[j].checked = true;
document.form1.findout.value="";
         }
      }
   }
}



function validate(form1) {

   if(form1.sal.value=="" )			
  {
    alert("Please Select Salutation!");
    form1.sal.focus();
	form1.sal.style.background='#FFCCCC'
    return false;
  }   
  

  if(form1.fname.value=="")				//fnsme(empty)
  {
    alert("Please Enter Your First Name!");
    form1.fname.focus();
	form1.fname.select();
	form1.fname.style.background='#FFCCCC'
    return false;
  }
  

  if(form1.lname.value=="")				//fnsme(empty)
  {
    alert("Please Enter Your Family Name!");
    form1.lname.focus();
	form1.lname.select();
	form1.lname.style.background='#FFCCCC'
    return false;
  }    

  if(form1.jobtitle.value=="")				//jobtitle(empty)
  {
    alert("Please Enter Your Job Title!");
    form1.jobtitle.focus();
	form1.jobtitle.select();
    form1.jobtitle.style.background='#FFCCCC'
    return false;
  }  

  if(form1.company.value=="")				//company(empty)
  {
    alert("Please Enter Your Company!");
    form1.company.focus();
	form1.company.select();
	form1.company.style.background='#FFCCCC'
    return false;
  }  
  
    if(form1.Nature.value=="")				//company(empty)
  {
    alert("Please Enter Nature of business!");
    form1.Nature.focus();
	form1.Nature.select();
	form1.Nature.style.background='#FFCCCC'
    return false;
  }  
  
  if(form1.address.value=="")				//address(empty)
  {
    alert("Please Enter Your Address!");
    form1.address.focus();
	form1.address.select();
    form1.address.style.background='#FFCCCC'
    return false;
  }  
  
  
    if(form1.city.value=="")				//fnsme(empty)
  {
    alert("Please Enter Your City!");
    form1.city.focus();
	form1.city.select();
	form1.city.style.background='#FFCCCC'
    return false;
  }
  if (form1.country.value=="Singapore") {				//postalcode(empty)
		if(form1.zipcode.value=="")
  		{
    		alert("Please Enter Your Postal Code!");
    		form1.zipcode.focus();
			form1.zipcode.select();
    		form1.zipcode.style.background='#FFCCCC'
			return false;
  		}
	}
	
  if(form1.telcc.value=="")				//telcc(empty)
  {
    alert("Please Enter Your Country Code For Telephone Number!");
    form1.telcc.focus();
	form1.telcc.select();
    form1.telcc.style.background='#FFCCCC'
    return false;
  }

  if(!isAlldigits(form1.telcc.value))
  {
    alert("Country Code For Telephone Number Must Contain Only Digits!");
    form1.telcc.focus();
	form1.telcc.select();
    form1.telcc.style.background='#FFCCCC'
    return false;
  }
  
  if(form1.tel.value=="")				//tel(empty)
  {
    alert("Please Enter Your Telephone Number!");
    form1.tel.focus();
	form1.tel.select();
    form1.tel.style.background='#FFCCCC'
    return false;
  }
  
  if(!isAlldigits(form1.tel.value))
  {
    alert("Telephone Number Must Contain Only Digits!");
    form1.tel.focus();
	form1.tel.select();
    form1.tel.style.background='#FFCCCC'
    return false;
  }


  if(!isAlldigits(form1.faxcc.value))
  {
    alert("Country Code For Fax Number Must Contain Only Digits!");
    form1.faxcc.focus();
	form1.faxcc.select();
    form1.faxcc.style.background='#FFCCCC'
    return false;
  }
  

  
  if(!isAlldigits(form1.fax.value))
  {
    alert("Fax Number Must Contain Only Digits!");
    form1.fax.focus();
	form1.fax.select();
    form1.fax.style.background='#FFCCCC'
    return false;
  }

  if(form1.email.value=="")				//email(empty)
  {
    alert("Please Enter Your Email!");
    form1.email.focus();
	form1.email.select();
    form1.email.style.background='#FFCCCC'
    return false;
  }
  
  if(!isEmail(form1.email.value))
  {
    alert("Invalid Email Address!");
    form1.email.focus();
	form1.email.select();
    form1.email.style.background='#FFCCCC'
    return false;
  }
  

  

  if(getCheckedRadioValue(form1.jobfunc) == "")				//jobfunc(empty)
	  {
	    alert("Please Select ABOUT  (What is your job function?)");
	    form1.jobfunc[0].focus();
		form1.jobfunc[0].select();
		form1.jobfunc[0].style.background='#FFCCCC'
		return false;
	  }

  if(form1.jobfunc[7].checked &&				//jobfunc(others)  
  	form1.jobfuncothers.value=="")
  {
    alert("Please Enter Others For Your Job Function!");
    form1.jobfuncothers.focus();
	form1.jobfuncothers.select();
	form1.jobfuncothers.style.background='#FFCCCC'
    return false;
  }

  if(!form1.jobfunc[7].checked &&				//jobfunc(others)  
  	!form1.jobfuncothers.value=="")
  {
    alert("You Did Not Select Others For Your  Job Function. Please Leave This Field Empty!");
    form1.jobfuncothers.focus();
	form1.jobfuncothers.select();
	form1.jobfuncothers.style.background='#FFCCCC'
    return false;
  }
  
   if(getCheckedRadioValue(form1.role) == "")				//jobfunc(empty)
	  {
	    alert("Please Select ABOUT  (What is your job function?)");
	    form1.role[0].focus();
		form1.role[0].select();
		form1.role[0].style.background='#FFCCCC'
		return false;
	  }


  if(getCheckedRadioValue(form1.business) == "")				//jobfunc(empty)
	  {
	    alert("Please Select ABOUT  (What is your job function?)");
	    form1.business[0].focus();
		form1.business[0].select();
		form1.business[0].style.background='#FFCCCC'
		return false;
	  }

  if(form1.business[10].checked &&				//jobfunc(others)  
  	form1.businessothers.value=="")
  {
    alert("Please Enter Others For (What is the main business sector of your company)!");
    form1.businessothers.focus();
	form1.businessothers.select();
	form1.businessothers.style.background='#FFCCCC'
    return false;
  }

  if(!form1.business[10].checked &&				//jobfunc(others)  
  	!form1.businessothers.value=="")
  {
    alert("You Did Not Select Others For (What is the main business sector of your company). Please Leave This Field Empty!");
    form1.businessothers.focus();
	form1.businessothers.select();
	form1.businessothers.style.background='#FFCCCC'
    return false;
  }

  if(getCheckedRadioValue(form1.products) == "")				//jobfunc(empty)
	  {
//	    alert("Please Select ABOUT  (Products and Materials)");
//	    form1.products[0].focus();
//		form1.products[0].select();
//		form1.products[0].style.background='#FFCCCC'
//		return false;
	  }


   if(getCheckedRadioValue(form1.Systems) == "")				//jobfunc(empty)
	  {
//	    alert("Please Select ABOUT  (Systems & Equipment)");
//	    form1.Systems[0].focus();
//		form1.Systems[0].select();
//		form1.Systems[0].style.background='#FFCCCC'
//		return false;
	  }
	  
   if(getCheckedRadioValue(form1.Services) == "")				//jobfunc(empty)
	  {
//	    alert("Please Select ABOUT  (Services)");
//	    form1.Services[0].focus();
//		form1.Services[0].select();
//		form1.Services[0].style.background='#FFCCCC'
//		return false;
	  }
 

   if(getCheckedRadioValue(form1.purpose) == "")				//jobfunc(empty)
	  {
	    alert("Please Select ABOUT  (What is the purpose of your visit? )");
	    form1.purpose[0].focus();
		form1.purpose[0].select();
		form1.purpose[0].style.background='#FFCCCC'
		return false;
	  }
 
  if(form1.purpose[6].checked &&				//jobfunc(others)  
  	form1.purposeothers.value=="")
  {
    alert("Please Enter Others For (What is the purpose of your visit? )");
    form1.purposeothers.focus();
	form1.purposeothers.select();
	form1.purposeothers.style.background='#FFCCCC'
    return false;
  }

  if(!form1.purpose[6].checked &&				//jobfunc(others)  
  	!form1.purposeothers.value=="")
  {
    alert("You Did Not Select Others For What is the purpose of your visit? ). Please Leave This Field Empty!");
    form1.purposeothers.focus();
	form1.purposeothers.select();
	form1.purposeothers.style.background='#FFCCCC'
    return false;
  }

   if(getCheckedRadioValue(form1.findout) == "")				//jobfunc(empty)
	  {
	    alert("Please Select ABOUT  (What is the purpose of your visit? )");
	    form1.findout[0].focus();
		form1.findout[0].select();
		form1.findout[0].style.background='#FFCCCC'
		return false;
	  }
 
  if(form1.findout[6].checked &&				//jobfunc(others)  
  	form1.magazines.value=="")
  {
    alert("Please Enter Others For (Trade magazines)");
    form1.magazines.focus();
	form1.magazines.select();
	form1.magazines.style.background='#FFCCCC'
    return false;
  }

  if(!form1.findout[6].checked &&				//jobfunc(others)  
  	!form1.magazines.value=="")
  {
    alert("You Did Not Select Others For What is the purpose of Trade magazines . Please Leave This Field Empty!");
    form1.magazines.focus();
	form1.magazines.select();
	form1.magazines.style.background='#FFCCCC'
    return false;
  }
  if(form1.findout[7].checked &&				//jobfunc(others)  
  	form1.findoutothers.value=="")
  {
    alert("Please Enter Others For (How did you find out about ProcessCEM Asia 2010?)");
    form1.findoutothers.focus();
	form1.findoutothers.select();
	form1.findoutothers.style.background='#FFCCCC'
    return false;
  }

  if(!form1.findout[7].checked &&				//jobfunc(others)  
  	!form1.findoutothers.value=="")
  {
    alert("You Did Not Select Others For What is the purpose of (How did you find out about ProcessCEM Asia 2010?) . Please Leave This Field Empty!");
    form1.findoutothers.focus();
	form1.findoutothers.select();
	form1.findoutothers.style.background='#FFCCCC'
    return false;
  }
  

  

	 return true
}


	

function isAlphabet(ch)
{
  return((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'));
}

function isSpace(ch)
{
  return (ch==' ');
}

function isDigit(ch)
{
  return(ch>='0'&&ch<='9')||(ch=='-')||(ch==',')||(ch=='/')||(ch==' ');
}

function isAllalphabets(str)
{
  var i;
  for(i=0;i<str.length;i++)
  {
    if(!isAlphabet(str.charAt(i))&&!isSpace(str.charAt(i)))return false;
  }
  return true;
}


function isAlldigits(str)
{
  var i;
  for(i=0;i<str.length;i++)
  {
    if(!isDigit(str.charAt(i)))return false;
  }
  return true;
}

function isEmail(str)
{
  if(str.indexOf('@')==-1||str.indexOf('.')==-1)  return false;
  if(str.length<5)  return false;
  return true;
}

