var page_loaded = false;

//Single Field Check
function check_single(field, message){
				if(Trim(field.value) == ""){
								alert(message);
								field.focus();
								field.value = '';
								return false;
				}
				return true;
}

//Disable Submit Button
function disableButton(theButton, value){
				theButton.value = value;
				theButton.disabled = true;
				return true;
}


//Make them confirm
function rusure(link, desc){
				question = confirm(desc)
				if (question !="0"){
								top.location = link
				}
}

function colorRow(E) {
				if(E.checked)
								(E.parentNode).parentNode.style.backgroundColor ="red";
				else
								(E.parentNode).parentNode.style.backgroundColor ="";
}

function togglechecked(form){
				for (var i = 0; i < form.elements.length; i++) {
								var E = form.elements[i];
								if ((E.disabled == false) && (E.name != 'cbxSelectAll') && (E.type == 'checkbox')) {
												E.checked = form.cbxSelectAll.checked;
								}
								colorRow(E);
				}
}

function showhide(theShow, theHide){
        if(theShow){
                var theShow = document.getElementById(theShow); //Section to show
                theShow.style.display = "";
        }
        if(theHide){
                var theHide = document.getElementById(theHide); //Section to show
                theHide.style.display = "none";
        }
}


//Stuff to run once page is loaded.
function pageLoader() {
				page_loaded = true;
}

//Syntax
//addEvent(current[j],'mouseover',this.tipOver);
//addEvent(window, 'load', pageLoader);
function addEvent( obj, type, fn ) {
				if (obj.addEventListener) {
								obj.addEventListener( type, fn, false );
								EventCache.add(obj, type, fn);
				}
				else if (obj.attachEvent) {
								obj["e"+type+fn] = fn;
								obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
								obj.attachEvent( "on"+type, obj[type+fn] );
								EventCache.add(obj, type, fn);
				}
				else {
								obj["on"+type] = obj["e"+type+fn];
				}
}
var EventCache = function(){
				var listEvents = [];
				return {
								listEvents : listEvents,
								add : function(node, sEventName, fHandler){
												listEvents.push(arguments);
								},
								flush : function(){
												var i, item;
												for(i = listEvents.length - 1; i >= 0; i = i - 1){
																item = listEvents[i];
																if(item[0].removeEventListener){
																				item[0].removeEventListener(item[1], item[2], item[3]);
																};
																if(item[1].substring(0, 2) != "on"){
																				item[1] = "on" + item[1];
																};
																if(item[0].detachEvent){
																				item[0].detachEvent(item[1], item[2]);
																};
																item[0][item[1]] = null;
												};
								}
				};
}();

function inputTip(){
		var inputItems = document.getElementsByTagName('input');
		var blurClass = 'grey';

		for(var i=0; i < inputItems.length; i++){
			if ((inputItems[i].type == 'text' || inputItems[i].type == 'password') && inputItems[i].title != ''){

				if(inputItems[i].type == 'password'){
					inputItems[i].onfocus = function (){
						if (this.value == this.title){
							this.value = '';
							this.className = '';
							this.type = 'password';
						}
					}//End onfocus

					inputItems[i].onblur = function (){
						if (this.value == ''){
							this.className = blurClass;
							this.value = this.title;
							this.type = 'text';
						}
					}//End onblur

					if (inputItems[i].value == ''){
						inputItems[i].className = blurClass;
						inputItems[i].value = inputItems[i].title;
						inputItems[i].type = 'text';
					}
				}//End if password

				//if its just a text field
				else{
					inputItems[i].onfocus = function (){
						if (this.value == this.title){
							this.value = '';
							this.className = '';
						}
					}//End onfocus

					inputItems[i].onblur = function (){
						if (this.value == ''){
							this.className = blurClass;
							this.value = this.title;
						}
					}//End onblur

					if (inputItems[i].value == ''){
						inputItems[i].className = blurClass;
						inputItems[i].value = inputItems[i].title;
					}
				}//End else
			}//End if
		}//End for
}//End function
addEvent(window, 'load', pageLoader);
