// JavaScript Document
/*function cornerize() {
	imgl = document.images.length;
	for (i = 0; i <imgl; i++) {
		if (document.images[i].height > 30) {
			creatediv("corner");
			alert(document.images[i].style.left)
		}
	}
}

function creatediv(id,what) {

   var newdiv = document.createElement('div');
   newdiv.setAttribute('id', id);
   newdiv.style.width = "100px";
   newdiv.style.height = "100px";
   newdiv.style.background = "#00C";
   newdiv.style.border = "4px solid #000";
   newdiv.style.position = "absolute";
   newdiv.style.left= "0";
   newdiv.style.top = "0"
   document.body.appendChild(newdiv);

} */

function cornerize() {
		
 var content = document.getElementById('mainborder');
 var imgs = content.getElementsByTagName('img');
 
 for (var i = 0; i < imgs.length; i++) {         // start loop 
	if (parseInt(imgs[i].height) > 40 && imgs[i].src != "http://www.elektramontreal.ca/images/spacer.gif") {
   var wrapper = document.createElement('div');  // Create the outer-most div (wrapper)
   wrapper.className = 'wrapper';        
   if (imgs[i].width > 370) {// Give it a classname - wrapper
     wrapper.style.width = '370px';     // give wrapper the same width as the current img
   } else {
	   	wrapper.style.width = imgs[i].width+'px';
   }
   var original = imgs[i];                       // take the next image  
   /* Swap out the original img with our wrapper div (we'll put it back later) */
   if(original.parentNode.tagName.toUpperCase()=='A') original = original.parentNode; // if you link the image this will help the script find the right parent wrapper
   original.parentNode.replaceChild(wrapper, original);
   // IE crash fix - c/o Joshua Paine - http://fairsky.us/home
   // Create the four other inner nodes and give them classnames 
   var tl = document.createElement('div');
   tl.className = 'white_corner';
   /*
   var br = document.createElement('div');
   br.className = 'br';
   var tr = document.createElement('div');
   tr.className = 'tr';
   var bl = document.createElement('div');
   bl.className = 'bl';
    Glue the nodes back inside the wrapper 
	*/
   wrapper.appendChild(tl);
   /*wrapper.appendChild(tr);
   wrapper.appendChild(bl);
   wrapper.appendChild(br);*/
   /*And glue the img back in after the DIVs */
   wrapper.appendChild(original);
   }
 }
}
/* Run the function once the page has loaded: */
