//--------------------------------------------------------------
var AlreadySent=false;
//--------------------------------------------------------------
function getAboArt()
{	var aboart="?";
	var aboart_obj=document.getElementById("AboArt");

	if(aboart_obj)
	{	aboart=aboart_obj.value;
	}
	else
	{	var aboart_obj_e=document.getElementById("AboArt_E");
		var aboart_obj_g=document.getElementById("AboArt_G");
		var aboart_obj_w=document.getElementById("AboArt_W");
		var aboart_obj_wg=document.getElementById("AboArt_WG");

		if(aboart_obj_e && aboart_obj_e.checked)
			aboart=aboart_obj_e.value;
		else if(aboart_obj_g && aboart_obj_g.checked)
			aboart=aboart_obj_g.value;
		else if(aboart_obj_w && aboart_obj_w.checked)
			aboart=aboart_obj_w.value;
		else if(aboart_obj_wg && aboart_obj_wg.checked)
			aboart=aboart_obj_wg.value;
	}

	return aboart;
}
//--------------------------------------------------------------
function GetCountryCodeObject(id)
{
	var cc=document.getElementById(id+"_temp");
	if(!cc)
		cc=document.getElementById(id);
	return cc;
}
//--------------------------------------------------------------
function GetCountryCode(id)
{
	var CountryCode="";
	var cc=GetCountryCodeObject(id);
	if(cc)
	{	var index=cc.selectedIndex;
		CountryCode=ExtractCountryCode(cc.options[index].value);
	}
	return CountryCode;
}
//--------------------------------------------------------------
function ValidFromSelected(res)
{
	if(res)
	{	var as=document.getElementById("AllowAS").value;
		var vf1=document.getElementById("valid-from_1");
		var vf2=document.getElementById("valid-from_2");
		var vd=document.getElementById("valid-from_d");
		var vm=document.getElementById("valid-from_m");
		var vy=document.getElementById("valid-from_y");

		if(as=="0" || as==" ")
		{	res=true;
			vd.value="";
			vm.value="";
			vy.value="";
		}
		else
		{	if(vf1.checked)
			{	vd.value="";
				vm.value="";
				vy.value="";
				res=true;
			}
			else if(vf2.checked)
			{	res=AboStart(vd, vm, vy, res);
			}
			else
			{	alert("Ab welchem Zeitpunkt soll das Abo beginnen ?");
				res=false;
				vf1.focus();
			}
		}
	}

	return res;
}
//--------------------------------------------------------------
function ValidToSelected(res)
{
	if(res)
	{	var ae=document.getElementById("AllowAE").value;
		var vf=document.getElementById("valid-to_fix");
		var v1=document.getElementById("valid-to_1");
		var v2=document.getElementById("valid-to_2");
		var u=document.getElementById("unit");
		var d=document.getElementById("duration");
		var d1=document.getElementById("duration_1");
		var d2=document.getElementById("duration_2");
		var fday=document.getElementById("valid-from_d").value;
		var fmonth=document.getElementById("valid-from_m").value;
		var fyear=document.getElementById("valid-from_y").value;
		var tday=document.getElementById("valid-to_d");
		var tmonth=document.getElementById("valid-to_m");
		var tyear=document.getElementById("valid-to_y");
		var inc;
		var sel;

		if(ae=="1" || vf)
		{	if(vf)
			{	sel=99;
				inc=vf.value;
			}
			else if(v1.checked)
			{	sel=1;
				inc=v1.value;
			}
			else if(v2.checked)
			{	sel=2;
				inc=v2.value;
			}
			else
			{	sel=0;
				inc=0;
			}

			if(sel)
			{	if(!u)
				{	// Abo-Laufzeit wird ueber valid-to bestimmt
					if(fday=="")
					{	var ActDat=new Date();
						fday=ActDat.getDate();
						fmonth=ActDat.getMonth()+1;
						fyear=getFullYear(ActDat);
					}
					if(fmonth.length==2 && fmonth.substr(0, 1)=='0')
						fmonth=fmonth.substr(1, 1);
					tday.value=fday;
					tmonth.value=parseInt(fmonth) + parseInt(inc);
					tyear.value=fyear;
					while(parseInt(tmonth.value) > 12)
					{	tyear.value=parseInt(tyear.value) + 1;
						tmonth.value=parseInt(tmonth.value) - 12;
					}
					var tdate=new Date(tyear.value, tmonth.value-1, tday.value);
					while(tday.value!=tdate.getDate())
					{	tday.value=parseInt(tday.value) - 1;
						var tdate=new Date(tyear.value, tmonth.value-1, tday.value);
					}
				}
				else
				{	// Abo-Laufzeit wird ueber duration/unit bestimmt
					u.value="FLG";
					if(sel==1)
						d.value=d1.value;
					else if(sel==2)
						d.value=d2.value;
				}
			}
			else
			{	alert("Wie lange soll das Abo laufen ?");
				v1.focus();
			}
		}
	}

	return res;
}
//--------------------------------------------------------------
function AboStart(day_obj, month_obj, year_obj, res)
{
	if(res)
	{	var day=day_obj.value;
		var month=month_obj.value;
		var year=year_obj.value;
		var ActDat=new Date();
		var AboDat=new Date(year, month-1, day);
		res=(	AboDat.getDate()==day &&
				AboDat.getMonth()==month-1 &&
				getFullYear(AboDat)==year &&
				AboDat > ActDat
			);
		if(!res)
		{	alert(unescape("Geben Sie bitte ein g%FCltiges Startdatum an !\nEs mu%DF in der Zukunft liegen."));
			day_obj.focus();
		}
	}
	return res;
}
//--------------------------------------------------------------
function BillingFrequencySelected(res)
{
	if(res)
	{	var zi=document.getElementById("AllowZI").value;
		var bf1=document.getElementById("billing-frequency_1");
		var bf2=document.getElementById("billing-frequency_2");
		var bf3=document.getElementById("billing-frequency_3");

		if(zi=="0" || zi=="")
		{	res=true;
			if(bf1) bf1.checked=false;
			if(bf2) bf2.checked=false;
			if(bf3) bf3.checked=false;
		}
		else
		{	res=(bf1 && bf1.checked) || (bf2 && bf2.checked) || (bf3 && bf3.checked);
		}
		if(!res)
		{	alert(unescape("Bitte w%E4hlen Sie das gew%FCnschte Zahlungsintervall aus !"));
			if(bf1)
				bf1.focus();
			else if(bf2)
				bf2.focus();
			else if(bf3)
				bf3.focus();
		}
	}

	return res;
}
//--------------------------------------------------------------
function ReplaceEMailFromAddress(from_name_id, from_address_id, first_name_id, last_name_id, email_id)
{
	var from_name=document.getElementById(from_name_id);
	var from_address=document.getElementById(from_address_id);
	var first_name=document.getElementById(first_name_id);
	var last_name=document.getElementById(last_name_id);
	var email=document.getElementById(email_id);

	if(email.value!="")
	{	from_name.value=first_name.value+" "+last_name.value;
		from_address.value=email.value;
	}
}
//--------------------------------------------------------------
function ExtractAirmailType(orgCountrycode)
{
	var AirmailType="";

	var p=orgCountrycode.indexOf('[');
	if(p>=0)
	{	var pe=orgCountrycode.indexOf(']', p);
		if(pe>=0)
			AirmailType=orgCountrycode.substring(p+1, pe);
	}
	return AirmailType;
}
//--------------------------------------------------------------
function ExtractCountryCode(orgCountrycode)
{
	var Countrycode;

	var p=orgCountrycode.indexOf(']');
	if(p>=0)
		Countrycode=orgCountrycode.substring(p+1);
	else
		Countrycode=orgCountrycode;

	return Countrycode;
}
//--------------------------------------------------------------
function ZipcodeFilledOut(zip_id, country_id, res)
{
	if(res)
	{   var zip=document.getElementById(zip_id);
		if((res=zip.value!="")==true)
		{	if(GetCountryCode(country_id)=="DE")
			{	if((res=isNumeric(zip.value))==true)
				{	if((res=zip.value.length==5)==false)
						alert("Die Postleitzahl muss 5-stellig sein");
				}
				else
				{	alert("Die Postleitzahl muss numerisch sein");
				}
			}
		}
		else
		{	alert(unescape("Bitte f%FCllen Sie das Feld 'Postleitzahl' aus !"));
		}
		if(!res)
			zip.focus();
	}
	return res;
}
//--------------------------------------------------------------
function isNumeric(str)
{
	var x, len;
	var res=true;
	len=str.length;
	for(x=0; x<len && res; x++)
		res=getZiffer(x, str)!=-1;
	return res;
}
//--------------------------------------------------------------
function EditFilledOut(id, feldname, num, res)
{
	if(res)
	{   var obj=document.getElementById(id);
		res=obj.value!="";
		if(res)
		{	if((res=!num)==false)
			{	if((res=isNumeric(obj.value))==false)
				{	obj.focus();
					alert(unescape("Bitte nur Ziffern im Feld '"+feldname+"'"));
				}
			}
		}
		else
		{	obj.focus();
			alert(unescape("Bitte f%FCllen Sie das Feld '"+feldname+"' aus !"));
		}
	}
	return res;
}
//--------------------------------------------------------------
function ComboFilledOut(id, feldname, res)
{
	if(res)
	{	var obj=document.getElementById(id);
		res=obj.options[obj.selectedIndex].value!="";
		if(!res)
		{	obj.focus();
			alert(unescape("Bitte w%E4hlen Sie einen Wert aus dem Feld '"+feldname+"' aus !"));
		}
	}
	return res;
}
//--------------------------------------------------------------
function CorrectEMail(email_id, res)
{
	if(res)
	{	var reg_exist;
		var res=false;
		var email_obj=document.getElementById(email_id);
		var email=email_obj.value;
		var email_required=document.getElementById(email_id + "_required");

		if((email_required && email_required.value=="1") || email.length)
		{	reg_exist=(typeof(RegExp)=='function');
			if(reg_exist)
			{	var dummy=new RegExp('abc');
				reg_exist=dummy.test('abc');
			}

			if(reg_exist)
			{	reg=new RegExp(	'^([a-zA-Z0-9\\+\\-\\.\\_]+)'+
								'(\\@)([a-zA-Z0-9\\-\\.]+)'+
								'(\\.)([a-zA-Z]{2,4})$'
							);
				res=(reg.test(email));
			}
			else
			{	res=(	email.search('@') >= 1 &&
						email.lastIndexOf('.') > s.search('@') &&
						email.lastIndexOf('.') >= s.length-5
					)
			}
			if(!res)
			{	email_obj.focus();
				alert("Bitte geben Sie Ihre korrekte E-Mail Adresse ein !");
			}
		}
		else
		{	res=true;
		}
	}
	return res;
}
//--------------------------------------------------------------
function isCompany(id)
{
	var element=document.getElementById(id);
	return element.options[element.selectedIndex].value=="F";
}
//--------------------------------------------------------------
function Bankeinzug()
{
	return document.getElementById("payment-method_E").checked;
}
//--------------------------------------------------------------
function Kreditkarte()
{
	return document.getElementById("payment-method_K").checked;
}
//--------------------------------------------------------------
function RequiredWFieldsOK()
{
	var res=true;

	res=ComboFilledOut("w_salutation-code", "Anrede", res);
	res=EditFilledOut("w_last-name1", "Name", false, res);
	res=EditFilledOut("w_street", "Stra%DFe", false, res);
	res=EditFilledOut("w_street-number", "Hausnummer", false, res);
	res=ZipcodeFilledOut("w_zipcode", "w_country-code", res);
	res=EditFilledOut("w_city", "Ort", false, res);
	res=CountryCodeFilledOut("w_country-code", res);
	res=DayOfBirth("w_date-of-birth_d", "w_date-of-birth_m", "w_date-of-birth_y", false, res);
	res=CorrectEMail("w_email", res);

	return res;
}
//--------------------------------------------------------------
function RequiredLFieldsOK()
{
	var res=true;

	res=ComboFilledOut("l_salutation-code", "Anrede", res);
	res=EditFilledOut("l_last-name1", "Name", false, res);
	res=EditFilledOut("l_street", "Stra%DFe", false, res);
	res=EditFilledOut("l_street-number", "Hausnummer", false, res);
	res=ZipcodeFilledOut("l_zipcode", "l_country-code", res);
	res=EditFilledOut("l_city", "Ort", false, res);
	res=CountryCodeFilledOut("l_country-code", res);
	res=DayOfBirth("l_date-of-birth_d", "l_date-of-birth_m", "l_date-of-birth_y", false, res);
	res=CorrectEMail("l_email", res);

	return res;
}
//--------------------------------------------------------------
function RequiredFieldsOK()
{	var res=true;

	res=ComboFilledOut("r_salutation-code", "Anrede", res);
	res=EditFilledOut("r_first-name", "Vorname", false, res);
	res=EditFilledOut("r_last-name1", "Name", false, res);
	res=EditFilledOut("r_street", "Strasse", false, res);
	res=EditFilledOut("r_street-number", "Hausnummer", false, res);
	res=ZipcodeFilledOut("r_zipcode", "r_country-code", res);
	res=EditFilledOut("r_city", "Ort", false, res);
	res=CountryCodeFilledOut("r_country-code", res);
	res=DayOfBirth("r_date-of-birth_d", "r_date-of-birth_m", "r_date-of-birth_y", false, res);
	res=CorrectEMail("r_email", res);

	res=BillingFrequencySelected(res);
	res=ValidFromSelected(res);
	res=ValidToSelected(res);

	if(Bankeinzug())
	{	res=EditFilledOut("debit-account-holder", "KontoinhaberIn", false, res);
		res=EditFilledOut("debit-account-number", "Kontonummer", true, res);
		res=EditFilledOut("debit-bank-code", "Bankleitzahl", true, res);
	}

	if(Kreditkarte())
	{	res=ComboFilledOut("cc-company-code", "Kreditkarteninstitut", res);
		//res=EditFilledOut("cc-holder", "KarteninhaberIn", true, res);
		res=EditFilledOut("cc-number", "Kreditkartennummer", true, res);
		res=ComboFilledOut("cc-expiry_m", "g%FCltig bis (Monat)", res);
		res=ComboFilledOut("cc-expiry_y", "g%FCltig bis (Jahr)", res);
		res=KKNummerOk("cc-number", res);
	}

	return res;
}
//--------------------------------------------------------------
function CountryCodeFilledOut(id, res)
{
	if(res)
	{	var id2=id+"_temp";
		var cc=document.getElementById(id2);
		if(!cc)
		{	id2=id;
			cc=document.getElementById(id2);
		}
		if(cc)
			res=ComboFilledOut(id2, "Land", res);
		else
			res=false;
	}
	return res;
}
//--------------------------------------------------------------
function getFullYear(date_obj)
{
	var year=date_obj.getYear();
	if(year<1000)
		year+=1900;
	return year;
}
//--------------------------------------------------------------
function DayOfBirth(day_id, month_id, year_id, mandatory, res)
{
	if(res)
	{	var day_obj=document.getElementById(day_id);
		var day=day_obj.value;
		var month=document.getElementById(month_id).value;
		var year=document.getElementById(year_id).value;
		if(day!="" || month!="" || year!="")
		{   month=month-1;
			var ActDat=new Date();
			var Age=getFullYear(ActDat)-year;
			var GebDat=new Date(year, month, day);
			res=(	GebDat.getDate()==day &&
					GebDat.getMonth()==month &&
					getFullYear(GebDat)==year &&
					(Age>=18 && Age <=100)
				);
		}
		else
		{	res=!mandatory;
		}
		if(!res)
		{	day_obj.focus();
			alert(unescape("Bitte geben sie ein g%FCltiges Geburtsdatum an !\n(Bestellungen sind %FCbrigens erst ab 18 m%F6glich)"));
		}
	}
	return res;
}
//--------------------------------------------------------------
function querSumme(x)
{
	return (x%10) + Math.floor(x/10);
}
//--------------------------------------------------------------
function getZiffer(x, txt)
{
	var res=-1;
	var chr=txt.charAt(x);

	if(chr >= '0' && chr <= '9')
		res=parseInt(chr);

	return res;
}
//--------------------------------------------------------------
function KKNummerOk(knr_id, res)
{
	if(res)
	{	var x, z, sum, gw, knr;
		gw=1;
		sum=0;
		knr=document.getElementById(knr_id).value;
		for(x=knr.length-1; x>=0; x--)
		{   z=getZiffer(x, knr);
			if(z!=-1)
			{	sum+=querSumme(z * gw );
				gw=3-gw;
			}
		}
		res=(sum%10==0);
		if(!res)
			alert(unescape("Die eingegebene Kreditkartennummer ist ung%FCltig !"));
	}
	return res;
}
//--------------------------------------------------------------
function RadioChecked(id, txt, res)
{
	if(res)
	{	var i, obj;
		for(i=0;;i++)
		{	obj=document.getElementById(id+i);
			if(obj)
			{	if((res=obj.checked)==true)
					break;
			}
			else
			{	break;
			}
		}
		if(!res)
		{	document.getElementById(id+"0").focus();
			alert(unescape(txt));
		}
	}
	return res;
}
//--------------------------------------------------------------
function CountrySpecs(land)
{
	var e,k;
	var allowkolo;
	var f=document.BestellForm;
	var countrycode=GetCountryCode(land.id);
	var obj_allowkolo=document.getElementById("AllowKolo");
	var obj_paymenttext=document.getElementById("payment-method_text");
	var allowcc=document.getElementById("AllowCC").value;
	var allowvw=document.getElementById("AllowVW").value;
	var allowzi=document.getElementById("AllowZI").value;
	var pilp=document.getElementById("PILP");
	var pi=document.getElementById("PI");
	var lp=document.getElementById("LP");
	var cbpi=document.getElementById("delivery-type_PI");
	var cblp=document.getElementById("delivery-type_LP");

	if(obj_allowkolo)
	{	allowkolo=obj_allowkolo.value;
		if(allowkolo=="")
			allowkolo="0";
	}
	else
	{	allowkolo="0";
	}

	if(countrycode=="DE")
	{	if(allowvw=="1")
		{	document.getElementById("PILP").style.display="block";
			pi.style.display="block";
			lp.style.display="none";
			cbpi.checked=true;
		}
		else if(allowvw=="2")
		{	document.getElementById("PILP").style.display="block";
			pi.style.display="block";
			lp.style.display="none";
			cbpi.checked=true;
		}
		else
		{	document.getElementById("PILP").style.display="none";
			pi.style.display="none";
			lp.style.display="none";
			cbpi.checked=false;
			cblp.checked=false;
		}

		if(allowkolo=="1")
		{	document.getElementById("payment").style.display="none";
			document.getElementById("payment-method_R").checked=true;
			if(obj_paymenttext)
				obj_paymenttext.value="#kostenlos";
			if(allowzi=="1")
				document.getElementById("ZI").style.display="none";
		}
		else
		{	document.getElementById("payment").style.display="block";
			if(obj_paymenttext)
				obj_paymenttext.value="";
			document.getElementById("e1").style.display="block";
			if(allowcc=="A" || allowcc=="0" || allowcc=="")
			{	document.getElementById("k1").style.display="none";
			}
			else
			{	document.getElementById("k1").style.display="block";
			}
			document.getElementById("payment-method_E").checked=true;
			if(allowzi=="1")
				document.getElementById("ZI").style.display="block";
		}
	}
	else
	{	if(allowvw=="1")
		{	document.getElementById("PILP").style.display="block";
			pi.style.display="block";
			lp.style.display="none";
			cbpi.checked=true;
		}
		else if(allowvw=="2")
		{	document.getElementById("PILP").style.display="block";
			pi.style.display="block";
			lp.style.display="block";
			cbpi.checked=true;
		}
		else
		{	document.getElementById("PILP").style.display="none";
			pi.style.display="none";
			lp.style.display="none";
			cbpi.checked=false;
			cblp.checked=false;
		}

		if(allowkolo=="1" || allowkolo=="A")
		{	document.getElementById("payment").style.display="none";
			document.getElementById("payment-method_R").checked=true;
			if(obj_paymenttext)
				obj_paymenttext.value="#kostenlos";
			if(allowzi=="1")
				document.getElementById("ZI").style.display="none";
		}
		else
		{	document.getElementById("payment").style.display="block";
			document.getElementById("e1").style.display="none";
			if(obj_paymenttext)
				obj_paymenttext.value="";
			if(allowcc=="0" || allowcc=="")
			{	document.getElementById("k1").style.display="none";
				document.getElementById("payment-method_R").checked=true;
			}
			else
			{	document.getElementById("k1").style.display="block";
				document.getElementById("payment-method_K").checked=true;
			}
			if(allowzi=="1")
				document.getElementById("ZI").style.display="block";
		}
	}
}
//--------------------------------------------------------------
function onRLandChange(land)
{
	var aboart=getAboArt();
	if(aboart=="E" || aboart=="W")
		CountrySpecs(land)
}
//--------------------------------------------------------------
function onLLandChange(land)
{
	var aboart=getAboArt();
	if(aboart=="G" || aboart=="WG")
		CountrySpecs(land)
}
//--------------------------------------------------------------
function onWLandChange(land)
{
}
//--------------------------------------------------------------
function onAboArtChanged(radio)
{
	handleAboArt(radio.value);
}
//--------------------------------------------------------------
function PremiumSelected()
{
	var res=true;
	var allowpr=document.getElementById("AllowPR").value;
	if(allowpr!="0" && allowpr!="")
	{	res=RadioChecked("premium-numbers", "Bitte w%E4hlen Sie eine Pr%E4mie aus", true);
	}
	return res;
}
//--------------------------------------------------------------
function GetAirmailType(id)
{
	var AirmailType="";
	var cc=document.getElementById(id+"_temp");
	if(!cc)
		cc=document.getElementById(id);
	if(cc)
	{	var index=cc.selectedIndex;
		AirmailType=ExtractAirmailType(cc.options[index].value);
	}
	return AirmailType;
}
//--------------------------------------------------------------
function SetCountryCode(cc_id, includeDeliveryType)
{
	var cc=document.getElementById(cc_id);
	var cc_temp=document.getElementById(cc_id+"_temp");
	if(cc_temp && cc)
	{	var cc_code=cc_temp.options[cc_temp.selectedIndex].value;
		cc.value=ExtractCountryCode(cc_code);
		if(includeDeliveryType)
		{	var dt=document.getElementById("delivery-type");
			if(dt && dt.type=="hidden")
			{	dt_lp=document.getElementById("delivery-type_LP");
				if(dt_lp && dt_lp.checked && dt_lp.value=="LP")
				{	dt.value=ExtractAirmailType(cc_code)+"L";
				}
				else
				{	dt.value="";
				}
			}
		}
	}
}
//--------------------------------------------------------------
function SendenAbo()
{
	var f=document.BestellForm;
	var aboart=getAboArt();

	if(document.getElementById("Testmode"))
	{	SendenTest();
	}
	else
	{	if(aboart=="E")
			SendenEAbo();
		else if(aboart=="G")
			SendenGAbo();
		else if(aboart=="W")
			SendenWAbo();
		else if(aboart=="WG")
			SendenWGAbo();
		else
			alert("ACHTUNG !  Unbekannte Aboart '"+aboart+"'");
	}
}
//--------------------------------------------------------------
function SendenEAbo()
{	// Eigenabo
	if(!AlreadySent)
	{	var f=document.BestellForm;
		if(RequiredFieldsOK())
		{   if(PremiumSelected())
			{	ReplaceEMailFromAddress("FromName", "FromAddress", "r_first-name", "r_last-name1", "r_email");
				SetCountryCode("r_country-code", true);
				AlreadySent=true;
				f.submit();
			}
		}
	}
}
//--------------------------------------------------------------
function SendenGAbo()
{	// Geschenkabo
	if(!AlreadySent)
	{	var f=document.BestellForm;
		if(RequiredFieldsOK())
		{	if(RequiredLFieldsOK())
			{   if(PremiumSelected())
				{	ReplaceEMailFromAddress("FromName", "FromAddress", "r_first-name", "r_last-name1", "r_email");
					SetCountryCode("r_country-code", false);
					SetCountryCode("l_country-code", true);
					AlreadySent=true;
					f.submit();
				}
			}
		}
	}
}
//--------------------------------------------------------------
function SendenWAbo()
{	// Werbeabo
	if(!AlreadySent)
	{	var f=document.BestellForm;
		if(RequiredWFieldsOK())
		{	if(RequiredFieldsOK())
			{   if(PremiumSelected())
				{   ReplaceEMailFromAddress("FromName", "FromAddress", "r_first-name", "r_last-name1", "r_email");
					SetCountryCode("r_country-code", true);
					SetCountryCode("w_country-code", false);
					AlreadySent=true;
					f.submit();
				}
			}
		}
	}
}
//--------------------------------------------------------------
function SendenWGAbo()
{	// Werbeabo
	if(!AlreadySent)
	{	var f=document.BestellForm;
		if(RequiredWFieldsOK())
		{	if(RequiredFieldsOK())
			{	if(RequiredLFieldsOK())
				{	if(PremiumSelected())
					{   ReplaceEMailFromAddress("FromName", "FromAddress", "r_first-name", "r_last-name1", "r_email");
						SetCountryCode("r_country-code", false);
						SetCountryCode("l_country-code", true);
						SetCountryCode("w_country-code", false);
						AlreadySent=true;
						f.submit();
					}
				}
			}
		}
	}
}
//--------------------------------------------------------------
function onLoad()
{
	var f=document.BestellForm;
	var allowpr=document.getElementById("AllowPR").value;
	var allowzi=document.getElementById("AllowZI").value;
	var allowas=document.getElementById("AllowAS").value;
	var allowae=document.getElementById("AllowAE").value;
	var aboart=getAboArt();

	// Praemien
	if(allowpr=="0" || allowpr=="")
		document.getElementById("premium").style.display="none";
	else
		document.getElementById("premium").style.display="block";

	// Abostart
	if(allowas=="0" || allowas=="")
		document.getElementById("AS").style.display="none";
	else
		document.getElementById("AS").style.display="block";

	// Aboende
	if(allowae=="0" || allowae=="")
		document.getElementById("AE").style.display="none";
	else
		document.getElementById("AE").style.display="block";

	// Zahlungsintervall
	if(allowzi=="0" || allowzi=="")
		document.getElementById("ZI").style.display="none";
	else
		document.getElementById("ZI").style.display="block";

	//document.getElementById("r_country-code").options[0].selected=true;
	//onRLandChange(document.getElementById("r_country-code"));

	//document.getElementById("l_country-code").options[0].selected=true;
	//onRLandChange(document.getElementById("l_country-code"));

	//document.getElementById("w_country-code").options[0].selected=true;
	//onRLandChange(document.getElementById("w_country-code"));

	handleAboArt(aboart);
}
//--------------------------------------------------------------
function handleAboArt(aboart)
{
	var allowkolo;
	var radr=document.getElementById("RAdr");
	var ladr=document.getElementById("LAdr");
	var wadr=document.getElementById("WAdr");
	var obj_allowkolo=document.getElementById("AllowKolo");
	var rlegend=document.getElementById("RLegend");
	if(rlegend)
	{	textRLAnschr="Rechnungs- und Lieferanschrift";
		textRAnschr="Rechnungsanschrift";
		textLAnschr="Lieferanschrift";
	}
	else
	{	rlegend=document.getElementById("RLegendEngl");
		textRLAnschr="Invoice and shipping address";
		textRAnschr="Invoice address";
		textLAnschr="Shipping address";
	}

	if(obj_allowkolo)
	{	allowkolo=obj_allowkolo.value;
		if(allowkolo=="")
			allowkolo="0";
	}
	else
	{	allowkolo="0";
	}

	if(aboart=="E")
	{	// Eigenabo
		if(radr) radr.style.display="block";
		if(ladr) ladr.style.display="none";
		if(wadr) wadr.style.display="none";
		if(rlegend)
		{	if(allowkolo=="0")
				rlegend.innerHTML=textRLAnschr;
			else
				rlegend.innerHTML=textLAnschr;
		}
		CountrySpecs(GetCountryCodeObject("r_country-code"));
	}
	else if(aboart=="G")
	{	// Geschenkabo
		if(radr) radr.style.display="block";
		if(ladr) ladr.style.display="block";
		if(wadr) wadr.style.display="none";
		if(rlegend) rlegend.innerHTML=textRAnschr;
		CountrySpecs(GetCountryCodeObject("l_country-code"));
	}
	else if(aboart=="W")
	{	// Werbeabo
		if(radr) radr.style.display="block";
		if(ladr) ladr.style.display="none";
		if(wadr) wadr.style.display="block";
		if(rlegend) rlegend.innerHTML=textRLAnschr;
		CountrySpecs(GetCountryCodeObject("r_country-code"));
	}
	else if(aboart=="WG")
	{	// Werbeabo mit abweichender Lieferanschrift
		if(radr) radr.style.display="block";
		if(ladr) ladr.style.display="block";
		if(wadr) wadr.style.display="block";
		if(rlegend) rlegend.innerHTML=textRAnschr;
		CountrySpecs(GetCountryCodeObject("l_country-code"));
	}
	else
	{	alert("ACHTUNG !  Unbekannte Aboart '"+aboart+"'");
	}
}
//--------------------------------------------------------------
function SendenTest()
{
	var res=true;

	res=ValidFromSelected(res);
	res=ValidToSelected(res);
	alert(
	document.getElementById("valid-to_d").value + "." +
	document.getElementById("valid-to_m").value + "." +
	document.getElementById("valid-to_y").value
	);
}
//--------------------------------------------------------------
