//Actionscript
//Funktion die die Emailadresse auf Validität prüft, Beschränkung des Telefonnummernfelds, Anzeige der Korrektheit/Vollständigkeit der Eingaben mittels „Typo Highlighting“
var field=new Array(this.field_name,this.field_email,this.field_phone,this.field_subject,this.field_message);
var designation=new Array(this.name,this.email,this.phone,this.subject,this.message);
var onFocusAlpha=90;
var killFocusAlpha=45;
emailAdressError=function (mail)
{
var badtype=[' '];
if (mail.indexOf('@')>0 && mail.lastIndexOf('.')>2 && mail.lastIndexOf('.')-1 !== mail.indexOf('@') && mail.length<mail.lastIndexOf('.')+6 && mail.length>mail.lastIndexOf('.')+2)
{
for (var i=0; i<badtype.length; i++)
{
if (mail.indexOf(badtype[i])>0)
{
return true;
}
}
}
else
{
return true;
}
};
for(var i=0;i<=4;i++)
{
switch(i)
{
case 0:
designation[i]._alpha=killFocusAlpha;
var textfield=field[i];
textfield.tabIndex=i+1;
textfield.text='';
textfield._designation=designation[i];
textfield.onSetFocus=function()
{
this._designation._alpha=onFocusAlpha;
};
textfield.onKillFocus=function()
{
if(this.text=='')
{
this._designation._alpha=killFocusAlpha;
}
};
selection.setFocus(textfield);
break;
case 1:
designation[i]._alpha=killFocusAlpha;
var textfield=field[i];
textfield.tabIndex=i+1;
textfield.text='';
textfield.restrict='a-zA-ZäöüÄÖÜ0-9@._\\-';
textfield._designation=designation[i];
textfield.onSetFocus=function()
{
this._designation._alpha=onFocusAlpha;
};
textfield.onKillFocus=function()
{
if(emailAdressError(this.text))
{
this._designation._alpha=killFocusAlpha;
}
};
break;
case 2:
designation[i]._alpha=killFocusAlpha;
var textfield=field[i];
textfield.tabIndex=i+1;
textfield.text='';
textfield.restrict='0-9+\\-/() ';
textfield._designation=designation[i];
textfield.onSetFocus=function()
{
this._designation._alpha=onFocusAlpha;
};
textfield.onKillFocus=function()
{
if(this.text=='')
{
this._designation._alpha=killFocusAlpha;
}
};
break;
case 3:
designation[i]._alpha=killFocusAlpha;
var textfield=field[i];
textfield.tabIndex=i+1;
textfield.text='';
textfield._designation=designation[i];
textfield.onSetFocus=function()
{
this._designation._alpha=onFocusAlpha;
};
textfield.onKillFocus=function()
{
if(this.text=='')
{
this._designation._alpha=killFocusAlpha;
}
};
break;
case 4:
designation[i]._alpha=killFocusAlpha;
var textfield=field[i];
textfield.tabIndex=i+1;
textfield.text='';
textfield._designation=designation[i];
textfield.onSetFocus=function()
{
this._designation._alpha=onFocusAlpha;
};
textfield.onKillFocus=function()
{
if(this.text=='')
{
this._designation._alpha=killFocusAlpha;
}
};
break;
}
}
this.stop();
//Und das hier auf den Button zum abschicken
on(release)
{
if ((var_name !=='' && var_message !=='') && !emailAdressError(var_email))
{
attachMovie("MacOs", "MacOs_instance",1)
MacOs_instance.startDrag(true);
Mouse.hide();
var sender=new LoadVars()
sender.object=this;
sender.recipient=_global.recipient;
sender.var_name=var_name;
sender.var_email=var_email;
sender.var_phone=var_phone;
sender.var_subject=var_subject;
sender.var_message=var_message;
sender.sendAndLoad('mail.php', sender, 'POST');
sender.onLoad=function(success)
{
if(success)
{
if(this.status=='sent')
{
_root.elements.content.mail.mailform_display.gotoAndPlay('valid');
MacOs_instance.stopDrag();
MacOs_instance.removeMovieClip();
Mouse.show();
delete this.object['sender'];
}
}
};
}
else
{
this.mailform_display.gotoAndPlay('invalid');
}
}