function ErrorCheck(errorColor,color,div)
{
	this.errorBGColor = errorColor;
	this.BGColor = color;
	this.div = div;
	this.errMessage = "";
	this.div.innerHTML = "";
	this.noErrors = true;
	this.email = true;
	this.isEmpty = function(object,userFldName)
	{
	   if(object.value=="")
	   {		
			object.style.backgroundColor = this.errorBGColor;
			this.errMessage = this.errMessage+ "<li>"+"The "+userFldName+" is blank. Please make sure this field is filled in."+"</li>"
			this.noErrors = false;
	   	
	   }
	   else 
	   {
			object.style.backgroundColor = this.BGColor;
		
	   }
	} 
	// invalid phone number error
	this.checkPhone = function(object,userFldName)
	{
			var filter = /\(?\d{3}\)?([-\/\.])\d{3}\1\d{4}/;
			var re = new RegExp(filter);
			if (re.test(object.value))
			{
				object.style.backgroundColor = this.BGColor;
			}
			else{
				object.style.backgroundColor = this.errorBGColor;
				this.errMessage = this.errMessage+ "<li>The phone number you entered is an invalid phone number.</li>";
				this.noErrors =  false;
			}
	
	}
    this.isEmail = function(object)
	{   
			var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			var re = new RegExp(filter);
			if (re.test(object.value.toString()))
			{	
				object.style.backgroundColor = this.BGColor;
	
			}
			else{
				object.style.backgroundColor = this.errorBGColor;
				this.errMessage = this.errMessage+ "<li>The email address you entered is not valid."+"</li>";
				this.email = false;
				this.noErrors =  false;
			}
	}
	this.isInteger = function(object,userFldName)
	{
		var filter = /^\d+$/;
		var re = new RegExp(filter);
		if (re.test(object.value)){
			object.style.backgroundColor = this.BGColor;
		}
		else{
			object.style.backgroundColor = this.errorBGColor;
			this.errMessage = this.errMessage+ "<li>The "+userFldName+" you entered is not a numeric value.</li>";
		    this.noErrors =  false;
		}
	}
	this.dealership = function(object1,object2){
		if(object1[1].checked==true && object2.value=="0" && (object1[1].checked!=undefined)){
			object2.style.backgroundColor = this.errorBGColor;
			this.errMessage = this.errMessage+ "<li>Please select a dealership.</li>";
		    this.noErrors =  false;
		}
		else{
			object2.style.backgroundColor = this.BGColor;
		}
		
	}
	this.validVIN = function(object)
	{
	    var VIN = object.value.toString();
	    if(VIN.length==17)
		{
			object.style.backgroundColor = this.BGColor;
		}
		else
		{
			object.style.backgroundColor = this.errorBGColor;
			this.errMessage = this.errMessage+ "<li>Invalid VIN Number.</li>";
		    this.noErrors =  false;
		}
	}
	this.isMatch = function(object1,object2,userFldName)
	{
		
		if(object1.value==object2.value){
			object1.style.backgroundColor = this.BGColor;
			object2.style.backgroundColor = this.BGColor;
		}
		else{	
			object1.style.backgroundColor = this.errorBGColor;
			object2.style.backgroundColor = this.errorBGColor;
			this.errMessage = this.errMessage.toString()+ "<li>The two "+userFldName.toString()+" you entered have different values. Please check the fields and make sure they both match.</li>";
		    this.noErrors =  false;
		}
		
	
	}
	this.display = function(){
	
		if(this.errMessage!="" && this.noErrors==false)
		{
			this.div.innerHTML = "<ol style='color:"+this.errorBGColor+"';>"+this.errMessage.toString()+"</ol>";
			this.div.style.backgroundColor = this.BGColor.toString();
		}
	}
	this.isDate = function(fld){
			  var RegExPattern = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;
				var errorMessage = 'Please enter valid date as month, day, and four digit year.\nYou may use a slash, hyphen or period to separate the values.\nThe date must be a real date. 2-30-2000 would not be accepted.\nFormay mm/dd/yyyy.';
				if ((fld.value.match(RegExPattern)) && (fld.value!='')) {
					
				} else {
					 this.noErrors =  false;
					 this.errMessage = this.errMessage+ "<li>Invalid Date. Valid Dates <i>Example: (01/01/2008,03/28/2008)</li></i>";
				} 
	}
}