//	Enter in textbox submits bid
function txtClickSubmit_KeyEnter(e, btn)
{
	if (e.keyCode == 13)
	{
		document.getElementById(btn).click();
		return false;
	}
}

function sConvertTextBoxToHTML(sTxt)
{
	var i = sTxt.indexOf("  ");
	while (i > -1)
	{
		sTxt = sTxt.replace("  ", " &nbsp;");
		i = sTxt.indexOf("  ");
    }
    
    i = sTxt.indexOf("\n");
    while (sTxt.indexOf("\n") > -1)
	{
		sTxt = sTxt.replace("\n", "<br>");
		i = sTxt.indexOf("\n");
    }

    return sTxt;
}

function checkEmailAddress(sEmail)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(sEmail))
		return true;
	else
		return false;
}

function ToggleShow(sID, bShow)
{
	var sItem = document.getElementById(sID);
	
	if (sItem != null)
	{
		if (bShow)
			sItem.style.display = '';
		else
			sItem.style.display = 'none';
	}
}

function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}