//Function antiSpiderEMail() version 1.1 
//Original source last update: 11:02 2007-12-14
//Coded and commented by:
    //Linus Persson
    //Webdesigner
    //Softgear AB
    //+46 (0) 735 88 74 14
    //linus.persson@softgear.se
    //http://softgear.se
    
//If you copy this code and change something in it, write when you did it here.
//-----------------------------------------------------------------------------
//Changed by:   Your Name
//Last change:  ##:## ####-##-##
//-----------------------------------------------------------------------------


//Call this function width: 
//            antiSpiderEMail(
//input 1:          "username",
//input 2:          "domain",
//input 3:          "alternativ link name"(leave this empty to use mail address as link name),
//input 5:          true(function returns a string that we can use to set an variable)/false(function directly document.writes our e-mail)
//            );
//
//Example 1:
//  <scrpit....> var testMail = antiSpiderEMail("test.person", "maildomain.com", "", true); </script>
//  Will sett testMail to <a href="mailto:test.person@maildomain.com">test.person@maildomain.com</a>
//
//Example 2:
//  <script....> antiSpiderEMail("test.person", "maildomain.com", "My E-mail!", false); </script>
//  Will diretly write "<a href="mailto:test.person@maildomain.com">My E-mail!</a>"



//Scritp that loads mailto links that can not be detected by spiders.
//SHORT DESCRIPTION:    Chopping up our mail information in to different variables and then printing the correct mail information
//                      with this script will prevent e-mail spiders to find our mail in the HTML code we place it.
function antispider( mail1, mail2, mail3, returnString ) {
    if ( returnString ) { //If we want the function to return our mail to us, so that we can set it in a variable.
        
        if ( mail3 == "" ) { //If no alternative mail name has been defined
            var echo = "<a href=\"mail" + "to:" + mail1 + "@" + mail2 + "\">" + mail1 + "@" + mail2 + "</a>";
            return echo;
        }
        else { //If an alternative mail name has been defined
            var echo = "<a href=\"mail" + "to:" + mail1 + "@" + mail2 + "\">" + mail3 + "</a>";
            return echo;
        }
        
    }
    else { //If we want the function to document.write our mail directly.
        
        if ( mail3 == "" ) { //If no alternative mail name has been defined
            document.write("<a href=\"mail" + "to:" + mail1 + "@" + mail2 + "\">" + mail1 + "@" + mail2 + "</a>");
        }
        else { //If an alternative mail name has been defined
            document.write("<a href=\"mail" + "to:" + mail1 + "@" + mail2 + "\">" + mail3 + "</a>");
        }
        
    }
}