/** Shows the price of the product of which number was entered into the 
   "Product Number" input box. */
   
function show_results(PageNumber, PartNumber, Vendor, Section, Page) {
  if (PartNumber == null)
  {
    PageNumber = -1;
    
    cookie_name = "part";
    var YouEntered;
    var ApplicationPath = ""; //for development purposes, on server will be equal ""

    if (document.cookie != document.cookie) 
      index = document.cookie.indexOf(cookie_name);
    else 
      index = -1;

    if (index == -1) {
      //if the document form is not available, take data from function parameters; the input comes from the Next Page button instead from the product page this time
      if (document.userdata != null)
        YouEntered = document.userdata.partnumber.value + "^" + document.userdata.vendor.value + "^" + document.userdata.section.value;
      else
        YouEntered = PartNumber + "^" + Vendor + "^" + Section;
      document.cookie = cookie_name + "=" + YouEntered + "; expires=time() + 3600; path=/";
    }
  
    //url = location.protocol + '//' + location.host + ApplicationPath + "/scripts/result.php?p=" + YouEntered;
    if (document.userdata != null) {
      CommingFrom = document.userdata.commingfrom.value;
      PageValue = document.userdata.page.value;
      SectionValue = document.userdata.section.value;
    }
    else {
      CommingFrom = "productpage";
      SectionValue = Section;
      PageValue = Page;
    }
    
    url = location.protocol + '//' + location.host + ApplicationPath + "/scripts/getproducts.php?p=" + YouEntered + "&commingfrom=" + CommingFrom + "&page=" + PageValue + "&section=" + SectionValue + "&pagenumber=" + PageNumber;
    new_window = window.open(url, 'test1', 'directories=no, location=no, menubar=no, resizable=yes, status=no, toolbar=no, width=800, scrollbars=yes, height=600, left=20, top=20');
    new_window.focus();
  }
  else
  {
    var YouEntered;
    var ApplicationPath = ""; //for development purposes, on server will be equal ""

    YouEntered = PartNumber;

    // document.cookie = cookie_name + "=" + YouEntered + "; expires=time() + 3600; path=/";
    // url = location.protocol + '//' + location.host + ApplicationPath + "/scripts/result.php?p=" + YouEntered;

    CommingFrom = "productpage";
    SectionValue = Section;
    PageValue = Page;

    url = location.protocol + '//' + location.host + ApplicationPath + "/scripts/getproducts.php?p=" + YouEntered + "&commingfrom=" + CommingFrom + "&page=" + PageValue + "&section=" + SectionValue + "&pagenumber=" + PageNumber;
    new_window = window.open(url, 'test1', 'directories=no, location=no, menubar=no, resizable=yes, status=no, toolbar=no, width=800, scrollbars=yes, height=600, left=20, top=20');
    new_window.focus();
  }
}

/** Opens a pop-up window with the MX South policies in it. */

function showPolicy(path) {
	widthx = 800;
	heightx = 600;
	x_left = (screen.width / 2) - (widthx / 2);
  x_top = (screen.height / 2) - (heightx / 2);
  win = window.open(path, "win", "dependent=yes, titlebar=no, toolbar=no, location=no, directories=no, status=no, menubar=no, resizeable=no, scrollbars=yes, width=" + (widthx) + ", height=" + (heightx) + ", left=" + x_left + ", top=" + x_top);
  win.document.open; 
}

function menuitemon(id)
{
  document.getElementById(id).style.backgroundColor = '#FF9900';
}

function menuitemoff(id)
{
  document.getElementById(id).style.backgroundColor = '#000000';
}

function menulink( url )
{
  window.location.href = url;
}

