function PopupPic(page,name,size) {
	var popup = window.open(page, name, size, 'border=0,directories=0,menubar=0,location=0,resizable=0,scrollbars=1,status=0,toolbar=0');
}

function PopupPage(page,name,size) {
	var popup = window.open(page, name, size);
}

function checkTextEmpty(theText){
	if ( theText.value != "" ) {
		return true;
	}
	return false;
}

function cf() {
	var i;
	var myArray = new Array("recipient","realname","email","subject","message");
	var myItems = new Array("the inquiry type","your name","your email address","your subject line","your message");

	for (i = 0; i < myArray.length; i++) {
		if (!checkTextEmpty(eval("document.mf." + myArray[i]))) {
			alert('Please enter ' + myItems[i] + '.');
			return false;
		}
	}

if (!checkEmail(eval("document.mf.email"))) {
		alert('Please enter a valid email address.');
		return false;
	}

	return true;
}

	function checkEmail(theField) {
		var validEmail = 1;
		var tfV = theField.value;
		var whereAt = tfV.indexOf("@");
		var whereDot = tfV.indexOf(".",whereAt);
	
		if ( (whereAt == -1) || (whereDot == -1) ) {
			validEmail = 0;
		}
		if ( whereAt < 1 ){
			validEmail = 0;
		}
		if ( (whereDot - whereAt) < 2 ){
			validEmail = 0;
		}
		if ( (tfV.length - whereDot) < 3 ){
			validEmail = 0;
		}

		if (validEmail) {
			return true;
		} else {
			return false;
		}
}

var submitcount=0;
   function checkSubmit() {

      if (submitcount == 0)
      {
      submitcount++;
      document.mf.submit();
      }
   }


function wordCounter(field, countfield, maxlimit) {
wordcounter=0;
for (x=0;x<field.value.length;x++) {
      if (field.value.charAt(x) == " " && field.value.charAt(x-1) != " ")  {wordcounter++}  // Counts the spaces while ignoring double spaces, usually one in between each word.
      if (wordcounter > 300) {field.value = field.value.substring(0, x);}
      else {countfield.value = maxlimit - wordcounter;}
      }
   }

function textCounter(field, countfield, maxlimit) {
  if (field.value.length > maxlimit)
      {field.value = field.value.substring(0, maxlimit);}
      else
      {countfield.value = maxlimit - field.value.length;}
  }
