function openMailTo(typePic)
{
	var extraTxt = '';
	if(typePic == 'piece')
		extraTxt = '\n\nOnce you have sent the email, be sure to submit your information (back on the main window) on the Rumph ' + typePic + ' you are adding!';
	alert('Since you don\'t have any digital pictures of your Rumph ' + typePic + ', I need you to mail photographs to me.\n\nAfter you click \"OK\", your email program (Outlook, Eudora, etc.) will launch with a pre-composed email to be sent to me.  All you have to do is Send the email.  Once I receive the email, I will send you instructions on where to snail mail your photographs to.  I will make digital pictures from those.' + extraTxt);
	var who = "sendpictures" + "@" + "therumph.com";
	var subj = "No Digital Pictures";
	var bod = "!!! SENDER !!!  ALL YOU HAVE TO DO IS SEND THIS EMAIL.  " + escape("\r\n") + "The Rumph Collector sending this email has no digital pictures of his/her Rumph " + typePic +".  Please reply to him/her with the proper mailing address for sending photographs.";
	window.location = "mailto:"+who+"?subject="+subj+"&body="+bod;	
}

function checkNewItemForm(inForm)
{
//	var inForm = eval("document.form");
	
	if(isBlank(inForm.theName.value))
	{
		alert('Please provide the name of the Rumph piece you are adding.');
		inForm.theName.focus();
		return false;
	}
	if(! verifyYear(inForm.theYear.value))
	{
		alert('Please enter the 4-digit year of production for your Rumph piece.  Enter a question mark (?) if you don\'t know the year.');
		inForm.theYear.focus();
		return false;
	}
	if(! verifyDollars(inForm.theValue.value))
	{
		alert('Please enter the estimated value of your Rumph piece.  Enter $0.00 if it is priceless.');
		inForm.theValue.focus();
		return false;
	}
	if(isBlank(inForm.theDescription.value))
	{
		alert('Please provide a description of the Rumph piece you are adding.');
		inForm.theDescription.focus();
		return false;
	}
	for(var i=1; i<=5; i++)
	{
		if(! verifyFileType(eval("inForm.thePicture"+i+".value")))
		{
			alert('TheRumph.com can only accept pictures that end in one of these extensions: .jpg, .gif, .png, or .bmp');
			eval("inForm.thePicture"+i+".select()");
			return false;
		}
	}
	if(isBlank(inForm.theContName.value))
	{
		alert('Please provide your first name and last initial (ex: John D.).  Enter "Anonymous" if you wish to not give your name.');
		inForm.theContName.focus();
		return false;
	}
	if(isBlank(inForm.theContFrom.value))
	{
		alert('Please provide your city and state (ex: Chicago, IL).  If you do not wish to give your real location, please make something up.');
		inForm.theContFrom.focus();
		return false;
	}
	return checkForNoPics(inForm);	
}

function checkPicturesForm()
{
	var inForm = eval("document.form");
	
	for(var i=1; i<=5; i++)
	{
		if(! verifyFileType(eval("inForm.thePicture"+i+".value")))
		{
			alert('TheRumph.com can only accept pictures that end in one of these extensions: .jpg, .gif, .png, or .bmp');
			eval("inForm.thePicture"+i+".select()");
			return false;
		}
	}
	if(isBlank(inForm.theContName.value))
	{
		alert('Please provide your first name and last initial (ex: John D.).  Enter "Anonymous" if you wish to not give your name.');
		inForm.theContName.focus();
		return false;
	}
	if(isBlank(inForm.theContFrom.value))
	{
		alert('Please provide your city and state (ex: Chicago, IL).  If you do not wish to give your real location, please make something up.');
		inForm.theContFrom.focus();
		return false;
	}
	
	return checkDblSubmit(inForm);
}

function checkExtraForm()
{
	var inForm = eval("document.form");
	
	if(isBlank(inForm.theExtra.value))
	{
		alert('Please provide the additional information you have about this piece.');
		inForm.theExtra.focus();
		return false;
	}
	if(isBlank(inForm.theContName.value))
	{
		alert('Please provide your first name and last initial (ex: John D.).  Enter "Anonymous" if you wish to not give your name.');
		inForm.theContName.focus();
		return false;
	}
	if(isBlank(inForm.theContFrom.value))
	{
		alert('Please provide your city and state (ex: Chicago, IL).  If you do not wish to give your real location, please make something up.');
		inForm.theContFrom.focus();
		return false;
	}
	
	return checkDblSubmit(inForm);
}

function checkBioForm()
{
	var inForm = eval("document.form");
	
	if(isBlank(inForm.theBio.value))
	{
		alert('Please provide the additional information you have about Jim Rumph.');
		inForm.theBio.focus();
		return false;
	}
	if(isBlank(inForm.theContName.value))
	{
		alert('Please provide your first name and last initial (ex: John D.).  Enter "Anonymous" if you wish to not give your name.');
		inForm.theContName.focus();
		return false;
	}
	if(isBlank(inForm.theContFrom.value))
	{
		alert('Please provide your city and state (ex: Chicago, IL).  If you do not wish to give your real location, please make something up.');
		inForm.theContFrom.focus();
		return false;
	}
	
	return checkDblSubmit(inForm);
}

function checkContributorForm()
{
	var inForm = eval("document.form");
	
	if(isBlank(inForm.theFromEml.value))
	{
		alert('Please provide your email address so the contributor can reply to you.');
		inForm.theFromEml.focus();
		return false;
	}
	if(isBlank(inForm.theSubject.value))
	{
		alert('Please provide the subject of this email.');
		inForm.theSubject.focus();
		return false;
	}
	if(isBlank(inForm.theBody.value))
	{
		alert('Please provide the message or reason for contacting the contributor.');
		inForm.theBody.focus();
		return false;
	}
	
	return checkDblSubmit(inForm);
}

function checkContactForm()
{
	var inForm = eval("document.form");
	
	if(isBlank(inForm.theFrom.value))
	{
		alert('Please provide your name.');
		inForm.theFrom.focus();
		return false;
	}
	if(isBlank(inForm.theFromEml.value))
	{
		alert('Please provide your email address so I can reply to you.');
		inForm.theFromEml.focus();
		return false;
	}
	if(isBlank(inForm.theSubject.value))
	{
		alert('Please provide the subject of this email.');
		inForm.theSubject.focus();
		return false;
	}
	if(isBlank(inForm.theBody.value))
	{
		alert('Please provide the message or reason for contacting me.');
		inForm.theBody.focus();
		return false;
	}
	
	return checkDblSubmit(inForm);
}

function isBlank(val)
{
	return (val == '');
}

function verifyYear(val)
{
	return (val.search(/(^[1-2][90][0-9]{2}$)|(^\?$)/) != -1);
}

function verifyDollars(val)
{
	if((val == '')||(val == '$'))	return false;
	var newVal = val.replace(/(\.|\$|,|\s)/g,"");
	return (newVal.search(/^[0-9]{1,10}$/) != -1);
}	

function verifyFileType(val)
{
	if(val == '')	return true;	
	return (val.substr((val.length-3),3).search(/(^jpg$)|(^gif$)|(^png$)|(^bmp$)/i) != -1);
}

function checkForNoPics(inForm)
{
//	var inForm = eval("document.form");
	
	if(isBlank(inForm.thePicture1.value) && isBlank(inForm.thePicture2.value) && isBlank(inForm.thePicture3.value) && isBlank(inForm.thePicture4.value) && isBlank(inForm.thePicture5.value))
	{
		if(confirm('Are you sure you don\'t want to submit any digital pictures with your Rumph item?\n\nClick "OK" to continue your Rumph contribution.\nClick "Cancel" to add pictures to your submission.'))
			return checkDblSubmit(inForm);
		else
			return false;
	}
	return checkDblSubmit(inForm);
}

var submitcount=0;		
function checkDblSubmit(inForm)
{  // moved here for speed
	if (submitcount == 0)
      	{
      		submitcount++;
      		inForm.submit.value="Please wait...";
      		inForm.submit.disabled = true;
      		inForm.clear.disabled = true;
      		wait.style.color = 'red';
      		return true;
      	}
   	else
      	{
      		alert('You have already submitted this form.  Please wait for the system to process your request or Refresh the page to try again.  Thanks!');
      		return false;
     	}
}

function popBigCollection(fileName)
{
	newWin = window.open(fileName,"BigCollection","menubar=no,location=no,resizable=yes,scrollbars=yes,status=yes");
	newWin.focus();
}
