
function togglediv(id)
{
  show = document.getElementById(id).style.display;
  
   
  if ((show == "none") || (show == ""))
  {
   document.getElementById(id).style.display = "block";
  }
  else
  {
   document.getElementById(id).style.display = "none";
  }
}

function highlight(id)
{

 document.getElementById(id).style.background = "#99CC99";

}

function fade(id)
{
 document.getElementById(id).style.background = "#669966";
}

function udimgswitch(id)
{
 img = document.getElementById(id);
 a = img.src.substring(0, img.src.lastIndexOf('/') + 1);
 b = img.src.substring(img.src.lastIndexOf('/') + 1, img.src.length);
 
 
 if (b == "up.png")
 {
  img.src = a + 'down.png';
 }
 else
 {
  img.src = a + 'up.png';
 }
}

function getnewsimgpath(id)
{
 file = document.getElementById(id);
 file = file.value;
 //alert(file);
 
 dir = "/eryndor/images/news/";
 filename = file.substring(file.lastIndexOf('\\') + 1, file.length);
 
 if (filename != "")
 {
  path = dir + filename;
  document.getElementById("content").value += path;
 }
}

function geteventimgpath(id)
{
 file = document.getElementById(id);
 file = file.value;
 //alert(file);
 
 dir = "/eryndor/images/events/";
 filename = file.substring(file.lastIndexOf('\\') + 1, file.length);
 
 if (filename != "")
 {
  path = dir + filename;
  document.getElementById("content").value += path;
 }
}

function calexpand(id, imgid)
{
 togglediv(id);
 
 udimgswitch(imgid);
}

function ietouch()
{
 objects = document.getElementsByTagName("object");
 for (var i = 0; i < objects.length; i++)
 {
     objects[i].outerHTML = objects[i].outerHTML;
 }
}

function popup(url, h, w)
{
 newwindow = window.open(url);
 if (window.focus)
 { newwindow.focus(); }
 //return false; //Stops browser from following link
}

function clearvalue(id)
{
 document.getElementById(id).value = "";
}


function centerthumb(id, count)
{
 key = id + count;
 
 
 while (document.getElementById(key))
 {
  
  img = document.getElementById(key);
  
  a = img.parentNode;
  
  p = a.parentNode;
  
  //alert(a.offsetHeight);
  //alert(p.offsetHeight);
  
  
  img.style.marginTop = Math.floor( (p.offsetHeight - img.height) / 2) + 'px';
  
  //alert(img.style.marginTop);
  
  count++;
  key = id + count;
 }
}

function validatereg()
{
 var s = "";

 if (document.input.iname.value == "")
 {  
  s += "Please enter a login name.\n";
 }
 else
 {
  if (document.input.iname.value.length < 6)
  {
   s += "Your login name must be at least 6 characters long.\n"
  }
 }
 
 if ((document.input.ipassword.value == "") || (document.input.ipassword2.value == ""))
 {
  s += "Please fill in both password fields.\n";
 }
 else
 {
  if ((document.input.ipassword.value.length < 6) || (document.input.ipassword2.length < 6))
  {
   s += "Your password must be at least 6 characters long.\n"
  }
  else
  {
   if (document.input.ipassword.value != document.input.ipassword2.value)
   { 
    s += "The passwords fields do not match.\n";
   }
  }
 }
 
 if ((document.input.iemail.value == "") || (document.input.iemail2.value == ""))
 {
  s += "Please fill in both email fields.\n";
 }
 else
 { 
  if (document.input.iemail.value != document.input.iemail2.value)
   {
    s += "The email fields do not match.\n";
   }
 }
 
 if (s != "") 
 {
  alert(s);
  return false;
 }
 else
 {
  document.register.username.value = document.input.iname.value;
  document.register.displayname.value = document.input.idisplay.value;
  document.register.password.value = document.input.ipassword.value;
  document.register.email.value = document.input.iemail.value;
  
  document.register.submit();
 }
}

function checkAllThumb()
{
 var count = 0;
 
 name = "c" + count;
 
 while (cb = document.getElementById(name))
 {
  cb.checked = true;
  count++;
  name = "c" + count;
 }
}

function uncheckAllThumb()
{
 var count = 0;
 
 name = "c" + count;
 
 
 while (cb = document.getElementById(name))
 {
  cb.checked = false;
  count++;
  name = "c" + count;
 }
}


function validateevent()
{
 var s = ""; //Message to be output
 form = document.eventUpdateForm;
 
 if (form.title.value == "")
 {
  s += "Please enter a title.\n";
 }
 
 slen = document.getElementById("short").value.length;
 
 if (slen > 300)
 {
  s += "The Brief Description field cannot be longer than 300 characters. You currently have " + slen + " characters entered.\n";
 }
 
 if (document.getElementById("short").value == "")
 {
  s += "Please enter a brief description.\n";
 }
 
 if (form.start.value == "")
 {
  s += "Please enter a start date.\n";
 }
 
 if (s != "")
 {
  alert(s);
  return false;
 }
 
 return true;
}


function validatenews()
{
 var s = "";
 form = document.newsUpdateForm;
 
 if (form.title.value == "")
 {
  s += "Please enter a title.\n";
 }
 
 if (form.content.value == "")
 {
  s += "Please enter a post body.\n";
 }
 
 if (s != "")
 {
  alert(s);
  return false;
 }
 
 return true;
}
 
function validatelogin()
{
 document.login_out.login_o.value = document.login_in.login_name_i.value;
 document.login_out.password_o.value = document.login_in.password_i.value;
 document.login_out.remember_o.value = document.login_in.remember_me.checked;
 
 document.login_out.submit();
}
 
function validateauth()
{
 document.auth_out.login_o.value = document.auth_in.login_name.value;
 document.auth_out.password_o.value = document.auth_in.password.value;
  
 document.auth_out.submit();
}   

function validategallery()
{
 var s = "";
 
 if (document.galleryUpdateForm.path.value == "")
 {
  s += "You must enter a path.\n";
 }
 
 if (document.galleryUpdateForm.name.value == "")
 {
  s += "You must enter a gallery name.\n";
 }
 
 if (s != "")
 {
  alert(s);
  return false;
 }
 else
 {
  return true;
 }
}

function markChange(id)
{
 hf = document.getElementById(id);
 hf.value = "true";
}

