function getUserPreferenceParam() {
  var selectMicronail = document.getElementById("micronail");
  var labelPerPage = document.getElementById("labelperpage");
  var findmethod = document.getElementById("findmethod");
  var url;
  if (selectMicronail == null || labelPerPage == null || findmethod == null)
    url = "";
  else   
    url = "&micronail=" + selectMicronail.value + "&labelPerPage=" + labelPerPage.value +
          "&findmethod=" + findmethod.value;
  return url;
}

function changeQuickFindType() {
  getEl("findmethod").value = getEl("quickfindselect").value;    
  constructParameters();
}

function sortList(parameters) {
  document.getElementById("sortbycolumn").value = parameters;
  constructParameters();
}

function validateQuickFindCallback(responseStr) {
  //var d = new Date();
  //alert((d.getTime() - startTime) / 1000);
  //alert(responseStr);
  
  if (responseStr.indexOf("There is nothing to display") != -1) {
		responseStr =
    "<table id=\"labellist\" style=\"width: 100%; border: 1px solid black; padding: 5px; text-align: center;\">"+
		"<tr>"+
		"<td>"+
		"No Result"+
		"</td>"+
		"</tr>"+
		"</table>";
  }	
  rowID = 1;
  
  if (responseStr.indexOf("pagecontroltbl") > 0) {
    var index = responseStr.indexOf("</table>");
    var pagectl = responseStr.substring(0, index+8);
    document.getElementById("pagecontrol").innerHTML = pagectl;
    responseStr = responseStr.substring(index+8, responseStr.length);
    //document.getElementById("txtHTML").value = responseStr;
  }
  
  document.getElementById("txtHint").innerHTML = responseStr;
  setLabelListDivHeight();
  focusOnLineOne();
  
  //var newd = new Date();
  //alert(newd.getTime() - d.getTime());
} 

function updateRadioButtonTip() {
  if (getEl("noteshref") == null)
    return;
    
  strHref = getEl("noteshref").href;
  if (strHref.indexOf("?") < 0)
    getEl("ahref_btnnotes").title = "Return to original list";
  else
    getEl("ahref_btnnotes").title = "Show items with notes";
  
  strHref = getEl("favhref").href;
  if (strHref.indexOf("?") < 0)
    getEl("ahref_btnfav").title = "Return to original list";
  else
    getEl("ahref_btnfav").title = "Show items in the favourite list";
  
  strHref = getEl("carthref").href;
  if (strHref.indexOf("?") < 0)
    getEl("ahref_btncart").title = "Return to original list";
  else
    getEl("ahref_btncart").title = "Show items in the shopping cart";
  
  if (getEl("imageshref") == null) {return;}
  
  strHref = getEl("imageshref").href;
  if (strHref.indexOf("?") < 0)
    getEl("ahref_btnimg").title = "Return to original list";
  else
    getEl("ahref_btnimg").title = "Show items to download";    
}

function focusOnLineOne() {
  if (getEl("labelsinthelist") == null || 
      getEl("labelperpage") == null || 
      getEl("micronail") == null ||
      getEl("typeinterval") == null || 
      getEl("fontsize") == null) {
    setTimeout("focusOnLineOne()", 100);
  }
  else {
    var visible = readCookie("SearchVisible");
    var advsearch = (visible == "visible") ? "on" : "off";
    
    var searchDIV = document.getElementById("StockSuperSearch");    
    if (searchDIV != null) {
      if ((advsearch == "on" && searchDIV.style.visibility == "hidden") ||
          (advsearch == "off" && searchDIV.style.visibility == "visible") ){
        gotoPage(5);
      }
    }
    
    getEl("quickfindselect").value = getEl("findmethod").value;
    moveRowFocus(0);
    updateRadioButtonTip(); 
  }
}

function setLabelListDivHeight() {
  var labellist = document.getElementById("labellist");
  var quickfindtbl = document.getElementById("quickfindtbl");
  
  if (labellist != null && quickfindtbl != null) {
    if (document.body.clientHeight - getElementY(quickfindtbl) > 110) {
      labellist.style.height = document.body.clientHeight - getElementY(quickfindtbl) - 110;
    } else {
      labellist.style.height = document.body.clientHeight - getElementY(quickfindtbl);
    }
        
  }  
  
  //alert(labellist.scrollHeight - (document.body.clientHeight - getElementY(quickfindtbl) - 120));
}
//var startTime;

function sendQuickFindAJAX(url) {
  //alert(url);
  //var d = new Date();
  //startTime = d.getTime();    
  var ajax = new AJAXAction(url, validateQuickFindCallback); 
  ajax.doGet();
  setLoadingMessage(); // -- Jimmy 3:08 PM Thursday, June 08, 2006
}
