$(document).ready(function(){
	// count
    $("#hide").bind("click", function(e){
	hide();
    });
	$(window).bind('resize', function() {
		calc();
	});
	// also do it on page load
	
	if(! $.browser.msie){
		// we need a delay for FF
		setTimeout('calc()', 2000);
	}else{
		calc();
	}
	setTimeout('run_slides(0)', delay);
	//run_slides(0);
});
delay=10000;
fade_in_speed=1000;
fade_out_speed=1500;

function calc(){
	// get the width of the main div
	var newheight=$('#main').height();
	$('#main-left-content').css({ "height":newheight });
}

function hide(){
	$('#main-left-content').slideUp(1000, showbar());
	$('#slidedown').fadeIn(500);
}
function showbar(){
	$('#slidedown').fadeIn(1000);
}

function show(){
	$('#slidedown').fadeOut(100);
	$('#main-left-content').slideDown(1000);
}

function run_slides(id){
    var curid;
    var nextid;

    curid=id;
    nextid=id+1;
    //fade out the current one...

    $('#gimg'+curid).fadeOut(fade_out_speed, function(){
        $('#gimg'+nextid).fadeIn(fade_in_speed);
    });// when done fade in the new one...
	var maxx = $('#main').children().size(); 
    if(nextid>maxx){
        nextid=1;
    }
    // recurse
    setTimeout('run_slides('+nextid+')', delay); 
}