function flipdisplay(id) {

  subject = document.getElementById(id);
  if (subject.style.display=='none') {
    subject.style.display='';
  } else {
    subject.style.display='none';
  }

}

function validateURL(Val) {

  var j = new RegExp();
  j.compile("^http://.+\..+");
  if (!j.test(Val)) {
    return false;
  } else {
    return true;
  }

}

function validateEmail(Val) {

  var j = new RegExp();
  j.compile("^.+\@.+\..+");
  if (!j.test(Val)) {
    return false;
  } else {
    return true;
  }

}

function checkuploadform(f){
  if (f.terms.value != '1' ) {
    alert('You must hold the rights to publish any images you upload.');
    return false;   
  } else if (f.username.value.length == 0) {
    alert('You must have a 0daymeme username.');
    return false;
  } else if (f.userdescription.value.length == 0) {
    alert('You must enter a description.');
    return false;
  } else {     
    return true;
  }
}   

function checkcommentform(f){
  if (f.username.value.length == 0) {
    alert('You must enter a name.');
    return false;
  } else if ( (f.email.value.length > 0) && (!validateEmail(f.email.value)) ) {
    alert('Email addresses need to look like email addresses');
    return false;
  } else if ( (f.url.value.length > 0) && (!validateURL(f.url.value)) ) {
    alert('URLs need to start with http:// (and go on to look like a URL)');
    return false;
  } else if (f.message.value.length == 0) {
    alert('You must enter a comment.');
    return false;
  } else {     
    return true;
  }
}   

var saveWidth = 0;
var winW = 0;
var allowresize = 1;
         
function resizeImagesIfNeeded() {

  return;

  subject = document.getElementById('mainimage');

  if (! subject) {
    return;
  }

  n = navigator;
  na = n.appVersion;
  nua = n.userAgent;

  konq = ( nua.indexOf( 'Konqueror' ) != -1 );
  saf = ( nua.indexOf( 'Safari' ) != -1 );

  if (konq || saf) {
    return;
  }

  cell = document.getElementById('imagecell');
  hintblock1 = document.getElementById('resizehint1');
  hintblock2 = document.getElementById('resizehint2');
        
  subject.style.display="none";

  if(navigator&&navigator.userAgent.toLowerCase().indexOf("msie")==-1){
    winW = cell.offsetWidth - 2;
  }else{
    winW = cell.offsetWidth
  }

  if (saveWidth == 0) {
    saveWidth = subject.width;
  }

  var maxWidth = winW - 50;

  if ( (saveWidth < maxWidth) || (allowresize == 0) ) {
    subject.width = saveWidth;
    hintblock1.style.display='none';
    hintblock2.style.display='none';
  } else {
    subject.width = maxWidth;
    hintblock1.style.display='';
    hintblock2.style.display='';
  }

  subject.style.display="";

}

window.onresize = function() { setTimeout('resizeImagesIfNeeded()', 500) }
window.onload= function() { setTimeout('resizeImagesIfNeeded()', 500) }


