﻿VisualConfig = {
	requiredParams : { isClass : false, cssData : "" },
	acceptedParams : { isClass : false, cssData : "" },
	rejectedParams : { isClass : false, cssData : "" },
	tagParams : { isClass : false, cssData : "background-color: #FF0000; color: #FFFFFF; padding: 3px 5px; margin-bottom: 12px; width: 300px; font-weight: bold;" },
	
	setRequiredStyle : function(x) {
		this.requiredParams.isClass = (x.indexOf(":") == -1);
		this.requiredParams.cssData = x;
		return (this);
	},
	
	setAcceptedStyle : function(x) {
		this.acceptedParams.isClass = (x.indexOf(":") == -1);
		this.acceptedParams.cssData = x;
		return (this);
	},
	
	setRejectedStyle : function(x) {
		this.rejectedParams.isClass = (x.indexOf(":") == -1);
		this.rejectedParams.cssData = x;
		return (this);
	},
	
	setTagStyle : function(x) {
		this.tagParams.isClass = (x.indexOf(":") == -1);
		this.tagParams.cssData = x;
		return (this);
	},
	
	accept : function(x) {
		if (this.acceptedParams.isClass) x.className = this.acceptedParams.cssData;
		else x.style.cssText = this.acceptedParams.cssData;
		
		if (x.errorTag != null) {
			if (typeof(jQuery) == "function") $(x.errorTag).slideUp(300);
			x.parentNode.removeChild(x.errorTag);
			x.errorTag = null;
		}
	},
	
	reject : function(x, y) {
		if (this.rejectedParams.isClass) x.className = this.rejectedParams.cssData;
		else x.style.cssText = this.rejectedParams.cssData;
		if (x.errorTag == null) this.createErrorTag(x, y);
	},
	
	bind : function(x) {
		x.binder = this;
		//alert(this.requiredParams.cssData);
		if (this.requiredParams.isClass) x.className = this.requiredParams.cssData;
		else x.style.cssText = this.requiredParams.cssData;
	},
	
	createErrorTag : function(x, y) {
		var d = document.createElement("div");
		if (this.tagParams.isClass) d.className = this.tagParams.cssData;
		else d.style.cssText = this.tagParams.cssData;
		
		if (typeof(jQuery) == "function") d.style.display = "none";
		d.innerHTML = y;
		x.errorTag = d;
		x.parentNode.appendChild(d);
		
		if (typeof(jQuery) == "function") $(d).slideDown(150);
	}
};
