//
// offer2send(): shows the page to specify a card 
// getmsg()    : gets the message, email address and the picture selected from the form
// warn()      : shows the order, to get it confirmed
// present2me(): shows the card (for confirmation)
// sendecard() : sends an email to inform the recipient 
// emailmsg()  : Here is the message to the receiver formulated
// emailurl()  : Here is the way the email is sent using the ISP's email-form-cgi is coded
// emailsend() : Here is the mechanism for the actual email sending (link page) coded
// show()      : shows the card (for delivery)

 //   var absadr='D:\\ecard\\';
    var absadr='http://www.worditude.com/ecards/';
    var i, picno;
    var ecardmsg  = '';
    var recipient = '';
    var sender    = 'webmaster@worditude.com';
    var ecardpic  = '';

    // getmsg():    gets the message, email address and the picture selected from the form
    function getmsg()
    { 
      ecardmsg  = this.document.sendanecard.id99.value;
      recipient  = this.document.sendanecard.id98.value;
       var radiopic = this.document.sendanecard.ecard
       for (var i = 0; i <= radiopic.length; i++) {
         if (radiopic[i].checked) {
           ecardpic  = radiopic[i].value;
           break
         }
       }
      warn(ecardmsg,recipient,ecardpic );
    }// getmsg():  

    function warn(msg,rec,img)
    { 
      // alert('warn(\'' +msg+'\',\''+rec+'\',\''+img+ '\')');// for debugging
      // var win = window.open('','ecard','resizable=yes,scrollbars=yes,width=500,height=600 ' );
      with (this.document) {
        open("text/html", "replace");        
        write('<HTML><HEAD><TITLE>ECARD</TITLE>' );
        write('\n<script language="JavaScript" type="text/javascript" src="'+absadr+'ecard.js"></script>');
        write('\n<META HTTP-EQUIV="Pragma" CONTENT="no-cache">' );
        write('\n</head>');
        write('\n<body><CENTER><FONT FACE="Arial"><H2>YOU ARE SENDING AN ECARD</H2></FONT>');
        write('\n<BR>to (email address) : '                 + rec +' ');
        write('\n<BR>picture: <IMG SRC="'                   + img +'">' );
        write('\n<BR>message :<FONT TYPE="Arial" SIZE="16">'+ msg +'</FONT>' );
        write('\n<BR><A onClick="{Javascript:offer2send(' );
        write('\'' +msg+'\',\''+rec+'\',\''+img+ '\'' );
        write(');}">[New]</A>' );
        write('\n<A onClick="{Javascript:present2me(' );
        write('\'' +msg+'\',\''+rec+'\',\''+img+ '\'' );
        write(');}">[Show]</A>' );
        write('\n<A onClick="{Javascript:sendecard(' );
        write('\'' +msg+'\',\''+rec+'\',\''+img+ '\'' );
        write(');}">[Send]</A>' );
        write('\n</CENTER></BODY></HTML>' );
        alert('next, you will be shown your choice to confirm.');// for debugging
        close();
      }
    } // warn(msg,rec,img)

    function present2me(msg,rec,img)
    { 
      // alert('present2me(\'' +msg+'\',\''+rec+'\',\''+img+ '\')');// for debugging
      // var win = window.open('','ecard','resizable=yes,scrollbars=yes,width=500,height=600 ' );
      with (this.document) {
        open("text/html", "replace");        
        write('<HTML><HEAD><TITLE>ECARD</TITLE>' );
        write('\n<script language="JavaScript" type="text/javascript" src="'+absadr+'ecard.js"></script>');
        write('\n<META HTTP-EQUIV="Pragma" CONTENT="no-cache">' );
        write('\n</head>');
        // --- here is the card laid out-------------------------------------
        write('\n<body><CENTER><FONT FACE="Arial"><H2>A www.worditude.com ECARD FOR YOU</H2></FONT>');
        write('\n<A HREF="http://www.worditude.com/ecard/" ');
        write('TITLE="[send a similar card yourself]">' );
        write('\n<IMG SRC="http://www.worditude.com/ecard/'+img+'" BORDER="0"></A>' );
        write('\n<BR><FONT TYPE="" SIZE="">'+msg+'</FONT>' );
        write('\n</CENTER>' );
        // ---  end of card layout-------------------------------------------
        write('\n<BR><BR><A onClick="{Javascript:sendecard(' );
        write('\'' +msg+'\',\''+rec+'\',\''+img+ '\'' );
        write(');}">[Send]</A>' );
        write('\n</CENTER></BODY></HTML>' );
        alert('next, you will be shown what the receiver will see, to confirm.');// for debugging
        close();
      }
    } // present2me(msg,rec,img)

    function sendecard(msg,rec,img)
    { 
      // alert('sendecard(\'' +msg+'\',\''+rec+'\',\''+img+ '\')');// for debugging
      var content=emailmsg(msg,img);
      var url=emailurl(content,rec);
      emailsend(url);
    }// sendecard(msg,rec,img)

    function emailmsg(msg,img)
    {  
      // alert('emailmsg(\'' +msg+'\',\''+img+ '\')');// for debugging
      var content='\n<BR> '+absadr+'ecard.asp?m='+escape(msg)+'&g='+img;
      content='<FONT FACE="Arial,Helvetica" SIZE="+2" COLOR="BLUE">'+content+'</FONT>';
      // --- here is the email laid out ------------------------------------------
      content='<HTML><BODY>'
             +'\n<CENTER><FONT FACE="Arial,Helvetica" SIZE="+2" COLOR="RED">'
             +'You have been sent an e-card, '
             +'\n<BR>get it from:<BR> <A HREF="'+absadr+'ecard.asp?m='+escape(msg)+'&g='+img+' " >here</A>.'
             +'\n<BR>(you must be online).'
             +'\n</FONT></CENTER></BODY></HTML>'
             ;
       // ---  end of email layout-------------------------------------------------
       return content;
    } // emailmsg(msg,img)

    function emailurl(content,rec)
    {  
       // alert('emailurl(\''+content+'\',\''+rec+'\')');// for debugging
       var url=absadr+'sendm.asp';
       url=url+'?mail-from=www.worditude.com'
       url=url+'&mail-fromAddress='+escape(sender);
       url=url+'&mail-to=You';
       url=url+'&mail-toaddress='+escape(rec);
       url=url+'&mail-subject=you%20have%20got%20a%20worditude%20e-card';
       url=url+'&mail-relay=mail.online.no'
       url=url+'&mail-contentType=text/html'
       url=url+'&mailbody=';
       url=url+escape(content)+'&button=Send';
       return url;
    } // emailurl(content,rec)

    function emailsend(url)
    {  
      // alert('emailurl('+url+')');// for debugging
      // var win = window.open('','ecard','resizable=yes,scrollbars=yes,width=500,height=600 ' );
      with (this.document) {
        open("text/html", "replace");    
        write('<HTML><head>');
        write('<title>Sending an ecard from worditude</title>');
        write('<script language=JavaScript>');
        write('window.open (\''+url+'\', \'win\');');
        write('</script>');
        write('</head><body></body></html>');
        close();
      }
    } // emailsend(url)

    function show(msg,img)
    {   var rec=" ";
        this.document.open("text/html", "replace");        
        this.document.write('<HTML><HEAD><TITLE>ECARD</TITLE>' );
        this.document.write('\n</head>');
        // --- here is the card laid out
        this.document.write('\n<body><CENTER><FONT FACE="Arial"><H2>A www.worditude.com ECARD FOR YOU</H2></FONT>');
        this.document.write('\n<A HREF="http://www.worditude.com/ecard/" ');
        this.document.write('TITLE="[send a similar card yourself]">' );
        this.document.write('\n<IMG SRC="http://www.worditude.com/ecard/'+img+'" BORDER="0"></A>' );
        this.document.write('\n<BR><FONT TYPE="" SIZE="">'+msg+'</FONT>' );
        this.document.write('\n</CENTER>' );
        // ---  end of card layout
        this.document.write('</BODY></HTML>' );
        alert('next, you will be shown what the receiver will see.');// for debugging
        this.document.close();
    } // show(msg,img)

    function emailurl_old(content,rec)
    {  
      // alert('emailurl_old(\''+content+'\',\''+rec+'\')');// for debugging
       var url='http://www.activeisp.com/scripts/sendformmail.dll?';
       url=url+'mail-to='+escape(rec);
       url=url+'&mail-from='+escape(sender);
       url=url+'&mail-subject=you%20have%20got%20a%20worditude%20e-card';
       url=url+'&mailbody=';
       url=url+escape(content)+'&button=Send';
       return url;
    } // emailurl_old(content,rec)

    function offer2send(msg,rec,img)
    {
      // alert('offer2send(\'' +msg+'\',\''+rec+'\',\''+img+ '\')');// for debugging
      var chckd='';
      // var win = window.open('','ecard','resizable=yes,scrollbars=yes,width=500,height=600 ' );
      with (this.document) {
        open("text/html", "replace");        
        write('<HTML><HEAD><TITLE>SEND AN E-CARD</TITLE>' );
        write('<script language="JavaScript" type="text/javascript" src="'+absadr+'ecard.js"></script>' );
        write('</head><body><CENTER><H1>SEND AN E-CARD</H1>' );
        write('<FORM NAME="sendanecard">' );
        write('Pick the picture that you want to send to your friend:' );
        if (img=="ecard1.jpg") { chckd='CHECKED';} else { chckd='';}
        write('<BR><INPUT TYPE="RADIO" NAME="ecard" value="ecard1.jpg" '+chckd+' ID="id1">' );
        write(' <IMG SRC="ecard1.jpg">' );
        if (img=="ecard2.jpg") { chckd='CHECKED';} else { chckd='';}
        write('<INPUT TYPE="RADIO" NAME="ecard" value="ecard2.jpg" '+chckd+' ID="id2">' );
        write('<IMG SRC="ecard2.jpg">' );
        write('<BR>Please type the message you want to send to your friend:' );
        write('<BR><INPUT TYPE="TEXT" SIZE="50" NAME="message" VALUE="'+msg+'" ID="id99">' );
        write('<BR>Please type the email address of your friend:' );
        write('<BR><INPUT TYPE="TEXT" SIZE="50" NAME="recipient" VALUE="'+rec+'" ID="id98">' );
        write('<BR><INPUT TYPE="SUBMIT" value="send"  NAME="send"  onClick="{Javascript:getmsg();}">' );
        write('\n</CENTER></BODY></HTML>' );
        alert('start again');// for debugging
        close();
      }
    } // offer2send(msg,rec,img)
