﻿function convertimages_broken()
{
	//must be put at the very end of the body of the page
	var images = document.getElementsByTagName("img");
	for (x in images)
	{
		var image = images[x];
			if (image.className == "slimboxed")
			{
				var source = image.getAttribute("src");
         		image.setAttribute("class","hello");
         		document.writeln(source);
         		newEl = document.createElement("a");
		        newEl.setAttribute("src",source);
		        var temp = document.getElementsByTagName("body")
	            temp[0].insertBefore(newEl,image);
	            newEl.innerHTML = '<img src="'+source+'"/>';
				
				
				var estring = image.innerHTML.toString();
				var index = estring.indexOf("at");
				var namestring = estring.slice(0,index);
				var emailstring = estring.slice(index+2);
				
				var fEmail = namestring+'@'+emailstring;
				image.innerHTML = '<a href="mailto:'+fEmail+'">'+fEmail+'</a>';
			}
		
	}
}

function convertimages2_broken()
{
  $(document).ready(function ()
  {
    $('a[rel=lightbox]').click(function (e)
    {
        var a = $(this);
        var href = a.attr('href');

        // do something to add slimbox to the link/image

        e.preventDefault();
    });
});
}

function slimboxImages()
{
	//must be put at the very end of the body of the page
   var images = document.getElementsByTagName("span");
   for (x in images)
   {
      var span = images[x];
      if (span.className == "slimboxed")
      {
         image = span.innerHTML;
         
         var reg = /\s/g;
         var innerstring=image.toString().replace(reg,"");
         
         
         var index = innerstring.indexOf("src");
         var sliced = innerstring.slice(index+5);
         var index2 = sliced.indexOf('"');
         var src = sliced.slice(0,index2);
         
         newstr = '<a href="'+src+'?mw=640" rel="lightbox"><img src="'+src+'?mw=520" /></a>'
         span.innerHTML = newstr;
         

/*
         var nource = image.nodeType
         image.setAttribute("class","hello");
         document.writeln(source);
         document.writeln(nource);
         image.innerHTML="<p>hi</p>";


         newEl = document.createElement("a");
         newEl.setAttribute("href",source);
         newEl.setAttribute("rel","testtest");

         newImg = document.createElement("img");
         newImg.setAttribute("src",source);

         newEl.appendChild(newImg);
         body[0].insertBefore(newEl,image);

*/
      }
   }
}
