﻿function OnContact(form)
{
  var ok;
  
  ok = true;

  ok = OnTextBox(ok, form.model, "Model", 50, false);
  if (ok) {
     if (form.model.value.match(/\w{4,}/) == null) {
        alert("You must enter at least 4 digits for 'Model'");
        ok = false;
        form.model.focus();
     }
  }

  ok = OnTextBox(ok, form.name, "Name", 50, false);
  if (ok) {
     if (form.name.value.match(/\w{4,}/) == null) {
        alert("You must enter at least 4 digits for 'Name'");
        ok = false;
        form.name.focus();
     }
  }

  ok = OnDigit(ok, form.phone, "Phone");
  if (ok) {
     if (form.phone.value.match(/\d{8,}/) == null) {
        alert("You must enter at least 8 digits for 'Phone'");
        ok = false;
        form.phone.focus();
     }
  }
  
  ok = OnEmail(ok, form.email);  
  
  ok = OnTextBox(ok, form.address1, "Address", 50, false);
  ok = OnTextBox(ok, form.city, "City", 50, false);
  
  ok = OnSelect(ok, form.state, "State");

  ok = OnDigit(ok, form.postcode, "Postcode");
  if (ok) {
     if (form.postcode.value.match(/\d{4,}/) == null) {
        alert("You must enter at least 4 digits for 'Postcode'");
        ok = false;
        form.postcode.focus();
     }
  }
  
  ok = OnTextBox(ok, form.comments, "Comments", 1000, false);
  
  if(ok)
    form.submit();

}

function OnLargeImage(ID)
{
  var left, top1;
  
  width = 630;  height = 370;  left = (screen.width - 0.85*screen.width)/2;  top1 = (screen.height - 0.85*screen.height)/4;  window.open('large_image.aspx?ID=' + ID, 'large_image', 'width=' + width + ',height=' + height + ',alwaysLowered=1,alwaysRaised=0,channelmode=0,dependent=0,directories=0,fullscreen=0,hotkeys=1,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,left=' + left + ',top=' + top1 + ',z-lock=0');
}
