// JavaScript Document
(jQuery)
jQuery(function()
    {	
    Cufon.replace('.content-title h2,.pro_govor h2,  h2.pro, h2.pro2, .col2 .tab h3', {fontFamily: 'Bodoni'});
$('.pro_wrote h2.pro2').css('margin-top','-3px')
$('.content-title h2').css('margin-top','10px')
$('.pro_wrote h2.pro').css('margin-top','-10px')
$('.col2 .tab h3').css('margin', '10px 0 10px 5px');
        $("#header-login input[name^='login']").attr('placeholder',"Логин")  
        $("#header-login input[name^='password']").attr('placeholder',"Пароль") 
        $(".header-search-form input[name^='q']").attr('placeholder',"Что ищем?") 

        $("#header-login form").keypress(function(e){
                if(((e.keyCode == 0xA)||(e.keyCode == 0xD)))
                        {
                                $(this).submit();
                        }
        })
        $("#header-login form a:not(.soc)").click(function(e){
                return $("#header-login form").submit();
        })
        $("#header-login form a.soc").click(function(){
if (!$(this).hasClass('hide')){
$("#bx_auth_float").parent().show()
}else{
$("#bx_auth_float").parent().hide()
}
$(this).toggleClass('hide')
                return false;
        })
        $('.tabs').tabs()
        $('.pro_govor .tabs').tabs({selected: 1})

        $('.pool .submit').click(function(){
            return $(this).parent().find('form').submit()            
        })

        var timessroll = $(".times-sroll"),
            timessrollwidth = 0,
            timessrollul = $("ul",timessroll);
            
            $("li",timessroll)
                .each(function(){
                    timessrollwidth = Math.max(timessroll.width(), $(this).width());
                })
                .width(timessrollwidth);
            timessroll.width(timessrollwidth);
var timessrollint;
timessrollint = setInterval(function(){
autoscroll()                
}, 3000)

function autoscroll(){
var li = $("li:last",timessrollul).clone();
                timessrollul
                    .prepend(li)
                    .css({"left": -(timessrollwidth+50)})
                    .animate({                        
                            "left": "0"
                        },500,function(){
                            $("li:last",timessrollul).remove()
                    })
}

timessrollul.hover(function(){
clearInterval(timessrollint)
},function(){
timessrollint = setInterval(function(){
autoscroll()                
}, 3000)
})

            $(".times-scoll-button", timessroll).click(function(){return false;});
            $(".times-scoll-button.left", timessroll).click(function(){
                var li = $("li:first",timessrollul).clone();
                timessrollul.animate({
                        "left": "-="+(timessrollwidth+50)
                    },500,function(){
                        $("li:first",timessrollul).remove();
                        timessrollul
                            .append(li)
                            .css({"left":"0"});
                })
            })
            $(".times-scoll-button.right",timessroll).click(function(){
                var li = $("li:last",timessrollul).clone();
                timessrollul
                    .prepend(li)
                    .css({"left": -(timessrollwidth+50)})
                    .animate({                        
                            "left": "0"
                        },500,function(){
                            $("li:last",timessrollul).remove()
                    })
            })
var images = [];
function loadImage(sources, callback){
    var loadedImages = 0;
    var numImages = 0;
    for (var src in sources.src) {
        numImages++;
        images[src] = new Image();
        images[src].onload = function(){
            if (++loadedImages >= numImages) {
                callback();
            }
            };
        images[src].src = sources.src[src];
        }
}
     $.fn.extend({
          photogal: function(){
               var defaults = {  
                wrap: '.photo-gallery-items-list-wrap', 
                items: 'ul.items', 
                item: 'li.item', 
                speed: 300
            }
            var options = $.extend(defaults, options);                                            
            var slider = this
            var items = $(options.items, this)
            if ($(options.item,items).size()<1)
                return false;                                           

            var itemswrap = $(options.wrap, this);
            var itemwidth = $(options.item+':eq(0)',items).outerWidth();
            var itemheight = $(options.item+':eq(0)',items).outerHeight();

            var arrows = $("<div class='slider_arrows'><a href='#' class='prev' /><a href='#' class='next' /></div>");
/*			    arrows.css({
                    'position': 'absolute',
                    'top' : 10,
                    'right' : 11
                })*/
                slider.css({
                        'position' : 'relative'
                    })
                    .prepend(arrows)

                itemswrap.css({
                    'height': itemheight,
                    'width' : '100%',
                    'position' : 'relative',
                    'overflow' : 'hidden'                                                    
                })
                items
                    .data('animated',false)
                    .css({                                                    
                        'position': 'absolute',
                        'left' : 0,
                        'width': '100000em'
                    })
                function check(first){
                    if ($(options.item+':last',items).position()['left']+items.position()['left']<=itemswrap.width()&&!first){
                        $('a.next',arrows).addClass('nonext')
                    }else{
                        $('a.next',arrows).removeClass('nonext')
                    }
                    if (items.position()['left']>=0){
                        $('a.prev',arrows).addClass('noprev')
                    }else{
                        $('a.prev',arrows).removeClass('noprev')
                    }
                }

                check(true)
                $('a',arrows).click(function(){
                    return false;
                })
                $('a.next',arrows).click(function(){
                    if ($(this).hasClass('nonext')||items.data('animated'))
                        return false;

                    items.data('animated',true)
                        .animate({
                            'left': '-='+(itemwidth) //+11)
                        },options.speed,function(){
                            check()
                            items.data('animated',false)
                        })
                })
                $('a.prev',arrows).click(function(){
                    if ($(this).hasClass('noprev')||items.data('animated'))
                        return false; 

                    items.data('animated',true)
                        .animate({
                            'left': '+='+(itemwidth) //+11)
                        },options.speed,function(){
                            check()
                            items.data('animated',false)
                        })
                    })
                }
      });
    
      
    $("#piclist1").photogal();

});

$(document).ready(function() {		
	$questBlock = $('.questions_block');
	$question = $('.questions span', $questBlock),
		
	$question.click(function() {
		$.thisLink = $(this);
		
		if(! $(this).parent().parent().hasClass('act')){
			$.thisLink.parent().parent().addClass('act');
			$.thisLink.parent().parent().find('.fulltxt').slideDown(500);
			
		} else {
			
			$.thisLink.parent().parent().removeClass('act');
			$.thisLink.parent().parent().find('.fulltxt').slideUp(500);
	
		}
		return false;	
	});
});

(function($){                                    
    $.fn.extend({
        suslider:  function(options){

           var defaults = {  
                    wrap: '.items-wrap', 
                    items: '.items', 
                    item: '.try', //item', 
                    speed: 300
            };
            var options = $.extend(defaults, options);                                            
            var slider = this
            var items = $(options.items, this)
            if ($(options.item,items).size()<4)
                return false;                                           

            var itemswrap = $(options.wrap, this)
            var itemwidth = 145// $(options.item+':eq(0)',items).width()
                var arrows = $("<div class='slider_arrows'><a href='#' class='prev' /><a href='#' class='next' /></div>")
                arrows.css({
                    'position': 'absolute',
                    'top' : 10,
                    'right' : 11
                })
                slider.css({
                        'position' : 'relative'
                    })
                    .prepend(arrows)

                itemswrap.css({
                    'height': 260,
                    'width' : '100%',
                    'position' : 'relative',
                    'overflow' : 'hidden'                                                    
                })
                items
                    .data('animated',false)
                    .css({                                                    
                        'position': 'absolute',
                        'left' : 0,
                        'width': '100000em'
                    })
                function check(first){
                    if ($(options.item+':last',items).position()['left']+items.position()['left']<=itemswrap.width()&&!first){
                        $('a.next',arrows).addClass('nonext')
                    }else{
                        $('a.next',arrows).removeClass('nonext')
                    }
                    if (items.position()['left']>=0){
                        $('a.prev',arrows).addClass('noprev')
                    }else{
                        $('a.prev',arrows).removeClass('noprev')
                    }
                }

                check(true)
                $('a',arrows).click(function(){
                    return false;
                })
                $('a.next',arrows).click(function(){
                    if ($(this).hasClass('nonext')||items.data('animated'))
                        return false;

                    items.data('animated',true)
                        .animate({
                            'left': '-='+(itemwidth+11)
                        },options.speed,function(){
                            check()
                            items.data('animated',false)
                        })
                })
                $('a.prev',arrows).click(function(){
                    if ($(this).hasClass('noprev')||items.data('animated'))
                        return false; 

                    items.data('animated',true)
                        .animate({
                            'left': '+='+(itemwidth+11)
                        },options.speed,function(){
                            check()
                            items.data('animated',false)
                        })
                    })
                }
   })
})(jQuery);

(function($){                                    
    $.fn.extend({
        suslidernew:  function(options){

           var defaults = {  
                    wrap: '.items-wrap', 
                    items: '.items', 
                    item: '.try',
                    speed: 300
            };
            var options = $.extend(defaults, options);                                            
            var slider = this
            var items = $(options.items, this)
            if ($(options.item,items).size()<1)
                return false;                                           

            var itemswrap = $(options.wrap, this)
            var itemwidth = 480// $(options.item+':eq(0)',items).width()
                var arrows = $("<div class='slider_arrows'><a href='#' class='prev' /><a href='#' class='next' /></div>")
                arrows.css({
                    'position': 'absolute',
                    'top' : 10,
                    'right' : 11
                })
                slider.css({
                        'position' : 'relative'
                    })
                    .prepend(arrows)

                itemswrap.css({
                    'height': 250,
                    'width' : '100%',
                    'position' : 'relative',
                    'overflow' : 'hidden'                                                    
                })
                items
                    .data('animated',false)
                    .css({                                                    
                        'position': 'absolute',
                        'left' : 0,
                        'width': '100000em'
                    })
                function check(first){
                    if ($(options.item+':last',items).position()['left']+items.position()['left']<=itemswrap.width()&&!first){
                        $('a.next',arrows).addClass('nonext')
                    }else{
                        $('a.next',arrows).removeClass('nonext')
                    }
                    if (items.position()['left']>=0){
                        $('a.prev',arrows).addClass('noprev')
                    }else{
                        $('a.prev',arrows).removeClass('noprev')
                    }
                }

                check(true)
                $('a',arrows).click(function(){
                    return false;
                })
                $('a.next',arrows).click(function(){
                    if ($(this).hasClass('nonext')||items.data('animated'))
                        return false;

                    items.data('animated',true)
                        .animate({
                            'left': '-='+itemwidth
                        },options.speed,function(){
                            check()
                            items.data('animated',false)
                        })
                })
                $('a.prev',arrows).click(function(){
                    if ($(this).hasClass('noprev')||items.data('animated'))
                        return false; 

                    items.data('animated',true)
                        .animate({
                            'left': '+='+itemwidth
                        },options.speed,function(){
                            check()
                            items.data('animated',false)
                        })
                    })
                }
   })
})(jQuery);










































