function trim(str) {
	return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');	
}

function checkNameEmail(names, emails) {
	names = trim(names);
	emails = trim(emails);	
	nameArray = names.split(',');
	emailArray = emails.split(',');
	
	if (nameArray.length != emailArray.length) {
		return false;
	}
	
	return true;
}

function isEmail(s) {
	s = trim(s);
	var email = s.split(',');
	for (var i = 0; i < email.length; i++) {
		if (!checkEmail(email[i])) {
			return false;
		}
	}
	
	return true;
}



function checkEmail(str) {	
  	
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		  // alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   // alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true	
}

$(document).ready(function(){ 
	
	<!-- request material mail -->
	$("#yourName2").focus(function() {
		if($(this).val() == "*Your Name") {
			$(this).val("");
			$(this).addClass(" ActiveInput");
		}
	});
	$("#yourName2").blur(function() {
		if($(this).val() == "") {
			$(this).val("*Your Name");
			$(this).removeClass(" ActiveInput");
		}
	});
	
	$("#address1").focus(function() {
		if($(this).val() == "*Address 1 (no PO boxes, please)") {
			$(this).val("");
			$(this).addClass(" ActiveInput");
		}
	});
	$("#address1").blur(function() {
		if($(this).val() == "") {
			$(this).val("*Address 1 (no PO boxes, please)");
			$(this).removeClass(" ActiveInput");
		}
	});
	
	$("#address2").focus(function() {
		if($(this).val() == "Address 2") {
			$(this).val("");
			$(this).addClass(" ActiveInput");
		}
	});
	$("#address2").blur(function() {
		if($(this).val() == "") {
			$(this).val("Address 2");
			$(this).removeClass(" ActiveInput");
		}
	});
	
	$("#city").focus(function() {
		if($(this).val() == "*City") {
			$(this).val("");
			$(this).addClass(" ActiveInput");
		}
	});
	$("#city").blur(function() {
		if($(this).val() == "") {
			$(this).val("*City");
			$(this).removeClass(" ActiveInput");
		}
	});
	
	$("#message").focus(function() {
		if($(this).val() == "If these materials are for an event, please tell us the name of your event and how many people will attend.") {
			$(this).val("");
			$(this).addClass(" ActiveInput");
		}
	});
	$("#message").blur(function() {
		if($(this).val() == "" ) {
			$(this).val("If these materials are for an event, please tell us the name of your event and how many people will attend.");
			$(this).removeClass(" ActiveInput");
		}
	});
	
	$("#zipCode").focus(function() {
		if($(this).val() == "*ZIP Code") {
			$(this).val("");
			$(this).addClass(" ActiveInput");
		}
	});
	$("#zipCode").blur(function() {
		if($(this).val() == "") {
			$(this).val("*ZIP Code");
			$(this).removeClass(" ActiveInput");
		}
	});
	
	$("#email").focus(function() {
		if($(this).val() == "*E-mail Address") {
			$(this).val("");
			$(this).addClass(" ActiveInput");
		}
	});
	$("#email").blur(function() {
		if($(this).val() == "") {
			$(this).val("*E-mail Address");
			$(this).removeClass(" ActiveInput");
		}
	});
	
	<!-- end -->
						   
	$("#yourName").focus(function() {
		if($(this).val() == "Your Name") {
			$(this).val("");
			$(this).addClass(" ActiveInput");
		}
	});
	$("#yourName").blur(function() {
		if($(this).val() == "") {
			$(this).val("Your Name");
			$(this).removeClass(" ActiveInput");
		}
	});
	
	$("#yourEmail").focus(function() {
		if($(this).val() == "Your E-mail") {
			$(this).val("");
			$(this).addClass(" ActiveInput");
		}
	});
	$("#yourEmail").blur(function() {
		if($(this).val() == "") {
			$(this).val("Your E-mail");
			$(this).removeClass(" ActiveInput");
		}
	});
	
	$("#friendName").focus(function() {
		if($(this).val() == "Friend's Name") {
			$(this).val("");
			$(this).addClass(" ActiveInput");
		}
	});
	$("#friendName").blur(function() {
		if($(this).val() == "") {
			$(this).val("Friend's Name");
			$(this).removeClass(" ActiveInput");
		}
	});
	
	$("#friendEmail").focus(function() {
		if($(this).val() == "Friend's E-mail") {
			$(this).val("");
			$(this).addClass(" ActiveInput");
		}
	});
	$("#friendEmail").blur(function() {
		if($(this).val() == "") {
			$(this).val("Friend's E-mail");
			$(this).removeClass(" ActiveInput");
		}
	});
  $("#to").focus(function() {
		if($(this).val() == "To") {
			$(this).val("");
			$(this).addClass(" ActiveInput");
		}
	});
  $("#to").blur(function() {
		if($(this).val() == "") {
			$(this).val("To");
			$(this).removeClass(" ActiveInput");
		}
	});
  $("#emailTemplate").focus(function() {
		if($(this).val() == "Email template") {
			$(this).val("");
			$(this).addClass(" ActiveInput");
		}
	});
  $("#emailTemplate").blur(function() {
		if($(this).val() == "") {
			$(this).val("Email template");
			$(this).removeClass(" ActiveInput");
		}
	});

          $("#subject").focus(function() {
		if($(this).val() == "Subject") {
			$(this).val("");
			$(this).addClass(" ActiveInput");
		}
	});
  $("#subject").blur(function() {
		if($(this).val() == "") {
			$(this).val("Subject");
			$(this).removeClass(" ActiveInput");
		}
	});
});


