window.addEvent('domready',function(){

var p = new Array();
$$('a').each(function(el){
		
		var obj = el.getAttribute('title');
		if(obj != null){
			if(obj.indexOf('.jpg') != -1 || obj.indexOf('.png') != -1 || obj.indexOf('.gif') != -1 ){
				var x = new Image();
				x.src = obj;
				p.push(x);
			}
			
			if(obj.indexOf('.pdf') != -1){
				var y = new Element('embed');
				y.src = obj;
				p.push(x);
			}
			
			if(obj.indexOf('.swf') != -1){
				var container = new Swiff(obj);
				p.push(container);
			}
			
			
			
		}
		
 })


$$('#right a').addEvent('click',function(el){ // #right a -> adjust this to your needs
	if(this.getAttribute('rel') == "bumpbox"){

	el.stop();
	topPos = window.getScrollTop();
	
	// GET THE DEFINED SIZE FOR THE BOXES
	sizes = this.getAttribute('rev');
	
	if(sizes != null){
		sizes = sizes.split(" ");
		width = sizes[0];
		height = sizes[1];
	}
	// DARK BACKGROUND
	overlay = new Element('div', {
		styles: {
					'visiblity':'hidden',
					'z-index':'0',
					'top':topPos,
					'padding-bottom':'0px',
					'background':'#000000 no-repeat bottom right',
					'z-index':'0'
		}
   })
	
	overlay.setAttribute('id', 'overlay');
	var p = $('container');
	overlay.injectBefore(p);
	overlay.setStyle('z-index',0);
	overlay.effect('opacity').set(0.9);
		
	nav = navigator.appName;
	if(nav.indexOf('Microsoft') != -1){
		if(navigator.appVersion.indexOf('MSIE 6') != -1){
			windowHeight =  document.body.clientHeight;
			windowWidth = document.body.clientWidth;
			scrollTopPos = window.getScrollTop();
			$('overlay').setStyle('height', windowHeight+70+scrollTopPos);
			$('overlay').setStyle('width', windowWidth+10);
		}
	
	}else{
				coords = window.getCoordinates();
				windowHeight = coords['height'];
				windowWidth  = coords['width'];
				scrollTopPos = window.getScrollTop();
	}

	div = new Element('div', {
				styles: {
						
							'padding':'10px',
							'background':'#000000',
							'border':'0px solid #ffffff',							
							'visibility':'hidden'	
							
						
				}
	  })
			
			

		div.setAttribute('id','bumpbox');
		div.injectAfter(this);		
		obj = this.getAttribute('title');
		
		if(obj.indexOf('.pdf') != -1){			
			var container 	= new Element('embed');
			container.src 	= obj;
			sizes 			= this.getAttribute('rev');
	
			if(sizes != null){
				sizes = sizes.split(" ");
				width = sizes[0];
				height = sizes[1];
			}
			
			container.set('width',width);
			container.set('height',height);
			container.injectInside(div);
			div.setStyle('width',width);
			
		}
		
			if(obj.indexOf('.swf') != -1){
			var container 	= new Swiff(obj, {
					styles: {
							'width':width,
							'height':height
					},
					params: {
						
							'height':height,
							container: div,
							'width':width,
							'src':obj
					}
		 })

					container.src = obj;
					container.set('width',width);
					container.set('height',height);
					height = container.getStyle('height').toInt();
					container.injectInside(div);
						
			
		}
		
		if(obj.indexOf('.jpg') != -1 || obj.indexOf('.png') != -1 || obj.indexOf('.gif') != -1 ){
			var container = new Element('img');
			container.src = obj;		
			width = container.width;
			height = container.height;		
			container.set('width',width);
			container.set('height',height);
			div.setStyle('height',height);
			container.injectInside(div);
		}
		
		var v = new RegExp();
	    v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$"); 
		isURL = (v.test(obj));
		
		if(isURL){
			var container = new Element('iframe');
			container.src = obj;
			container.setStyle('overflow','auto');
			container.set('border','none');
			container.set('width',width);
			container.set('height',height);
			container.injectInside(div);
			
	}
		closebtn = new Image();
		closebtn.src = 'http://www.tkorlando.com/THR/ThickBoxScripts/close.jpg';
		closebtn.setStyle('float','right');
		closebtn.setStyle('margin','10px 0 0 0');

		closebtn.injectAfter(container);
	
		totalLeft = ((windowWidth) - width) / 2;
		div.setStyle('left',totalLeft + "px");
		div.setStyle('width', width + "px");
		div.setStyle('height', height + "px");
		container.setStyle('width', width);
		container.setStyle('height',height);
		
		scrollTopPos = window.getScrollTop();
		
		
			div.effect('top',{ duration: 300, transition: Fx.Transitions.Bounce.easeOut, wait: false}).start(0,0+scrollTopPos);
	div.effect('opacity',{ duration: 300, transition: Fx.Transitions.linear, wait: false, delay: 1000  }).start(0,1);	
	
		div.addEvent('click',function(){
			this.effect('opacity',{duration: 300, transition: Fx.Transitions.Bounce.easeIn, wait:true }).start(1,0);
			overlay.effect('opacity',{duration: 300, transition: Fx.Transitions.Bounce.easeIn, wait:true }).start(1,0).chain(function(){
			overlay.remove();
			$('bumpbox').remove();
			})
		})
		this.stop;
		
  }
	return false;
})
})