/**
 * @author Vyacheslav Glazov
 */

function init() {

	main = $( ".main-menu" ).jcarousel({
		scroll: 1
	});

	sidebar = $( ".sidebar-menu" ).jcarousel({
		scroll: 4,
		vertical: true
	});

	$.localScroll.defaults.axis = "x";
	$.localScroll.hash({
		target: ".scroll",
		queue:true,
		duration:1500
	});
	$.localScroll({
		target: ".scroll",
		queue: true,
		duration: 1500,
		hash: true,
		onBefore : mainMenuClick
	});
	
	$( ".secondary-cont" ).bind( "mouseover", function() {
		$( this ).find( ".first-img" ).hide();
		$( this ).find( "p" ).css( "bottom", "0" );
	});
	
	$( ".secondary-cont" ).bind( "mouseout", function() {
		$( this ).find( ".first-img" ).show();
		$( this ).find( "p" ).css( "bottom", "1000px" );
	});
	
}

function mainMenuClick( e, anchor, $target ) {
	if ( $( this ).not( ".blog" ) ) {
		$.post( "request.php", { id : $( this ).parent().find( "span" ).html() }, function( data ) {
			if ( !$.browser.msie ) {
				$( "title" ).html( "Olga Degtiarova: " + data );
			}
		});
	}
}

function showImage( elem, id ) {
	
	var div = $( "#" + $( elem ).attr( "class" ) );
	
	$( elem ).parents( ".sect" ).find( ".vis-cont" ).removeClass( "vis-cont" ).addClass( "hid-cont" );
	div.removeClass( "hid-cont" ).addClass( "vis-cont" ).css( "background", "url(../img/load.gif) no-repeat 50% 50%" );
	
	$.post( "request.php", { "foto-id": id }, function( data ) {
		div.css( "background", "" );
		div.html( data );
	});
	
	return false;
	
}