function accform(){
  // Hide forms
  $( 'form' ).hide().end();
  
  // Processing
  $( 'form' ).not( '.noacc' ).find( 'li/label' ).each( function( i ){
    var labelContent = this.innerHTML;
    var labelWidth = document.defaultView.getComputedStyle( this, '' ).getPropertyValue( 'width' );
    var labelSpan = document.createElement( 'span' );
        labelSpan.style.display = 'block';
        labelSpan.style.width = labelWidth;
        labelSpan.innerHTML = labelContent;
    this.style.display = '-moz-inline-box';
    this.innerHTML = null;
    this.appendChild( labelSpan );
  } ).end();
  
  // Show forms
  $( 'form' ).show().end();
}

function getParameter ( queryString, parameterName ) {
   // Add "=" to the parameter name (i.e. parameterName=value)
   var parameterName = parameterName + "=";
   if ( queryString.length > 0 ) {
      // Find the beginning of the string
      begin = queryString.indexOf ( parameterName );
      // If the parameter name is not found, skip it, otherwise return the value
      if ( begin != -1 ) {
         // Add the length (integer) to the beginning
         begin += parameterName.length;
         // Multiple parameters are separated by the "&" sign
         end = queryString.indexOf ( "&" , begin );
      if ( end == -1 ) {
         end = queryString.length
      }
      // Return the string
      return unescape ( queryString.substring ( begin, end ) );
   }
   // Return "null" if no parameter has been found
   return "null";
   }
}

function initSearch() {
  // Ensure we're working with a 'relatively' standards 
  // compliant browser
  if (document.getElementById) {
    var objFormDiv = document.getElementById('search_options');
    var objSearchLink = document.getElementById('advanced_search');
	var queryString = window.top.location.search.substring(1);
	
	//only hide div form if the user is not filtering their results...
	//we will use color code as a basis (or filter can be toggled on with ?filter)
	var colorCode = getParameter(queryString, 'colorCode');
	var filter = getParameter(queryString, 'filter');

	if(colorCode == "null" || colorCode == null) {
	  if(filter == "1") {
		objFormDiv.style.display = 'block';
	  }else{
		//user is not filtering their results, filter form is useless..
		//Hide form div
		objFormDiv.style.display = 'none';
	  }
	}
	
	//attach onclick event to show form again on user request...
	objSearchLink.onclick = function() {
	  if(objFormDiv.style.display == 'none') {
		objFormDiv.style.display = 'block';
	  }else{
		objFormDiv.style.display = 'none';
	  }
	}
  }
}

function addClass(element,name) {	
	  if (!element.className) {
		element.className = name;
	  } else {
		element.className+= " " + name;
	  }
}

function removeClass(element, name) {
  element_class = element.className;
  
  if(element_class == name) {
	element_class = element_class.replace(name,"");	
	element.className = element_class;
  }
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}