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 checkEntry3 (current)
{
 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;
 
 document.entryform.timestamp.value= current;
/* 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, priceF) {
	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;
	this.priceF=priceF;
	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 PopUpGallery(url, w, h){
var popUpWin=0;
screenW = 10;
screenH = 0;
	if(popUpWin){
		if(!popUpWin.closed) popUpWin.close();
	}
	popUpWin = open(url, '', 'scrollbars=no,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;
	}
}

function customSize(){
var newwindow = "http://site.overstockart.com/contactus/customsize.php?code=" + escape(code) + "&name=" + escape(itemname);
var popUpWin=0;
if(popUpWin){
    if(!popUpWin.closed) popUpWin.close();
  }
popUpWin = open(newwindow ,'sizepopup','resizable=yes, left=0, top=0, scrollbars=yes, width=600, height=700');
popUpWin.focus();
}

function otherSize(){
var newwindow = "http://site.overstockart.com/compare/othersizes.php?code=" + escape(code) + "&name=" + escape(itemname);
var popUpWin=0;
if(popUpWin){
    if(!popUpWin.closed) popUpWin.close();
  }
popUpWin = open(newwindow ,'sizepopup','menubar=no,scrollbars=yes,resizable=yes, height=630, width=800');
popUpWin.focus();
}

function myGallery(){
var newwindow = "http://site.overstockart.com/mygallery/addGallery.php?code=" + escape(code) + "&artid=" + escape(artid) + "&artname=" + escape(artname) + "&headline=" + escape(headline) + "&price=" + escape(price) + "&saleprice=" + escape(saleprice) + "&artist=" + escape(artist) + "&subject=" + escape(subject) + "&style=" + escape(style) + "&size=" + escape(size) + "&suggested=" + escape(suggested) + "&image=" + escape(image);
var popUpWin=0;
if(popUpWin){
    if(!popUpWin.closed) popUpWin.close();
  }
popUpWin = open(newwindow ,'mygallerypopup','resizable=yes, left=0, top=0, scrollbars=no, width=330, height=330');
popUpWin.focus();
}

function decorHelp(){
var newwindow = "http://site.overstockart.com/contactus/decor-assistance.php?code=" + escape(code) + "&artid=" + escape(artid) + "&artname=" + escape(artname);
var popUpWin=0;
if(popUpWin){
    if(!popUpWin.closed) popUpWin.close();
  }
popUpWin = open(newwindow ,'decorpopup','resizable=yes, left=0, top=0, scrollbars=yes, width=583, height=600');
popUpWin.focus();
}

function ShipTimeWindow() 
{
  ShipWindow=window.open('','ShipTime','height=200,width=430,resizable=yes,top=100,left=100');
  var tmp = ShipWindow.document;

  tmp.write('<html><head><title>OverstockArt.com</title>');

  tmp.write('</head><body><p style=\"font-family:Verdana;font-size:12px;\"><b>Ships Same Day</b></p>');

tmp.write('<p style=\"font-family:Verdana;font-size:12px;line-height:120%\">Ship time indicates the typical time it takes for your item(s) to leave our facilities. This includes any framing or customizing services ordered as well as careful packaging to prevent damage in transit.</p>');
  tmp.write('<p style=\"font-family:Verdana;font-size:12px;line-height:120%\">In Stock items normally leave our facilities on the same business day if your order is placed before 2:00pm CST.</p>');
tmp.write('<center><a href=\"#\" onclick=\"window.close()\" style=\"font-family:Verdana;font-size:12px;line-height:120%\"><b><u>[ Close Window ]</u></b></a></center>');

  tmp.write('</body></html>');

  tmp.close();
}