startList = function() {
	
  moveRefinements();
  
  if($("rightColDHTML")) {
    $("rightColDHTML").style.display="none";
	  searchSpecificDomChanges();  
  } else {
    browseSpecificDomChanges();  
  }

  if(BrowserDetect.browser == "Explorer" && BrowserDetect.version == "6") {
	  correctStyles($("attributes-root"));
	  correctStyles($("location-root"));
    correctStyles($("sellerrating-root"));
  }
}

correctStyles = function(refinementsTopNode) {
  for(i=0; i< refinementsTopNode.childNodes.length; i++) {
    node = refinementsTopNode.childNodes[i];
    if (node.nodeName=="LI") {
      node.onmouseover=function() {
      this.className+=" over";
    }
    node.onmouseout=function() {
      this.className=this.className.replace(" over", "");
    }
   }
  }
}

moveRefinements = function() {
	$("searchPanel").className = "formFrame";
	$("go").style.display = "none";
	addEvent(document.forms["sortResults"].elements["sortby"], "change", handleSortBySelection);
	$("dhtmlattributesContainer").appendChild($("attributes"));
	$("dhtmllocationContainer").appendChild($("location"));
	$("dhtmlsellerratingContainer").appendChild($("sellerrating"));
	$("newSearchLocation").appendChild($("refineSearchDIV"));
	$("searchwithinlabel").style.display="inline";
}

searchSpecificDomChanges = function() {
	$("matchesHeader").appendChild($("sortResultsDIV"));	
	$("searchkeySelect").style.display="none";
	$("searchkeySelect").style.display = "none";
  $("searchkeySelect").value = "kn";
}

browseSpecificDomChanges = function() {
  $("dhtmlmatches").appendChild($("matches"));
	$("subcatstableMiddle2").appendChild($("categories"));
	$("leftpaneldhtml").insertBefore($("subcatsdiv"),$("controlBox"));
	$("browsewithincat").style.display = "inline";
	$("subcatsdiv").style.display = "inline";
	$("dhtmlmatches").style.padding = "10px 0px 10px 0px";
  $("subcatstable").className = "formFrame subcats";
  $("controlBox").style.display ="none";
  $("controlBox").type = "hidden";
}

$ = function(elementId) {
	var domNode = document.getElementById(elementId);
	return domNode;
}


addEvent = function(obj, type, fn) {
	if (obj.addEventListener) {
			obj.addEventListener(type, fn, false);
	}
	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]);
	}
}

handleSortBySelection = function() {
	document.forms["sortResults"].submit();
}

/*
 * The vCounter object literal is used to set a non-expiring cookie.
 * This cookie can be used later on to determine if a visitor as been
 * to the site before.
 */

var vCounter = {

  domain: "abebooks.com",
  expirationYear: 2015,
  name: "abe_vc",
  path: "/",

  init: function() {
    var baker = new AbeCookie();
    var cookieValue = baker.getValue(vCounter.name);
    var expires = new Date();
    expires.setFullYear(vCounter.expirationYear);

    var numberOfVisits = 0;
    if (cookieValue != null) {
      numberOfVisits = parseInt(cookieValue);
      if (numberOfVisits < 100) {
        numberOfVisits++;
      }
    }
    baker.bake(vCounter.name, numberOfVisits, expires, vCounter.path, vCounter.domain, false);
  }
}
