var helper = {

	Version: '0.6',
	extKey: 'sfpHelper',
	author: 'mbirchler@snowflake.ch',
	
	sfHover : function(idList, tagList) {  
		if(!idList || tagList) return;
		var count;
		for (count=0; count<idList.length; count++) {
			if(document.getElementById(idList[count])) {
				var sfEls = document.getElementById(idList[count]).getElementsByTagName(tagList[count]);
				for (var i=0; i<sfEls.length; i++) {
					sfEls[i].onmouseover=function() {
						this.className+=' sfhover';
					}
					sfEls[i].onmouseout=function() {
						this.className=this.className.replace(new RegExp(' sfhover\\b'), '');
					}
				}
			}
		}		
	},

	/**
	* Searches the content for elementsBySelector and substitute the images with <span style="filter>|</span>
	* @param selector expression for $$() getElementsBySelector inspired by wc_png_me_once
	*
	* @return    void
	*/
	pngTransparencyForIe6 : function (getElementsBySelector) {
		getElementsBySelector.each(function(selector) {
		
			var imgsToSubstitute = $$(selector);
			if(!imgsToSubstitute) return;
			
			imgsToSubstitute.each(function(image) {
				// is img a png?
				if(! image.src.substring(image.src.length-3,image.src.length).toUpperCase()=='PNG') return
	
				var imageDimensions = image.getCoordinates();
	                	var imageWidth = imageDimensions.width;
	                	var imageHeight = imageDimensions.height;
	                	var imageSource = image.src;
	                
	                   	 //a random number to assign to the div to make sure it is unique!
	                  	var randomNumber = helper.generateRandomNumeral();       
	                  	var imageId = 'microsoftAlphaImageLoader'+randomNumber;
	                    
	                   	var imageSpan = new Element('span', {
					'id': imageId,
					'styles': {
						'height': imageHeight+'px',
						'width': imageWidth+'px',
						'display': 'block',
						'backgroundRepeat': 'no-repeat',
						'backgroundColor': 'transparent',
						'cursor': 'hand',
						'filter': 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+imageSource+'", sizingMethod="trim")'
					}
				});
				
				
				imageSpan.inject(image, 'after');
				image.destroy();
			});
		 });
	},
	
	/**
	* @return    random number eg 2234234
	*/
	generateRandomNumeral : function () {
		return Math.floor(Math.random()*100000);
	}
};
