    $(function(){
               
        $('.link').each(function(){
            var $obj = $(this)
            var $is = $obj.html().split(',');   
            //alert($is.length)
            var l = $is.length;
            var i = 1;
            var $i = $obj.siblings('.imgg');
            
            var $img = $('img',$i);
            $img.attr('src',$is[0]);
            $i.css('backgroundImage','url('+$is[1]+')');
            setInterval(function(){
                                 
                i==l?i=0:'';
                $img.css({'opacity':1}).animate({'opacity':0},1000,function(){ $(this).attr('src',$is[i]); $i.css('backgroundImage','url('+$is[(i+1==l)?0:i+1]+')'); i++;     $(this).animate({'opacity':1},1000); });            
                
                        
            },8000);
        });
    });
    $(function(){

            function selects($f) {
                ($.browser.msie&&parseInt($.browser.version)<8)?ea=true:ea=false;
                $('select', $f).each(function(index){
                    var $select = $(this);      
                    var $class = $select.attr('class');
                    $select.addClass('hide').wrap('<span class="jselect '+$class+'" style="'+$select.attr('style')+'"><div class="jNiceSelectWrapper"></div></span>');
                    var $wrapper = $select.parent().css({zIndex: 100-index});
                    $wrapper.prepend('<a class="selectedItem" href="#"></a><ul class="spec"></ul>');
                    var $ul = $('ul.spec', $wrapper);
                    $('option', $select).each(function(i){
                        $ul.append('<li><a href="#" index="'+ i +'">'+ this.text +'</a></li>');
                    });
                    $ul.height()>150?$ul.height('150px'):'';                    
                    $ul.hide().find('a').click(function(){
                        var $obj = $(this);
                        $('a.selected', $wrapper).removeClass('selected');
                        $obj.addClass('selected');  
                        if($select.attr('selectedIndex')!=$obj.attr('index')&&$select.change) {$select.attr('selectedIndex',$obj.attr('index')); $select.change(); }
                        $select.attr('selectedIndex',$obj.attr('index'));                       
                        $('a.selectedItem', $wrapper).html($obj.html());
                        $ul.hide();
                        return false;
                    });         
                    $('a:eq('+ $select.attr('selectedIndex') +')', $ul).click();
                });
                $('a.selectedItem').click(function(){
                    var $ul = $(this).siblings('ul');
                    if ($ul.css('display')=='none'){ hideSelect(); } 
                    $ul.slideToggle(100,function(){
                        var offSet = parseInt(((ea ? $('a.selected', $ul).parent().attr('offsetTop') : $('a.selected', $ul).attr('offsetTop')) - $ul.attr('offsetTop')));                   
                        $ul.animate({scrollTop: offSet});                   
                    });                 
                    return false;
                });
            
                var hideSelect = function(){
                    $('.jNiceSelectWrapper ul:visible').hide();
                };      
                
                var checkExternalClick = function(event) {
                    if ($(event.target).parents('.jselect').length === 0) { hideSelect(); }
                };
        
                $(document).mousedown(checkExternalClick);
                
            }
        selects($('.jnice'))
    });
    $(function(){
            $('.quest').hover(function(){
                $(this).parent().addClass('act-ib')
            
            },function(){
            $(this).parent().removeClass('act-ib')
            })
            $('.ho').hover(function(){
                $(this).siblings('.ib').addClass('act-ib')
            
            },function(){
            $(this).siblings('.ib').removeClass('act-ib')
            })
                    
            function scrolling(){
                var $s = $('#scroll');
                var $ul = $('ul.spec',$s);
                var hUl = $ul.height();
                var hS = $s.height();
                var res = hUl-hS;
                
                var t;
                var i=0;
                function anime(){
                    if(res>0){
                        t = setInterval(function(){
                            if(i<=res){
                                i++;
                            } else {
                                clearInterval(t);
                                i=0;
                                $ul.animate({'opacity':0},500,function(){
                                    
                                    $ul.css({'marginTop':0}).animate({'opacity':1},500,function(){
                                        $ul.css({'filter':'none'});
                                        anime()
                                    });     
                                })
                            }
                            $ul.css({'marginTop':-i});                          
                        },100);
                    }
                }
                
                anime();
                $s.bind('mouseenter',function(){
                    clearInterval(t);
                }).bind('mouseleave',anime)
            }
            if(('#scroll').length) scrolling();    
            
    });
    
    function changeStylesheet()
    {
        var loc = location.href
            loc = loc.replace(/http:\/\/(www\.)?(.*?)\.?b2bcontext\.ru\//,'');
            
        if(loc != '' && loc != 'for_advertiser' && loc != 'for_agency' && loc != 'for_agency/advertising_agency') 
        {
            document.getElementById('width_styles_link').href = '/css/width_high.css' 
            return;
        }
        
        var workspace_H, workspace_W;
        if(typeof(window.innerHeight) != 'undefined')
        {
            workspace_H = window.innerHeight;
            workspace_W = window.innerWidth;
        }
        else if(typeof(document.documentElement) != 'undefined' && 
                typeof(document.documentElement.clientHeight) != 'undefined' &&
                document.documentElement.clientHeight != 0)
        {
            workspace_H = document.documentElement.clientHeight;
            workspace_W = document.documentElement.clientWidth;     
        }    
        else
        {
            workspace_H = document.getElementsByTagName('body')[0].clientHeight;
            workspace_W = document.getElementsByTagName('body')[0].clientWidth;
        }   
        
        //document.title = " | loc = " + loc + " | workspace_W = " + workspace_W + " | workspace_H = " + workspace_H
        
        if(workspace_W < 1200)
        {
            document.getElementById('width_styles_link').href = '/css/width_low.css'
        }
        else
        {
            document.getElementById('width_styles_link').href = '/css/width_high.css'
        }
    }


