// JScript source code
function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }



function validateComments(theForm)
{

   	var objError = new ErrorMsg();

    if (objError.isNull(theForm.FirstName.value)) {
	       objError.addMessage('Enter a value for the "First Name" field.');
	}  
	
	if (objError.isNull(theForm.LastName.value)) {
	       objError.addMessage('Enter a value for the "Last Name" field.');
	}  
	
	if (objError.isNull(theForm.Email.value)) {
	       objError.addMessage('Enter a value for the "E-Mail" field.');
	}  
	
	if (objError.isNull(theForm.Brand.value)) {
		       objError.addMessage('Enter a value for the "Brand" field.');
	}  

    if (objError.isNull(theForm.comments.value)) {
	       objError.addMessage('Enter a value for the "Question/Comment" field.');
	}  
		       
	if (!objError.isNull(theForm.ContactPhone.value)) {
	    if (objError.isInternationalPhoneNumber(theForm.ContactPhone.value) == false)
	       objError.addMessage('Contact Phone needs to be a valid phone number');
	}	       


    if (theForm.Email.value != theForm.ConfirmEmail.value) {
	       objError.addMessage('Email addresses need to match');    
    }

    if ((theForm.Email.value == theForm.FirstName.value) && (theForm.Email.value == theForm.LastName.value) && (theForm.FirstName.value == theForm.LastName.value)) {
	       objError.addMessage('First name, last name and email address must be different');    
    }
		       
	objError.setErrorMsgDiv('CommentsErrorMsg');
	
	if (objError.hasErrors) {
	     window.scrollTo(findPosX(document.getElementById('CommentsErrorMsg')), findPosY(document.getElementById('CommentsErrorMsg')));
	     return false;
	} 
	else {
	     theForm.action = actionValue;
		//alert("In order to better help you, the Consumer Affairs group is spending this week with our wine makers and our Quality Team.  We will respond to your email when we return.  If you need immediate assistance, please call 1-800-836-9463 Ext. 35706.");  
		 
		 return true;
	}
}

function validateProductIssues(theForm)
{
   	var objError = new ErrorMsg();

    if (objError.isNull(theForm.FirstName.value)) {
	       objError.addMessage('Enter a value for the "First Name" field.');
	}  
	
	if (objError.isNull(theForm.LastName.value)) {
	       objError.addMessage('Enter a value for the "Last Name" field.');
	}  
	
	if (objError.isNull(theForm.Email.value)) {
	       objError.addMessage('Enter a value for the "E-Mail" field.');
	}  

	if (objError.isNull(theForm.Brand.value)) {
		       objError.addMessage('Enter a value for the "Brand" field.');
	}
		
	if (objError.isNull(theForm.comments.value)) {
	       objError.addMessage('Enter a value for the "Question/Comment" field.');
	}  
	if (objError.isNull(theForm.UPC.value)) {
	       objError.addMessage('Enter a value for the "UPC" field.');
	}  
	if (objError.isNull(theForm.Size.value)) {
	       objError.addMessage('Enter a value for the "Size" field.');
	}  
    if (objError.isNull(theForm.Type.value)) {
	       objError.addMessage('Enter a value for the "Type" field.');
	}  
    if (objError.isNull(theForm.ProdCode.value)) {
	       objError.addMessage('Enter a value for the "Production Code" field.');
	}  
	
    if (objError.isNull(theForm.ContactPhone.value)) {
	    objError.addMessage('Enter a value for the "Contact Phone" field.');
	}  
		       
    
   if (!objError.isNull(theForm.ContactPhone.value)) {
	    if (objError.isInternationalPhoneNumber(theForm.ContactPhone.value) == false)
	       objError.addMessage('Contact Phone needs to be a valid phone number');
	}	
	
	   
    if (theForm.Email.value != theForm.ConfirmEmail.value) {
	       objError.addMessage('Email addresses need to match');    
    }
		       
	objError.setErrorMsgDiv('ComplaintsErrorMsg');
	
	if (objError.hasErrors) {
	     window.scrollTo(findPosX(document.getElementById('ComplaintsErrorMsg')), findPosY(document.getElementById('ComplaintsErrorMsg')));
	     return false;
	} else {
	     theForm.action = actionValue;
	     return true;
	}
  
  return (true);
}

