function jump1_search_submit(l)
{
//  alert(document.search.jump1.selectedIndex);
//  alert(document.search.jump1.options[document.search.jump1.selectedIndex].text);
  document.search.limit.value = l;
  document.search.offset.value = ((document.search.jump1.options[document.search.jump1.selectedIndex].text - 1) * l);
  document.search.submit();
}

function jump2_search_submit(l)
{
//  alert(document.search.jump2.selectedIndex);
//  alert(document.search.jump2.options[document.search.jump2.selectedIndex].text);
  document.search.limit.value = l;
  document.search.offset.value = ((document.search.jump2.options[document.search.jump2.selectedIndex].text - 1) * l);
  document.search.submit();
}

function search_submit(l, o)
{
  document.search.limit.value = l;
  document.search.offset.value = o;
  document.search.submit();
}

function search_reset_submit(l, o)
{
  search_reset('B');
  document.search.reset_criteria.value = "Y";
  document.search.limit.value = l;
  document.search.offset.value = o;
  document.search.submit();
}

function search_reset(type)
{
  document.search.brand.value = "";
  document.search.finish.options[0].selected = true;
  document.search.color_range.options[0].selected = true;
  //document.search.weight_lbs.options[0].selected = true;
  document.search.weight_lbs.value = "";
  document.search.desc.options[0].selected = true;

  if( type == 'A' )
  {
    document.search.pms.value = "";
    document.search.mid.options[0].selected = true;
    document.search.app.options[0].selected = true;
    document.search.price_range.options[0].selected = true;
    document.search.gsm.value = "";
    document.search.caliper.value = "";
    document.search.env.options[0].selected = true;
    document.search.man_color.value = "";
    clearList(document.search.features, document.search.all_features);
    document.search.trc.value = "";
    document.search.pcw.value = "";
    document.search.trc_op.options[0].selected = true;
    document.search.pcw_op.options[0].selected = true;
  }

}

// Not used right now
function adv_search_reset()
{
  search_reset();

  document.search.pms.value = "";
  document.search.mid.options[0].selected = true;
  document.search.price_range.options[0].selected = true;
  document.search.gsm.value = "";
  document.search.caliper.value = "";
  document.search.env.options[0].selected = true;
  document.search.man_color.value = "";
  clearList(document.search.features, document.search.all_features);

  document.search.reset = "Y";
}

function search_order(orderby)
{
  document.search.orderby.value = orderby;
  document.search.submit();
}


// Show a popup, resizable page for features (aka characteristics)
function show_chars(family_id, paper_id)
{
  args = "height=" + "450" + ",width=" + "600" + ",resizable,scrollbars";
  //alert(args);
  window.open("chars_popup.php?fid=" + family_id + "&pid=" + paper_id, "_blank", args);
}

// Show a popup, resizable page for weights
function show_weights(family_id, paper_id)
{
  args = "height=" + "560" + ",width=" + "725" + ",resizable,scrollbars";
  //alert(args);
  window.open("weights_popup.php?fid=" + family_id + "&pid=" + paper_id, "_blank", args);
}

// Show a popup, resizable page for comparison details
function show_compare(family_id, paper_id)
{
  args = "height=" + "750" + ",width=" + "900" + ",resizable,scrollbars";
  //alert(args);
  window.open("compare_popup.php?fid=" + family_id + "&pid=" + paper_id, "_blank", args);
}

// Show a popup, resizable page for paper details
function show_paper(family_id, paper_id, m_item)
{
  args = "height=" + "575" + ",width=" + "785" + ",resizable,scrollbars";
  //alert(args);
  window.open("paper_popup.php?fid=" + family_id + "&pid=" + paper_id + "&m_item=" + m_item, "_blank", args);
}

// Show a popup, resizable page for color
function show_color(family_id, paper_id, color_id)
{
  args = "height=" + "570" + ",width=" + "536" + ",scrollbars";
  //alert(args);
  window.open("color_popup.php?fid=" + family_id + "&pid=" + paper_id + "&cid=" + color_id, "_blank", args);
}



// Show a popup, resizable page for envs
function show_envs(family_id, paper_id)
{
  if( family_id != "" && paper_id != "" )
  {
    args = "top=100, left=100, height=" + "500" + ",width=" + "750" + ",resizable,scrollbars";
    //alert(args);
    window.open("show_envs.php?fid=" + family_id + "&pid=" + paper_id, "_blank", args);
  }
}

// Show a popup, resizable page for competitor lists
function show_comps(cl_id)
{
  if( cl_id != "" )
  {
    args = "top=100, left=100, height=" + "500" + ",width=" + "750" + ",resizable,scrollbars";
    //alert(args);
    window.open("show_comps.php?clid=" + cl_id , "_blank", args);
  }
}

// Show a popup, resizable page for distis
function show_distis(family_id)
{
  if( family_id != "")
  {
    args = "top=100, left=100, height=" + "600" + ",width=" + "450" + ",resizable,scrollbars";
    //alert(args);
    window.open("show_distis.php?fid=" + family_id, "_blank", args);
  }
}

// Show a popup, resizable page for disti lists
function show_disti_list(dlist_id)
{
  if( dlist_id != "")
  {
    args = "top=100, left=100, height=" + "600" + ",width=" + "450" + ",resizable,scrollbars";
    //alert(args);
    window.open("show_disti_list.php?dlid=" + dlist_id, "_blank", args);
  }
}

// Show a popup, resizable page for features
function show_features(family_id)
{
  if( family_id != "")
  {
    args = "top=100, left=100, height=" + "500" + ",width=" + "750" + ",resizable,scrollbars";
    //alert(args);
    window.open("show_features.php?fid=" + family_id, "_blank", args);
  }
}

// Show a popup, resizable page for applications
function show_applications(family_id)
{
  if( family_id != "")
  {
    args = "top=100, left=100, height=" + "500" + ",width=" + "750" + ",resizable,scrollbars";
    //alert(args);
    window.open("show_applications.php?fid=" + family_id, "_blank", args);
  }
}

// Show a popup, resizable page for distis
function show_loc_details(loc_id)
{
  if( loc_id != "")
  {
    args = "height=" + "375px" + ",width=" + "400px" + ",resizable,scrollbars";
    //alert(args);
    window.open("loc_details_popup.php?lid=" + loc_id, "_blank", args);
  }
}


// Show a popup, resizable page for the help file
function show_help(pos)
{
    args = "height=550px, width=575px, resizable, scrollbars";
    //alert(args);
    window.open("../../common/help/help_newtext.htm#" + pos, "_blank", args);
}


// Show a popup, resizable page for the light/pro file
function show_pro_popup(pos)
{
    args = "height=475px, width=425px, scrollbars";
    //alert(args);
    window.open("../../common/help/pro_popup.htm", "_blank", args);
}




// Move selected items from one list to the other ignoring the Any option.
  function moveList(from,to)
  {
    if( from.options[0].text == "Any" )
      return;

    fromlen = from.length ;
    for ( i=0; i<fromlen ; i++)
    {
      if (from.options[i].selected == true )
      {
				tolen = to.length;
        to.options[tolen]= new Option(from.options[i].text);
        to.options[tolen].value = from.options[i].value;
      }
    }

    for ( i = (fromlen -1); i>=0; i--)
    {
      if (from.options[i].selected == true )
      {
        from.options[i] = null;
      }
    }

//    seedList();
  }

  // Select all items in the runList so that they will be passed in the POST call.
  function setList(runList)
  {
    for (i=0; i<runList.length; i++)
    {
      runList.options[i].selected = true;
    }
  }

  // Clear all items from selected list
  function clearList(from, to)
  {
  setList(from);
  moveList(from, to);
  }

  // Make sure List has at least an Any option.
  // Any disappears when another option is added.
  function seedList(list)
  {
    len = list.length;
    if(len == 0 )
      list.options[len] = new Option("Any")
    else if( document.search.features.options[0].text == "Any" )
      list.options[0] = null;
  }


// Create a target popup page for a form to post to
function createTarget(form)
{
  _win = window.open('',form.target,'height=550,width=550,resizable,scrollbars');

  if(typeof(focus)=="function")
    _win.focus();

  return true;
}



