window.addEvent('load', function() {
	styleImages(Array('.blockContent', '.blockProject', '.blockContact'));
});

function styleImages(blockType) {
	
	for(i=0; i < blockType.length; i++) {
		
		$$(blockType[i] + ' img').each(function(el) {
			
			if(!el.getParent().getProperty('class').contains("styledImage")) {
						
				var imageWidth = el.offsetWidth;
				var imageHeight = el.offsetHeight;
				
				var imageClass = '';
				
				if(el.getProperty('class'))	{
					
					var imageClass = ' ' + el.getProperty('class');
					el.removeProperty('class');
				
				}
				
				if(el.getProperty('align') && el.getProperty('align') != 'undefined') {
					
					var imageClass = ' ' + el.getProperty('align');
					el.removeProperty('align');
					
				} 
				
				var imageWidth = el.offsetWidth;
				var imageHeight = el.offsetHeight;
				
				var styledImage = new Element('div').addClass('styledImage' + imageClass).setStyles({width: imageWidth, height: imageHeight}).injectBefore(el).adopt(el);
				
				if(window.gecko) {
					
					el.setStyle('margin', '0 0 -5px 0');
					$(styledImage).setStyles({height: ''});
					
				}
				
				var imgTop = new Element('span').addClass('imgTop').injectInside(styledImage);
				var imgRight = new Element('span').addClass('imgRight').injectInside(styledImage);
				var imgBottom = new Element('span').addClass('imgBottom').injectInside(styledImage);
				var imgLeft = new Element('span').addClass('imgLeft').injectInside(styledImage);
				
				var imgTopLeft = new Element('span').addClass('imgTopLeft').injectInside(styledImage);
				var imgTopRight = new Element('span').addClass('imgTopRight').injectInside(styledImage);
				var imgBottomRight = new Element('span').addClass('imgBottomRight').injectInside(styledImage);
				var imgBottomLeft = new Element('span').addClass('imgBottomLeft').injectInside(styledImage);
				
				if(window.ie6) {
					
					var imageHeight = el.offsetHeight;
				
					$(imgTop).setStyle('width', '100%');
					$(imgRight).setStyle('height', imageHeight);
					$(imgBottom).setStyle('width', '100%');
					$(imgLeft).setStyle('height', imageHeight);
					
					$(imgBottomRight).setStyle('bottom', '-6px');
					$(imgBottom).setStyle('bottom', '-6px');
					$(imgBottomLeft).setStyle('bottom', '-6px');

				}
			
			}
		
		});	
	
	}

}
