
//jQuery.noConflict();

function toggleScroller() {
	moveScroll = Math.round(bodyHeight/2) + document.documentElement.scrollTop;
	$("#pop-contact").stop().animate({top:moveScroll+'px'},{queue:false,duration:1500,easing:'easeOutCirc'});
	if($(toggleTable).css('margin-left') != '-367px'){
		$(toggleTable).stop().animate({marginLeft:'-367px'},{queue:false,duration:1000,easing:'easeOutExpo'});
		$(toggleButton).removeClass('close');
	}
}

function popSlide(){
//	if($(toggleTable).css('margin-left') != '-367px'){
	if(document.getElementById('pop-table').style.marginLeft != '-367px'){


		$(toggleTable).stop().animate({marginLeft:'-367px'},{queue:false,duration:1000,easing:'easeOutExpo'});
		$(toggleButton).removeClass('close');
	}else{
		$(toggleTable).stop().animate({marginLeft:0},{queue:false,duration:1000,easing:'easeOutCirc'});
		$(toggleButton).addClass('close');
	}
}





function vid_iz_okonSlide(){
//	if($(toggleTable).css('margin-left') != '-367px'){
	if($('#header').css("display") == 'none')
	{
		$('#header').fadeIn(700);
		$('#vid_iz_okon_link').text('Свернуть окошко');
	}
	else
	{
		$('#header').fadeOut(700);
		$('#vid_iz_okon_link').text('Развернуть окошко');
	}
}



$(document).ready(function(){

	elem = $(window);
	toggleButton = $('#pop-contact td.toggle > a');
	toggleTable = $('#pop-contact > table');
	toggleY = elem.scrollLeft;
	bodyHeight = $(window).height();

	moveScroll = Math.round(bodyHeight/2) + document.documentElement.scrollTop;
	$("#pop-contact").css('top',moveScroll+'px');
	$(toggleTable).stop().animate({marginLeft:'-367px'},{queue:false,duration:600,easing:'easeOutExpo'});


	if($.support.noCloneEvent){ document.addEventListener('scroll',toggleScroller,false); }
	else{window.attachEvent("onscroll", toggleScroller);}

	$('#pop-contact td.toggle > a').click(function(){
		popSlide();
		return(false);
	});


	$('#perezvonit_2011_07_24').click(function(){
		popSlide();
		return(false);
	});

	$('#box-pop a.close').click(function(){
		$('#box-pop').animate({opacity:'hide'},600);
		return(false);
	});


        /** delaem back na vsu vysotu ekrana */
	var h = $(document).height();
	$('.action_bg_link').height(h);
	$('#side_actions_div').height(h);


        $('#side_actions_center_a').attr('href', $('#side_actions_a').attr('href'))



    var options = {
        target:        '#phone-send',   // target element(s) to be updated with server response
        beforeSubmit:  showRequest,  // pre-submit callback
        success:       showResponse  // post-submit callback
    };
    $('#phone-send').ajaxForm(options);

});

// pre-submit callback
function showRequest(formData, jqForm, options) {
    return true;
}
// post-submit callback
function showResponse(responseText, statusText)  {
}
		$(document).ready(function() {
			$("#panorama").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
                                'overlayColor'		: '#000',
				'transitionOut'		: 'none',
                                'overlayOpacity'	: 0.9
			});
			$("#panorama2").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
                                'overlayColor'		: '#000',
				'transitionOut'		: 'none',
                                'overlayOpacity'	: 0.9
			});
			$("#panorama3").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
                                'overlayColor'		: '#000',
				'transitionOut'		: 'none',
                                'overlayOpacity'	: 0.9
			});
			$("#panorama4").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
                                'overlayColor'		: '#000',
				'transitionOut'		: 'none',
                                'overlayOpacity'	: 0.9
			});

			$("#panorama-in-text").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
                                'overlayColor'		: '#000',
				'transitionOut'		: 'none',
                                'overlayOpacity'	: 0.9
			});



			$("#calc").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
                                'overlayColor'		: '#000',
				'transitionOut'		: 'none',
                                'overlayOpacity'	: 0.9
			});
		});
		
		
