
function createTarget(target){

if (formvalidation() == true) {
    window.open("", target, "width=728,height=443,scrollbars=no");
    return true;
} else {
	return false;
}
}



function emailvalidation(entered, alertbox)
{
// E-mail-Validation (c) Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove the this line and the two lines above.
with (entered)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>4 || lastpos-dotpos<2) 
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}
}

function valuevalidation(entered, min, max, alertbox, datatype)
{
// Value-Validation (c) Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove the this line and the two lines above.
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
  {smalldatatype=datatype.toLowerCase();
   if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
  }
if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function digitvalidation(entered, min, max, alertbox, datatype)
{
// Digit-Validation (c) Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove the this line and the two lines above.
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
  {smalldatatype=datatype.toLowerCase();
   if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value); if (value.indexOf(".")!=-1) {checkvalue=checkvalue+1}};
  }
if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function emptyvalidation(entered, alertbox)
{
// Emptyfield-Validation (c) Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove the this line and the two lines above.
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function formvalidation()
{
  //thisform = window.document.f_emailkontakt;
 
  if (document.getElementById)
    thisform = window.document.sendecard;
  else if (document.all)
    thisform = window.document.sendecard;
  else {
    thisform = document.layers["layerform"].document.sendecard;
  }

  if (checkfields(thisform) == false) {
      //fehler	
      return false;
    } else {
      return true;
    }
}

function linecountvalidation(entered, lines, alertbox) {
// Textarea-Linecount-Validation (c) Chris Neuhäuser
// Please do not remove the this line and the two lines above.
	with (entered) {
		brcount = value.match(/\n/gi);
		//alert(brcount.length);
		if (brcount != null) {
			if (brcount.length > lines-1) {
				if (alertbox!="") {
					alert(alertbox);
				}
				return false;
			}
		} else {
			return true;
		}
	}
}

function scrollheightvalidation(entered, pixel, alertbox) {
// Textarea-Scrollheight-Validation (c) Chris Neuhäuser
// checks the scrollbar-height - works only in IE 4.0+
// Please do not remove the this line and the two lines above.
	with (entered) {
		//alert(scrollHeight);
		if (scrollHeight >= pixel) {
			if (alertbox!="") {
				alert(alertbox);
			}
			return false;
		} else {
			return true;
		}
	}
}

function checkfields(thisform)
{
with (thisform)
{

//cardtext
if (emptyvalidation(cardtext, "Bitte geben Sie Ihren Einladungstext ein!")==false) {cardtext.focus(); return false;};
if (linecountvalidation(cardtext, 7, "Bitte nicht mehr als 7 Zeilen eingeben!")==false) {cardtext.focus(); return false;};
if (scrollheightvalidation(cardtext, 100, "Bitte nicht mehr als 7 Zeilen eingeben!")==false) {cardtext.focus(); return false;};

//autogram
if (emptyvalidation(autogram, "Bitte unterschreiben Sie die Einladungskarte!")==false) {autogram.focus(); return false;};

//email_von
if (emailvalidation(von, "Ihre Absender-Email wurde nicht richtig angegeben!")==false) {von.focus(); return false;};

//email_an
if (emailvalidation(an, "Die E-Mail-Adresse des Empfängers wurde nicht richtig angegeben!")==false) {an.focus(); return false;};

return true;
}
}