window.submitCount = 0; //hit count for onSubmit
var alreadySubmitting = false;

function checkEntry ()
{
 window.submitCount++;

 // if(window.submitCount%2>0){
 //  return false;
 //}

 if(alreadySubmitting){
   alert ("This form has already been submitted.\n Thank you for your request");
   return false;
 }
 
 var FirstName = document.entryform.FirstName.value;
 var LastName =  document.entryform.LastName.value;
 var EmailFrom =  document.entryform.EmailFrom.value;
 var Telephone =  document.entryform.Telephone.value;
 
/* var first_1 = trim (document.entryform.first_1.value);*/

 if (FirstName == "" || LastName == "")
 {
  alert ("Please enter your first name and your last name. \n Please enter them before continuing.");
  return false;
 }
 
 if (EmailFrom == "")
 {
  alert ("Email address is required. \n Please enter it before continuing.");
  return false;
 }

 var atsign_1 = EmailFrom.indexOf ('@');
 var dot_1 = EmailFrom.indexOf ('.');

 if (
  atsign_1 == -1 || dot_1 == -1 )
 {
  alert ("The format of your email may be wrong. Did you forget the '@'?\nExample: joe@abc.com. Please try again.");
  return false;
 }

 if (Telephone == "")
 {
  alert ("Please enter your Telephone Number.");
  return false;
 }

 alreadySubmitting = true;
 return true;
}

function changeDiv(the_div,the_change)
{
  var the_style = getStyleObject(the_div);
  if (the_style != false)
  {
    the_style.display = the_change;
  }
}

function hideAll()
{
  changeDiv("painting_questions","none");
  changeDiv("photo_questions","none");
}

function getStyleObject(objectId) {
  if (document.getElementById && document.getElementById(objectId)) {
    return document.getElementById(objectId).style;
  } else if (document.all && document.all(objectId)) {
    return document.all(objectId).style;
  } else {
    return false;
  }
}

function framingItem(imSrc, blurbText, fullSize, fullSizeW, fullSizeH, fullSizeFrame) {
	if (!window.a) window.a = new Array();
	this.imSrc=imSrc;
	this.blurbText=blurbText;
	this.fullSize=fullSize;
	this.fullSizeW=fullSizeW;
	this.fullSizeH=fullSizeH;
	this.fullSizeFrame=fullSizeFrame;
	window.a[window.a.length] = this;
}

function GlobalPopUp(url, w, h){
var popUpWin=0;
screenW = screen.availWidth;
screenH = screen.availHeight;
screenW = (screenW-w)/2
screenH = (screenH-h)/2
	if(popUpWin){
		if(!popUpWin.closed) popUpWin.close();
	}
	popUpWin = open(url, '', 'scrollbars=yes,resizable=yes,width='+w+',height='+h+',left='+screenW+',top='+screenH);
	popUpWin.focus();
}

function isEmail(str) {
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
    var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
    var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
    return (!r1.test(str) && r2.test(str));
}
function openNewsLetterWin(fName, wName, wWidth, wHeight, wResize){
var el = fName.email;
	if(isEmail(el.value) == "") {
		alert("A Valid E-mail Address is Required");
		el.focus();
		return false;
	}else{
		features = 'top=0,left=0,scrollbars=1,status=0,resizable=' + ((wResize) ? 1 : 0) + ((wWidth) ? ',width=' + wWidth : '') + ((wHeight) ? ',height=' + wHeight : '');
		popWin = window.open('', wName, features);
		if(popWin.focus){
			popWin.focus();
		}
		return true;
	}
}
