function submittheform(){  
		document.Mailing_Form.action = "http://formmail.dreamhost.com/cgi-bin/formmail.cgi"    // First target
//		document.Mailing_Form.target = "iframe";    // Open in a iframe
	    document.Mailing_Form.submit();        // Submit the page
}

function MM_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_preloadImages() { //v1.2
  if (document.images) {
    var imgFiles = MM_preloadImages.arguments;
    var preloadArray = new Array();
    for (var i=0; i<imgFiles.length; i++) {
      preloadArray[i] = new Image;
      preloadArray[i].src = imgFiles[i];
    }
  }
}

function MM_swapImage() { //v1.2
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = MM_swapImage.arguments[i+2];
  } }
  document.MM_swapImgData = swapArray; //used for restore
}

function MM_swapImgRestore() { //v1.2
  if (document.MM_swapImgData != null)
    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  var otherWindow = window.open(theURL,winName,features);
  if (otherWindow != null) otherWindow.close();
  window.open(theURL,winName,features);
}

function setCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "1000";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}

function ValidateData(){  
	var errorMsg = "Please fix the following:\n\n";
	var errors = false
    if(document.Mailing_Form.email.value == "") {
		errorMsg = errorMsg + "Please enter your e-mail address\n";
		errors = true;
	}
     x = emailCheck(document.Mailing_Form.email.value);
    if ((x != true) && (document.Mailing_Form.email.value != "")) {
        errorMsg = errorMsg + x + ": please enter a valid email\n";
		errors = true;
    }

	if(errors){
		alert(errorMsg);
		return false;
	}
    else{
		return true
	}
}

function emailCheck (emailStr) {

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */
 errorMsgEmail = "invalid e-mail format";
return errorMsgEmail;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
 errorMsgEmail = "non_ASCII characters used";
return errorMsgEmail;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
 errorMsgEmail = "non_ASCII characters used";
return errorMsgEmail;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid
 errorMsgEmail = "invalid user name";
return errorMsgEmail;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
 errorMsgEmail = "invalid IP address used";
return errorMsgEmail;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
 errorMsgEmail = "invalid domain name";
return errorMsgEmail;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
 errorMsgEmail = "no hostname preceding the domain or country";
return errorMsgEmail;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
 errorMsgEmail = "no host name preceding the domain";
return errorMsgEmail;
}

// If we've gotten this far, everything's valid!
return true;
}

function check_all(){
  var f = document.forms.searchform;
  for(var i = 0; i < f.elements.length; i++){
    x = f.elements[i];
    x.checked = true;
  }

}
function check_none(){
  var f = document.forms.searchform;
  f.reset();

}

function toggleview(id){
  var elem = document.getElementById(id);
  if(elem.style.visibility == 'hidden'){
    elem.style.visibility = 'visible';
    elem.style.display = 'block';
  }else{
    elem.style.visibility = 'hidden';
    elem.style.display = 'none';
  }
//var b = setCookie(id,elem.style.visibility,1000);

}

function moveObject(id, event) {

  var tempX = 0;
  var tempY = 0;
  var offset = 120;

  var obj = document.getElementById(id);

  tempX = event.clientX + document.body.scrollLeft;
  tempY = event.clientY + document.body.scrollTop;

//  tempX = event.clientX;
  //tempY = event.clientY;

  if (tempX < offset){tempX = offset}
  if (tempY < offset){tempY = offset}

  obj.style.top  = (tempY - offset) + 'px';
  obj.style.left = (tempX - 50) + 'px';

  var makeVis = toggleview(id);
}
