$(document).ready(function(){

    $('#contacts-form').ketchup();


$('a#gallery').fancybox({
				'titleShow'		: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});

	$('a[rel=gallerys]').fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});




$('a.poplight[href^=#]').click(function() {
var popID = $(this).attr('rel'); //Получить Popup Название
var popURL = $(this).attr('href'); //Get Popup href to define size

//Pull запросов и Переменные HREF URL
var query= popURL.split('?');
var dim= query[1].split('&');
var popWidth = dim[0].split('=')[1]; //Gets the first query string value

//Fade в Popup и добавить кнопку "Закрыть"
$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" border=0 class="close" ><img border=0 src="/css/close_pop.png" class="btn_close" title="Close Window" alt="Close" /></a>');

// Определяем запас на выравнивание по центру ( по вертикали по горизонтали )
var popMargTop = ($('#' + popID).height() + 10) / 2;
var popMargLeft = ($('#' + popID).width() + 80) / 2;

//Применение Margin в Popup
$('#' + popID).css({
'margin-top' : -popMargTop,
'margin-left' : -popMargLeft
});

//Fade в фоновом режиме
$('body').append('<div id="fade"></div>');
$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();
return false;
});

//Закрыть Popups и Fade слой
$('a.close, #fade').live('click', function() { $('#fade , .popup_block').fadeOut(function() {
$('#fade, a.close').remove(); });
return false;
});


 $('#slideshow').cycle({
        fx:     'fade',
        speed:  'slow',
        timeout: 3000,
        pager:  '#slider_nav',
        pagerAnchorBuilder: function(idx, slide) {
            // return sel string for existing anchor
            return '#slider_nav li:eq(' + (idx) + ') a';
        }
    });




   $('.guest1').bind("click", function(){
         
            var href = $(this).attr('href');
            $('#content').fadeOut(function(){
        	$(this).load(href+"&ajax=1",
        	    function(){
        		$(this).fadeIn();
        	})
    	    });
                 return false;
        
        
        
        });
        });



