
  var win = null;
	var t = null;
	var winuid = Math.round(Math.random() * 999999999);
	function browse(url)
	{
	  try
			{
				var test = win.document;
				win.focus();
				win.location.href = url;
			}
			catch(e)
			{
				win = null;
			}
		if(win == null)
		{
			try
			{
				win = window.open(url, ('user_list_' + winuid), 'resizable=1, scrollbars=1,toolbar=0,location=0,width=750,height=650');
			}
			catch(e)
			{
				return;
			}
			t = setInterval('check()', 1000);
		}
		
	}
	function check()
	{
		if(win == null && t != null) clearInterval(t);
		if(win != null)
		{
			try
			{
				var test = win.document;
			}
			catch(e)
			{
				win = null;
			}
		}
	}
	
	function cls()
	{
		win.close();
		win = null;
		if(t != null)
		{
			clearInterval(t);
		}
		t = null;
	}


function clearField(controlID, value) {
    var control = document.getElementById(controlID);
    if (control.value == value) {
        control.value = '';
    }
}

function clearPasswordField(controlID) {
    var control = document.getElementById(controlID);
    if (control.value == '************') {
        control.value = '';
    }
}


function changeState(obj, catId)
  {
    var catContainer = document.getElementById('category_' + catId);
    if(catContainer.style.display == 'none')
    {
      catContainer.style.display = 'block';
      obj.className = obj.className.replace('collapse', 'expand');
    }
    else
    {
      catContainer.style.display = 'none';
      obj.className = obj.className.replace('expand', 'collapse');
    }
  }
  
  function changeStateTo(obj, catId, state)
  {
    var catContainer = document.getElementById('category_' + catId);
    if(state == 'block')
    {
      catContainer.style.display = 'block';
      obj.className = obj.className.replace('collapse', 'expand');
    }
    else
    {
      catContainer.style.display = 'none';
      obj.className = obj.className.replace('expand', 'collapse');
    }
  }
  
  function expandAll(button)
    {
      var expand = false;;
      if(button.className == "expand-image-button")
      {
        button.className="collapse-image-button";
        expand = true;
      }
      else
      {
        button.className="expand-image-button";
        expand = false;
      }
      var menuContainer = document.getElementById('menu');
      if(menuContainer)
      {
        var controlList = menuContainer.getElementsByTagName("div");
        for(i=0; i<controlList.length; i++)
        {
          if(controlList[i].id.indexOf("category_arrow_") >= 0)
          {
            var catId = controlList[i].id.split('_')[2];
            if(expand)
              changeStateTo(controlList[i], catId, "block");
            else
              changeStateTo(controlList[i], catId, "none");
          }
        }
      }
    }
  
  function $(id)
  {
    return document.getElementById(id);
  }
  
  function SetItems(ContainerID)
      {
          var el, el2;
          var array = document.getElementById(ContainerID).childNodes;
          var menuList = document.getElementById('menu').getElementsByTagName("input");
                    
          for(j = 0 ; j < menuList.length; j ++)
          {
              if(menuList[j].type !="button")
                  menuList[j].value = '';
          }
          for(i = 0; i < array.length; i++)
          {
              el = array[i];
              if (el && el.id != '' && el.childNodes &&  el.childNodes.length > 0 && el.childNodes[0].tagName == 'TD')
              {
                    
                    var inputRadioList = el.getElementsByTagName("INPUT")
                    var radioButton = null;
                    for(g=0; g<inputRadioList.length; g++)
                    {
                      if(inputRadioList[g].type == "radio")
                      {
                        radioButton = inputRadioList[g];
                        break;
                      }
                    }
                    
                    
                     
                    if (radioButton && radioButton.checked == true)
                    {
                      var tableContainer = document.getElementById('category_' + radioButton.value + '_order').getElementsByTagName("TABLE")[0];                      
                      var inputList = tableContainer.getElementsByTagName("input");
                      for(k=0; k<inputList.length; k++)
                      { 
                        if(inputList[k].type == "text" && inputList[k-1].checked)
                        {
                          objName = "countitem_" + inputList[k].id.split('_')[3] + "_" + inputList[k].id.split('_')[4];
                          obj = document.getElementById(objName);
                          if(obj)
                          {
                            obj.value = inputList[k].value;
                          }
                        }                        
                      }                     
                    }
              }        
          }
      }
      
      function SetValue()
      {
          
      }