jQuery(function(){
	$('#text_all2').hide();
    //Cufon.replace('#menu > ul > li > a, #header h3, #inner_banner a, .title h1, h2, #ops h3,.summary p, #main > ul.ul li, .total, #send_resume h3, .open_popup strong, .obg dt');
	
    Cufon.replace('.open_popup strong');
    
	/*$("#main ul.ul li").click(function () {
		$(this).siblings().removeClass('active').end().addClass('active');
		$(this).siblings().children().css('background','url(i/border_V_W.gif) repeat-y top left');
		$(this).next().children().css('background','none');
		$('#info > div').hide().eq($('#main li').index($(this))).show();
	// Cufon.replace('#main > ul.ul li');
		if ($(this).attr('id') == 'info_action') {$(this).parent().css('background','#efefef')}
		else {$(this).parent().css('background','#127042')}
		return false;
	});*/
	
	
		$("#main li.active").siblings().removeClass('active').end().addClass('active');
		$("#main li.active").siblings().children().css('background','url(i/border_V_W.gif) repeat-y top left');
		$("#main li.active").next().children().css('background','none');
		//$('#info > div').not('.index').hide().eq($('#main li').index($("#main li.active"))).show();
	//   Cufon.replace('#main > ul.ul li');
		if ($("#main li.active").attr('id') == 'info_action') {$(this).parent().css('background','#efefef')}
		else {$("#main li.active").parent().css('background','#127042')}
	
	
	$("div.moscow div:not(.flag) a, div.piter div:not(.flag) a").click(function() {
		$('.map_popup').show().children('p').text($(this).children().text()).end()
		               .children('strong').text($(this).attr('title')).end()
		               .css({
                           'visibility': 'visible',
                           'left'      : $(this).position().left + ($(this).width()/2) + 'px',
                           'top'       : $(this).position().top - $('.map_popup').height() + 'px'
                       });
		return false;
	});
	
	$("div.moscow a.flag").hover(
		function() {
		$('.map_popup').show().children('p').hide().end()
		               .children('strong').text($(this).attr('title')).end()
		               .css({
                           'visibility': 'visible',
                           'left'      : $(this).position().left + ($(this).width()/2) + 'px',
                           'top'       : $(this).position().top - $('.map_popup').height() -10 + 'px'
                       });
		},
      function () {        
        $('.map_popup').hide().children('p').show()
      }
		);
	
		$("div.moscow div.flag a:not(.flag)").hover(
		function() {
		$('.map_popup').show().children('p').hide().end()
		               .children('strong').text('Архив работ').end()
		               .css({
                           'visibility': 'visible',
                           'left'      : $(this).position().left + ($(this).width()/2) + 'px',
                           'top'       : $(this).position().top - $('.map_popup').height() -32 + 'px'
                       });
		},
      function () {        
        $('.map_popup').hide().children('p').show()
      }
		);
	
	
	$("a.m1").click(function() {
		$('.map_popup').css({'visibility':'hidden'});
		$(this).addClass('active').siblings().removeClass('active');
		$("div.piter").hide();
		$("div.moscow").show();
		return false;
	});
	
	$("a.m2").click(function() {
		$('.map_popup').css({'visibility':'hidden'});
		$(this).addClass('active').siblings().removeClass('active');
		$("div.piter").show();
		$("div.moscow").hide();
		return false;
    });
	
	$(".offer h2").click(function() {
		$(this).next().slideToggle("slow");
	});
	
	$(".response").click(function() {
		$('<div id="shadow"></div>').css({'height':  $('html').height()}).prependTo('body');
		$(".resume").show();
		$(".resume input:hidden").val($(this).parent().children('h4').text());
		return false;
    });
	
	$(".send a").click(function() {
		$("#shadow").remove();
		$(".send").hide()
		return false;
    });

$(".popup .open").click(
	function() {
		if ($(".open_popup").css('left').substring('0', $(".open_popup").css('left').indexOf('p')) > 300) 
		{
		$(".popup").css({'overflow':'visible', 'width':'auto'});
		$(".open_popup").animate({'left':'0'})
		$(".popup .open div").addClass('cl')}
		else 
		{
		$(".open_popup").animate({'left':'600'});		
        $('.popup').css({'overflow':'hidden', 'width':'44px'});
		$(".popup .open div").removeClass('cl')}
	  return false;
	}
    );



/*	$(".popup .open").click(function() {
		$(".popup").css({'overflow':'visible', 'width':'auto'});
		$(".open_popup").animate({'left':'0'})
		return false;
	});
	
	$(".popup .close").click(function() {
        $('.popup').css({'overflow':'hidden', 'width':'44px'});
        $(".open_popup").animate({'left':'600'});
        return false;
    });*/
    
    /* Контактная информация */

	$(".contactInfo.map01").click(function() {
		$('<div id="shadow"></div>').css({'height': $('html').height()}).prependTo('body');
  	    $(".map01").show();
		$(".map01").css({'marginTop':$(this).offset().top - 300 + 'px'})
		return false;
	});

	$(".contactInfo.map02").click(function() {
		$('<div id="shadow"></div>').css({'height': $('html').height()}).prependTo('body');
  	    $(".map02").show();
		$(".map02").css({'marginTop':$(this).offset().top - 400 + 'px'})
		return false;
	});

	$(".contactInfo.map03").click(function() {
		$('<div id="shadow"></div>').css({'height': $('html').height()}).prependTo('body');
  	    $(".map03").show();
		$(".map03").css({'marginTop':$(this).offset().top - 500 + 'px'})
		return false;
	});
	
	$(".contactInfo.map04").click(function() {
		$('<div id="shadow"></div>').css({'height': $('html').height()}).prependTo('body');
  	    $(".map04").show();
		$(".map04").css({'marginTop':$(this).offset().top - 500 + 'px'})
		return false;
	});

	$(".mapWrapper a").click(function() {
		$("#shadow").remove();
		$(".mapWrapper").hide();
		return false;
	});
	
	$("#archive a").click(function() {
		$('<div id="shadow"></div>').css({'height': $('html').height()}).prependTo('body');
		$('<div id="archiveimg"><a href="#">Закрыть окно</a><h3>Архив работ</h3><br><img src="' + $(this).attr('href') + '" /></div>').css({'top': $(this).offset().top - 250 + 'px'}).prependTo('body');
	
			$("#shadow, #archiveimg a").click(function() {
				$("#archiveimg, #shadow").remove()
				return false;
			});
		return false;
	});
	

    
    /* Консультация online */
    
    $('#consult a').click(function() {
        $('<div id="shadow"></div>').css({'height': $('html').height()}).prependTo('body');
        $('#consulting').show();
        return false;
    });
	
	$('#read_all').click(function() {				  
        $('#text_all').show();
		$('#read_all').hide();		
        return false;
    });
	
	$('#read_all2').click(function() {									   
		$('#read_all2').css({'border':'none'});
        $('#text_all2').show();
        return false;
    });
    $('a.descToggle').click(function() {
      $('.hiddenText').slideToggle('slow');
      return false;
    })
});
