function getEmailLink(){
    var str = "mailto:?subject=check out my calculation&body=Hi, I found this website and thought you might like it http://www.geocities.com/wowhtml/";  
    return str;
  }
  
  function editDescription(){
	//Effect.Fade( document.getElementById('readdescription') );
	//Effect.Appear( document.getElementById('editdescription') );
	
	hideItem('readdescription');
	showItem('editdescription');
	loadDescription();
  }
  
  function cancelDescription(){
	//Effect.Appear( document.getElementById('readdescription'), {queue: 'parallel'} );
	//Effect.Fade( document.getElementById('editdescription'), {queue: 'parallel'} );
  
    showItem('readdescription');
	hideItem('editdescription');
  }
  
  function updateDescription(){
	setDescription( document.getElementById('descriptiontextarea').value );
	
	//Effect.Appear( document.getElementById('readdescription') );
	//Effect.Fade( document.getElementById('editdescription') );
	
	showItem('readdescription');
	hideItem('editdescription');
  }
  
  function getDescription(){ 
    //InstaCalc.description = document.getElementById('descriptiontextarea').value;
	return InstaCalc.description;
  }
  
  function setDescription(str){
    var x = document.getElementById("descriptiontext");
	
	InstaCalc.description = str;
	
	x.innerHTML = txt2html(InstaCalc.description);
  }
  
  // convert to html -- allow links and newlines
  
  // TODO: Make sure this works properly!!!
  function html2txt(str){
    str = str.replace(/<a href="(https?:\S*)"[^>]*>([^<]*)<\/a>/ig, "[$2]($1)");
	
	str = unescapeHTML(str);
		
    return str;
  }
  
  // convert input into html -- "
  function txt2html(str){
    str = escapeHTML(str);
	//str = Markdown(str);
	//str = DoAnchors(str);
	//str = str.replace(/\[(\w*)\]\s*[(](https?:\S*)[)]/ig, "<a href=\"$2\">$1</a>");
	str = str.replace(/\[([^\]]*)\]\s*[(](https?:\S*)[)]/ig, "<a href=\"$2\" target=\"_blank\">$1</a>");
	
	return str;
  }
    
  function escapeHTML(str){
		return str.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g," <br/> ");
  }  
  
  function unescapeHTML(str){
		return str.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/\s?<br[\/]?>\s?/ig,"\n");
  }
	  
  function loadDescription(){
    var x = document.getElementById("descriptiontext");
	var y = document.getElementById("descriptiontextarea");
	
	//tmp = x.innerHTML;
	//y.value = tmp;
	
	y.value = html2txt(x.innerHTML);
	InstaCalc.description = html2txt(x.innerHTML);
  }
  
  function createDeliciousLink(){
   var tags = "&tags=instacalc";
   var title = "&title=InstaCalc:%20";
   var ending = "&noui&jump=close&v=4";
   //var description = InstaCalc.description;
   
   createURL();
   var link = "http://del.icio.us/jshell.com?url=" + 
		InstaCalc.permalink.replace(/&/g, "%3D") + title + tags + ending; // need to replace &; not meant for delicious
		
   return link;
}

function createEmbedURL(){
  createURL();
  return InstaCalc.embedlink;
}