var isMSIE = function() {
     return navigator.appVersion.indexOf("MSIE") != -1;
};

var protectImages = function() {
        if( pageIsBlog ) {
                var blogImages = $('content').getElements('img');
                blogImages.each( function(el) {
                        //the navigation buttons don't format well if their image is protected, so here's a hack to prevent that
                        if( !el.getParent().hasClass('navigationButton') ) {
                                  el.addClass('protect');
                        }
                        })
        }

	var images = $$('img.protect');
	
	images.each(function(el) {
		if( isMSIE() ) {
			var height = el.offsetHeight + 'px';
			var width = el.offsetWidth + 'px';
		}
		else {
			var height = el.getStyle('height');
			var width = el.getStyle('width');
		}
		
		//if(showHeight) {
		//	alert("el: " + el +" height: " + height + " getClass: " + el.get('class'));
		//}
		
		var heightNum = parseInt(height);
		var widthNum = parseInt(width);
		
		var coverElement  = new Element('img');
		coverElement.set('class', 'coverImage');
		coverElement.set('src', 'http://anagram-press.com/images/dontDoThat.gif');
		/*
		coverElement.set('height', height);
		coverElement.set('width', width);
		*/
		coverElement.setStyle('height', height);
		coverElement.setStyle('width', width);
		
		
		if( el.hasClass('moveHorizontal')) { //coverImage is initially placed to the real of the real image, and then moved leftwards 
			coverElement.setStyle('position', 'relative');
			coverElement.setStyle('left', (-1 * widthNum) + 'px');
			coverElement.setStyle('margin-right', (-1 * widthNum) + 'px');
		}
		else if( el.hasClass('absoluteCover') ) {  //cover image is place directly over the real image, using absolute positioning
			coverElement.setStyle('position', 'absolute');
			coverElement.setStyle('top', '0px');
			coverElement.setStyle('left', '0px');
			coverElement.setStyle('z-index', '3');
		}
		else {//default: the coverImage is initially placed below the real image, and then moved upwards 
			coverElement.setStyle('position', 'relative');
			coverElement.setStyle('top', (-1 * heightNum) + 'px');
			coverElement.setStyle('margin-bottom', (-1 * heightNum) + 'px');
			coverElement.setStyle('display', 'block');
		}
		
		coverElement.inject(el, 'after');
	});
};


//if( !isMSIE() ) {
  window.addEvent('load', function() {
	protectImages();
  });
//}
