$(document).ready(function()
 {
$(".SetApachePort").ClassHilighter("ApachePort");
$(".SetIP").ClassHilighter("IP");

   
$(".SetServerName").ClassHilighter("ServerName");
$(".SetServerAlias input[@type=text]").ClassHilighter("ServerAlias");
$(".SetServerAlias input[@type=checkbox]").click(ShowServerAliasSection);

$(".SetLogFiles input[@type=checkbox]").click(ShowLogFileSection);
$(".SetLogFiles input[@type=text]").ClassHilighter("LogPath");

$("input.SetPortNumber").ClassHilighter("PortNumber");
$("input.SetManageHostName").ClassHilighter("ManageHostName");
$("input.SetShortUrl").ClassHilighter("ShortUrl");


$(".SetRedirectZMI input[@type=checkbox]").click(ShowRedirectZMISection);

$("input[@type=checkbox][@checked]").attr("checked","");

 }
);



function ShowLogFileSection()
{
  if ($(this).attr("checked"))
    $(".LogFileSection").fadeIn();
  else
    $(".LogFileSection").fadeOut();
}

function ShowRedirectZMISection()
{
  if ($(this).attr("checked"))
    $(".RedirectZMI").fadeIn();
  else
    $(".RedirectZMI").fadeOut();
}

function ShowServerAliasSection()
{
  if ($(this).attr("checked"))
    $(".ServerAliasSection").fadeIn();
  else
    $(".ServerAliasSection").fadeOut();
}


jQuery.fn.ClassHilighter = function(cssClass) 
{
  return this.each(function()
  {
    var t = jQuery(this); 
    if (cssClass == undefined)
    {
      cssClass = t.attr('class'); // get it once since it won't change
      cssClass = cssClass.replace(/Set/gi,"");
    }
    if (cssClass) 
    { 
      t.blur(function()
      {
        $('.'+ cssClass).toggleClass("focused");
      })

      t.focus(function()
      {
        $('.'+ cssClass).toggleClass("focused");
        $('.'+ cssClass).html(t.attr("value"));
      })

      t.keyup(function()
      {
        $('.'+ cssClass).html(t.attr("value"));
      })

      t.keyup();
      t.attr("value",$('.'+ cssClass).html());
    }
  })
}

