function WriteShareThisCodeThickbox(title,url) {
    // write out the ShareThis toolbar  
    // static images 
    var icoDelicious = "../images-nav/sharethis/delicious_32.png";
    var icoFav = "../images-nav/sharethis/favorites_32.png";
    var icoDigg = "../images-nav/sharethis/digg_32.png";
    var icoReddit = "../images-nav/sharethis/reddit_32.png";
    var icoGoogle = "../images-nav/sharethis/google_32.png";
    var icoMySpace = "../images-nav/sharethis/myspace_32.png";
    var icoLive = "../images-nav/sharethis/windows_32.png";
    var icoFacebook = "../images-nav/sharethis/facebook_32.png";
    var icoYahoo = "../images-nav/sharethis/yahoo_32.png";
    var icoNewsvine = "../images-nav/sharethis/newsvine_32.png";

    var pageTitle = URLEncode(title);
    pageTitle = pageTitle.replace("'", "")
    var pageURL = URLEncode(url);

    document.writeln ('\n' +
                  '                  <!-- SHARE THIS PAGE -->\n' +
                  '                  <div id="shareitdiv">\n' +
                  '                  <table width="100%" border="0" cellspacing="3" cellpadding="3">\n' +
                  '                    <tr>\n' +
                  '                      <td width="50%" align="left" valign="top">\n' + 
                  '                      <ul>\n' +
                  '                      <li><a href="http://www.mdc.edu/main/system/app/sharethis/sharethis_count.asp?service=delicious&title=' + pageTitle + '&url=' + pageURL + '" target="_blank" rel="nofollow"><img src="' + icoDelicious + '" alt="Bookmark on Del.icio.us" width="32" height="32" class="icon" /></a><a href="http://www.mdc.edu/main/system/app/sharethis/sharethis_count.asp?service=delicious&title=' + pageTitle + '&url=' + pageURL + '" target="_blank" rel="nofollow">Del.icio.us</a></li>\n' +
                  '                      <li><a href="http://www.mdc.edu/main/system/app/sharethis/sharethis_count.asp?service=digg&title=' + pageTitle + '&url=' + pageURL + '" target="_blank" rel="nofollow"><img src="' + icoDigg + '" alt="Digg" width="32" height="32" class="icon" /></a><a href="http://www.mdc.edu/main/system/app/sharethis/sharethis_count.asp?service=digg&title=' + pageTitle + '&url=' + pageURL + '" target="_blank" rel="nofollow">Digg</a></li>\n' +
                  '                      <li><a href="http://www.mdc.edu/main/system/app/sharethis/sharethis_count.asp?service=facebook&title=' + pageTitle + '&url=' + pageURL + '" target="_blank" rel="nofollow"><img src="' + icoFacebook + '" alt="Post on Facebook" width="32" height="32" class="icon" /></a><a href="http://www.mdc.edu/main/system/app/sharethis/sharethis_count.asp?service=facebook&title=' + pageTitle + '&url=' + pageURL + '" target="_blank" rel="nofollow">Facebook</a></li>\n' +  
                  '                      <li><a onclick="bookmarkSite(URLDecode(\'' + pageTitle + '\'), URLDecode(\'' + pageURL + '\'))"><img src="' + icoFav + '" alt="Favorites" width="32" height="32" class="icon" /></a><a onclick="bookmarkSite(URLDecode(\'' + pageTitle + '\'), URLDecode(\'' + pageURL + '\'))">Favorites</a></li>\n' +
                  '                      <li><a href="http://www.mdc.edu/main/system/app/sharethis/sharethis_count.asp?service=google&title=' + pageTitle + '&url=' + pageURL + '" target="_blank" rel="nofollow"><img src="' + icoGoogle + '" alt="Google" width="32" height="32" class="icon" /></a><a href="http://www.mdc.edu/main/system/app/sharethis/sharethis_count.asp?service=google&title=' + pageTitle + '&url=' + pageURL + '" target="_blank" rel="nofollow">Google</a></li>\n' +
                  '                      </ul>\n' +
                  '                      </td>\n' +
                  '                      <td width="50%" align="left" valign="top">\n' + 
                  '                      <ul>\n' +           
                  '                      <li><a href="http://www.mdc.edu/main/system/app/sharethis/sharethis_count.asp?service=live&title=' + pageTitle + '&url=' + pageURL + '" target="_blank" rel="nofollow"><img src="' + icoLive + '" alt="Live" width="32" height="32" class="icon" /></a><a href="http://www.mdc.edu/main/system/app/sharethis/sharethis_count.asp?service=live&title=' + pageTitle + '&url=' + pageURL + '" target="_blank" rel="nofollow">Live</a></li>\n' +
                  '                      <li><a href="http://www.mdc.edu/main/system/app/sharethis/sharethis_count.asp?service=myspace&title=' + pageTitle + '&url=' + pageURL + '" target="_blank" rel="nofollow"><img src="' + icoMySpace + '" alt="Post to MySpace" width="32" height="32" class="icon" /></a><a href="http://www.mdc.edu/main/system/app/sharethis/sharethis_count.asp?service=myspace&title=' + pageTitle + '&url=' + pageURL + '" target="_blank" rel="nofollow">Myspace</a></li>\n' +
                  '                      <li><a href="http://www.mdc.edu/main/system/app/sharethis/sharethis_count.asp?service=newsvine&title=' + pageTitle + '&url=' + pageURL + '" target="_blank" rel="nofollow"><img src="' + icoNewsvine + '" alt="Seed on Newsvine" width="32" height="32" class="icon" /></a><a href="http://www.mdc.edu/main/system/app/sharethis/sharethis_count.asp?service=newsvine&title=' + pageTitle + '&url=' + pageURL + '" target="_blank" rel="nofollow">Newsvine</a></li>\n' +
                  '                      <li><a href="http://www.mdc.edu/main/system/app/sharethis/sharethis_count.asp?service=reddit&title=' + pageTitle + '&url=' + pageURL + '" target="_blank" rel="nofollow"><img src="' + icoReddit + '" alt="Reddit" width="32" height="32" class="icon" /></a><a href="http://www.mdc.edu/main/system/app/sharethis/sharethis_count.asp?service=reddit&title=' + pageTitle + '&url=' + pageURL + '" target="_blank" rel="nofollow">Reddit</a></li>\n' +
                  '                      <li><a href="http://www.mdc.edu/main/system/app/sharethis/sharethis_count.asp?service=yahoomyweb&title=' + pageTitle + '&url=' + pageURL + '" target="_blank" rel="nofollow"><img src="' + icoYahoo + '" alt="Yahoo MyWeb" width="32" height="32" class="icon" /></a><a href="http://www.mdc.edu/main/system/app/sharethis/sharethis_count.asp?service=yahoomyweb&title=' + pageTitle + '&url=' + pageURL + '" target="_blank" rel="nofollow">Yahoo MyWeb</a></li>\n' +
                  '                      </ul>\n' +
                  '                      </td>\n' +
                  '                    </tr>\n' +
                  '                  </table>\n' +
                  '                  </div>\n' +
                  '                  <!-- END SHARE THIS PAGE -->');
}

function WriteShareThisEmailThickbox(title,url) {
    // write out the ShareThis email form 
    title = title.replace("'", "")
    url = url.replace("'", "")
    document.writeln ('\n' +
                  '                  <div id="emaildiv">\n' +
                  '                      <span id="email-sent"></span>\n' +
                  '                      <div id="emailer">\n' +
                  '                          <h5>' + title + '</h5>\n' +             
                  '                          <p><a href="' + url + '">' + url + '</a></p>\n' +
                  '                          <div id="sharemailform">\n' +
                  '                              <form name="sendemail">\n' +
                  '                              <input name="toemail" id="toemail" type="text" value="Send to (up to 5 email addresses)" size="62" onblur="emailValidate(\'toemail\');" /> <span id="toemail-error"></span>\n' +
                  '                              <br />\n' +
                  '                              <span>Separate multiple addresses with commas.</span>\n' +
                  '                              <br />\n' +
                  '                              <input name="fromemail" id="fromemail" type="text" value="Enter your email address" size="62" onblur="emailValidate(\'fromemail\');" /> <span id="fromemail-error"></span>\n' +
                  '                              <br />\n' +
                  '                              <span>You will automatically receive a copy of this email.</span>\n' +
                  '                              <br />\n' +
                  '                              <textarea name="notes" id="notes" cols="59" rows="4">Type your message here</textarea>\n' +
                  '                              <br />\n' +
                  '                              <span style="color:red">*</span> Two-word code:</strong> <span id="recaptcha-error"></span>\n' +
                  '                              <div id="recaptcha">\n' +
                  '                                  <script type="text/javascript" src="http://api.recaptcha.net/js/recaptcha_ajax.js"></script>\n' +
                  '                                  <script type="text/javascript">\n' +                  
                  '                                      $(document).ready(function(){\n' +  
                  '                                          $(\'#toemail\').autofill({\n' +  
                  '                                          value: \'Send to (up to 5 email addresses)\',\n' +  
                  '                                          defaultTextColor: \'#000\',\n' +  
                  '                                          activeTextColor: \'#000\'\n' +  
                  '                                          });\n' +  
                  '                                          $(\'#fromemail\').autofill({\n' +  
                  '                                          value: \'Enter your email address\',\n' +  
                  '                                          defaultTextColor: \'#000\',\n' +  
                  '                                          activeTextColor: \'#000\'\n' +  
                  '                                          });\n' +  
                  '                                          $(\'#notes\').autofill({\n' +  
                  '                                          value: \'Type your message here\',\n' +  
                  '                                          defaultTextColor: \'#000\',\n' +  
                  '                                          activeTextColor: \'#000\'\n' +  
                  '                                          });\n' + 
                  '                                      });\n' + 
                  '                                      setTimeout(\'Recaptcha.create("6LdDdggAAAAAANpmOTYD9wF6-gMOsVyfo_kGe0er","recaptcha", {theme: "white", lang: "en"})\',5);\n' +
                  '                                  </script>\n' +
                  '                              </div>\n' +                           
                  '                              <br />\n' +
                  '                              <table cellpadding="0" cellspacing="0" border="0"><tr><td><input name="submit" type="button" id="submit" value=" Send Email Now " onclick="disableSend(true); reCaptchaValidateThickbox(\'email\',\'' + title + '\', \'' + url + '\',\'thickbox\'); emailValidate(\'toemail\'); emailValidate(\'fromemail\'); setTimeout(\'disableSend(false)\', 5000);" /></td><td valign="bottom" style="padding-left:10px;"><span>[ <a href="#" onclick="tb_mdc_clearSTEmail();">Reset Form</a> ]</span></td></tr></table>\n' +
                  '                              <input name="url" type="hidden" id="url" value="url" />\n' +
                  '                              </form>\n' +
                  '                          </div>\n' +
                  '                          <p>Note: Your email address, and that of your recipients, will be used only in the case of transmission errors and to let the recipient know who sent the article. The information will not be used for any other purpose.</p>\n' +         
                  '                      </div>\n' +
                  '                  </div>');
    
}

function showEmailDiv()
{
    $(function() { 
        $("#emailer").show();
    }); 
}

function emailValidate(emailmssg)
{
// Validate email using AJAX
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
	  // Check which email field to validate and display error message
	  if (emailmssg == "toemail") 
	  	{
	  	document.getElementById("toemail-error").innerHTML = xmlHttp.responseText;
	  	} else {
		document.getElementById("fromemail-error").innerHTML = xmlHttp.responseText;
		}
      }
    }
	
	// Check which email field to validate
    if (emailmssg == "toemail") 
	  {
	  xmlHttp.open("GET","http://www.mdc.edu/main/system/app/sharethis/sharethis_email_validate.asp?email="+encodeURIComponent(document.sendemail.toemail.value),true);
	  } else {
	  xmlHttp.open("GET","http://www.mdc.edu/main/system/app/sharethis/sharethis_email_validate.asp?email="+encodeURIComponent(document.sendemail.fromemail.value),true);
	  }
	  
  xmlHttp.send(null);
}


function reCaptchaValidateThickbox(service,title,url,version)
{
// Validate captcha using AJAX
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
	  if (xmlHttp.responseText == "Incorrect code. Please try again.")
	  {
		document.getElementById("email-sent").innerHTML = '';
		document.getElementById("recaptcha-error").innerHTML = xmlHttp.responseText;
	  } else {
		document.getElementById("email-sent").innerHTML = xmlHttp.responseText;		
		document.getElementById("recaptcha-error").innerHTML = '';
		document.sendemail.reset();
		$(function() { $("#emailer").hide(); });
	  }	  
	  Recaptcha.destroy();
	  Recaptcha.create("6LdjoAMAAAAAAPgpueJqhTrGNysoADnkHowvnrnD", "recaptcha", {theme: 'white', lang: 'en'});
      }
    }
  xmlHttp.open("GET","http://www.mdc.edu/main/system/app/sharethis/sharethis_email_captcha.asp?toemail="+encodeURIComponent(document.sendemail.toemail.value)+"&fromemail="+encodeURIComponent(document.sendemail.fromemail.value)+"&notes="+encodeURIComponent(document.sendemail.notes.value)+"&service="+encodeURIComponent(service)+"&title="+encodeURIComponent(title)+"&url="+encodeURIComponent(url)+"&challenge="+encodeURIComponent(document.sendemail.recaptcha_challenge_field.value)+"&response="+encodeURIComponent(document.sendemail.recaptcha_response_field.value)+"&version="+version,true);
  xmlHttp.send(null);
}

function disableSend(enable)
{
    // disable the 'Send Email' button for 5 seconds
    var sendButton = document.getElementById("submit")
    if (enable) {
        sendButton.disabled = true;
	sendButton.value=' Please Wait... ';
    } else {
        sendButton.disabled = false;
	sendButton.value=' Send Email Now ';
    }
}