/*
  -------------------------------------------------------------------------
	                    JavaScript Form Validator 
                                Version 2.0.2
	Copyright 2003 JavaScript-coder.com. All rights reserved.
	You use this script in your Web pages, provided these opening credit
    lines are kept intact.
	The Form validation script is distributed free from JavaScript-Coder.com

	You may please add a link to JavaScript-Coder.com, 
	making it easy for others to find this script.
	Checkout the Give a link and Get a link page:
	http://www.javascript-coder.com/links/how-to-link.php

    You may not reprint or redistribute this code without permission from 
    JavaScript-Coder.com.
	
	JavaScript Coder
	It precisely codes what you imagine!
	Grab your copy here:
		http://www.javascript-coder.com/
    -------------------------------------------------------------------------  
*/
function Validator(frmname)
{
  this.formobj=document.forms[frmname];
	if(!this.formobj)
	{
	  alert("BUG: couldnot get Form object "+frmname);
		return;
	}
	if(this.formobj.onsubmit)
	{
	 this.formobj.old_onsubmit = this.formobj.onsubmit;
	 this.formobj.onsubmit=null;
	}
	else
	{
	 this.formobj.old_onsubmit = null;
	}
	this.formobj.onsubmit=form_submit_handler;
	this.addValidation = add_validation;
	this.setAddnlValidationFunction=set_addnl_vfunction;
	this.clearAllValidations = clear_all_validations;
}
function set_addnl_vfunction(functionname)
{
  this.formobj.addnlvalidation = functionname;
}
function clear_all_validations()
{
	for(var itr=0;itr < this.formobj.elements.length;itr++)
	{
		this.formobj.elements[itr].validationset = null;
	}
}
function form_submit_handler()
{
	for(var itr=0;itr < this.elements.length;itr++)
	{
		if(this.elements[itr].validationset &&
	   !this.elements[itr].validationset.validate())
		{
		  return false;
		}
	}
	if(this.addnlvalidation)
	{
	  str =" var ret = "+this.addnlvalidation+"()";
	  eval(str);
    if(!ret) return ret;
	}
	return true;
}
function add_validation(itemname,descriptor,errstr)
{
  if(!this.formobj)
	{
	  alert("BUG: the form object is not set properly");
		return;
	}//if
	var itemobj = this.formobj[itemname];
  if(!itemobj)
	{
	  alert("BUG: Couldnot get the input object named: "+itemname);
		return;
	}
	if(!itemobj.validationset)
	{
	  itemobj.validationset = new ValidationSet(itemobj);
	}
  itemobj.validationset.add(descriptor,errstr);
}
function ValidationDesc(inputitem,desc,error)
{
  this.desc=desc;
	this.error=error;
	this.itemobj = inputitem;
	this.validate=vdesc_validate;
}
function vdesc_validate()
{
 if(!V2validateData(this.desc,this.itemobj,this.error))
 {
    this.itemobj.focus();
		return false;
 }
 return true;
}
function ValidationSet(inputitem)
{
    this.vSet=new Array();
	this.add= add_validationdesc;
	this.validate= vset_validate;
	this.itemobj = inputitem;
}
function add_validationdesc(desc,error)
{
  this.vSet[this.vSet.length]= 
	  new ValidationDesc(this.itemobj,desc,error);
}
function vset_validate()
{
   for(var itr=0;itr<this.vSet.length;itr++)
	 {
	   if(!this.vSet[itr].validate())
		 {
		   return false;
		 }
	 }
	 return true;
}
function validateEmailv2(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
    if(email.length <= 0 || email == "---" )
	{
	  return true;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) 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) return false;
      }// if
      return true;
    }
return false;
}
function V2validateData(strValidateStr,objValue,strError) 
{ 
    var epos = strValidateStr.search("="); 
    var  command  = ""; 
    var  cmdvalue = ""; 
    if(epos >= 0) 
    { 
     command  = strValidateStr.substring(0,epos); 
     cmdvalue = strValidateStr.substr(epos+1); 
    } 
    else 
    { 
     command = strValidateStr; 
    } 
    switch(command) 
    { 
        case "req": 
        case "required": 
         { 
           if(eval(objValue.value.length) == 0) 
           { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : Required Field"; 
              }//if 
              alert(strError); 
              return false; 
           }//if 
           break;             
         }//case required 
        case "maxlength": 
        case "maxlen": 
          { 
             if(eval(objValue.value.length) >  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : "+cmdvalue+" characters maximum "; 
               }//if 
               alert(strError + "\n[Current length = " + objValue.value.length + " ]"); 
               return false; 
             }//if 
             break; 
          }//case maxlen 
        case "minlength": 
        case "minlen": 
           { 
             if(eval(objValue.value.length) <  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : " + cmdvalue + " characters minimum  "; 
               }//if               
               alert(strError + "\n[Current length = " + objValue.value.length + " ]"); 
               return false;                 
             }//if 
             break; 
            }//case minlen 
        case "alnum": 
        case "alphanumeric": 
           { 
              var charpos = objValue.value.search("[^A-Za-z0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
               if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only alpha-numeric characters allowed "; 
                }//if 
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//case alphanumeric 
        case "num": 
        case "numeric": 
           { 
              var charpos = objValue.value.search("[^0-9|.]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only digits allowed "; 
                }//if               
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break;               
           }//numeric 
        case "alphabetic": 
        case "alpha": 
           { 
              var charpos = objValue.value.search("[^A-Za-z]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only alphabetic characters allowed "; 
                }//if                             
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//alpha 
		case "alnumhyphen":
			{
              var charpos = objValue.value.search("[^A-Za-z0-9\-_]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": characters allowed are A-Z,a-z,0-9,- and _"; 
                }//if                             
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 			
			break;
			}
        case "email": 
          { 
               if(!validateEmailv2(objValue.value)) 
               { 
                 if(!strError || strError.length ==0) 
                 { 
                    strError = objValue.name+": Enter a valid Email address "; 
                 }//if                                               
                 alert(strError); 
                 return false; 
               }//if 
           break; 
          }//case email 
        case "lt": 
        case "lessthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Should be a number "); 
              return false; 
            }//if 
            if(eval(objValue.value) >=  eval(cmdvalue)) 
            { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : value should be less than "+ cmdvalue; 
              }//if               
              alert(strError); 
              return false;                 
             }//if             
            break; 
         }//case lessthan 
        case "gt": 
        case "greaterthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Should be a number "); 
              return false; 
            }//if 
             if(eval(objValue.value) <=  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : value should be greater than "+ cmdvalue; 
               }//if               
               alert(strError); 
               return false;                 
             }//if             
            break; 
         }//case greaterthan 
        case "regexp": 
         { 
		 	if(objValue.value.length > 0)
			{
	            if(!objValue.value.match(cmdvalue)) 
	            { 
	              if(!strError || strError.length ==0) 
	              { 
	                strError = objValue.name+": Invalid characters found "; 
	              }//if                                                               
	              alert(strError); 
	              return false;                   
	            }//if 
			}
           break; 
         }//case regexp 
        case "dontselect": 
         { 
            if(objValue.selectedIndex == null) 
            { 
              alert("BUG: dontselect command for non-select Item"); 
              return false; 
            } 
            if(objValue.selectedIndex == eval(cmdvalue)) 
            { 
             if(!strError || strError.length ==0) 
              { 
              strError = objValue.name+": Please Select one option "; 
              }//if                                                               
              alert(strError); 
              return false;                                   
             } 
             break; 
         }//case dontselect 
    }//switch 
    return true; 
}
/*
	Copyright 2003 JavaScript-coder.com. All rights reserved.
*/


function CheckStDate ()
{
	var frm = document.forms["phpform"];
	str=frm.stdate.value;
	arr=str.split("-");

	if ( str.length == 0  )
	{
		alert ("Start Date should not be null");
		frm.stdate.focus();
		return false;
	}
	else if ( str.length < 10 && str.length !=0 )
	{
		alert ("Date Format should be dd-mm-yyyy");
		frm.stdate.focus();
		return false;
	}

	else if ( (str.charAt(2) != "-" || str.charAt(5) !="-") && str.length != 0 )
	{
		alert ("Date Format should be dd-mm-yyyy");
		frm.stdate.focus();
		return false;
	}
	else if ( (arr[1] < 1 || arr[1] > 12) && str.length != 0 )
	{
		alert ("Month should be between 1 and 12");
		frm.stdate.focus();
		return false;
	}
	else if ( (arr[0] < 1 || arr[0] > 30) && str.length != 0 && ( arr[1] != 1 && arr[1] !=3 && arr[1] !=5 && arr[1] !=7 && arr[1] !=8 && arr[1] !=10 && arr[1] !=12 ) )
	{
		alert ("Check Date Information");
		frm.stdate.focus();
		return false;
	}
	else if ( arr[1] == 2 && arr[0] > 29 && str.length !=0 )
	{
		alert ("Check Date Information");
		frm.stdate.focus();
		return false;
	}

	else if ( str.length != 0 && arr[1] == 2 && arr[0] == 29 && (( arr[2] % 400 != 0) && ( arr[2] % 100 == 0  || arr[2] % 4 != 0 )))
	{
		alert ("Check Date Information");
		frm.stdate.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function CheckEndDate ()
{
	var frm = document.forms["phpform"];
	str=frm.enddate.value;
	arr=str.split("-");

	if ( str.length == 0  )
	{
		alert ("End Date should not be null");
		frm.enddate.focus();
		return false;
	}
	else if ( str.length < 10 && str.length !=0 )
	{
		alert ("Date Format should be dd-mm-yyyy");
		frm.enddate.focus();
		return false;
	}

	else if ( (str.charAt(2) != "-" || str.charAt(5) !="-") && str.length != 0 )
	{
		alert (" Date Format should be dd-mm-yyyy");
		frm.enddate.focus();
		return false;
	}
	else if ( (arr[1] < 1 || arr[1] > 12) && str.length != 0 )
	{
		alert ("Month should be between 1 and 12");
		frm.enddate.focus();
		return false;
	}
	else if ( (arr[0] < 1 || arr[0] > 30) && str.length != 0 && ( arr[1] != 1 && arr[1] !=3 && arr[1] !=5 && arr[1] !=7 && arr[1] !=8 && arr[1] !=10 && arr[1] !=12 ) )
	{
		alert ("Check Date Information");
		frm.enddate.focus();
		return false;
	}
	else if ( arr[1] == 2 && arr[0] > 29 && str.length !=0 )
	{
		alert ("Check Date Information");
		frm.enddate.focus();
		return false;
	}

	else if ( str.length != 0 && arr[1] == 2 && arr[0] == 29 && (( arr[2] % 400 != 0) && ( arr[2] % 100 == 0  || arr[2] % 4 != 0 )))
	{
		alert ("Check Date Information");
		frm.enddate.focus();
		return false;
	}
	else
	{
		return true;
	}
}


function DoCustomValidation4 ()
{
	var frm = document.forms["bmiform1"];
	weight1=frm.weight1.value;
	var charpos = frm.weight1.value.search("[.]"); 
	if ( frm.weight1.value <= 2 ) {
		alert ("Weight cannot be less than 2");
		frm.weight1.focus();
		return false;
	}

	else if ( eval(weight1.length) > 3 && charpos < 1 ) {
		alert ("Weight cannot be more than 3 digits");
		frm.weight1.focus();
		return false;
	}
	if ( frm.weight.value == "stone and pounds" && eval(frm.poun.value) >= 14 ) {
		alert ("Pounds cannot be greater than 13");
		frm.poun.focus();
		return false;
	}
}
function DoCustomValidation()
{
  var frm = document.forms["form2"];
 
  if ( frm.sUnit.value == "kilograms" ) {
	if ( frm.stvalue.value == "0" || frm.stvalue.value == "" ) {
		alert ("Please enter your weight in kilograms box");
		frm.stvalue.focus();
		return false;
	}
	else if ( eval(frm.stvalue.value) > 600 ) {
		alert ("Start value cannot be greater than 600 kilograms");
		frm.stvalue.focus();
		return false;
	}
	else {
	    var charpos = frm.stvalue.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.stvalue.focus();
			return false;
	    }
	}
  }
else if ( frm.sUnit.value == "centimetres" || frm.stvalue.value == "" ) {
	if ( frm.stvalue.value == "0" ) {
		alert ("Please enter your measurement in centimetres box");
		frm.stvalue.focus();
		return false;
	}
	else {
	    var charpos = frm.stvalue.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.stvalue.focus();
			return false;
	    }
	}
  }
else if ( frm.sUnit.value == "inches" ) {
	if ( frm.stvalue.value == "0"  || frm.stvalue.value == "" ) {
		alert ("Please enter your measurement in inches box");
		frm.stvalue.focus();
		return false;
	}
	else {
	    var charpos = frm.stvalue.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.stvalue.focus();
			return false;
	    }
	}
  }
 else if ( frm.sUnit.value == "lbs" ) {
	if ( frm.stpounds1.value == "0"  || frm.stpounds1.value == "" ) {
		alert ("Please enter your weight in pounds box");
		frm.stpounds1.focus();
		return false;
	}
	else if ( eval(frm.stpounds1.value) > 1320 ) {
		alert ("Start value cannot be greater than 1320 pounds");
		frm.stpounds1.focus();
		return false;
	}
	else {
	    var charpos = frm.stpounds1.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.stpounds1.focus();
			return false;
	    }
	}

  }
 else if ( frm.sUnit.value == "stone and lbs" ) {
	if ( frm.ststones.value == "0"  || frm.ststones.value == "" ) {
		alert ("Please enter your weight in stone and pounds box");
		frm.ststones.focus();
		return false;
	}
	else if ( eval(frm.ststones.value) > 100 ) {
		alert ("Start value cannot be greater than 100 stones");
		frm.ststones.focus();
		return false;
	}
	else if ( eval(frm.ststones.value) < 3 ) {
		alert ("Start value cannot be less than 3 stones");
		frm.ststones.focus();
		return false;
	}
	else if ( eval(frm.stpounds.value) >= 14 ) {
		alert ("Start value cannot be greater than 13 pounds");
		frm.stpounds.focus();
		return false;
	}
	else {
	    var charpos = frm.ststones.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.ststones.focus();
			return false;
	    }
	    else {
	   	 var charpos = frm.stpounds.value.search("[^0-9|.]"); 
	            if ( charpos >= 0 ) {
				alert ("Numerics only allowed");
				frm.stpounds.focus();
				return false;
	    		}

	    }
	}
  }

}

function DoCustomValidation1()
{
  var frm = document.forms["form2"];
 
  if ( frm.weight.value == "" ) {
	alert ("Please choose a unit of measurement");
	frm.weight.focus();
	return false;
  }
  if ( frm.weight.value == "kilograms" ) {
	if ( frm.stwt.value == "" ) {
		alert ("Please enter your weight in kilograms box");
		frm.stwt.focus();
		return false;
	}
	else if ( eval(frm.stwt.value) > 600 ) {
		alert ("Start weight cannot be greater than 600 kilograms");
		frm.stwt.focus();
		return false;
	}
	else if ( eval(frm.stwt.value) == eval(frm.endwt.value)) {
		alert ("Start and End Weight should not be the same");
		frm.stwt.focus();
		return false;
	}
	else {
	    var charpos = frm.stwt.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.stwt.focus();
			return false;
	    }
	}
  }
 else if ( frm.weight.value == "pounds" ) {
	if ( frm.stpounds1.value == "" ) {
		alert ("Please enter your weight in pounds box");
		frm.stpounds1.focus();
		return false;
	}
	else if ( eval(frm.stpounds1.value) > 1320 ) {
		alert ("Start weight cannot be greater than 1320 pounds");
		frm.stpounds1.focus();
		return false;
	}
	else if ( eval(frm.stpounds1.value) == eval(frm.endpounds1.value)) {
		alert ("Start and End Weight should not be the same");
		frm.stpounds1.focus();
		return false;
	}
	else {
		var charpos = frm.stpounds1.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.stpounds1.focus();
			return false;
		}
	}

  }
 else if ( frm.weight.value == "stone and pounds" ) {
	if ( frm.ststone.value == "" ) {
		alert ("Please enter your weight in stone and pounds box");
		frm.ststone.focus();
		return false;
	}
	else if ( eval(frm.ststone.value) > 100 ) {
		alert ("Start weight cannot be greater than 100 stones");
		frm.ststone.focus();
		return false;
	}
	else if ( eval(frm.stpounds.value) >= 14 ) {
		alert ("Pounds value cannot be greater than 13");
		frm.stpounds.focus();
		return false;
	}
	else if ( eval(frm.ststone.value) == eval(frm.endstone.value)) {
		alert ("Start and End Weight should not be the same");
		frm.ststone.focus();
		return false;
	}
	else {
		var charpos = frm.ststone.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.ststone.focus();
			return false;
		}
	}

  }
 if ( frm.weight.value == "kilograms" ) {
	if ( frm.endwt.value == "" ) {
		alert ("Please enter your weight in kilograms box");
		frm.endwt.focus();
		return false;
	}
	else if ( eval(frm.endwt.value) > 600 ) {
		alert ("End weight cannot be greater than 600 kilograms");
		frm.endwt.focus();
		return false;
	}
	else {
		var charpos = frm.endwt.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.endwt.focus();
			return false;
		}
	}
  }
 else if ( frm.weight.value == "pounds" ) {
	if ( frm.endpounds1.value == "" ) {
		alert ("Please enter your weight in pounds box");
		frm.endpounds1.focus();
		return false;
	}
	else if ( eval(frm.endpounds1.value) > 1320 ) {
		alert ("End weight cannot be greater than 1320 pounds");
		frm.endpounds1.focus();
		return false;
	}
	else {
		var charpos = frm.endpounds1.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.endpounds1.focus();
			return false;
		}
	}
  }
 else if ( frm.weight.value == "stone and pounds" ) {
	if ( frm.endstone.value == "" ) {
		alert ("Please enter your weight in stone and pounds box");
		frm.endstone.focus();
		return false;
	}
	else if ( eval(frm.endstone.value) > 100 ) {
		alert ("End weight cannot be greater than 100 stones");
		frm.endstone.focus();
		return false;
	}
	else if ( eval(frm.endpounds.value) >= 14 ) {
		alert ("Pounds value cannot be greater than 13");
		frm.endpounds.focus();
		return false;
	}
	else {
		var charpos = frm.endstone.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.endstone.focus();
			return false;
		}
	}
  }

}

function DoCustomValidation3 ()
{
  var frm = document.forms["bmiform"];
 
  if ( frm.wunit.value == "" ) {
	alert ("Please select a unit of measurement");
	frm.wunit.focus();
	return false;
}

 if ( frm.wunit.value == "Kilograms" ) {
	if ( frm.weight1.value == "0" || frm.weight1.value == "" ) {
		alert ("Please enter your weight in kilograms box");
		frm.weight1.focus();
		return false;
	}
	else if ( eval(frm.weight1.value) > 600 ) {
		alert ("Weight cannot be greater than 600 Kilograms");
		frm.weight1.focus();
		return false;
	}
	else {
		var charpos = frm.weight1.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.weight1.focus();
			return false;
		}
	}
  }
 else if ( frm.wunit.value == "Pounds" ) {
	if ( frm.weight2.value == "0" || frm.weight2.value == "" ) {
		alert ("Please enter your weight in pounds box");
		frm.weight2.focus();
		return false;
	}
	else if ( eval(frm.weight2.value) > 1320 ) {
		alert ("Weight cannot be greater than 1320 Pounds");
		frm.weight2.focus();
		return false;
	}
	else {
		var charpos = frm.weight2.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.weight2.focus();
			return false;
		}
	}

  }
 else if ( frm.wunit.value == "Stone and Pounds" ) {
	if ( frm.weight3.value == "0"  || frm.weight3.value == "" ) {
		alert ("Please enter your weight in stone and pounds box");
		frm.weight3.focus();
		return false;
	}
	else if ( eval(frm.weight3.value) > 100 ) {
		alert ("Weight cannot be greater than 100 stones");
		frm.weight3.focus();
		return false;
	}
	else if ( eval(frm.weight2.value) > 13 ) {
		alert ("Pounds value cannot be greater than 13 pounds");
		frm.weight2.focus();
		return false;
	}

	else {
		var charpos = frm.weight3.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.weight3.focus();
			return false;
		}
	}
  }
 if ( frm.hunit.value == "" ) {
	alert ("Please select a unit of measurement");
	frm.hunit.focus();
	return false;
 }

 if (frm.hunit.value == "Metres") {
	if (frm.height1.value != "0"){
  		if ((frm.height2.value == "0") || (frm.height2.value == "" )){
		}
		else{
		alert ("Please enter your height in Metres box only");
		frm.height1.focus();
		return false;
		}
	}
}

 if (frm.hunit.value ==  "Centimeters") {
	if (frm.height2.value != "0"){
  		if ((frm.height1.value == "0") || (frm.height1.value == "" )){
		}
		else{
		alert ("Please enter your height in Centimeters box only");
		frm.height2.focus();
		return false;
		}
	}
}

 if ( frm.hunit.value == "Metres" ) {
	if ( frm.height1.value == "0"  || frm.height1.value == "" ) {
		alert ("Please enter your height in metres box");
		frm.height1.focus();
		return false;
	}
	else {
		var charpos = frm.height1.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.height1.focus();
			return false;
		}
	}
  }
 else if ( frm.hunit.value == "Centimeters" ) {
	if ( frm.height2.value == "0"  || frm.height2.value == "" ) {
		alert ("Please enter your height in centimeters box");
		frm.height2.focus();
		return false;
	}
	else {
		var charpos = frm.height2.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.height2.focus();
			return false;
		}
	}

  }
 else if ( frm.hunit.value == "Feet and inches" ) {
	if ((frm.height3.value == "0" && frm.height4.value == "0")  || (frm.height3.value == "" && frm.height4.value == "" )) {
		alert ("Please enter your height in feet and inches box");
		frm.height3.focus();
		return false;
	}
	else if ( eval(frm.height4.value) > 12 ) {
		alert ("Inches cannot be greater than 12");
		frm.height4.focus();
		return false;
	}

	else {
		var charpos = frm.height3.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.height3.focus();
			return false;
		}
	}
  }
}


function DoCustomValidation2()
{
  var frm = document.forms["form2"];
 
  if ( frm.weight.value == "" ) {
	alert ("Please select a unit of measurement");
	frm.weight.focus();
	return false;
  }
  if ( frm.weight.value == "kilograms" ) {
	if ( frm.stwt.value == "" ) {
		alert ("Please enter your weight in kilograms box");
		frm.stwt.focus();
		return false;
	}
	else if ( eval(frm.stwt.value) > 600 ) {
		alert ("Start weight cannot be greater than 600 kilograms");
		frm.stwt.focus();
		return false;
	}
	else if ( eval(frm.stwt.value) == eval(frm.endwt.value)) {
		alert ("Start and End Weight should not be the same");
		frm.stwt.focus();
		return false;
	}
	else {
		var charpos = frm.stwt.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.stwt.focus();
			return false;
		}
	}
  }
 else if ( frm.weight.value == "pounds" ) {
	if ( frm.stpounds1.value == "" ) {
		alert ("Please enter your weight in pounds box");
		frm.stpounds1.focus();
		return false;
	}
	else if ( eval(frm.stpounds1.value) > 1320 ) {
		alert ("Start weight cannot be greater than 1320 pounds");
		frm.stpounds1.focus();
		return false;
	}
	else if ( eval(frm.stpounds1.value) == eval(frm.endpounds1.value)) {
		alert ("Start and End Weight should not be the same");
		frm.stpounds1.focus();
		return false;
	}
	else {
		var charpos = frm.stpounds1.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.stpounds1.focus();
			return false;
		}
	}

  }
 else if ( frm.weight.value == "stone and pounds" ) {
	if ( frm.ststone.value == "" ) {
		alert ("Please enter your weight in stone and pounds box");
		frm.ststone.focus();
		return false;
	}
	else if ( eval(frm.ststone.value) > 100 ) {
		alert ("Start weight cannot be greater than 100 stones");
		frm.ststone.focus();
		return false;
	}
	else if ( eval(frm.stpounds.value) >= 14 ) {
		alert ("Pounds value cannot be greater than 13");
		frm.stpounds.focus();
		return false;
	}
	else if ( eval(frm.ststone.value) == eval(frm.endstone.value)) {
		alert ("Start and End Weight should not be the same");
		frm.ststone.focus();
		return false;
	}
	else {
		var charpos = frm.ststone.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.ststone.focus();
			return false;
		}
	}

  }

 if ( frm.weight.value == "kilograms" ) {
	if ( frm.endwt.value == "" ) {
		alert ("Please enter your weight in kilograms box");
		frm.endwt.focus();
		return false;
	}
	else if ( eval(frm.endwt.value) > 600 ) {
		alert ("End weight cannot be greater than 600 kilograms");
		frm.endwt.focus();
		return false;
	}
	else {
		var charpos = frm.endwt.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.endwt.focus();
			return false;
		}
	}
  }
 else if ( frm.weight.value == "pounds" ) {
	if ( frm.endpounds1.value == "" ) {
		alert ("Please enter your weight in pounds box");
		frm.endpounds1.focus();
		return false;
	}
	else if ( eval(frm.endpounds1.value) > 1320 ) {
		alert ("End weight cannot be greater than 1320 pounds");
		frm.endpounds1.focus();
		return false;
	}
	else {
		var charpos = frm.endpounds1.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.endpounds1.focus();
			return false;
		}
	}
  }
 else if ( frm.weight.value == "stone and pounds" ) {
	if ( frm.endstone.value == "" ) {
		alert ("Please enter your weight in stone and pounds box");
		frm.endstone.focus();
		return false;
	}
	else if ( eval(frm.endstone.value) > 100 ) {
		alert ("End weight cannot be greater than 100 stones");
		frm.endstone.focus();
		return false;
	}
	else if ( eval(frm.endpounds.value) >= 14 ) {
		alert ("End value cannot be greater than 13");
		frm.endpounds.focus();
		return false;
	}
	else {
		var charpos = frm.endstone.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.endstone.focus();
			return false;
		}
	}
  }
if ( frm.weight.value == "kilograms" ) {
	if ( frm.amtwt.value == "" ) {
		alert ("Please enter your weight in kilograms box");
		frm.amtwt.focus();
		return false;
	}
	else if ( eval(frm.amtwt.value) > 600 ) {
		alert ("Amount of weight to reduce/gain cannot be greater than 600 kilograms");
		frm.amtwt.focus();
		return false;
	}
	else if ( eval(frm.amtwt.value) >= eval(frm.stwt.value) ) {
		alert ("Amount of weight to reduce/gain cannot be greater than start weight");
		frm.amtwt.focus();
		return false;
	}
	else if (eval(frm.stwt.value - frm.endwt.value) > 0 )
	{
		if ( eval(frm.amtwt.value) >= eval(frm.stwt.value - frm.endwt.value)) {
			alert ("Amount of weight to reduce/gain cannot be greater than the difference between start weight and end weight");
			frm.amtwt.focus()
			return false;
		}
	}
	else if (eval(frm.endwt.value - frm.stwt.value) > 0 )
	{
		if ( eval(frm.amtwt.value) >= eval(frm.endwt.value - frm.stwt.value)) {
			alert ("Amount of weight to reduce/gain cannot be greater than the difference between start weight and end weight");
			frm.amtwt.focus()
			return false;
		}
	}
	else {
		var charpos = frm.amtwt.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.amtwt.focus();
			return false;
		}
	}

  }
 else if ( frm.weight.value == "pounds" ) {
	if ( frm.amtpounds.value == "" ) {
		alert ("Please enter your weight in pounds box");
		frm.amtpounds.focus();
		return false;
	}
	else if ( eval(frm.amtpounds.value) > 1320 ) {
		alert ("End weight cannot be greater than 1320 pounds");
		frm.amtpounds.focus();
		return false;
	}
	else if ( eval(frm.amtpounds.value) >= eval(frm.stpounds1.value) ) {
		alert ("Amount of weight to reduce/gain cannot be greater than start weight");
		frm.amtpounds.focus();
		return false;
	}
	else if (eval(frm.stpounds1.value - frm.endpounds1.value) > 0 )
	{
		if ( eval(frm.amtpounds.value) >= eval(frm.stpounds1.value - frm.endpounds1.value)) {
			alert ("Amount of weight to reduce/gain cannot be greater than the difference between start weight and end weight");
			frm.amtpounds.focus()
			return false;
		}
	}
	else if (eval(frm.endpounds1.value - frm.stpounds1.value) > 0 )
	{
		if ( eval(frm.amtpounds.value) >= eval(frm.endpounds1.value - frm.stpounds1.value)) {
			alert ("Amount of weight to reduce/gain cannot be greater than the difference between start weight and end weight");
			frm.amtpounds.focus()
			return false;
		}
	}
	else {
		var charpos = frm.amtpounds.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.amtpounds.focus();
			return false;
		}
	}
  }
 else if ( frm.weight.value == "stone and pounds" ) {
	if ( frm.amtpounds.value == "" ) {
		alert ("Please enter your weight in pounds box");
		frm.amtpounds.focus();
		return false;
	}
	else if ( eval(frm.amtpounds.value) > 1320 ) {
		alert ("End weight cannot be greater than 1320 pounds");
		frm.amtpounds.focus();
		return false;
	}
	else {
		var charpos = frm.amtpounds.value.search("[^0-9|.]"); 
            if ( charpos >= 0 ) {
			alert ("Numerics only allowed");
			frm.amtpounds.focus();
			return false;
		}
	}
  }
}

