
	document.observe("dom:loaded", function(){
	
		if ($('image_header')){
		
			// Assign the whole of the image header with the link of the active item
			$('image_header').observe('click', function(){
				var active = $('image_header').select('div.right_panel div.active a')[0];
				if (active)
				{
					var href = active.getAttribute('href');
					var blank = active.getAttribute('class');
					if (blank == 'blank'){
						window.open(href);
					} else {
						window.location = href;
					}
				}
			});
			
			
			$('image_header').select('div.right_panel div.text').each(function(element, key){
				
				var panels = $('image_header').select('div.left_panel div.text');
				
				// Add a dummy "Read more..." link to each legy panel
				var a = new Element('a');
				a.insert('Read more &raquo;');
				panels[key].insert(a);
				
				element.observe('mouseover', function(){
					
					// deactivate the currently active title
					var active = element.adjacent('div.active')[0];
					if (active){ active.removeClassName('active'); }
					
					// Activate this title
					element.addClassName('active');
					
					// Hide all description panels and show the one which corresponds to this element
					panels.invoke('hide');
					panels[key].show();
					
					
					var file_name = element.down('a').getAttribute('rel');
					var src = '/assets/file_uploads/m_dynamicheader_items_image/950x270/';
					$('image_header').down().setStyle({'backgroundImage': 'url("' + src + file_name + '")'});
					
				});
				
			});
		
		}
	
	});

