var xmlHttp=false;
try
{
  xmlHttp=new ActiveXObject('Msxml2.XMLHTTP');
}
catch(e)
{
  try
  {
    xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
  }
  catch(e2)
  {
    xmlHttp=false;
  }
}

if(!xmlHttp && typeof XMLHttpRequest != 'undefined')
  xmlHttp=new XMLHttpRequest();

function checkUserName()
{
  var userName=document.getElementById('_control_reg_name').value;

  if((userName == null) || (userName == ''))
    return;

  var url='/index.php?scriptlet=Portal/CheckNickName&userName='+userName;
  xmlHttp.open('GET', url, true);
  xmlHttp.onreadystatechange=function updateData()
  {
    if(xmlHttp.readyState == 4)
    {
      var response=xmlHttp.responseText;
      document.getElementById('checkUserName').innerHTML=response;
    }
  }
  xmlHttp.send(null);
}

function newProduct(id)
{
  if((id == null) || (id == '') || (id < 1))
    return;

  var url='/index.php?scriptlet=Portal/ShoppingCartActionAdd&productID='+id;
  xmlHttp.open('GET', url, true);
  xmlHttp.onreadystatechange=function updateData()
  {
    if(xmlHttp.readyState == 4)
    {
      var response=xmlHttp.responseText;
      document.getElementById('newProduct').innerHTML=response;
      alert('已经成功添加商品！');
    }
  }
  xmlHttp.send(null);
}