showGallery = function(f) {
  if(f == 1) {
    popUpWindow("gallery.asp", "gallery", 800, 700);
  } else {
    return !popUpWindow("gallery.asp", "gallery", 800, 700);
  }
}

showRewind = function(f) {
  if(f == 1) {
    popUpWindow("rewind.asp", "rewind", 800, 700);
  } else {
    return !popUpWindow("rewind.asp", "rewind", 800, 700);
  }
}

validateForm = function(f) {
  var d = document;
  
  if(d.getElementById("name").value.isEmpty()) {
    d.getElementById("name").focus();
    alert("Please enter your name.");
    return false;
  }
  
  if(d.getElementById("email").value.isEmpty() || !d.getElementById("email").value.isEmail()) {
    d.getElementById("email").focus();
    alert("Please enter a valid e-mail address.");
    return false;
  }
  
  if(d.getElementById("subject").value.isEmpty()) {
    d.getElementById("subject").focus();
    alert("Please enter a subject.");
    return false;
  }
  
  if(d.getElementById("message").value.isEmpty()) {
    d.getElementById("message").focus();
    alert("Please enter a message.");
    return false;
  }
  
  return true;
}

// validation prototypes
////////////////////////////////////////

String.prototype.isEmpty = function() {
  return ((this == null) || (this.length == 0) || /^\s+$/.test(this));
}

String.prototype.isEmail = function() {
	return /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(this);
}

// utility functions
////////////////////////////////////////

popUpWindow = function(URL,windowName,width,height) {
	var w = screen.availWidth;
	var h = screen.availHeight;
	var leftPos = Math.round((w-width)/2);
	var topPos = Math.round((h-height)/2);
	var defaults = "scrollbars, resizable";
	var centerOnScreen = "top="+topPos+", left="+leftPos+", width="+width+", height="+height;
	var options = centerOnScreen + " ," + defaults;
	var msgWindow = window.open(URL,windowName,options);
	if(!msgWindow) {
		return false;
	} else {
		msgWindow.creator=self;
		msgWindow.focus();
	}
  return true;
}

// parseQuery deals with query string
parseQuery = function() {
	var returnVals = new Array();
	qString = new String(window.location);
	var queryStart = qString.indexOf('?');
	if (queryStart==-1) {
		return returnVals;
	}
	var query = qString.substring(queryStart + 1, qString.length);
	var parts = query.split("&");
	for (var i=0; i<parts.length; i++) {
		bits = parts[i].split("=");
		if(bits[1]) {
			subbits = bits[1].split("#"); // added by T.D. to handle fragment identifier in URL
			returnVals[bits[0]] = subbits[0];
		}
	}
	return returnVals;
}

var query = parseQuery();