
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		goth_news_over = newImage("/_images/goth-news-over.jpg");
		goth_horror_over = newImage("/_images/goth-horror-over.jpg");
		goth_lifestyle_over = newImage("/_images/goth-lifestyle-over.jpg");
		goth_fiction_over = newImage("/_images/goth-fiction-over.jpg");
		goth_fiction_out = newImage("/_images/goth-fiction-out.jpg");
		goth_movies_over = newImage("/_images/goth-movies-over.jpg");
		goth_books_over = newImage("/_images/goth-books-over.jpg");
		goth_dark_tv_over = newImage("/_images/goth-dark-tv-over.jpg");
		goth_whos_who_over = newImage("/_images/goth-whos-who-over.jpg");
		goth_whos_who_out = newImage("/_images/goth-whos-who-out.jpg");
		goth_writers_resources_over = newImage("/_images/goth-writers-resources-over.jpg");
		goth_writers_resources_out = newImage("/_images/goth-writers-resources-out.jpg");
		goth_links_over = newImage("/_images/goth-links-over.jpg");
		goth_links_out = newImage("/_images/goth-links-out.jpg");
		goth_forum_over = newImage("/_images/goth-forum-over.jpg");
		goth_forum_down = newImage("/_images/goth-forum-down.jpg");
		preloadFlag = true;
	}
}

function validate(form){
 var author = form.author.value;
 var email = form.email.value;
 var errors = [];

 if (!checkLength(author)) {
  errors[errors.length] = "You must enter your name.";
 }

 if (!checkLength(email)) {
  errors[errors.length] = "You must enter an email address.";
 }
 
 if (errors.length > 0) {
  reportErrors(errors);
  return false;
 }

 return true;
}

function checkLength(text, min, max){
 min = min || 1;
 max = max || 10000;

 if (text.length < min || text.length > max) {
  return false;
 }
 return true;
}

function reportErrors(errors){
 var msg = "There were some problems...\n";
 var numError;
 for (var i = 0; i<errors.length; i++) {
  numError = i + 1;
  msg += "\n" + numError + ". " + errors[i];
 }
 alert(msg);
}



