// JavaScript Document

function delModule(id)
{
  if(confirm("Are you sure you want to delete this module?"))
  {
    window.location.href = 'processAction.php?action=deleteModule&id='+id;
  }
}

function checkCal()
{
  with(window.document.frmCal)
  {
    if(txt_col1.value=="")
    {
      alert("Please select the present month colour.");
      return false;
    }
    else if(txt_col2.value=="")
    {
      alert("Please select the other month colour");
      return false;
    }
    else if(txt_col3.value=="")
    {
      alert("Please select the header colour");
      return false;
    }
    else
    {
      return true;
    }
  }
}

function checkUserDetailForm()
{
  with(window.document.frmUserDetail)
  {
    if(txt_pword.value=="")
    {
      alert("Please enter the password before submitting.");
      return false;
    }
    else
    {
      return true;
    }
  }
}

function displayEvent(id)
{
  OpenWindow=window.open("getEvent.php?id="+id, "newwin", "height=300, width=520,toolbar=no,scrollbars="+scroll+",menubar=no");  
  OpenWindow.document.close()
  self.name="main"
}

function checkEventForm()
{
  with(window.document.frmEvent)
  {
    if(txt_title.value=="")
    {
      alert("Please fill in the Title.");
      return false;
    }
    else if(txt_date.value=="")
    {
      alert("Please fill in the date.");
      return false;
    }
    else
    {
      return true;
    }
  }
}

function addEvent(id)
{
  window.location.href = "index.php?view=addEvent&id="+id;
}

function del_attach(id, type)
{
  if(confirm("Are you sure you want to delete this attachment?"))
  {
    window.location.href = 'processAction.php?action=deleteAttach&id='+id+'&type='+type;
  }
}

function del_image(img)
{
  if(confirm("Are you sure you want to delete this image?"))
  {
    window.location.href = 'processAction.php?action=deleteImg&img='+img;
  }
}

function checkContentForm()
{
  with(window.document.frmContent)
  {
    if(txt_title.value=="")
    {
      alert("Please fill in the Title.");
      return false;
    }
    else
    {
      return true;
    }
  }
}

function checkModuleForm()
{
  with(window.document.frmModuleDetail)
  {
    if(txt_mod_name.value=="")
    {
      alert("Please fill in the Module Name.");
      return false;
    }    
    else
    {
      return true;
    }
  
  }
}

function checkAddModuleForm()
{
  with(window.document.frmAddModule)
  {
    if(txt_mod_name.value=="")
    {
      alert("Please fill in the Module Name.");
      return false;
    }
    else if(rad_mod[0].checked==false && rad_mod[1].checked==false && rad_mod[2].checked==false)
    {
      alert("Please select the Module Type.");
      return false;
    }
    else
    {
      return true;
    }
  }
}

function deleteUser(id)
{
  if(confirm("Delete this User?"))
  {
    window.location.href = 'processAction.php?action=deleteUser&id='+id ;
  }
}

function checkAddUserForm()
{
  with(window.document.frmAddUser)
  {
    if(txt_name.value=="")
    {
      alert("Please fill in the User Name.");
      return false;
    }
    else if(txt_pword.value=="")
    {
      alert("Please fill in the Password.");
      return false;
    }
    else if(sel_user_type.value=="")
    {
      alert("Please select the User Type.");
      return false;
    }
    else
    {
      return true;
    }
  }
}

function checkLogin()
{
  with(window.document.frmLogin)
  { 
    if(txtUserName.value=="")
    {
      alert('Please enter your login name');
      return false;
    }
    else if(password.value==hex_md5(challenge.value+hex_md5(hex_md5(''))))
    {      
      alert('Please enter your password.');
      return false;
    }
    else
    {
      return true;
    }
  }
}

function addContent(id)
{
  window.location.href = "index.php?view=addContent&id="+id;
}

function add()
{
  window.location.href = "index.php?view=add";
}


