function delete_default()
{
 if(document.prodSearchForm.item_number.value == "enter item # here")
       document.prodSearchForm.item_number.value = "";
};

function set_default()
{
 if(document.prodSearchForm.item_number.value == "")
       document.prodSearchForm.item_number.value = "enter item # here";
};

function gotoProductPage()
{
  window.location = "products/product_home.html";
};

function homeMouseOver()
{
  document.body.style.cursor='pointer';
};

function homeMouseOut()
{
  document.body.style.cursor='auto';
};

   // do nothing for now
function mouseClick( item_number )
{
      var cell_id = item_number + '_p';
//      document.getElementById( cell_id ).style.backgroundColor='#BBBBBB';

      cell_id = item_number + '_n';
//      document.getElementById( cell_id ).style.backgroundColor='#999999';
}

function mouseOver( item_number )
{
      var cell_id = item_number + '_p';
      document.getElementById( cell_id ).style.backgroundColor='#CCCCCC';

      cell_id = item_number + '_n';
      document.getElementById( cell_id ).style.backgroundColor='#7bc618';
}

function mouseOut( item_number )
{
      var cell_id = item_number + '_p';
      document.getElementById( cell_id ).style.backgroundColor='#ffffff';

      cell_id = item_number + '_n';
      document.getElementById( cell_id ).style.backgroundColor='#666666';
}

function trim ( str ) 
{
    if(str == "")
      return "";
    else
      return str.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
};

function submitWebMessage()
{
  if(trim(document.webMessageFrom.message.value) != "")
	{
	 alert("Thank you!");
	 document.webMessageFrom.action = "webmsg_handler.aspx";	
	 document.webMessageFrom.method = "post";
	 document.webMessageFrom.submit();
	}
	else
	 alert("The message box is empty.");
};

function displayCategoryMenu(fileName)
{
    if( categoryMenu.length > 0 )
    {
        var str="";
	  for(var i=0; i<categoryMenu.length; i++ )
		   str += "<p><a href=\"" + fileName + "?cid=" + categoryMenu[i][0] +"\">" + categoryMenu[i][1] +"</a>";           
	        
        document.getElementById("menu_link_div").innerHTML = str;
    }
};

function displayPageData(fileName, cid, page )
{
    var url = fileName+ "?cid=" + cid + "&pg=" + page;
    window.location = url;
};
		
function displayLink( fileName, cid, page )
{
    var maxPerPage = itemPerRow * rowPerPage;
    var count = maxPerPage;
    var functionCall = "displayPageData('" + fileName + "'," + cid + ",";
		
    var html = "<table align=\"center\"><tr>";

    if(currentPage > 1)
      html += "<td nowrap><b><a href=\"#products_list\" onclick=\"" + functionCall + (currentPage-1)+ ")\"><font size=\"3\" face=\"Times\" color=\"#ffff10\"><< Previous</font></a></b>&nbsp;&nbsp;</td>" ;

    if( maxPerPage < totalRec )
    {

        for(var i=1; count < totalRec; i++)
        {
            if(i == page)
                html += "<td width=10><b><font size=\"3\" face=\"Times\" color=\"#ffffff\">" + i + "</font></b></td>" ;
            else
                html += "<td width=10><b><a href=\"#products_list\" onclick=\"" + functionCall + i + ")\"><font size=\"3\" face=\"Times\" color=\"#ffff10\">" + i + "</font></a></b></td>" ;

            count = i * maxPerPage;
        }
    }

    if(totalRec > (currentPage*maxPerPage) )
      html += "<td nowrap>&nbsp;&nbsp;<b><a href=\"#products_list\" onclick=\"" + functionCall + (currentPage+1)+ ")\"><font size=\"3\" face=\"Times\" color=\"#ffff10\"> Next >> </font></a></b></td>" ;
				
    html += "</tr></table></font>";
    document.getElementById("page_link_bottom_div").innerHTML = html;				
};

		
    function displayProduct( page )
    {
        var startIndex, stopIndex;
        var str_picture="", str_itemNum="";
        var html = "";
			  var id_name="";

        if( productData.length == 0 )
            return;

        stopIndex = productData.length;

        html = "";
        for(var i=0; i<stopIndex; i++ )
        {
            if( (i % itemPerRow) == 0 )
            {
                str_picture = "<table><tr bgcolor=\"#ffffff\" >";
                str_itemNum = "<tr >";
             }

            str_picture += "<th scope=\"col\" width=\"110\" height=\"85\" id='" + productData[i][3] + "_p'  onClick=\"mouseClick(  '" + productData[i][3] + "' );\" onMouseOver=\"mouseOver(  '" + productData[i][3] + "' );\" onmouseout=\"mouseOut(  '" + productData[i][3] + "' );\"  ><a href=productDetail.aspx?pid=" + productData[i][0] + "><img border=0 src=\"productImages/" + productData[i][1] + "/" + productData[i][2] + "\"></a></th>" ;
            str_itemNum += "<th scope=\"row\" bgcolor=\"#666666\" class=\"item_number\" id='" + productData[i][3] + "_n'  onClick=\"mouseClick(  '" + productData[i][3] + "' );\"  onMouseOver=\"mouseOver( '" + productData[i][3] + "' );\" onMouseout=\"mouseOut(  '" + productData[i][3] + "' );\"  >" + productData[i][3] + "</th>" ;

            if( ((i != 0) && ((i+1) % itemPerRow) == 0) || ((i+1) == stopIndex) )
            {
                str_picture += "</tr>";
                str_itemNum += "</tr></table>";

                html += str_picture + str_itemNum;
            }
        }
       html += "</font>";
       document.getElementById("one_category_div").innerHTML = html;
    };


				
