function validateForm(form)
{
	var pass = false;
	var textboxes = false;
	for (var x = 0; x < form.elements.length; x++){
		var element = form.elements[x];
		if((element.type == "text" || element.type == "select-one") && element.style.visibility != "hidden" && element.id != "PageSize")
		{
			if(element.type == "select-one"){
				if(!(element.value == "='" || element.value == "like '" || element.value == "like '%" || element.value == "=" || element.value == "<" || element.value == ">" || element.value == ">="  || element.value == "<=" )){

					textboxes = true;

					if(element.value != ""){
						pass = true;
					}
				}
			} else {
			
					textboxes = true;

					if(element.value != ""){
						pass = true;
					}
			}
		}

	}

	if(textboxes == true && pass == false)
	{
		alert("Please enter text into at least one of the boxes provided");
	} else {
		pass = true;
	}
	return pass;

}

//layer swaps adapted from: http://www.dyn-web.com/dhtml/show-hide/

var cur_lyr;	// holds id of currently visible layer
function swapLayers(id) {
  if (cur_lyr) hideLayer(cur_lyr);
  showLayer(id);
  cur_lyr = id;
}

function showLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.display = "block";
}

function hideLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.display = "none";
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

/* http://simon.incutio.com/archive/2004/05/26/addLoadEvent */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			if (oldonload) {
			    oldonload();
			}
			func();
		}
	}
}

/* http://www.dustindiaz.com/getelementsbyclass/ */
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

/* by Jeremy Keith */
function insertAfter(newElement, targetElement) {
	var parent = targetElement.parentNode;
	if (parent.lastChild == targetElement) {
		parent.appendChild(newElement);
	}
	else {
		parent.insertBefore(newElement, targetElement.nextSibling);
	}
}

/* http://hribar.info/en/archive/81/entrie.html */
function buttonEndings() {
	if (!document.getElementsByTagName) {
		return false
	}
	
	var buttons = getElementsByClass("button");
	var miscButtons = getElementsByClass("miscButton");
	var excelButtons = document.getElementsByName('DataView');
	var goButtons = document.getElementsByName('Go');
	/* loop through all buttons and attach a child div */
	for (i=0; i < buttons.length; i++) {
		var div = document.createElement("div");
		div.className = "buttonEnding";
		insertAfter(div, buttons[i]);
	}
	
	for(i=0; i < miscButtons.length; i++)
	{
		var div2 = document.createElement("div");
		div2.className = "miscButtonEnding";
		insertAfter(div2, miscButtons[i]);
	}
	
	/*for(i=0; i < excelButtons.length; i++)
	{
		var div3 = document.createElement("div");
		div3.className = "miscButtonEnding";
		insertAfter(div3, excelButtons[i]);
	}
	
	for(i=0; i < goButtons.length; i++)
	{
		var div4 = document.createElement("div");
		div4.className = "miscButtonEnding";
		insertAfter(div4, goButtons[i]);
	}*/
}

addLoadEvent(buttonEndings);

function btnRollOn(FRM,BTN)
{
   window.document.forms[FRM].elements[BTN].style.color = "#000000";
   
}

function btnRollOff(FRM,BTN)
{
   window.document.forms[FRM].elements[BTN].style.color = "";
}



/* Client-side access to querystring name=value pairs
	Version 1.2.4
	30 March 2008
	Adam Vandenberg
*/
function Querystring(qs) { // optionally pass a querystring to parse
	this.params = {};
	this.get=Querystring_get;
	
	if (qs == null);
		qs=location.search.substring(1,location.search.length);

	if (qs.length == 0) 
		return;

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ');
	var args = qs.split('&'); // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var pair = args[i].split('=');
		var name = unescape(pair[0]);
		
		var value = (pair.length==2)
			? unescape(pair[1])
			: name;
		
		this.params[name] = value;
	}
}

function Querystring_get(key, default_) {
	var value=this.params[key];
	return (value!=null) ? value : default_;
}


//JK Popup Window Script (version 3.0)- By JavaScript Kit (http://www.javascriptkit.com)
//modified AFritz to accept width + height arguments    	
	function openpopup(popurl, width, height){
	    var winpops=window.open(popurl,"","width="+width+",height="+height);
	    //toolbar,location,status,scrollbars,menubar,resizable
    	}