/**
 * @author Szymon
 */


function newZindex(){
	var highestIndex = 0;
	var currentIndex = 0;
	var elArray = document.getElementsByTagName('*');
	for(var i=0; i < elArray.length; i++){
	  if (elArray[i].currentStyle){
	     currentIndex = parseFloat(elArray[i].currentStyle['zIndex']);
	  }else if(window.getComputedStyle){
	     currentIndex = parseFloat(document.defaultView.getComputedStyle(elArray[i],null).getPropertyValue('z-index'));
	  }
	  if(!isNaN(currentIndex) && currentIndex > highestIndex){ highestIndex = currentIndex; }
	}
	return (highestIndex+1);
}


/**
 * hash = {name:{
 * 				src:'',
 * 				url:'',
 * 				title:''}
 * 		  }
 */
function powerd(){

	var powerdby = {
		hash: {},
		cont: null,
		init: function(){
			this.hash = arguments[0];
			this.buildCont();
			for (var i in this.hash) {
				this.buildButton(this.hash[i]);
			}
		},
		
		buildCont: function(){
			this.cont = document.createElement('div');
			this.cont.style.position = "absolute";
			this.cont.style.zIndex = parseInt(newZindex());
			this.cont.style.top = "0px";
			this.cont.style.left = "0px";
			this.cont.style.width = "210px";
			this.cont.style.overflow = "hidden";
			document.body.appendChild(this.cont);
		},
		
		buildButton: function(){
			var inHash = arguments[0];
			var img = document.createElement('img');
			img.src = inHash.src;
			img.style.cursor = "pointer";
			img.style.border = "0";
			img.url = inHash.url;
			img.title = img.alt = inHash.title;
			img.onclick = function(){
				window.location.href = this.url;
			}
			this.cont.appendChild(img);
			
		}
	};
	powerdby.init(arguments[0]);
}

new powerd({dc:{
 				src:'http://img689.imageshack.us/img689/2995/powerdbydc.png',
				url:'http://devilcorp.com',
 				title:'DevilCorp'}
 		  });
