function validateNewPass() {
  if (document.forms.adminpass.oldpass.value==''){
    alert('Old password cannot be emty.');
    return false;
  }
  if (document.forms.adminpass.newpass1.value==''){
    alert('New password cannot be emty.');
    return false;
  }
  if (document.forms.adminpass.newpass2.value==''){
    alert('Repeat new password cannot be empty.');
    return false;
  }
  if (document.forms.adminpass.newpass1.value!=document.forms.adminpass.newpass2.value){
    alert('New password does not match with repeat password.');
    return false;
  }
  return true;
}

function NewsDelConf(nid, title, s, p){
  var ans = window.confirm("Delete news \"" + title + "\"?");
  if (ans){
    location = "newsadmin.php?m=delete&nid="+nid+"&s="+s+"&p="+p;
  }
}

function onDelConf(nid, title, s, p){
  var ans = window.confirm("Delete \"" + title + "\"?");
  if (ans){
    location = "newsadmin.php?m=ondelete&onid="+nid+"&s="+s+"&p="+p;
  }
}
function magDelConf(nid, title, s, p){
  var ans = window.confirm("Delete \"" + title + "\"?");
  if (ans){
    location = "newsadmin.php?m=magdelete&magID="+nid+"&s="+s+"&p="+p;
  }
}
function eventDelConf(nid, title, s, p){
  var ans = window.confirm("Delete \"" + title + "\"?");
  if (ans){
    location = "newsadmin.php?m=eventdelete&eventID="+nid+"&s="+s+"&p="+p;
  }
}

function validateInsertNews() {
  if (document.forms.newsinsert.title.value==''){
    alert('News title is empty.');
    return false;
  }
  if (document.forms.newsinsert.content.value==''){
    alert('News content is empty.');
    return false;
  }
  return true;
}

function validateoutnownew() {
  if (document.forms.outnownew.outnowTitle.value==''){
    alert('Magazine is empty.');
    return false;
  }
  if (document.forms.outnownew.outnowEdition.value==''){
    alert('Edition is empty.');
    return false;
  }
  if (document.forms.outnownew.onCont1.value.length>512){
    alert('Content 1 is ever limit(512).');
    return false;
  }
  if (document.forms.outnownew.onCont2.value.length>512){
    alert('Content 2 is ever limit(512).');
    return false;
  }
  if (document.forms.outnownew.onCont3.value.length>512){
    alert('Content 3 is ever limit(512).');
    return false;
  }
  if (document.forms.outnownew.onCont4.value.length>512){
    alert('Content 4 is ever limit(512).');
    return false;
  }
  if (document.forms.outnownew.onCont15.value.length>512){
    alert('Content 5 is ever limit(512).');
    return false;
  }
  return true;
}
function validatemagazine() {
  if (document.forms.magazineform.magName.value==''){
    alert('Magazine name is empty.');
    return false;
  }
  if (document.forms.magazineform.magDesc.value==''){
    alert('Magazine description is empty.');
    return false;
  }
  return true;
}
function validateEvent() {
  if (document.forms.eventform.eventDate.value==''){
    alert('Date is empty.');
    return false;
  }
  if (document.forms.eventform.eventTitle.value==''){
    alert('Event title is empty.');
    return false;
  }
  if (document.forms.eventform.eventLocation.value==''){
    alert('Location is empty.');
    return false;
  }
  return true;
}

function checkJPG(filename){
  if((filename.substr(-4,4).toLowerCase()=='.jpg') || (filename.substr(-5,5).toLowerCase()=='.jpeg')){
    return true;
  }else{
    return false;
  }
}

function validateEditNews() {
  if (document.forms.newsedit.title.value==''){
    alert('News title is empty.');
    return false;
  }
  if (document.forms.newsedit.content.value==''){
    alert('News content is empty.');
    return false;
  }
  return true;
}

function gantibg(tr, color1){
	var theCells = null;
	theCells = tr.getElementsByTagName('td');
	for (c = 0; c < theCells.length; c++) {
  	theCells[c].style.backgroundColor = color1;
  }
	return true;
}
