var replace_time = 5000; // time in milliseconds
var prev_div;

jQuery(document).ready(function(){
	replace_pics();
	jQuery("#main_menu li").each(function(){
		jQuery(this).mouseover(function(){
			//alert(jQuery(this).attr('class'));
			//alert("#pic_" + jQuery(this).attr('class'));
			if(prev_div)
				jQuery(prev_div).animate({ backgroundPosition:"623px"}, 1000 );
			prev_div = "#pic_" + jQuery(this).attr('class');
			jQuery("#pic_" + jQuery(this).attr('class')).animate({ backgroundPosition:"0px"}, 1000 );
		})
	})
});

jQuery(document).ready(function(){

	jQuery("#main_menu ul").jFlow({
		slides: "#pic",
		controller: ".slide_button", // must be class, use . sign
		easing: "swing",
		duration: 1000,
		height: "199px",
		width: "623px"
	});

	jQuery("#antib_pics_div").cycle({
    timeout:       4000,  // milliseconds between slide transitions (0 to disable auto advance)
    speed:         1000,  // speed of the transition (any valid fx speed value)
    next:          null,  // id of element to use as click trigger for next slide
    prev:          null,  // id of element to use as click trigger for previous slide
    before:        null,  // transition callback (scope set to element to be shown)
    after:         null,  // transition callback (scope set to element that was shown)
    height:       'auto', // container height
    sync:          1,     // true if in/out transitions should occur simultaneously
    fit:           0,     // force slides to fit container
    pause:         0,     // true to enable "pause on hover"
    delay:         0,     // additional delay (in ms) for first transition (hint: can be negative)
    slideExpr:     null   // expression for selecting slides (if something other than all children is required)
});

});

function replace_pics()
{
	setTimeout(function(){
        if(jQuery('#images_div #merin_pic') && jQuery('#images_div #cargo_pic'))
        {
		    jQuery('#images_div #merin_pic').fadeIn("slow", function(){
			    jQuery('#images_div #cargo_pic').fadeOut("slow", function(){
				    setTimeout(function(){
					    jQuery('#images_div #cargo_pic').fadeIn("slow", function(){
						    jQuery('#images_div #merin_pic').fadeOut("slow", replace_pics);
					    });
				    }, replace_time);
			    });
		    });
      }
	}, replace_time);
}

