window.addEvent('domready', function(){
									 
	//switch off for IE6!!!
	// IE6 fix
	if ((Browser.Engine.trident) && (Browser.Engine.version<5)) {
		var ie = true;
	} else {
		var ie = false
	}
	
	if(ie != true) {
		// apply rollovers to all suitable elements
		applyRollovers($$(".yapb_thumbnail"));
		
		// titles right panel
		applyRollovers($$("a h2"));	
		
		// titles left panel
		applyRollovers($$("h2 a"));		

		// content images
		applyRollovers($$("a img"));
		applyRollovers($$("a.more-link"));		
		applyRollovers($$("a.web-link"));				
		
		// apply highlight
		applyHighlights($$(".commentCount"));
		
		// image links
		applyClickEffect($$("a"));
	}
	
	// clear dimmer just in case loading hangs
	var clearDimmer = function(){ 
		$('container').setStyle("opacity", 1);	
		$('loader').setStyle("display", "none");	
	};

	clearDimmer.delay(300); 

});

window.addEvent('load', function(){
	$('container').setStyle("opacity", 1);	
	$('loader').setStyle("display", "none");
});

// dim screen when links clicked
function applyClickEffect(elements) {
		elements.each(function(element, i) {		
			// exclude target blank
			var target = element.getProperty("target");
			if(target!="_blank") {
				element.addEvent("click", function() {						       
					$('container').setStyle("opacity", 0.1);	
					$('loader').setStyle("display", "block");
				});
			}
			
		});							   
}


function applyRollovers(rolloverButtons) {
		rolloverButtons.each(function(rolloverButton, i) {		
			//rollovers activate
			rolloverButton.addEvent("mouseenter", function() {
				F_addOver(this);
			});
			rolloverButton.addEvent("mouseleave", function() {						       
				F_removeOver(this);
			});	
		});
}

function applyHighlights(rolloverButtons) {
		rolloverButtons.each(function(rolloverButton, i) {		
			//rollovers activate
			rolloverButton.addEvent("mouseenter", function() {
				F_removeOver(this);
			});
			rolloverButton.addEvent("mouseleave", function() {						       
				F_addOver(this);				
			});	
			F_addOver(rolloverButton);
		});	
}

// functions for rollovers
function F_addOver(element) {
	element.setStyle("opacity", 0.7);
}
function F_removeOver(element) {
	element.setStyle("opacity", 1);	
}