function validate(field,alerttxt)
{
  with (field)
  {
    if (value==null||value=="") {
      alert(alerttxt);
      return false;
    } else {
      return true
    }
    }
}

function validate_two(field1,field2,alerttxt)
{
  if (field1.value!=null&&field1.value!=""&&field2.value!=null&&field2.value!=""&&field1.value==field2.value) {
    return true
  } else {
    alert(alerttxt);
    return false;
  }
}

function validate_email(field,alerttxt)
{
  with (field)
  {
    retval = agent.call('Functions/inc.php','checkmail','',value);
    if (retval == true) {
      return true;
    } else {
      alert(value+" "+alerttxt);
      return false;
    }
    }
}

function getSelectedValue(oplist)
{
  for (i = 0; i < oplist.length; ++i)
  {
    if (oplist.options[i].selected == true)
    {
      return oplist.options[i].value;
    }
  }
  return null;
}

function removeArticle(id)
{
    agent.call('Functions/session.php','removeArticleFromShopCard','',id);
}

function changeOrderTax(radio)
{
    if(radio.value == "Versand")
    {
        agent.call('Functions/session.php','setShopcardTax','',4.9);
    }
    else
    {
        agent.call('Functions/session.php','setShopcardTax','',0);
    }
    window.location.reload();
}

function validate_shirttrikots(thisform)
{
    with (thisform)
    {
        if (size.selectedIndex < 1) {
            alert("Größe auswählen!");
            size.focus();
            return false;
        }

        }
    return true;
}

function validate_order(thisform)
{
    with (thisform)
    {
        // Bestellung
        if (validate(surname,"Vorname ist noch leer!") == false) {
            surname.focus();
            return false;
        }
        if (validate(name,"Name ist noch leer!") == false) {
            name.focus();
            return false;
        }
        if (validate(street,"Straße/Nr. ist noch leer!") == false) {
            street.focus();
            return false;
        }
        if (validate(postalcode,"PLZ ist noch leer!") == false) {
            postalcode.focus();
            return false;
        }
        if (validate(town,"Ort ist noch leer!") == false) {
            town.focus();
            return false;
        }
        if (validate_two(email1,email2,"E-Mails stimmen nicht überein!") == false) {
            email1.focus();
            return false;
        } else {
            if (validate_email(email1,"Bitte E-Mailformat überprüfen!") == false) {
                email1.focus();
                return false;
            }
        }
        if (agb.checked == false) {
            alert("AGB wurde nicht bestätigt!");
            agb.focus();
            return false;
        }
        }
    return true;
}
	
