$(document).ready(function(){

	$("#victims_controller").jFlow({
		slides: "#victimsslides",
		controller: ".victims_controller_dot", // must be class, use . sign
		slideWrapper : "#victimsSlide", // must be id, use # sign
		selectedWrapper: "victims_controller_dot_selected",  // just pure text, no sign
		auto: true,		//auto change slide, default true
		width: "860px",
		height: "175px",
		duration: 400,
		prev: ".victims_controller_prev", // must be class, use . sign
		next: ".victims_controller_next" // must be class, use . sign
	});


	$("#asylum_controller").jFlow({
		slides: "#asylumslides",
		controller: ".asylum_controller_dot", // must be class, use . sign
		slideWrapper : "#asylumSlide", // must be id, use # sign
		selectedWrapper: "asylum_controller_dot_selected",  // just pure text, no sign
		auto: true,		//auto change slide, default true
		width: "410px",
		height: "138px",
		duration: 400,
		prev: ".asylum_controller_prev", // must be class, use . sign
		next: ".asylum_controller_next" // must be class, use . sign
	});

	$("#graves_controller").jFlow({
		slides: "#gravesslides",
		controller: ".graves_controller_dot", // must be class, use . sign
		slideWrapper : "#gravesSlide", // must be id, use # sign
		selectedWrapper: "graves_controller_dot_selected",  // just pure text, no sign
		auto: true,		//auto change slide, default true
		width: "410px",
		height: "138px",
		duration: 400,
		prev: ".graves_controller_prev", // must be class, use . sign
		next: ".graves_controller_next" // must be class, use . sign
	});

	$("#terror_controller").jFlow({
		slides: "#terrorslides",
		controller: ".terror_controller_dot", // must be class, use . sign
		slideWrapper : "#terrorSlide", // must be id, use # sign
		selectedWrapper: "terror_controller_dot_selected",  // just pure text, no sign
		auto: true,		//auto change slide, default true
		width: "290px",
		height: "320px",
		duration: 400,
		prev: ".terror_controller_prev", // must be class, use . sign
		next: ".terror_controller_next" // must be class, use . sign
	});

	
});

var timer = -1; 

/**
 * We use the initCallback callback
 * to assign functionality to the controls
 */


function slideSwitch(){
var imgTitle = '';
var imgAlt = '';
var $active = $('.image_thumb ul li.active');

var olddesc = $active.find('.block').html();
$active.removeClass('active last-active');
if ( $active.length == 0 ) $active = $('.image_thumb ul li:last');
var $next =  $active.next().length ? $active.next() : $('.image_thumb ul li:first');
$next.css({opacity: 1.0})
.addClass('active')
/*	
.animate({opacity: 1.0}, 1000, function() {
$active.removeClass('active last-active');
});
$next.animate({ opacity: 1}, 1000 );
*/	
//$(".main_image img").animate({opacity: 0}, 500 );
$(".main_image img").hide()
$(".main_image img").fadeIn(1000)
$(".main_image img").attr({ src: "" , alt: ""});	
var imgAlt = $next.find('img').attr("alt"); //Get Alt Tag of Image
var imgTitle = $next.find('.mainimg').attr("href"); //Get Main Image URL
var imgDesc = $next.find('.block').html(); 	//Get HTML of block
var imgDescHeight = $(".main_image").find('.block').height();	//Calculate height of block	
$(".main_image img").attr({ src: imgTitle , alt: imgAlt});	
$(".main_image img").animate({ opacity: 1.0}, 500 );
$(".main_image .block").html(olddesc);

$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 500 , function() {
$(".main_image .block").html(imgDesc).animate({ opacity: 0.85,	marginBottom: "0" }, 500 );
//$(".main_image .block").html(imgDesc).animate({ opacity: 0.85,	marginBottom: "0" }, 1000 );
/*
$(".main_image img").attr({ src: imgTitle , alt: imgAlt}).animate({ opacity: 1}, 1000 );
$(".main_image img").animate({ opacity: 1.0}, 1000 );;
*/	
});

}

$(document).ready(function(){
timer = setInterval( "slideSwitch()", 5000 );


$(".block").hover(
  function () {
	window.clearInterval(timer);
  }, 
  function () {
	timer = setInterval( "slideSwitch()", 5000 );
  }
);

// show banner

$(".main_image .desc").show(); //show banner
$(".main_image .block").animate({ opacity: 0.85 }, 1 ); //set opacity

// click and hover events for thumbnail list

$(".image_thumb ul li:first").addClass('active'); 
$(".image_thumb ul li").click(function(){ 

// set variables

var imgAlt = $(this).find('img').attr("alt"); // get alt tag of image
var imgTitle = $(this).find('.mainimg').attr("href"); // get main image url
var imgDesc = $(this).find('.block').html(); 	// get html of block
var imgDescHeight = $(".main_image").find('.block').height();	// calculate height of block	
if ($(this).is(".active")) {  // if it's already active, then...
return false; // don't click through
} else { 

// animate the teaser	
$(".main_image img").attr({ src: imgTitle , alt: imgAlt});		
$(".main_image img").hide()
$(".main_image img").fadeIn(1000)
//$(".main_image img").animate({ opacity: 0}, 500 );
//$(".main_image img").animate({ opacity: 1.0}, 500 );
$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 500 , function() {
$(".main_image .block").html(imgDesc).animate({ opacity: 0.85,	marginBottom: "0" }, 500 );
//$(".main_image .block").html(imgDesc).animate({ opacity: 0.85,	marginBottom: "0" }, 1000 );
/*
$(".main_image img").attr({ src: imgTitle , alt: imgAlt}).animate({ opacity: 1}, 1000 );
$(".main_image img").animate({ opacity: 1.0}, 1000 );;
*/	
});

}
		
$(".image_thumb ul li").removeClass('active'); // remove class of 'active' on all lists
$(this).addClass('active');  // add class of 'active' on this list only
window.clearInterval(timer);
return false;
}) .hover(function(){
$(this).addClass('hover');
}, function() {
$(this).removeClass('hover');
});
			
// toggle teaser
$("a.collapse").click(function(){
$(".main_image .block").slideToggle();
$("a.collapse").toggleClass("show");
});
});

function init()
{
document.getElementById("loading").style.display = "none"
document.getElementById("recent_victims").style.height = ""
document.getElementById("recent_victims").style.visibility = "visible"
$("#victimsslides").fadeIn(500)
}
window.onload = init;

function openDivBlog(id, total) {
document.getElementById('close_blog_'+id).style.display = 'none';
document.getElementById('open_blog_'+id).style.display = 'block';
for(i=1; i<=total; i++) {
if(i != id) {
document.getElementById('open_blog_'+i).style.display = 'none';
document.getElementById('close_blog_'+i).style.display = 'block';
}
}
}