/*
 * Load persone data with nice effects
 *
 * Author:FuN_ViT
 */
function load_persone_data(holder, fio, photo, position, about)
{
	h1=$('#'+holder);
	h2=$('#'+holder+'_alt');

	//fill data - to get right height
	h2.find('.photo').html(photo);
	h2.find('.desc .name').html(fio);
	h2.find('.desc .position').html(position);
	h2.find('.desc .about').html(about);

	full_height=h2.height();
	h1.css('position','absolute');
	h2.css({'position':'relative',
		'display':'block',
		'opacity':0,
		'height':h1.height()
	});


	h1.animate({opacity:0, height: full_height}, 700, 'swing',
		function() {
			h1.css('display','none');
		}
	);
	h2.animate({opacity:1, height: full_height}, 700, 'swing', function() {
		h1.find('.photo').html(photo);
		h1.find('.desc .name').html(fio);
		h1.find('.desc .position').html(position);
		h1.find('.desc .about').html(about);

		h2.css({display:'none', opacity:0, position:'absolute', height:'auto'});
		h1.css({display:'block', opacity:'', position:'relative', height:'auto'});

	});



}

$(document).ready( function() {
	//make right menu height = main page right bkg pic height for better look
	if ($('#uslugi').height()<318)
		$('#uslugi .body').height(318-$('#uslugi .top').height()-$('#uslugi .bottom').height());

	if ($('#personal_list').length!=0)
	{
		$('#personal_list table.item').each( function () {
			//click handler
			$(this).click( function () {
				load_persone_data('full_view',
					$(this).find('div.pagetitle').html(),
					$(this).find('div.persone_photo').html(),
					$(this).find('div.persone_position').html(),
					$(this).find('div.content').html()
				);
                                $(document).scrollTo('#col1', 200);
			});
		});

		if (window.location.href.indexOf('#')) {
			$('#personal_list table.item[rel="'+window.location.href.substr(window.location.href.indexOf('#')+1)+'"]').click();
		}

	}

	//random_persone click handler
    if ($('#random_persone').length!=0) {
		$('#random_persone').click( function () {
	    	//if already on persones_list page - make a click
	    	if	($('#personal_list').length!=0)
	    		$('#personal_list table.item[rel="'+$('#random_persone').attr('rel').substr($('#random_persone').attr('rel').indexOf('#')+1)+'"]').click();
	   		//else - redirect to pesrones_list page
	   		else
				window.location.href=$('#random_persone').attr('rel');
		});
	}

});




