function switchControl(id)
{
   var obj = document.getElementById(id);
   if (obj.style.display=='none') {
      obj.style.display='block';
      document.getElementById(id+'-switch').src = '/i/admin/item-open.gif';
   }
   else {
      obj.style.display='none';
      document.getElementById(id+'-switch').src = '/i/admin/item-close.gif';
   }
}

function openDialog(href, width, height, resizable, wnd_name)
{
   if (!width)
      width = 300;
   if (!height)
      height = 300;
   if (!resizable)
      resizable = 'yes';
   w=window.open(href, wnd_name, "height="+height+",width="+width+",resizable="+resizable+",directories=no,status=no,titlebar=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
   w.focus();
}

function urlSetParams(url, params)
{
   var value = '';
   
   for (key in params) {
      value = params[key];
      if (url.indexOf('?') == -1) {
         url += '?'+key+'='+value;
	 continue;
      }
      re = new RegExp('([\&\?]'+key+'=)[^\&\?]*','g');
      if (re.exec(url)) {
         url = url.replace(re, '$1'+value);
	 continue;
      }
      url += '&'+key+'='+value;
   }
   return url;
}

function urlOpenParams(url, params)
{
   var newUrl = urlSetParams(url, params);
   document.location.href = newUrl;
   return true;
}

function urlChangeParam(name, value)
{
   var url = document.location.href;
   var params = new Object();
   params[name] = value;
   urlOpenParams(url, params)
   return true;
}

