function credit(DonateNowForm){
	var amt1=DonateNowForm.amt1.value;
	var amt2=DonateNowForm.amt2.value;
	var custName=DonateNowForm.custName.value;
	var addrLine1=DonateNowForm.addrLine1.value;
	var city=DonateNowForm.city.value;
	var zip=DonateNowForm.zip.value;
	var email=DonateNowForm.email.value;
	var anonymous=DonateNowForm.anonymous.value;

	var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,6}$/;
	var phoneRegex = /^[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]/;	

	if(amt1 == "") {
		if(amt2 == ""){
			inlineMsg('amt1','Please Enter the amount That you Would like to Donate.',2);
			return false;
		}
	}
	//if(anonymous == "0") {		
		if(custName == "") {
			inlineMsg('custName','Please Enter Your Name.',2);
			return false;
		}
		if(addrLine1 == "") {
			inlineMsg('addrLine1','Please Enter your Address.',2);
			return false;
		}
		if(city == "") {
			inlineMsg('city','Please Enter your City.',2);
			return false;
		}
		if(zip == "") {
			inlineMsg('zip','Please Enter your Postal Code.',2);
			return false;
		}
		if(!zip.match(phoneRegex)) {
			inlineMsg('zip','You must enter Only Numbers.');
			return false;
		}	
		if(email == "") {
			inlineMsg('email','Please Enter your Email Id.',2);
			return false;
		}
		if(!email.match(emailRegex)) {
			inlineMsg('email','Error<br />You have entered an invalid email.',2);
			return false;
		}
	//}	
		return true;
}
function credit_ind(DonateNowForm){
	var amt1=DonateNowForm.amt1.value;
	var amt2=DonateNowForm.amt2.value;
	var custName=DonateNowForm.custName.value;
	var addrLine1=DonateNowForm.addrLine1.value;
	var city=DonateNowForm.city.value;
	var zip=DonateNowForm.zip.value;
	var email=DonateNowForm.email.value;
	var anonymous=DonateNowForm.anonymous.value;

	var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,6}$/;
	var phoneRegex = /^[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]/;	

	if(amt1 == "") {
		if(amt2 == ""){
			inlineMsg('amt1','Please Enter the amount That you Would like to Donate.',2);
			return false;
		}
	}
	//if(anonymous == "0") {		
		if(custName == "") {
			inlineMsg('custName','Please Enter Your Name.',2);
			return false;
		}
		if(addrLine1 == "") {
			inlineMsg('addrLine1','Please Enter your Address.',2);
			return false;
		}
		if(city == "") {
			inlineMsg('city','Please Enter your City.',2);
			return false;
		}
		/*if(zip == "") {
			inlineMsg('zip','Please Enter your Postal Code.',2);
			return false;
		}
		if(!zip.match(phoneRegex)) {
			inlineMsg('zip','You must enter Only Numbers.');
			return false;
		}*/	
		if(email == "") {
			inlineMsg('email','Please Enter your Email Id.',2);
			return false;
		}
		if(!email.match(emailRegex)) {
			inlineMsg('email','Error<br />You have entered an invalid email.',2);
			return false;
		}
	//}	
		return true;
}
function unabletodonate(unabletoDonate){
	var name=unabletoDonate.name.value;
	var email=unabletoDonate.email.value;
	var phone=unabletoDonate.phone.value;

	var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,6}$/;
	var phoneRegex = /^[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]/;

	if(name == "") {
		inlineMsg('name','Please Enter Your Name.',2);
		return false;
	}
	if(email == "") {
		inlineMsg('email','Please Enter Your Email ID.',2);
		return false;
	}
	if(!email.match(emailRegex)) {
		inlineMsg('email','Error<br />You have entered an invalid email.',2);
		return false;
	}
	if(phone == "") {
		inlineMsg('phone','Please Enter Your Phone Number.',2);
		return false;
	}
	if(!phone.match(phoneRegex)) {
		inlineMsg('phone','Please Enter only Numbers.',2);
		return false;
	}
	return true;
}

function contactus_valid(comments){
	var textfield322= comments.textfield322.value;
	var textfield32222= comments.textfield32222.value;
	var textfield322222= comments.textfield322222.value;
	var textfield322223= comments.textfield322223.value;
	var textfield32223= comments.textfield32223.value;
	var textfield32224= comments.textfield32224.value;
	var textfield32225= comments.textfield32225.value;
	var textfield32226= comments.textfield32226.value;
	var textfield32227= comments.textfield32227.value;

	var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,6}$/;
	if(textfield322 == "") {
		inlineMsg('textfield322','Please Enter Your Name.',2);
		return false;
	}
	if(textfield32222 == "") {
		inlineMsg('textfield32222','Please Enter date of Birth.',2);
		return false;
	}
	if(textfield322222 == "") {
		inlineMsg('textfield322222','Please Enter month of Birth.',2);
		return false;
	}
	if(textfield322223 == "") {
		inlineMsg('textfield322223','Please Enter year of Birth.',2);
		return false;
	}
	if(textfield32223 == "") {
		inlineMsg('textfield32223','Please Enter your City.',2);
		return false;
	}
	if(textfield32224 == "") {
		inlineMsg('textfield32224','Please Enter Your Pincode.',2);
		return false;
	}
	if(textfield32225 == "") {
		inlineMsg('textfield32225','Please Enter Your Country.',2);
		return false;
	}	
	if(textfield32226 == "") {
		inlineMsg('textfield32226','Please Enter Your Email ID.',2);
		return false;
	}
	if(!textfield32226.match(emailRegex)) {
		inlineMsg('textfield32226','Error<br />You have entered an invalid email.',2);
		return false;
	}
	if(textfield32227 == "") {
		inlineMsg('textfield32227','Please Enter Your Phone Number.',2);
		return false;
	}

	 return true;
}

// form validation function //
function validate(ContactRegister) {
  var firstname=ContactRegister.firstname.value;	
  var lastname=ContactRegister.lastname.value;
  var company=ContactRegister.company.value;
  var email=ContactRegister.email.value;
  var street=ContactRegister.street.value;
  var city=ContactRegister.city.value;
  var province=ContactRegister.province.value;
  var postalcode=ContactRegister.postalcode.value;
  var phone1=ContactRegister.phone1.value;
  var phone2=ContactRegister.phone2.value;
  var fax1=ContactRegister.fax1.value;
  var fax2=ContactRegister.fax2.value;
  var password=ContactRegister.password.value;
  var ConfPassword=ContactRegister.ConfPassword.value;
  
  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var phoneRegex = /^[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]/;

  if(firstname == "") {
    inlineMsg('firstname','You must enter your name.',2);
    return false;
  }
  if(!firstname.match(nameRegex)) {
    inlineMsg('firstname','You have entered an invalid name.',2);
    return false;
  }
  if(lastname == "") {
    inlineMsg('lastname','You must enter your name.',2);
    return false;
  }
  if(!lastname.match(nameRegex)) {
    inlineMsg('lastname','You have entered an invalid name.',2);
    return false;
  }
  if(company== "") {
    inlineMsg('company','You must enter Your Company Name.');
    return false;
  }
  if(email == "") {
    inlineMsg('email','<strong>Error</strong><br />You must enter your email.',2);
    return false;
  }
  if(!email.match(emailRegex)) {
    inlineMsg('email','<strong>Error</strong><br />You have entered an invalid email.',2);
    return false;
  }
  if(street == "") {
    inlineMsg('street','You must enter your Address.');
    return false;
  }
  if(city == "") {
    inlineMsg('city','You must enter Your City.');
    return false;
  }
  if(province == "") {
    inlineMsg('province','You must enter Your State.');
    return false;
  }
  if(postalcode == "") {
    inlineMsg('postalcode','You must enter Your Postal Code.');
    return false;
  }
  if(!postalcode.match(phoneRegex)) {
    inlineMsg('postalcode','You must enter Only Numbers.');
    return false;
  }
  if(phone1 == "") {
    inlineMsg('phone1','You must enter Your Country Code.');
    return false;
  }
  if(!phone1.match(phoneRegex)) {
    inlineMsg('phone1','You must enter a Valid Country Code.');
    return false;
  }
  if(!(phone1.length) > 3) {
    inlineMsg('phone1','You must enter a Valid Country Code.');
    return false;
  }
  if(phone2 == "") {
    inlineMsg('phone2','You must enter your Phone Number.');
    return false;
  }
  if(!phone2.match(phoneRegex)) {
    inlineMsg('phone2','You must enter a Valid Phone Number.',2);
    return false;
  }
  if(fax1 == "") {
    inlineMsg('fax1','You must enter Your Country Code.');
    return false;
  }
  if(fax2 == "") {
    inlineMsg('fax2','You must enter Your Fax Number.');
    return false;
  }
  if(!fax2.match(phoneRegex)) {
    inlineMsg('fax2','You must enter a Valid Fax Number.',2);
    return false;
  }
  if(password == "") {
    inlineMsg('password','You must enter Your Password.');
    return false;
  }
  if(ConfPassword == "") {
    inlineMsg('ConfPassword','You must ReEnter Your Password.');
    return false;
  }
  
  return true;
}

// START OF MESSAGE SCRIPT //

var MSGTIMER = 20;
var MSGSPEED = 5;
var MSGOFFSET = 3;
var MSGHIDE = 3;

// build out the divs, set attributes and call the fade function //
function inlineMsg(target,string,autohide) {
  var msg;
  var msgcontent;
  if(!document.getElementById('msg')) {
    msg = document.createElement('div');
    msg.id = 'msg';
    msgcontent = document.createElement('div');
    msgcontent.id = 'msgcontent';
    document.body.appendChild(msg);
    msg.appendChild(msgcontent);
    msg.style.filter = 'alpha(opacity=0)';
    msg.style.opacity = 0;
    msg.alpha = 0;
  } else {
    msg = document.getElementById('msg');
    msgcontent = document.getElementById('msgcontent');
  }
  msgcontent.innerHTML = string;
  msg.style.display = 'block';
  var msgheight = msg.offsetHeight;
  var targetdiv = document.getElementById(target);
  targetdiv.focus();
  var targetheight = targetdiv.offsetHeight;
  var targetwidth = targetdiv.offsetWidth;
  var topposition = topPosition(targetdiv) - ((msgheight - targetheight) / 2);
  var leftposition = leftPosition(targetdiv) + targetwidth + MSGOFFSET;
  msg.style.top = topposition + 'px';
  msg.style.left = leftposition + 'px';
  clearInterval(msg.timer);
  msg.timer = setInterval("fadeMsg(1)", MSGTIMER);
  if(!autohide) {
    autohide = MSGHIDE;  
  }
  window.setTimeout("hideMsg()", (autohide * 2000));
}

// hide the form alert //
function hideMsg(msg) {
  var msg = document.getElementById('msg');
  if(!msg.timer) {
    msg.timer = setInterval("fadeMsg(0)", MSGTIMER);
  }
}

// face the message box //
function fadeMsg(flag) {
  if(flag == null) {
    flag = 1;
  }
  var msg = document.getElementById('msg');
  var value;
  if(flag == 1) {
    value = msg.alpha + MSGSPEED;
  } else {
    value = msg.alpha - MSGSPEED;
  }
  msg.alpha = value;
  msg.style.opacity = (value / 100);
  msg.style.filter = 'alpha(opacity=' + value + ')';
  if(value >= 99) {
    clearInterval(msg.timer);
    msg.timer = null;
  } else if(value <= 1) {
    msg.style.display = "none";
    clearInterval(msg.timer);
  }
}

// calculate the position of the element in relation to the left of the browser //
function leftPosition(target) {
  var left = 0;
  if(target.offsetParent) {
    while(1) {
      left += target.offsetLeft;
      if(!target.offsetParent) {
        break;
      }
      target = target.offsetParent;
    }
  } else if(target.x) {
    left += target.x;
  }
  return left;
}

// calculate the position of the element in relation to the top of the browser window //
function topPosition(target) {
  var top = 0;
  if(target.offsetParent) {
    while(1) {
      top += target.offsetTop;
      if(!target.offsetParent) {
        break;
      }
      target = target.offsetParent;
    }
  } else if(target.y) {
    top += target.y;
  }
  return top;
}

// preload the arrow //
if(document.images) {
  arrow = new Image(7,80); 
  arrow.src = "images/msg_arrow.gif"; 
}