/*
  -------------------------------------------------------------------------
	                Validation Script in JavaScript
                                Version 2.0
	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

	In return, you are requested to add a link to JavaScript-Coder.com, 
	making it easy for others to find this script.
	You can get the code for the link from: 
	http://www.javascript-coder.com/gen/link-to-us.phtml 

	If you want to get your site listed in the members' page, 
	send an email to: support@javascript-coder.com 

    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;
	}
	
	if (this.id == 'frm_charity_update') {
		if (document.getElementById('bank_signature_changes').value == 'yes')	{
			alert('Any changes to the signature information will not take effect until validated by our admin staff. You will be notified by phone and/or email once the change has been completed.');
		}
	}// if
	
	if (this.id == 'frm_location_update') {
		if (document.getElementById('bank_information_changes').value == 'yes')	{
			alert('Please fax a new void cheque to 1-888-498-2455. The changes will not take effect until the new banking information has been validated by our admin staff. You will be notified by phone and/or email once the changes have been completed.');
		}
	}// if
		
	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 
    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 CompareDates2(obj, hh, mm) {
	var dateGEt = obj.split('-');
  var mon1 = parseInt(dateGEt[0]) - 1;
	var hh1 = parseInt(hh);
	var mm1 = parseInt(mm);
 	var cDate = new Date(Date.UTC(dateGEt[2], mon1, dateGEt[1], hh1, mm1, 0));
	var currdate = (cDate.getTime()/1000.0);
	return currdate;
}// function

	function isPostCode(entry) { // checks Canadian codes only
		strlen = entry.length; 
		if (strlen !== 6) {
			return false;
		}		
		//entry=entry.toUpperCase();  // in case of lowercase
		// Check for legal characters in string - note index starts at zero
		if('ABCEGHJKLMNPRSTVXY'.indexOf(entry.charAt(0))<0) {return false;}
		if('0123456789'.indexOf(entry.charAt(1))<0) {return false;}
		if('ABCDEFGHJKLMNPQRSTUVWXYZ'.indexOf(entry.charAt(2))<0) {return false;}
		if('0123456789'.indexOf(entry.charAt(3))<0) {return false;}
		if('ABCDEFGHJKLMNPQRSTUVWXYZ'.indexOf(entry.charAt(4))<0) {return false;}
		if('0123456789'.indexOf(entry.charAt(5))<0) {return false;}
		return true;
	}

 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(fnFixSpace(objValue.value).length) == 0) 
           { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : Required Field"; 
              }//if 
              alert(strError); 
							objValue.focus();
							objValue.select();
              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 + " ]"); 
							 objValue.focus();
							 objValue.select();
               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 + " ]");
							 objValue.focus();
							 objValue.select();
               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 [Enter valid data.]");
								objValue.focus();
								objValue.select();
                return false;
              }//if
              break;
           }//case alphanumeric
		    case "postalcode": { 
						var postalCodeGet = objValue.value;
						if(!isPostCode(postalCodeGet)) { 
							alert(strError + "\n [Enter valid data.]");
							objValue.focus();
							objValue.select();
							return false;
  	        }//if
	          break;
				}//case alphanumeric 
          case "alphanumericspc": 
           { 
              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 [Enter valid data.]");
								objValue.focus();
								objValue.select();
                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[Only digits allowed]");
								objValue.focus();
								objValue.select();
                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 [Enter only alphabetic data. ]");
								objValue.focus();
								objValue.select();
                return false; 
              }//if 
              break; 
           }//alpha 
		   
		    case "birthDate": {
					var currentTime = new Date();
					var cmonth = currentTime.getMonth() + 1;
					var cday = currentTime.getDate();
					var cyear = currentTime.getFullYear();
					var currentDate = cmonth + '-' + cday + '-' + cyear;
					
					var bDate = document.getElementById("dobdate").value;
					
					var cureentdatetimestamp = CompareDates2(currentDate, 0, 0);
					var birthdatetimestamp = CompareDates2(bDate, 0, 0);
					
					if (parseInt(birthdatetimestamp) >= parseInt(cureentdatetimestamp)) {
						alert(strError + "\n [Birth date must be less than from current date.]");
						objValue.focus();
						objValue.select();
						return false;
					}
					break;
				}//birthDate 
				
				case "deadDate": { 
					var currentTime = new Date();
					var cmonth = currentTime.getMonth() + 1;
					var cday = currentTime.getDate();
					var cyear = currentTime.getFullYear();
					var currentDate=cmonth+'-'+cday+'-'+cyear;
					
					var bDate = document.getElementById("doddate").value;
					
					var cureentdatetimestamp = CompareDates2(currentDate,0,0);
					var deaddatetimestamp = CompareDates2(bDate,0,0);
					
					if (parseInt(deaddatetimestamp)>=parseInt(cureentdatetimestamp)) {
						alert(strError + "\n [Death date must be less than from current date.]");
						objValue.focus();
						objValue.select();
						return false;
					}
					break; 
				}//deadDate 
		   
				case "dateCopareCheck": { 				
					var bDate = document.getElementById("dobdate").value;
					var dDate = document.getElementById("doddate").value;
					
					var birthdatetimestamp = CompareDates2(bDate, 0, 0);
					var deadtimestamp = CompareDates2(dDate, 0, 0);
					
					if (bDate != '' && dDate != '') {
						if(parseInt(birthdatetimestamp) >= parseInt(deadtimestamp)) {						
							alert(strError + "\n [Death date must be greater than from birth date.]");
							objValue.focus();
							objValue.select();
							return false;
						}
					}
					break;
				}//dateCopareCheck 
			
			
			case "datetimeappear": { 
 				
				var currentTime = new Date();
				var cmonth = currentTime.getMonth() + 1;
				var cday = currentTime.getDate();
				var cyear = currentTime.getFullYear();
 				var currentDate = cmonth + '-' + cday + '-' + cyear;
 				
				var bDate = document.getElementById("doddate").value;
 			 	
		  	var cureentdatetimestamp = CompareDates2(currentDate, 0, 0);
				
				var pc_hh = document.getElementById("adh").value;
				var pc_mm = document.getElementById("adm").value;
				var pcampm = document.getElementById("adampm").value;
				
				var pe_hh = document.getElementById("rdh").value;
				var pe_mm = document.getElementById("rdm").value;
				var peampm = document.getElementById("rdampm").value;
				
				if (pcampm == 'PM') {
					if (pc_hh == 12) {
						var pc_hh = 0;
					}	else {
						var pc_hh = parseInt(pc_hh) + 12;
					}// else
				}// if

				if (peampm == 'PM') {
					if (pe_hh == 12) {
						var pe_hh = 0;
					}	else	{
						var pe_hh = parseInt(pe_hh)+12;
					}
				}
				
				var dateapear = document.getElementById("appeardate").value;
				var removeDate = document.getElementById("removedate").value;
				
				var timestampappear = CompareDates2(dateapear, pc_hh, pc_mm);
				var timestampremove = CompareDates2(removeDate, pe_hh, pe_mm);
				 
				if (parseInt(timestampappear) < parseInt(cureentdatetimestamp)) {
					alert(strError + "\n [Date/Time to Appear should be greater than from current date time.]");
					objValue.focus();
					objValue.select();
					return false;
				}
				if (parseInt(timestampremove) <= parseInt(cureentdatetimestamp)) {
					alert(strError + "\n [Date/Time to Remove should be greater then from current date time.]");
					objValue.focus();
					objValue.select();
					return false; 
				}
				if (parseInt(timestampremove) <= parseInt(timestampappear)) {
					alert(strError + "\n [Date/Time to Remove should be greater then from date time appear.]");
					objValue.focus();
					objValue.select();
					return false; 
				}
				
				break; 
			}//datetimeappear
			
			case "checkprecharity": {
				
				var charityOne = document.getElementById("charity_one").value;
				var charityTwo = document.getElementById("charity_two").value;
				var charityThree = document.getElementById("charity_three").value;
				
				//if((charityOne != '' && charityTwo != '' ) && (charityOne != '0' && charityThree != '0'))
				if(charityOne != '0' && charityThree != '0')
				{
					if(parseInt(charityOne) == parseInt(charityTwo)) 
					{
						alert(strError + "\n [Select diffrent preferred charity for selection one and two.]");
						return false;
					}
				}
				if(charityOne != '0' && charityThree != '0')
				{
					if(parseInt(charityOne) == parseInt(charityThree)) {
						alert(strError + "\n [Select diffrent preferred charity for selection one and three.]");
						return false;
					}
				}
				if(charityTwo != '0' && charityThree != '0') 
				{
					if(parseInt(charityTwo) == parseInt(charityThree)) 
					{
						alert(strError + "\n [Select diffrent preferred charity for selection two and three.]");
						return false; 	
					}
				}
				break; 
			}//checkprecharity
		   
        case "alphaspc": 
           { 
              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 and space characters allowed "; 
                }//if                             
                alert(strError + "\n [Enter only alphabetic and space data]");
								objValue.focus();
								objValue.select();
                return false; 
              }//if 
              break; 
           }//alpha
					 
        case "location_name": 
        { 
					//var charpos = objValue.value.search("[^A-Za-z0-9 &-_@.]"); 
					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 alphabetic and space characters allowed "; 
						}//if 
						//alert(strError + "\n [Enter only alphabetic and space data]");
						alert(strError);
						objValue.focus();
						objValue.select();
						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 [Enter valid data]"); 
						return false;
					}//if
					break;
				}
				
				case "alphaspchyphen":
				{
					var charpos = objValue.value.search("[^A-Za-z\- ]");
					if(objValue.value.length > 0 &&  charpos >= 0)
					{ 
						if(!strError || strError.length == 0) 
						{ 
							strError = objValue.name + ": characters allowed are A-Z, a-z and -";
						}//if
						alert(strError + "\n [Enter valid data]");
						return false;
					}//if
					break;
				}// alphaspchyphen
				
		case "alnumhyphenheartbeat":
			{
              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 [Enter valid data]"); 
                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);
								objValue.focus();
								objValue.select();
                 return false; 
               }//if 
           break; 
          }//case email 
		  case "multiemail": 
          { 
               var allEmail=objValue.value;
			   var emailArray=allEmail.split(';');
			   for(k=0;k<emailArray.length;k++){
 			   if(!validateEmailv2(emailArray[k])) 
               { 
                 if(!strError || strError.length ==0) 
                 { 
                    strError = objValue.name+": Enter a valid Email address "; 
                 }//if 
                 alert(strError);
								objValue.focus();
								objValue.select();
                 return false; 
               }//if 
			 }
           break; 
          }//case email 
				
				case "servicecodes": { 
					var allCodes = objValue.value;
					var codesArray = allCodes.split(',');
					
					for (k=0; k < codesArray.length; k++) {
						
						var charpos = codesArray[k].search("[^0-9]"); 
						if(codesArray[k].length > 0 &&  charpos >= 0) { 
							if(!strError || strError.length ==0) 
							{ 
								strError = objValue.name + ": Only digits and , allowed "; 
							}//if               
							alert(strError + "\n[Only digits allowed]");
							objValue.focus();
							objValue.select();
							return false; 
						}//if 
						
					}// for
					break;
				}//case service codes 
					
        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 "phone": 
        { 
						var val = objValue.value;
						if(val != "")
						{
							for(var j=0; j<val.length; j++)
							{
								if((val.charAt(j)!='(')&&(val.charAt(j)!=')')&&(val.charAt(j)!=' ')&&(val.charAt(j)!="-")&& !((val.charAt(j)>=0)&&(val.charAt(j)<=9)))
								{									
									if(!strError || strError.length ==0) 
									{ 
										strError = objValue.name+": characters allowed are 0-9,(,) and spaces."; 
									}//if                                               
									alert(strError);
									objValue.focus();
									objValue.select();
									return false;
								}// if
							}// for
						}// if
            break; 
         }//case phone
				 
        case "phoneformat": { 
					var val = objValue.value;
					if(val != "") {
						if (val.search(/\(\d{3}\) \d{3}-\d{4}/) == -1)	{
							
							if(!strError || strError.length == 0) { 
								strError = objValue.name + ": Please enter a phone number with the format (xxx) xxx-xxxx";
							}//if
							
							alert(strError);
							objValue.focus();
							objValue.select();
							return false;
							
						}// if
						
					}// if
					break; 
         }//case phoneformat		

        case "phoneformat2": { 
					var val = objValue.value;
					if(val != "") {

						if(val.indexOf("1") == 1) {
							if(!strError || strError.length == 0) { 
								strError = objValue.name + ": 1 for first digit is not allowed.";
							}//if
							
							alert(strError);
							objValue.focus();
							objValue.select();
							return false;
						}
					}
					break; 
         }//case phoneformat2
				 
        case "phoneformat3": { 
					var val = objValue.value;
					if(val != "") {
						
						if(val.indexOf("1") == 6) {
							if(!strError || strError.length == 0) { 
								strError = objValue.name + ": 1 for fourth digit is not allowed.";
							}//if
							
							alert(strError);
							objValue.focus();
							objValue.select();
							return false;
						}
						
					}
					break; 
         }//case phoneformat3
				 
				 
        case "phoneformat4": { 
					var val = objValue.value;
					if (val != "") {
						
						if (val.indexOf("0") == 6) {
							if(!strError || strError.length == 0) { 
								strError = objValue.name + ": 0 for fourth digit is not allowed.";
							}//if
							
							alert(strError);
							objValue.focus();
							objValue.select();
							return false;
						}// if
						
					}//if
					break;
         }//case phoneformat4
		 
		  case "charityBusinessNumber":
        { 
					var val = objValue.value;
					if(val != "") {
						if (val.search(/\d{9}RR\d{4}$/) == -1)	{
							
							if(!strError || strError.length == 0) { 
								strError = objValue.name + ": Please enter a Charitable Business Number with the format 123456789RR0001";
							}//if
							
							alert(strError);
							objValue.focus();
							objValue.select();
							return false;
							
						}// if
						
					}// if
					break; 
         }//case phoneformat		
		 
				 
        case "regexp": 
         { 
						alert(cmdvalue);	
            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 "date":
				{
					alert(objValue.value);
					alert(V2validateData("regexp=/^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/",objValue,strError));
					break; 
				}
        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
				 
        case "select": { 
        	if ((objValue.selectedIndex == null) || (objValue.selectedIndex == 0)) { 
            if(!strError || strError.length == 0) { 
            	strError = objValue.name+": Please Select one option "; 
            }//if
            alert(strError);
						objValue.focus();
          	return false;
          }// if
          break; 
        }//case dontselect
				 
				 case "chk":
				 {
						 if(!objValue.checked) 
						 {
							 if(!strError || strError.length ==0)
							 {
								
								switch(objValue.id) {
										case "chk1" :
											//strError = "Please tick \"I can enter into agreement on behalf of my charity.\"";
											strError = "In order to register as a charity, you must be able to enter into the agreement on behalf of your charity!";
											break;
										case "chk2" :
											strError = "In order to register you must check the box stating that you understand the agreement!.";
											break;
										case "chk3" :
											strError = "In order to register you must check the box stating that the information you’ve entered above is correct!";
											break;
										case "chkLocation1" :
											//strError = "Please tick \"I can enter into agreement on behalf of my charity.\"";
											strError = "In order to register as a location, you must be able to enter into the agreement on behalf of your location!";
											break;
								}
								alert(strError);
								return false;
							}// if
						}// if
						break;
				}//case
				
				case 'password' : {	
					if (objValue.value.indexOf(" ") != -1) {
						if (!strError || strError.length == 0) { 
							strError = objValue.name + ": Spaces are not allowed in password";
						}//if
						alert(strError);
						objValue.focus();
						objValue.select();
						return false;
					}// if
					break;
				}// case
				
				case 'confirmpassword' : {
					if (document.getElementById('password').value != document.getElementById('confirm_password').value) {
						if (!strError || strError.length == 0) {
							strError = objValue.name + ": Passwords are not matching";
						}//if
						alert(strError);
						objValue.focus();
						objValue.select();
						return false;
					}// if
					break;
				}// case
				
				case 'float' : {
					if (objValue.value != '')	{						
						re = /^((\d+(\.\d*)?)|((\d*\.)?\d+))$/;
						if (re.test(objValue.value) == false) {
							alert(strError);
							objValue.focus();
							objValue.select();
							return false;
						}
					}
					break;
				}// case
				
				case 'customfloat' : {
					if (objValue.value != '')	{
						
						epos = objValue.value.search("-");
						if (epos == 0) {
							objValue.value = objValue.value.substr(1, objValue.value.length);
							document.getElementById('negative').value = "yes";
						} else {
							document.getElementById('negative').value = "no";
						}// else
						
						re = /^((\d+(\.\d*)?)|((\d*\.)?\d+))$/;
						if (re.test(objValue.value) == false) {
							alert(strError);
							objValue.focus();
							objValue.select();
							return false;
						}
					}
					break;
				}// case
				
				case 'suspend-req' : {
					var strObj = 	objValue.name;
					var strComp = '';
					
					if (strObj.indexOf("1") != -1) {
						strComp = "reactivate_date_1";
					} else if (strObj.indexOf("2") != -1) {
						strComp = "reactivate_date_2";
					}// else if
					
					if (strComp != '') {
						if ((eval(fnFixSpace(document.getElementById(strComp).value).length) > 0) && (eval(fnFixSpace(objValue.value).length) == '') ) {
							alert(strError);
							objValue.focus();
							objValue.select();
							return false;
						}// if
					}// if
					break;
					
				}// case
				
				case 'reactivate-req' : {
					var strObj = 	objValue.name;
					var strComp = '';
					
					if (strObj.indexOf("1") != -1) {
						strComp = "suspend_date_1";
					} else if (strObj.indexOf("2") != -1) {
						strComp = "suspend_date_2";
					}// else if
					
					if (strComp != '') {
						if ((eval(fnFixSpace(document.getElementById(strComp).value).length) > 0) && (eval(fnFixSpace(objValue.value).length) == '') ) {
							alert(strError);
							objValue.focus();
							objValue.select();
							return false;
						}// if
					}// if
					break;
				}// case
				
				case 'comp-suspend-reactivate' : {
					
					var strObj = 	objValue.name;
					var strComp = '';
					var strCompHour = '';
					var strCompMinute = '';
					var strCompMeridiem = '';
					
					var strReCompHour = '';
					var strReCompMinute = '';
					var strReCompMeridiem = '';
					
					if (strObj.indexOf("1") != -1) {
						strComp = "suspend_date_1";
						
						strCompHour = document.getElementById("suspend_date_1_hour").value;
						strCompMinute = document.getElementById("suspend_date_1_minute").value;
						strCompMeridiem = document.getElementById("suspend_date_1_meridiem").value;
						
						strReCompHour = document.getElementById("reactivate_date_1_hour").value;
						strReCompMinute = document.getElementById("reactivate_date_1_minute").value;
						strReCompMeridiem = document.getElementById("reactivate_date_1_meridiem").value;
						
					} else if (strObj.indexOf("2") != -1) {
						strComp = "suspend_date_2";
						
						strCompHour = document.getElementById("suspend_date_2_hour").value;
						strCompMinute = document.getElementById("suspend_date_2_minute").value;
						strCompMeridiem = document.getElementById("suspend_date_2_meridiem").value;
						
						strReCompHour = document.getElementById("reactivate_date_2_hour").value;
						strReCompMinute = document.getElementById("reactivate_date_2_minute").value;
						strReCompMeridiem = document.getElementById("reactivate_date_2_meridiem").value;
					}// else if
					
					if (strCompMeridiem == "PM") {
						if (strCompHour == "12") {
							strCompHour = 0;
						} else {
							strCompHour = parseInt(strCompHour) + 12;
						}// else
					} else if (strCompMeridiem == "AM") {
						if (strCompHour == "12") {
							strCompHour = 0;
						}// if
					}// else if
					
					if (strReCompMeridiem == "PM") {
						if (strReCompHour == "12") {
							strReCompHour = 0;
						} else {
							strReCompHour = parseInt(strReCompHour) + 12;
						}// else
					} else if (strReCompMeridiem == "AM") {
						if (strReCompHour == "12") {
							strReCompHour = 0;
						}// if
					}// else if
					
					var suspendDate = document.getElementById(strComp).value;
			  	var reactivateDate = objValue.value;
					
			 		//alert(suspendDate + " => " + strCompHour + ":" + strCompMinute);
			 		//alert(reactivateDate + " => " + strReCompHour + ":" + strReCompMinute);
										
	 			 	var suspendDateTimestamp = CompareDates2(suspendDate, strCompHour, strCompMinute);
  		  	var reactivateDateTimestamp = CompareDates2(reactivateDate, strReCompHour, strReCompMinute);
					
					if (suspendDate != '' && reactivateDate != '') {
						if (parseInt(suspendDateTimestamp) >= parseInt(reactivateDateTimestamp)) {
							alert(strError);
							//alert(strError + "\n [Reactivate Date should be greater than Suspend Date.]");
							objValue.focus();
							objValue.select();
							return false;
						}// if
					}//if
					
				}//case
				
    }//switch 
    return true;
		
}// function V2validateData

	function fnFixSpace(sFldval)
	{
		var sTemp=sFldval;
		var sReversedString="";
		var sTemp1;
		
		//remove spaces from the front
		sNewval = fnRemoveSpaces(sTemp);
		
		// reverse n remove spaces from the front
		for(var i=sNewval.length-1;i>=0;i--)
			sReversedString = sReversedString + sNewval.charAt(i);
		sTemp1 = fnRemoveSpaces(sReversedString);
		//reverse again
		sReversedString="";
		for(var i=sTemp1.length-1;i>=0;i--)
			sReversedString = sReversedString + sTemp1.charAt(i);
		sNewval = sReversedString;
		return sNewval;
	}
	
	function fnRemoveSpaces(sFldval)
	{
		var sTemp=sFldval;
		var sNewval=sTemp;
		//remove spaces from the front
		for(var i=0;i<sTemp.length;i++)
		{	
			if(sTemp.charAt(i)!=" ")
				break;
			else
				sNewval = sTemp.substring(i+1);
		}
		return sNewval;
	}
/*
	Copyright 2003 JavaScript-coder.com. All rights reserved.
*/
function TrimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
} 


function formatPhone(ele) {	
	
  if (eval(fnFixSpace(ele.value).length) > 0) {
			
		var str = ele.value;
		
		if ((str.indexOf("(") == 0) && (str.indexOf(")") == 4)) {
			return;
		}
		var len = str.length;
		var str1 = str.substring(0, 3);
		var strRes;
		
		strRes = "(" + str1 + ")";
		
		if (str.indexOf(" ") == 3) {
			
			var str2 = str.substring(3, 7);
			strRes += str2;
			
			if (str.indexOf("-") == 7) {
				var str3 = str.substring(7, 12);
				strRes += str3;
			} else {
				var str3 = str.substring(7, 11);
				strRes += "-";
				strRes += str3;
			}// else
			
		} else {
			
			var str2 = str.substring(3, 6);
			strRes += " ";
			strRes += str2;
			
			if (str.indexOf("-") == 6) {
				var str3 = str.substring(6, 11);
				strRes += str3;
			} else {
				var str3 = str.substring(6, 10);
				strRes += "-";
				strRes += str3;
			}// else
			
		}// else
		
		ele.value = strRes;
	}// if
	
}// function

	function formatPostalCode (ele) {
		ele.value = ele.value.toUpperCase();  // in case of lowercase
	}// function