var currentImage;
var currentIndex = -1;
var interval;
function showImage(index){
    if(index < $('#bigPic img').length){
        var indexImage = $('#bigPic img')[index];
        if(currentImage){   
            if(currentImage != indexImage ){
                $(currentImage).css('z-index',2);
                clearTimeout(myTimer);
                $(currentImage).fadeOut(800, function() {
                    myTimer = setTimeout("showNext()", 6000);
                    $(this).css({'display':'none','z-index':1})
                });
            }
        }
        $(indexImage).css({'display':'block', 'opacity':1});
        currentImage = indexImage;
        currentIndex = index;
        $('#thumbs li').removeClass('active');
        $($('#thumbs li')[index]).addClass('active');
    }
}
 
function showNext(){
    var len = $('#bigPic img').length;
    var next = currentIndex < (len-1) ? currentIndex + 1 : 0;
    showImage(next);
}

function showPrev(){
    var len = $('#bigPic img').length;
    var prev = currentIndex == 0 ? (len-1) : currentIndex - 1 ;
    showImage(prev);
}
 
var myTimer;
 
$(document).ready(function() {
    myTimer = setTimeout("showNext()", 6000);
    showNext(); //Load first image
    $('#thumbs li').bind('click',function(e){
        var count = $(this).attr('rel');
        showImage(parseInt(count)-1);
    });
});

$(document).ready(function() {
	$('#content_list a').click(function(){
		var content = "div ."+$(this).attr('class');
		$('#popUpMessage div').hide();
		$(content).fadeIn('slow');
		$('#content_wrap a').removeClass('active_content_list');
		$(this).addClass('active_content_list');
		
    });
});

/*$(document).ready(function() {
        $('title').html($('#page_title').val());
		
    });*/

/*//Z-index correction
$(document).ready(function() {
	var zIndexNumber = 1000;
	$('div').each(function() {
		$(this).css('zIndex', zIndexNumber);
		zIndexNumber -= 10;
	});
});

//Z-index correction
$(document).ready(function() {
	var zIndexNumber = 1000;
	$('ul').each(function() {
		$(this).css('zIndex', zIndexNumber);
		zIndexNumber -= 10;
	});
});

//Z-index correction
$(document).ready(function() {
	var zIndexNumber = 1000;
	$('div#popUpMessage div').each(function() {
		$(this).css('zIndex', zIndexNumber);
		zIndexNumber -= 10;
	});
});*/
