$(document).ready(function(){
	$('.rounded10').corner("round 10px");
	$('.rounded5').corner("round 5px");
	$('.rounded3').corner("round 3px");
	
	$('.rounded10right').corner("tr").corner("br");

    $(".scrollable").smoothDivScroll({
        scrollingSpeed: 12, 
        mouseDownSpeedBooster: 3, 
        autoScrollSpeed: 2, 
        visibleHotSpots: "always",
        startAtElementId: "galleryStart"
        });
        
// выделение для таблиц 
    $('.highlight tr').each(function(index) {
       $(this)
        .mouseover(function () {
            $(this).children('.light_on').attr('class','light_td');
        })
        .mouseout(function () {
            $(this).children('.light_td').attr('class','light_on');
        })
    });
});



function getPhoto(id, gallery_id, direction)
{
	$.post(
		'/ajax.php?action=Gallery',
		{'mod': 'getPhoto', 'photo_id': id, 'gallery_id': gallery_id, 'direction': direction},
		function (data) {refreshPhoto(data);},
		'json'
	);
}

function navigate(gallery_id, direction)
{
	$.post(
			'/ajax.php?action=Gallery',
			{'mod': 'navigatePhoto', 'photo_id': $('#currentPhoto' + gallery_id).val(), 'gallery_id': gallery_id, 'direction': direction},
			function (data) {refreshPhoto(data);},
			'json'
		);
}

function refreshPhoto(data)
{
	if (data)
	{
		$('#gallery' + data.gallery_id + ' > .block').css('background-image', 'url(\'/' + data.url.big + '\')');
		$('#title' + data.gallery_id).html(data.title);
		$('#desc' + data.gallery_id).html(data.description);
		$('.galleryPreview' + data.gallery_id + ' > .photo').removeClass('selected');
		$('#galleryPreview' + data.photo_id + ' > .photo').addClass('selected');
		$('#currentPhoto' + data.gallery_id).val(data.photo_id);
        if(data.label.length>0)
        {
            $('#zoom' + data.gallery_id + ' > a').attr('href', '/photo_' + data.photo_id + '_' + data.label + '.html');            
        }
        else{
            $('#zoom' + data.gallery_id + ' > a').attr('href', '/photo_' + data.photo_id + '.html');                
        }
        
	}
}
