	jQuery.fn.overlay=function() {
		var el=jQuery(this);
		jQuery('body').prepend('<div id="overlay"></div>');
		jQuery('#overlay').click(function(){ el.hide();el.parents('tr').removeClass('gr_tr');$('#overlay').remove();});
		jQuery('#overlay').show('slow');
		return this;
	}


jQuery(document).ready(function(){
	/* popups */
	
	jQuery('#link-other-pro').click(function(){
		jQuery('#pp-other-pro').overlay().css({top:0,left:getAbsolutePosition(this).x-10}).show();
		return false;
	});
	jQuery('.tpassport-login .enter').click(function(){
		jQuery("#pp-login").overlay().css({left:getAbsolutePosition(this).x-190}).show();
		return false;
	});
	jQuery('.tpassport-login .logo').click(function(){
		jQuery('#pp-login-about').overlay().css({left:getAbsolutePosition(this).x-230}).show();
		return false;
	});
	jQuery('#link-video').click(function(){
		jQuery('#pp-video').overlay().css({left:getAbsolutePosition(this).x-8,top:getAbsolutePosition(this).y-6}).show();
		return false;
	});
	jQuery('#link-phone').click(function(){
		jQuery('#pp-offices').overlay().css({right:5,top:getAbsolutePosition(this).y}).show();
		return false;
	});
	
	jQuery('.help').click(function(){
		jQuery('#pp-help').overlay().css({left:getAbsolutePosition(this).x-8,top:getAbsolutePosition(this).y-7}).show();
		return false;
	});
	jQuery('#pp-help h3').click(function(){
		jQuery(this).parents("div").hide(); //предполагается, что родительский div только один
		jQuery('#overlay').remove();
		return false;
	});
	
	jQuery('.close_pp,.pp-small-gray h3').click(function(){
            jQuery(this).parents("div:eq(0)").hide();
            jQuery('#overlay').remove();
            return false;
        });
	
	
	
		
	
	/* select */
	jQuery('#year').change(function(){
		jQuery('.hide_ny').show();
		return false;
	});
	
	/* tabs */
	jQuery('.page-tabs li').click(function(){
		jQuery(this).siblings().removeClass('active').end().addClass('active');
		jQuery('.page-tab').hide().eq(jQuery('.page-tabs li').index(this)).show();
	});
	
	jQuery('.link-toggle').click(function(){
		jQuery('.block-toggle').eq(jQuery('.link-toggle').index(this)).toggle();
		return false;
	});
	

	
	jQuery('.add_ta_city[@value="1"]:option').change(function(){
		jQuery(this).siblings('.add_ta_city').show();
	if ( jQuery(this).val() != 1 )
		jQuery(this).siblings('.add_ta_city').hide();
		return false;
	});		
	jQuery('.spo_type[@value="1"]:option').change(function(){
		jQuery(this).siblings('.spo_price').show();
	if ( jQuery(this).val() != 1 )
		jQuery(this).siblings('.spo_price').hide();
		return false;
	});
	
});
