var helper = {

	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'), '');
					}
				}
			}
		}		
	},

	/**
	* @author	Michael Birchler
	* @Description	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 ? continue : return;
				var fileType = image.src.substring(image.src.length-3).toUpperCase();
				if(fileType !='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);
	},
	
	/**
	* @param	int
	* @param	int
	* @param	int
	* @return	scaled imagesSize proportional 
	*/
	imageScale : function (orginalWidth, orginalHeight, desiredWidth) {

		var scaleRatio = orginalWidth/orginalHeight;
		if(desiredWidth) var desiredSize = (orginalWidth>orginalHeight) ? desiredWidth/scaleRatio : desiredWidth*scaleRatio;
		
		var roundedVal = Math.floor(desiredSize);		
		
		return roundedVal;		
	},
	
	/**
	* @author	Jonas Raoni Soares Silva
	*
	* @param	array
	* @return	shuffled array
	*/
	arrayShuffle : function(o){
		for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
		return o;
	}
};