$(function(){
 var bhref = $('#bottom_add').attr('href');
  if (bhref) {

  $('#top_add').attr('href',bhref);
  $('#top_add2').attr('href',bhref);
}

});



<!--
function trim(str) {
    return str.replace(/^\s*/,'').replace(/\s*$/,'');
}

function sw(url,w,h){
 w = w || 200;
 h = h || 300;
 var o = window.open(url, "w", "height="+(h+20)+",width="+(w+20)+",toolbar=0,scrollbars=0,resizable=1");
 o.focus();
}

var LinkDivActive=0;
var onDiv;
var timeOnDiv;
var layerRef;
var styleRef;
var showVar;
var hideVar;
var ua=navigator.userAgent.toLowerCase();
var dom=(document.getElementById) ? 1 : 0;
var nn4=(document.layers) ? 1 : 0;
var ie=(((ua.indexOf('msie')!=-1) && (ua.indexOf('opera')==-1))) ? 1 : 0;
var opera=(ua.indexOf('opera')!=-1) ? 1 : 0;
var pos=new Array();
var XMenuOffset=0;
var YMenuOffset=0;

if (dom) {
    layerRef="document.getElementById(divId)";
    styleRef=".style";
    showVar="'visible'";
    hideVar="'hidden'";
} else if (ie) {
    layerRef="document.all[divId]";
    styleRef=".style";
    showVar="'visible'";
    hideVar="'hidden'";
} else if (nn4) {
    layerRef="document.layers[divId]";
    styleRef="";
    showVar="'show'";
    hideVar="'hide'";
}

function hideDiv(divId) {
    if (eval(layerRef)) eval(layerRef+styleRef+'.visibility='+hideVar);
    if(document.getElementById('p'+divId)) document.getElementById('p'+divId).className='undefined'
}

function showDiv(divId) {
    if (eval(layerRef)) eval(layerRef+styleRef+'.visibility='+showVar);

}

function moveDiv(divId, xoff, yoff) {
    if (eval(layerRef)) eval(layerRef+styleRef+'.margin="0 0 0 '+xoff+'px"');
}

function show(divId) {
    if (eval(layerRef)) {
        if (timeOnDiv != null) {
            clearTimeout(timeOnDiv);
            hideDiv(onDiv);
        }
        moveDiv(divId,XMenuOffset,relPosY('p'+divId)+YMenuOffset);
        showDiv(divId);
        onDiv=divId;
        document.getElementById('p'+divId).className='hr';
    }
}

function timer() {
    timeOnDiv=setTimeout("divOut()",900)
}

function divOut() {
    if (LinkDivActive==0) {
        hideDiv(onDiv);
    }
}

function over() {
    LinkDivActive=1;
    clearTimeout(timeOnDiv);
}

function out() {
    LinkDivActive=0;
    timeOnDiv=setTimeout("divOut()",800)
}

function outAll() { 
    if (onDiv && LinkDivActive==0) {
        hideDiv(onDiv);
    }
}

function relPosX(divId) {
    if (eval(layerRef)) {
        if (nn4) return eval(layerRef+styleRef+'.pageX');
        else {
            var elem=eval(layerRef);
            var pos=elem.offsetLeft;
            while (elem.offsetParent!=null) {
                elem=elem.offsetParent;
                pos+=elem.offsetLeft;
                if (elem.tagName=='BODY') break;
            }
            return pos;
        }
    }
}

function relPosY(divId) {
    if (eval(layerRef)) {
        if (nn4) return eval(layerRef+styleRef+'.pageY');
        else {
            var elem=eval(layerRef);
            var pos=elem.offsetTop;
            while (elem.offsetParent!=null) {
                elem=elem.offsetParent;
                pos+=elem.offsetTop;
                if (elem.tagName=='BODY') break;
            }
            return pos;
        }
    }
}



$(document).ready(function(){

    $(".imgList li a").live('click',function(){
        var el = $(this);
        el.parent().parent().find('.a').html('<a href="'+el.parent().attr('fhref')+'" rel="gal'+el.parent().parent().attr('galid')+'">'+el.parent().parent().find('.a').html()+'</a>');
        el.parent().parent().find('.a').removeClass('a');
        el.parent().parent().parent().find('.imgBig img').attr('src',el.parent().attr('vhref'));
        el.parent().parent().parent().find('.imgBig img').attr('fsrc',el.parent().attr('fhref'));
        el.parent().parent().parent().find('.imgBig a').attr('href',el.parent().attr('fhref'));
        el.parent().addClass('a');
        el.parent().html(el.html());
        return false;
    });
    
    
    $("a.upLink").live('click',function(){
        var el = $(this);
        var ad = el.parent().parent();
        if(el.hasClass('vip')){
            
            if(el.hasClass('opened')){
                //  close VIP
                el.parent().find('.learnMore').fadeOut(500);
                ad.find('.advtContacts, .imgList').fadeOut(500);
                ad.find('.vipFull').fadeOut(300,function(){
                   ad.find('.adPreview').fadeIn(500);
                });
                el.removeClass('opened');
                el.html("<span>подробнее<span>&darr;");
            } else {
                //  open VIP
                el.parent().find('.learnMore').fadeIn(500);
                ad.find('.advtContacts, .imgList').fadeIn(500);
                ad.find('.adPreview').fadeOut(300,function(){
                   ad.find('.vipFull').fadeIn(500);
                });
                el.addClass('opened')
                el.html("<span>свернуть</span>&uarr;");
            }
            
        } else {
            //  close 
            ad.find(".advtTop").fadeIn(500);
            ad.find(".advtMdl, .advtBtm").slideUp(500);
        }
        return false;
    });
    
    $(".advtInfo h4").live('click',function(){
        var el = $(this);
        if(el.parent().parent().parent().hasClass('advtPay')==false){
            var ad = $(this).parent().parent().parent();
            ad.find(".advtTop").fadeIn(500);
            ad.find(".advtMdl, .advtBtm").slideUp(500);
        } else{
            el.parent().parent().next().find(".upLink").click();
        }
    });
    
    $(".advtTop h4").live('click',function(){
       var el = $(this); 
      
           el.parent().parent().removeClass('act');
           el.parent().parent().find('.advtTop').hide();
           el.parent().parent().find('.advtMdl, .advtBtm').slideDown(500,function(){
                
           }); 
       return false;
    });
    
    $(".till").live('click',function(){
        $('.activetill').fadeIn(300);
       //$(this).next().fadeIn(300,function(){});
       
       return false; 
    });
    
    //  favs
    $(".favoritesLink").live('click',function(){
       var el = $(this);
       if(el.hasClass('act')){
            //  remove
            $.cookie('adfav'+el.attr('iid'), null,{ expires: 0, path: '/advertisement/sell/', domain: 'bobr.by', secure: false });
            el.removeClass('act');
            el.html('Удалено');
       } else {
            //  add
            $.cookie('adfav'+el.attr('iid'), '1',{ expires: 7, path: '/advertisement/sell/', domain: 'bobr.by', secure: false });
            el.addClass('act');
            el.html('Добавлено');
       }
       return false; 
    });

    $(".galpreview").fancybox({
        'transitionIn'    :    'elastic',
        'transitionOut'    :    'elastic',
        'speedIn'        :    600, 
        'speedOut'        :    200, 
        'overlayShow'    :    true
    });
    
    
});

function getElementsByClass( searchClass, domNode, tagName) { 
    if (domNode == null) domNode = document;
    if (tagName == null) tagName = '*';
    var el = new Array();
    var tags = domNode.getElementsByTagName(tagName);
    var tcl = " "+searchClass+" ";
    for(i=0,j=0; i<tags.length; i++) { 
        var test = " " + tags[i].className + " ";
        if (test.indexOf(tcl) != -1) 
            el[j++] = tags[i];
    } 
    return el;
} 

function toggleItem(id){

document.getElementById('top'+id).style.display = "none";
document.getElementById('mdl'+id).style.display = "block";
document.getElementById('bot'+id).style.display = "block";
       
}


// -->



