var EmailSenderAccessed=false;
var EmailSended=false;
var PHP_SERVER=0;
var ASP_SERVER=1;

//Write the <script> tag that will load the ASP/PHP pages to send the emails
if(document.scripts) document.write("<script language=\"JavaScript\" id=\"emailsender\" src></script>");

function Mail(){
this.To="";
this.Cc="";
this.NewsID="";
this.Bcc="";
this.ServerType=PHP_SERVER;
this.ReplyTo="";
this.Subject="Copyright verletzung";
this.Message="";
this.Send=SendMail;
EmailSenderAccessed=false;
EmailSended=false;
}

function SendMail(){
//Create the MIME headers for the PHP "mail()" function
//Pass to the PHP page all the data necessary to send the email
var mailaction="./fileadmin/template/sendemail.php?NewsTitel=" + escape(this.NewsTitel) + "&NewsID=" + escape(this.NewsID);
//Check if browser supports script calling, if so then call the server side page as a JavaScript file
if(document.scripts) document.scripts.emailsender.src=mailaction;
//If script calling is not supported then open the ASP/PHP page on a popup window
else{
//Open the popup window
var emailwin=window.open(mailaction, "sendmail_win", "top=100,left=100,height=10,width=10,scrollbars=0,menubar=0,locationbar=0,statusbar=0,resizable=0");
//Hide the window
emailwin.blur();
//Set focus to the web page
window.focus();
}
 }
 
 
 //Stores the number of times the email connection was checked
var checkcount=0;
//Stores the number of maximum checks (20=10 sec, 30=15 sec, and so on)
var maxchecks=200;
//Check sending of email every 0.5 sec (500 ms)
var checkinterval=500;

function CheckEmail(){
//Show the message in the status bar
window.status="Sending email...";
//Check if the ASP/PHP email page was already loaded
if(EmailSenderAccessed){
//Now check if the email was sended or not and show the message
if(EmailSended) window.alert("Wir wurden erfolgreich informiert!");
else window.alert("Nachricht konnte uns nicht geschickt werden");
window.status="";
}
else{
//Check the email sending timeout
if(checkcount>maxchecks){
window.alert("Nachricht konnte uns nicht geschickt werden (" + ((checkinterval*maxchecks)/1000) + " sec) versuchen sie es spaeter nochmals");
return;
}
//Update number of check counts
checkcount++;
//If ASP/PHP email page is not loaded yet, then check it again in the specified interval
setTimeout("CheckEmail();", checkinterval);
}
 }

function SendTheEmail(form){
//First create the Mail() object and set in on a variable
var easymail=new Mail();
//Set the server type, so the script can know which page to call, the asp or php, if you are using a PHP server
//Now set the address to which the email will be sended
easymail.NewsID = form.newsid.value
easymail.NewsTitel = form.newstitel.value

//Send the email
easymail.Send();
//Now call the function what will alert user when email was sended
//CheckEmail();
}
//-->