window.onload=show;

function show(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=20; i++) {
		if (document.getElementById('answer_q'+i)) {document.getElementById('answer_q'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}

function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=280,screenX=150,screenY=150,top=150,left=150')
}
        function verify(form)
        {
        var passed = false;
        var blnRetval, intAtSign, intDot, intComma, intSpace, intLastDot, intDomain, intStrLen;
        if (form.Email){
                       intAtSign=form.Email.value.indexOf("@");
                        intDot=form.Email.value.indexOf(".",intAtSign);
                        intComma=form.Email.value.indexOf(",");
                        intSpace=form.Email.value.indexOf(" ");
                        intLastDot=form.Email.value.lastIndexOf(".");
                        intDomain=intDot-intAtSign;
                        intStrLen=form.Email.value.length;
                // *** CHECK FOR BLANK EMAIL VALUE
                   if (form.Email.value == "" )
                   {
                alert("You have not entered an email address.");
                form.Email.focus();
                passed = false;
                }
                // **** CHECK FOR THE  @ SIGN?
                else if (intAtSign == -1)
                {

                alert("Your email address is missing the \"@\".");
                        form.Email.focus();
                passed = false;

                }
                // **** Check for commas ****

                else if (intComma != -1)
                {
                alert("Email address cannot contain a comma.");
                form.Email.focus();
                passed = false;
                }

                // **** Check for a space ****

                else if (intSpace != -1)
                {
                alert("Email address cannot contain spaces.");
                form.Email.focus();
                passed = false;
                }

                // **** Check for char between the @ and dot, chars between dots, and at least 1 char after the last dot ****

                else if ((intDot <= 2) || (intDomain <= 1)  || (intStrLen-(intLastDot+1) < 2))
                {
                alert("Please enter a valid Email address.\n" + form.Email.value + " is invalid.");
                form.Email.focus();
                passed = false;
                }
                else {
                        passed = true;
                }
        }
        else    {
                passed = true;
        }
        return passed;
  }
  
  function checkFormUnrec()
  {
	 missinginfo = "";
	if(document.unreceivedOrders.name.value == "") {
	missinginfo += "\n     -  Name";
	}
	
	if ((document.unreceivedOrders.email.value == "") || 
	(document.unreceivedOrders.email.value.indexOf('@') == -1) || 
	(document.unreceivedOrders.email.value.indexOf('.') == -1)) {
	missinginfo += "\n     -  Email";
	}
	
	if(document.unreceivedOrders.loginId.value == "") {
	missinginfo += "\n     -  login name on VaporNation.com";
	}
	
	/*if (document.enquiry.displaycount.value > 150)
	{
	missinginfo += "\n     -  Comments";
	}*/
	
	if (missinginfo != "") {
	
	missinginfo ="_____________________________\n" +
	"There is some error in fields:\n" +
	missinginfo + "\n_____________________________" +
	"\nPlease correct and submit again!";
	alert(missinginfo);
	return false;
	}
	else return true;
}

function checkKeyword()
{
	if (document.quick_find.keywords.value.length < 1)
	{
	//alert(document.quick_find.keywords.value.length);
	windows.location="https://www.vapornation.com/store/advanced_search.php";
	return false;
	}
}
