// SLIDESHOW //////////////////////////////////////////////////////////////

$(window).load(function(){
						   
	$('.slideshow').find('img').each(function (){
		//alert(this.width);
		if(this.height > 400){
			$(this).addClass("hFix");		
		}
		else if(this.width > 380){
			$(this).addClass("wFix");
		}
	});
	
});

function slideSwitch(id) {
	var $active = $('ul#' + id + ' li.active');
    if ( $active.length == 0 ) $active = $('ul#' + id + ' li:last');
	var $next =  $active.next().length ? $active.next()
        : $('ul#' + id + ' li:first');
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
			//$active.fadeOut('slow');
        });
}
/*
// Slideswitch mk2!!
function slideSwitch(id){
	// hide all visible slideshow images
	//$('.slideshow li').fadeOut('fast');
	// var images = $('ul#' + id + 'li');
	// $(images + ':eq(0)').fadeIn('slow');
	
	var $active = $('ul#' + id + ' li.active');
	if ( $active.length == 0 ) $active = $('ul#' + id + ' li:last');
	var $next =  $active.next().length ? $active.next()
        : $('ul#' + id + ' li:first');
	$active.fadeOut('slow');
	$active.removeClass('active')
	$next.fadeIn('slow');
	$next.addClass('active');
	
	
}
*/
/*
var intval;
var startDiv = $('div.section:first').attr("title");
intval = window.setInterval( function(){slideSwitch(startDiv)}, 4000 );
*/
$(function() {
	var startDiv = $('div.section:first').attr("title");
	intval = setInterval( function(){slideSwitch(startDiv)}, 4000 );
});

///////////////////////////////////////////////////////////////////////////////

// SECTION DIV CONTROL
$(document).ready(function(){

 	$('div.section:eq(0)').show();
	$('div.section:gt(0)').hide();
	
	$('.subMenu a').click(function (event) {
		$("div.section").fadeOut('slow');
	 	var newDiv = $(this).attr("title");
	 	$("div#" + newDiv).fadeIn('slow'); 
		event.preventDefault();	
		clearInterval(intval);
    	intval = setInterval( function(){slideSwitch(newDiv)}, 4000 );

	});
	
	$('.openTitle').click(function(event){
		event.preventDefault();
		var div = $(this).attr("title");
		$('#' + div).slideToggle("slow"); 
	});
	
	$('div.newsSection:eq(0)').show();
	$('div.newsSection:gt(0)').hide();
	
	
});






