// JavaScript Document

H = new handler;

function AJAX(theElement,theHandler,theError) {
	Result = H.execute(theHandler,theElement.value);
	if(MainError = document.getElementById('mainerror')) {
		MainError.style.display = "none";
		if(ErrorExistsObj = document.getElementById('error_'+theElement.name)) {
				ErrorExistsObj.innerHTML = "";
				ErrorExistsObj.id="";
				ErrorExistsObj.className = "hidden";
				
				
				
		}
		if(lblObj = document.getElementById("label_"+theElement.id)) {
				
				cClass = lblObj.className;
				
				cClass = cClass.replace("error","");
				
				lblObj.className = cClass;
				
		}
		if(Result != false) {
			if(Result!="empty") {
				theElement.value = Result;
			}
		} else {
				MainError.style.display = "";
				MainError.innerHTML += "<li id=\"error_"+theElement.name+"\">"+theError+"</li>";
				
				if(lblObj = document.getElementById("label_"+theElement.id)) {
					cClass = lblObj.className;
					lblObj.className = cClass+" error";
				}
		}
	}
}

function Loader(What,Where,Sequencer) {
	if(WhereObj = document.getElementById(Where)) {
		if((SequencerObj = document.getElementById(Sequencer))&&((Sequencer.length)>0)) {
			
			Result = H.loader(What,Math.abs(SequencerObj.value)+1);
		} else {
			
			Result = H.loader(What);
		}
		if(Result!=false) {
			var theDiv = document.createElement("div");
			theDiv.innerHTML = Result;
			WhereObj.appendChild(theDiv);
			if(SequencerObj) {
				var newV  = Math.abs(SequencerObj.value)+1;
				SequencerObj.value = newV;
			}
		} else {
			alert("The "+What+" could not be loaded!");
		}
	}
}

function ProgressBar() {
	if(ProgressObj = document.getElementById("progress_bar")) {
		ProgressObj.style.display="";
	}
}

function Revelate(theContainer) {
	this._objectId;
	this.theContainerID = theContainer;
	this._containerObj = false;
	this.closeAll = false;
	this.tagSwap = "<div>";
	this.openTracker = new Array();
	this._debug = true;
	this._execute = true;
	this.hideClass = "hide";
	this.moreClass = "more";
	this._constructor = function() { 
		if((this._containerObj = document.getElementById(this.theContainerID))==false) {
			this._execute = false;
			if(this._debug) {
				alert('could not detect the container in which you have instantiated this class!');
			}
		}
	}
	this.show = function(theOpen) {
		
		this._objectId = theOpen;
		if(this._execute) {
			
			
			
			if(theObj = document.getElementById(this._objectId)) {
				
				var isOpen = this.openTracker[theObj.id];
				
				if(!isOpen) {
					this.openTracker[theObj.id] = false;
					isOpen = false;
				}
				
				
				if(isOpen != false) {
					
					//theObj.style.display="none";
					this.openTracker[theObj.id] = false;
					new Effect.BlindUp(theObj);
				} else {		
					if(this.closeAll==true) {
						this.closeAll();
					}
					
					this.trackOpen(theObj.id);
					//theObj.style.display="";
					new Effect.BlindDown(theObj);
				}
			} else if(this._debug) {
					alert('could not detect the object in which you wish to show!');
			}
		}
	}
	this.trackOpen = function(theClassName) {
		this.openTracker[this._objectId] = theClassName;
	}
	this.closeAll = function() {
		for(openJ in this.openTracker) {
			if(theTempO = document.getElementById(openJ)) {
				if(this.openTracker[openJ].length>0) {
					theTempO.style.display = "none"
				} else {
					theTempO.style.display = "none";;
				}
				delete this.openTracker[openJ];
			}
			
		}
		
	}
	this.hide = function(theClose) {
		
		if(this.closeAll==true) {
			this.closeAll();
		}
		if(theTempO = document.getElementById(theClose)) {
			
			if(this.openTracker[theClose]) {
				theTempO.style.display="none";
			} else {
				theTempO.style.display="none";
			}
			delete this.openTracker[theClose];
		}
	}
	this._trim = function(sInString) {
	  sInString = sInString.replace( /^\s+/g, "" );// strip leading
	  return sInString.replace( /\s+$/g, "" );// strip trailing
	}
}