/**
*Random Image Selector
*
*@author: Zinj Guo <recoilfx@gmail.com>
*@version: 1.0
*@Copyright: 2008, MIT License  http://www.opensource.org/licenses/mit-license.php
*Dependencies: mootools - core, element
*target= element to be modified by Rnadom Image Selector
*imgArray = array that contains paths of the images
*bgFlag = set true to make the image as background than inserting an img element inside the target
*
*@example var myImg = new randomImage(myElement, ["path/to/image.jpg", "path/to/image2.jpg", "path/to/image3.jpg"], false);
*/
randomImage = new Class({
		initialize: function(target, imgArrayArg, bgFlag){
			this.srcObj;
			srcObj=this.srcObj;
			
			this.imgArray = new Array();
			imgArray=this.imgArray;
			if(!$defined(bgFlag)){bgFlag=false;}
			
			this.imgSrc;
			curSrc=this.imgSrc
				
			if($type(target)=="string"){
				srcObj=$(target);
			}else{
				srcObj=target;
			}
		
			imgArrayArg.each(function(item){
				imgArray.push(item)
			})
			
			this.imgSrc=imgArray[$random(0, imgArray.length-1)];
			
			if(!bgFlag){
				this.curImg = new Element("img", {
					"src": this.imgSrc
				});
				this.curImg.injectInside(srcObj);
			}else{
				srcObj.setStyle("background", "url('"+this.imgSrc+"')");
				}
			
		},
		
		getImage:function(){
			return this.imgSrc;
		}
		
	})