
function resizePage(){

	var window_height = window.innerHeight || document.body.offsetHeight;
	
	var content_height = $('content').getHeight();
	if( content_height < window_height){
	
		//alert(height);
		$('content').style.minHeight = (window_height - 98) +"px";
		
	}
	$('footer').style.display = 'block';
}


window.onresize = resizePage;



	
if($('cpGallery')){
	
	var delay=7000;
	if($('cpGallery').readAttribute('delay') != null)
		delay = $('cpGallery').readAttribute('delay');

	var c=1000;
	var i=0;
	var l=0;
	
	// Smoother load on narrowband connections
	var first = 0;
	var firstImg ="";
	$$('#cpGallery div img').each(function(e) {
	
		if( first++ == 0)	
			firstImg = $(e).src;
			
		$(e).setOpacity(0.0);
	});


	var first = 0;
	$$('#cpGallery div img').each(function(e) {
		
		if( first++ == 0)
			$(e).observe('load', function(e){
				$$('#cpGallery div img').each(function(e) {
					$(e).setOpacity(1.0);
				});
			});
		else 
			$(e).setOpacity(0.0);
			
	});
	
	
	
	$$('#cpGallery div').each(function(e) {
		
		e.id = "cpGallery_" + i;
		e.setStyle({ zIndex: 0, position: 'absolute', top: '18px', left: '17px', display: 'none'});
		
		i++;
	});
	

	
	

}	

window.onload=function(){
		
		resizePage();
	
		if($('cpGallery')){
			$$('#cpGallery div img').each(function(e) {
					$(e).setOpacity(1.0);
			});
	
			cpSlideShow();
		}
};

function cpSlideShow(){
	
	if(l >= (i)) l=0;
	$("cpGallery_" + l).setStyle({ zIndex: c++, display: 'none'});
	new Effect.Appear("cpGallery_" + l, { duration: 1.0 });
	l++;
	
	setTimeout("cpSlideShow()", delay);	
}




// I bet you wish you thought of this:
$$('#nav a').each(function(e) {
	if(!location.pathname.endsWith('/') && $(e).href.match(location.pathname))
		$(e).addClassName("active");
});

