if (typeof(searchedDest) != "undefined" && searchedDest.length > 0) {
    BTRAV.ads.taxaAd += BTRAV.ads.setTaxaAd('customdest',searchedDest[0].toLowerCase().replace(/ /g,'-'));
}

function updatedCustomResultTaxa(itemName,itemId,itemSlug) {
    if (itemSlug.indexOf('destination') >= 0 ) {
        searchedDest.push(itemName);
        searchedDestId.push(itemId);
        BTRAV.ads.taxaAd += BTRAV.ads.setTaxaAd('customdest',itemName.toLowerCase().replace(/ /g,'-'));                 
    } else {
        if (!itemInArray(itemName,searchedActivities)) {       
            searchedActivities.push(itemName);
        }
        searchedActivitiesIds.push(itemId);
    }
}
        

/** hack for contact us  iframe **/
var curDate = new Date();
if (location.href.indexOf('dev.') < 0) {
    if ( location.href.indexOf('/users/login/') >= 0 && location.href.indexOf('displayMyPlace.kickAction') >= 0) {
        window.location.href = '/users/logout/';
    } 
} 

 
if ( typeof(navigator.userAgent) != "undefined" && navigator.userAgent.indexOf('Mac') >= 0) {
    /** no tynt for Mac **/
} else {
    if(  document.location.protocol=='http:'  ){
     var Tynt=Tynt||[];Tynt.push('a3epesvKOr4kN9adbi-bnq');Tynt.i={"ap":"Read more:"};
     (function(){var s=document.createElement('script');s.async="async";s.type="text/javascript";s.src='http://tcr.tynt.com/ti.js';var h=document.getElementsByTagName('script')[0];h.parentNode.insertBefore(s,h);})();
    }
}

$(document).ready(function() {
	BTRAV.updateBlogNavRecentPopular();
    BTRAV.update_user_login(); 
    /** add google plus button for now before push **/
    if ( $("#header .gplusheader").length ==0 && typeof(gapi) != "undefined" && !!gapi && !!gapi.plusone && !(location.hostname.indexOf('qa') >= 0 || location.hostname.indexOf('dev') >= 0) ) {
        if ( $.browser.msie ) {
            $("#loginInfo").before('<div style="float:left;width:80px;"><div id="___plusone_0" style="height: 20px; width: 90px; display: inline-block; text-indent: 0pt; margin: 0pt; padding: 0pt; background: none repeat scroll 0% 0% transparent; border-style: none; float: none; line-height: normal; font-size: 1px; vertical-align: baseline;"><iframe frameborder="0" width="100%" scrolling="no" title="+1" vspace="0" tabindex="-1" style="position: static; left: 0pt; top: 0pt; width: 90px; margin: 0px; border-style: none; height: 20px; visibility: visible;" src="https://plusone.google.com/_/+1/fastbutton?url=http%3A%2F%2Fwww.budgettravel.com%2F&amp;size=medium&amp;count=true&amp;annotation=&amp;hl=en-US&amp;jsh=m%3B%2F_%2Fapps-static%2F_%2Fjs%2Fwidget%2F__features__%2Frt%3Dj%2Fver%3DSeBSlJkF7Rk.en_US.%2Fsv%3D1%2Fam%3D!CONMiKjES8GIhnU5QQ%2Fd%3D1%2F#id=I1_1326233219681&amp;parent=http%3A%2F%2Fwww.budgettravel.com&amp;rpctoken=866734068&amp;_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe" name="I1_1326233219681" marginwidth="0" marginheight="0" id="I1_1326233219681" hspace="0" allowtransparency="true"></iframe></div></div>');
        } else {
            $("#loginInfo").before('<div style="float:left; width:80px;"><g:plusone size="medium" href="http://www.budgettravel.com/"></g:plusone></div>');
            gapi.plusone.go();
        }        
    }
    /** end google plus **/
    
    if (location.href.indexOf('/feature/') >= 0) {
        BTRAV.addArticleSrc();
    } else if (typeof(printArticleId) != "undefined" && printArticleId != "") {
            $("#sharetools .addthis_button_print").replaceWith('<a title="Print This Page" id="addthis_button_print_alt_bt" class="at300b" href="/print/' + printArticleId + '/"><span class="at300bs"></span></a>');
            $("#sharetools-bottom .addthis_button_print").replaceWith('<a title="Print This Page" id="addthis_button_print_alt_bt_bot" class="at300b" href="/print/' + printArticleId + '/"><span class="at300bs"></span></a>');  
            $("#sharetools>a").hover(function() {
                $("#sharetools .shareinfo").html($(this).attr("title"));
            }, function() {
                $("#sharetools .shareinfo").html('&nbsp;');
            });            
    } 

    if ($("#BTfblike").length == 0 || $("#BTfblike").length == 1 ) {
        if ($("#wrapper_content_right .blog_solicitcomments.posting").length > 0) {
            $("#wrapper_content_right .blog_solicitcomments.posting").eq(0).prepend('<iframe scrolling="no" frameborder="0" id="BTfblike" allowtransparency="true" src="http://www.facebook.com/plugins/like.php?href=' + 'http://' + location.hostname + location.pathname + '&amp;layout=button_count&amp;show_faces=false&amp;width=90&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=fblike"></iframe>');            
        } else {
            $("#sharetools .shareinfo").after('<iframe scrolling="no" frameborder="0" id="BTfblike" allowtransparency="true" src="http://www.facebook.com/plugins/like.php?href=' + 'http://' + location.hostname + location.pathname + '&amp;layout=button_count&amp;show_faces=false&amp;width=90&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=fblike"></iframe>');
        }
        $("#BTfblike").show();        
    }     
    
    /** popunder .. not from wpisrc or stumble upon***/
    if ( typeof(nosubpopup) == "undefined" && !(location.hostname.indexOf('qa') >= 0 || location.hostname.indexOf('dev') >= 0 || location.href.indexOf('wpisrc') >= 0 || location.href.indexOf('src=stm') >= 0 || location.href.indexOf("#no_popup") >= 0) ) {         
        BTRAV.BTpopunderTimerCookie = BTRAV.readCookie('popunderTimer');                            
        if (BTRAV.BTpopunderTimerCookie == null) {
            BTRAV.writeCookie("popunderTimer",new Date().getTime(),1440)            
            var popundertimer = setTimeout("BTRAV.showPopunder()",30000);
        } else if (BTRAV.BTpopunderTimerCookie != "yes") {
            var left60sec = (new Date().getTime()) -  parseInt(BTRAV.readCookie('popunderTimer'));
            if (left60sec <= 30000 && left60sec >= 3000) {
                var popundertimer = setTimeout("BTRAV.showPopunder()",left60sec);
            } else {
                var popundertimer = setTimeout("BTRAV.showPopunder()",3000);                
            }            
        }       
    }
    
    /** update hotels **/
    if ( $("#dyndest").length > 0 ) {
        if ($("#dyndest .dyndest-continent-pano").length > 0) {
            $("#anchor_realdeals").append('<h3 class="title seeall"><a href="/real-deals' + location.pathname + '"  class="kelly-green features">See all ' + $("h1").text() + ' Real Deals</a></h3></div>');            
        }
        if ( $("#hotels-editor-picks li").length < 5) {
            $("#eat-sleep-shop h3.seeall").hide()
        }
    } 
    
    if (typeof(bt_custom_search_dest) != "undefined" && bt_custom_search_dest.toString() == 'Las Vegas') {
    /** MGM Ad **/
        $("#customResults .numresults").after('<div style="float:right; height:60px; margin-bottom:10px;" class="sponsoredSearch"><span style="line-height:40px;float:left;margin-right:5px;font-style:italic;color:#666;">Sponsored by</span><a href="http://ad.doubleclick.net/jump/budgettravel.misc;adid=9484787;sz=120x60;ord=1234588?" target="_blank"><img src="http://ad.doubleclick.net/ad/budgettravel.misc;adid=9484787;sz=120x60;ord=1234588?" width="120" height="60" border="0" alt=""></a><img src="http://view.atdmt.com/MGM/view/373240343/direct/01/" border="0"></div>');
    } 
    
    /** update bttsub.com **/
    $("#header a[href='http://www.btsub.com/'], #footer a[href='http://www.btsub.com/']").attr('href','https://w1.buysub.com/pubs/F7/NBT/NBT_combo_entry.jsp?cds_page_id=30528&cds_mag_code=NBT');
    
});


/** update reader media to do after document load **/
BTRAV.loadReaderMediaModule = function(obj) {
    $(document).ready(function() {
        if (typeof(BTRAV.curCity) == "undefined") {
            BTRAV.curCity = BTRAV.ads.taxa.city[0].replace(/-/g," ");
        } 
        var readerUrl = '/reader_media_feed/?quantity=1000&sortType=recent&mediaType=photo,video,blog&tags=' + BTRAV.curCity;
        var $obj = obj;
        $.ajax({
            url: readerUrl,
            dataType: 'html',
            success: function(html) {
                if (html.trim() != "") {
                    $("#reader_media_ajax").html(html);
                    initReaderMedia();
                } else {
                    $obj.hide();
                }
            }
        });
    });
}

/***    
if (typeof("BTRAV.ads.activeAdSlots" != "undefined")) {
    BTRAV.ads.activeAdSlots += ',rightpromotile';
    BTRAV.ads.featureBar_ad_sitename += ',budgettravel.destinations/europe,budgettravel.destinations/caribbean,budgettravel.destinations/mexicoandcentralamerica, budgettravel.destinations/asia,budgettravel.destinations/southamerica,budgettravel.destinations/australiaandsouthpacific,,budgettravel.destinations/africaandmiddleeast,budgettravel.strategies, budgettravel.strategies/airfares,budgettravel.strategies/cruises, budgettravel.strategies/carrentals,budgettravel.strategies/dining,budgettravel.tripideas,budgettravel.tripideas/family,budgettravel.tripideas/roadtrips, budgettravel.tripideas/adventuretravel, budgettravel.tripideas/nationalparks,budgettravel.tripideas/wine,budgettravel.tripideas/solotravel,budgettravel.tripideas/longweekends';
}
***/

$(function() {
    if ( typeof(BTRAV.getQueryVariable("src")) != "undefined" ) {
        $("#content-body .pagination a").each(function() {
          var $aHref = $(this).attr("href");
          if ($aHref.indexOf("?") >= 0) { var newHref = $aHref + '&src=' + BTRAV.getQueryVariable("src"); } else {var newHref = $aHref + '?src=' + + BTRAV.getQueryVariable("src");}
          $(this).attr("href", newHref)
        });        
    } 
});

$(function() {
    if ( $("#commentsbar").length > 0 && $("#commentsbar").text().length > 5 && $("#commentsbar").css("margin-left") == '4px') {
        $("#commentsbar").appendTo($("#sharetools"));
    }
});



/*** take out vertical layout -- remove after push ***/
if (typeof(BTRAV.dynDest) != "undefined") {
    BTRAV.dynDest.continentLayout = function() {
      // reset function.
    }
}
   
        




