function validateForm(strForm) {
  var formOK = true;
  for (i = 0 ; i < document.forms[strForm].elements.length ; i++) {
    if(document.forms[strForm].elements[i].className=="email") {
      if (!emailvalidate(document.forms[strForm].elements[i].value)) {
        alert(document.forms[strForm].elements[i].value+" is not a valid email address");
        formOK = false;
      }
    }
    else if(document.forms[strForm].elements[i].className=="string"|document.forms[strForm].elements[i].className=="file"|document.forms[strForm].elements[i].className=="text") {
      if (document.forms[strForm].elements[i].value.length<1) {
        alert("Fields may not be left blank");
        formOK = false;
      }
    }
    else if(document.forms[strForm].elements[i].className=="integer") {
      if (!integervalidate(document.forms[strForm].elements[i].value)) {
        alert(document.forms[strForm].elements[i].value+" is not an integer");
        formOK = false;
      }
    }
    else if(document.forms[strForm].elements[i].className=="decimal") {
      if (!decimalvalidate(document.forms[strForm].elements[i].value)) {
        alert(document.forms[strForm].elements[i].value+" is not a real number");
        formOK = false;
      }
    }
  }
  if (formOK) document.forms[strForm].submit();
}

function emailvalidate(email) {
  emval = /^\w+@\w+(\.(\w+))+$/i;
  return emval.test(email);
}

function integervalidate(integer) {
  emval = /^\d+$/i;
  return emval.test(integer);
}

function decimalvalidate(decimal) {
  emval = /^\d+([,\.]\d+)?$/i;
  return emval.test(decimal);
}

function SubmitBasket() {
 document.getElementById('emailaddr').value = document.getElementById('email').value
 document.getElementById('notefield').value = document.getElementById('remarks').value
 if(validateForm())
  document.getElementById('Form2').submit()
 return false
}

function partIn(text) {
 document.getElementById('partName').innerHTML = text;
}

function partOut() {
 document.getElementById('partName').innerHTML = '&nbsp;';
}

function partReady(partName) {
 if(document.visual.brand.options[document.visual.brand.selectedIndex].value == '' || document.visual.model.options[document.visual.model.selectedIndex].value == '') {
  alert('Du mangler at vælge bilens mærke og model!');
 }else{
  var brand, modelId, modelName;
  brand = document.visual.brand.options[document.visual.brand.selectedIndex].value;
  modelId = document.visual.model.options[document.visual.model.selectedIndex].value;
  modelName = document.visual.model.options[document.visual.model.selectedIndex].text;
  document.location = '?id=13&IDI2='+brand+'&page=cat&Action=Sec&partName='+partName+'&ModelId='+modelId+'&BilModel='+escape(modelName)+'&BilType='+brand;
 }
}

function categoryReady(categoryName) {
 document.location = document.location = '?id=13&IDI2=&page=cat&Action=Sec&partName=' + categoryName + '&ModelId=&BilModel=&BilType=';
}

function carAngle(angle) {
 brand = document.visual.brand.options[document.visual.brand.selectedIndex].value;
 modelId = document.visual.model.options[document.visual.model.selectedIndex].value;
 autotax = document.visual.search.value;
 document.location = '?id=71&brand=' + brand + '&model=' + modelId + '&angle=' + angle + '&autotax=' + autotax;
}

function confirmUrl(url, text) {
 if(confirm(text)) location.href = url;
}


