function initPopup(){
	$('a.diagram-opener').each(function(){
		$(this).click(function(){
			var _scroll = $(window).scrollTop();
			var _href = $(this).attr('href');
			$('.popup').hide();
			var _popup = $(_href);
			_popup.css('top', _scroll);
			_popup.show();
			var _closer = _popup.find('div.popup-holder');
				_closer.click(function(){
					_popup.hide();
					return false;
				})
			return false;
		});
	});
	
};

function initSlide() {
    var _tab_box = $('.tab-box').eq(0),
        _tab_box_top = _tab_box.position().top;
        _tab_box_small = $('.tab-box-min').eq(0).show(),
        _tab_box_small_top = _tab_box_small.position().top;
        _speed = 1000,
        _info = _tab_box.find('.info').eq(0),
        _popup = $('.popup').eq(0).hide(),
        _popup_close = _popup.find('.close>a'),
        _close_link = _tab_box.find('.no-thanks').eq(0);

        _tab_box_small.hide();
        _close_link.click(function(){
            _tab_box.animate({
                'top': _tab_box_small_top
            },_speed,function(){
                $(this).hide();
                _tab_box_small.show();
                $('.footer-area').addClass('collapse');
            });
            return false;
        });
        _tab_box_small.click(function(){
            $(this).hide();
            $('.footer-area').removeClass('collapse');
            _tab_box.show().animate({
                'top': _tab_box_top
            },_speed);
            return false;
        });
        _info.click(function(){
            _popup.show();
            return false;
        });
        _popup_close.click(function(){
            _popup.hide();
            return false;
        });
}


	
$(document).ready(function(){
	initPopup();
    initSlide();
});


