

//------------------------------------------------------------------------
function ChangeVisible(element)
{
    var obj = document.getElementById(element);
    if( obj == null )
    {
        alert( element + ' not found');
    }
    
    $(obj).toggle("slow");
} 

function SetVisible(element, boolValue)
{
    var obj = document.getElementById(element);
    if( obj == null )
    {
        alert( element + ' not found');
    }
    obj.style.display = ( boolValue )?'block':'none'; 

} 

//------------------------------------------------------------------------
function OpenWindow( url )
{
    var win = window.open(url, "", "resizable=yes,scrollbars=yes,location=no,status=yes,toolbar=no; width=800, height=600");
    try
    {
        win.opener = window;
    }
    catch(e)
    {}
    
    return win;
} 



//------------------------------------------------------------------------
function CloseWindow()
{
    if(window.opener)
    {
        window.opener.document.location.reload();
    }
    window.close();
} 

// cookie
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function getCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}


function SetCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
} 

//-----------------------------------------------
function disableInputFields()
{
    var inputs = document.body.getElementsByTagName( "INPUT" );
    for( var i=0; i < inputs.length; i++ )
    {
        inputs[i].setAttribute("disabled", "disabled");
    } 

    var inputs = document.body.getElementsByTagName( "TEXTAREA" );
    for( var i=0; i < inputs.length; i++ )
    {
        inputs[i].setAttribute("disabled", "disabled");
    }

    var inputs = document.body.getElementsByTagName( "SELECT" );
    for( var i=0; i < inputs.length; i++ )
    {
        inputs[i].setAttribute("disabled", "disabled");
    }
}

window.currentMenuId = null;

function ChangeMenuGroup(groupId)
{
    if(window.currentMenuId == groupId)
       return;

    if(window.currentMenuId != null)
    {
    	var contentid = "content_" + window.currentMenuId;
    	SetVisible(contentid, false);
    }
    var contentid = "content_" + groupId;
    SetVisible(contentid, true);
    window.currentMenuId = groupId;
    
}



