//	Functions

// Simple JavaScript Templating
// John Resig - http://ejohn.org/ - MIT Licensed
(function(){
  var cache = {};

  this.tmpl = function tmpl(str, data){
    // Figure out if we're getting a template, or if we need to
    // load the template - and be sure to cache the result.
    var fn = !/\W/.test(str) ?
      cache[str] = cache[str] ||
        tmpl(document.getElementById(str).innerHTML) :

      // Generate a reusable function that will serve as a template
      // generator (and which will be cached).
      new Function("obj",
        "var p=[],print=function(){p.push.apply(p,arguments);};" +

        // Introduce the data as local variables using with(){}
        "with(obj){p.push('" +

        // Convert the template into pure JavaScript
        str
          .replace(/[\r\t\n]/g, " ")
          .split("<%").join("\t")
          .replace(/((^|%>)[^\t]*)'/g, "$1\r")
          .replace(/\t=(.*?)%>/g, "',$1,'")
          .split("\t").join("');")
          .split("%>").join("p.push('")
          .split("\r").join("\\'")
      + "');}return p.join('');");

    // Provide some basic currying to the user
    return data ? fn( data ) : fn;
  };
})();


// form input awaken
setInputConscious = function(t, off, on) {

    jQuery('input.' + t).each(function() {
        el = jQuery(this);
        tV = jQuery(this).val();

        jQuery(this).bind("click focus", function() {
            if (jQuery(this).val() === tV) {
                jQuery(this).val('');
                jQuery(this).toggleClass(on).toggleClass(off);
            }
        });

        jQuery(this).bind("focusout", function() {

            if (jQuery(this).val().length == 0) {
                jQuery(this).val(tV);
                jQuery(this).toggleClass(on).toggleClass(off);
            }

        });

        jQuery(this).closest('form').submit(function() {
            if (el.val() === tV) el.val('');
        });
    })
}

function videoPlaylist(args) {
    $f("flowplayer1", "../flash/flowplayer/flowplayer-3.0.7.swf", args).playlist("ul#clips1", {loop:true});
    ;
}

function singleVideo(className) {
    flowplayer("a." + className, "../flash/flowplayer/flowplayer-3.0.7.swf", {

        // this is the player configuration.
        plugins:  {
            controls:  {
                volume: false
            }
        }
    });
}

function toggleCheckBox() {
    jQuery('li.long').find('input:checked').each(function() {
        jQuery(this).parent('li').addClass('enabled');
    });
    jQuery('li.long').click(function() {
        jQuery(this).toggleClass('enabled');
        jQuery(this).find('input').each(function() {
            if (jQuery(this).is(':checked')) {
                jQuery(this).attr('checked', false);
            } else {
                jQuery(this).attr('checked', true);
            }
        })
    })
}

function advancedSearchToggleCheck() {
	// full text long titles popup
	jQuery('.long label').each(function() {
		// capture abbreviated title in memory
		var abbreviatedText = jQuery(this).text();
		// replace abbreviated title with full title
		jQuery(this).mouseover(function() {
			jQuery(this).removeClass("clipped").addClass("full");
			jQuery(this).text($(this).attr('title'));
		});
		// replace full title with abbreviated title
		jQuery(this).mouseout(function() {
			jQuery(this).removeClass("full").addClass("clipped");
			jQuery(this).text(abbreviatedText);
		});
	});

		jQuery('.long a').click(function() { 
		window.location.href = $(this).attr('href');
})

}

// Intelligent pop-up resizing
function resizeWindow() {

    // position popup in top left
    window.moveTo(0, 0);

    // init bodywidth + height
    var bodyWidth = 0;
    var bodyHeight = (document.body.clientHeight <= 80) ? jQuery(document).height() : document.body.clientHeight;
    //alert(bodyHeight);
    if (jQuery('#poparticle').width() > document.body.clientWidth) {
        bodyWidth = jQuery('#poparticle').width() + 50;
    }
    else {
        bodyWidth = document.body.clientWidth;
    }


// calculate toolbar height + width
    if (window.outerHeight) {
        var toolbarWidth = window.outerWidth - jQuery(window).width();
        var toolbarHeight = window.outerHeight - jQuery(window).height();

    }
    else {
        if (document.documentElement.clientWidth) {
            var clientW = document.documentElement.clientWidth;
            var clientH = document.documentElement.clientHeight;
            // resize the window, the new window will be smaller
            window.resizeTo(clientW, clientH);

            // calculate the difference between the client and the total size in the new window
            var frameW = clientW - document.documentElement.clientWidth;
            var frameH = clientH - document.documentElement.clientHeight;

            var toolbarWidth = frameW
            var toolbarHeight = frameH;
        }
    }
//alert(toolbarHeight);


// calculate total height and width
    var totalHeight = bodyHeight + toolbarHeight;
    var totalWidth = bodyWidth + toolbarWidth;
    //alert(totalHeight);

    var finalWidth = 0;
    var finalHeight = 0;

    // if totalwidth is bigger than screen, minimise to screenwidth
    if (totalWidth > screen.availWidth || bodyWidth > screen.availWidth) {
        finalWidth = screen.availWidth;
        //console.log('body width=' + bodyWidth + ' final width=' + finalWidth + ' horiz-max\n');
    }
    // otherwise wrap content to screen width
    else {
        finalWidth = totalWidth;
        //console.log('body width=' + bodyWidth + ' final width=' + finalWidth + ' horiz-min\n');
    }

    // if body + toolbars is bigger than screen, window should maximise to screen.
    if (totalHeight > screen.availHeight || bodyHeight > screen.availHeight) {
        // maximise
        finalHeight = screen.availHeight;
        //console.log('body height=' + bodyHeight + ' final height=' + finalHeight + ' vert-max');

    }
    // else innerwindow should be just enough to show content
    else {
        finalHeight = totalHeight;
        //console.log('body height=' + bodyHeight + ' final height=' + finalHeight + ' vert-min');
    }

    window.resizeTo(finalWidth, finalHeight);

}

// will collapse an accordion if anchor on the h2 matches hash in url
function collapseAccordionByAnchor() {
    if (window.location.hash.length > 0) {
        if ($('h2' + window.location.hash).length > 0) {
            $('h2' + window.location.hash).click();
			if(site.page == "article_stats") {
				$('h2' + window.location.hash).siblings('div').children('h3').click();
        }
    }
    }
}

function format(selected, total) {
    return selected + '/' + total + ' selected';
}

function initializeAccordion(options) {
    defaultOptions = {
        activeClass: 'new-action',
        speed:'fast'/*'slow', 'fast', 'def'*/,
        defaultActive:0,
        showDefault:true
    }

    this.options = jQuery.extend(defaultOptions, options);

// jQuery('.wrap-in', '.wrap').find('table').wrap('<div/>');
    jQuery('h2', '.wrap').removeClass('active');
    jQuery('h2', '.wrap:has(table.' + this.options.activeClass + ')').addClass('active');
    jQuery('.wrap-in', '.wrap').find('table.' + this.options.activeClass).parent('div').prev('h3').addClass('active');
    jQuery('.wrap-in', '.wrap').find('table').not('.' + this.options.activeClass).parent('div').prev('h3').removeClass('active'); // removed .hide() after parent(div)
    jQuery('.wrap-in', '.wrap').not(':has(table.' + this.options.activeClass + ')').hide();
    jQuery('.wrap-in').each(
            function(index, element) {
                var parent = jQuery(element).parent();
                var note = parent.find('.note').show();
            });

    var self = this;

    jQuery('.wrap').find('h2').click(
            function() {
                jQuery(this).parent().find('div').
                        eq(0).slideToggle(self.options.speed,
                        function() {
                            jQuery(this).prev('h2').toggleClass('active')
                        })
            }
            )
    jQuery('.wrap-in', '.wrap').find('h3').click(
            function() {
                jQuery(this).next('div').slideToggle(self.options.speed,
                        function() {
                            jQuery(this).prev('h3').toggleClass('active')
                        })
            }
            )

    if (this.options.showDefault) {
        if (jQuery('.wrap:has(table.' + this.options.activeClass + ')').length == 0) {
            jQuery('.wrap').eq(this.options.defaultActive).find('h2').addClass('active');
            jQuery('.wrap').eq(this.options.defaultActive).find('.wrap-in').show();
        }
    }
	
	if(this.options.hideAll === true) {
		jQuery('h2').removeClass('active');
		jQuery('.wrap-in').hide();
	}
}


function accordionHover() {
    $('.accordion .wrap-in h3').hover(function() {
        $(this).toggleClass('hover');
    });
}


function ieSelectExpand(el, original, expand) {
    var option = el + ' option';
    if (jQuery.browser.msie) {

        jQuery(el).focusin(function(event) {
            $(this).width(expand);
            $(this).blur();
        });
        jQuery(el).change(function() {
            $(this).width(original);
        });
    }
}

/* generates tooltip on all alt tags within el - must also include tooltip.js on styles.vm for this
 to work */
function tooltip(el) {
    jQuery(el).tooltip({
        track: true,
        delay: 0,
        showURL: false,
        fixPNG: true,
        showBody: " - ",
        top: -20,
        left: 15
    });
}

/* used to toggle browse by subject accordion */
function toggler(el) {
    var toggler = jQuery(el);
	
	toggler.each(function() {
	if($(this).parent('li').attr('id') != window.location.hash.replace('#','')) {
		$(this).add(jQuery('i', $(this)).removeClass('active'));
		$(this).next().hide();
	} else {
		$(this).addClass('active');
		$(this).next().show();
	}	
	});

	
		
	toggler.click(function() {
        jQuery(this).add(jQuery('i', this)).toggleClass('active');
        jQuery(this).next().slideToggle();
        jQuery(this).toggleClass('selected');
    }
            );

    if (site.section == "journals") {
        toggler.mouseover(function(e) {
            jQuery(this).css('background-color', '#F1F1F1');
        });


        toggler.mouseout(function(e) {
            if ((jQuery(this).hasClass('selected')) != true) {
                jQuery(this).css('background-color', 'transparent');
            }
        });

        tooltip('.tooltip');
		
		
		
    }
}

function addTextAreaMaxLengthListener() {

    $('textarea[maxlength]').bind('paste cut keyup input blur load',
            function(e) {
                //get the limit from maxlength attribute
                var limit = parseInt($(this).attr('maxlength'));
                //get the current text inside the textarea
                var text = $(this).val();
                //count the number of characters in the text
                var chars = text.length;

                var label = $("label[for='" + this.id + "']");
                //var label = $('label[for="userInterests.interests"]');

                if (label) {
                    var new_limit = limit - chars;
                    label.text(new_limit);
                }
                // do not merge with if above
                if (chars >= limit && $('span.error').text().length === 0) {
                    $('.textarea-count').show();
                    // disable form submission whilst char > limit
                    jQuery('#update-interests').attr('disabled', 'true').attr('style', 'background-color: #ccc');
                    jQuery('input').bind('keydown keypress keyup', function(event) {
                        if (event.which == 13) {
                            event.preventDefault();
                        }
                    });
                }
                else {
                    $('.textarea-count').hide();
                    jQuery('#update-interests').removeAttr('disabled').removeAttr('style');
                }
            }
            );
}

// collapsing list utility 
// toggle visibility of element that is a sibling of an element with class .collapser
function toggleList() {
    if (jQuery('.collapser').siblings('ul').attr('class') != 'hidebeforeload') {
        jQuery('.collapser').siblings('ul').toggle(); // show list if js is disabled
    }
    jQuery('.collapser').click(function() {
        jQuery(this).siblings('ul').toggle();
        jQuery(this).children('i').toggleClass('active');
    });
}

// Remove advert block when there is no ad inside. Show 'advert' text when there is an ad 
function hideAdverts() {
    jQuery('.google-ad,.skyscraper,.advert').each(function() {

        // if there is no ad hide container
        if (jQuery(this).find('img').length > 0 && jQuery(this).find('img').attr('src').match('empty.gif')) {
            if (jQuery.browser.msie && jQuery.browser.version <= 7) {
                jQuery(this).css({'visibility':'hidden'});
            }
            else if (jQuery.browser.msie && jQuery.browser.version == 8) {
                jQuery(this).css({'visibility':'hidden', 'height':'0'});
            }

            else {
                jQuery(this).css({'display':'none', 'height':'0'});
            }
        } // otherwise show container
        else if (jQuery(this).children('dd').height() > 20) {
            jQuery(this).children('dt').css('display', 'block');
        }
        // display advertisement bg image for top ad
        if (jQuery(this).hasClass('wide') && jQuery(this).children('dd').height() > 20) { // for wide ads which us bg image
            jQuery(this).addClass('advert-text');
        }
    });
}

// If there is an element with id "scroll-here" than it will be focused
function scrollToTop() {
    if (jQuery('#scroll-here').length == 1) {
        window.location = "#scroll-here";
    }
}

function popup(url, n, w, h) {
    var popup_window = 0;

    if (!popup_window.top) {
        popup_window = window.open(url, n, 'width=' + w + ',height=' + h + ',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no');
    }
    popup_window.focus();
}

function addParameterIfSkipCache() {
    if (/skipCache/.test(window.location.href)) {
        return "?skipCache=true";
    } else {
        return "";
    }
}

function getParameterIfSkipCache() {
    if (/skipCache/.test(window.location.href)) {
        return "&skipCache=true";
    } else {
        return "";
    }
}

function reverse(str) {
    if (!str) return '';
    var revstr = '';
    for (i = str.length - 1; i >= 0; i--)
        revstr += str.charAt(i)
    return revstr;
}
//	onLoadJson(id of panel in which to insert feed, number of results to show, url to fetch, panel )

function onLoadJson(feedUri, length, panel, heading, template, prefix, args) {

    // template to use, falls back to default if not specified
    var jsTemplate = template || "feed_template";
    var jsPrefix = prefix || "/webapi/1.0/blogs/";
    var webApiUrl;

    // using regex to match word "search", to treat searchuri's differently
    var containsSearch = feedUri.match(/\bsearch/g);
    var twitterMatch = feedUri.match(/\btwitter/g);

    var mostviewed = feedUri.match(/\bmost_viewed/g);

    if (containsSearch !== null && twitterMatch === null) {
        webApiUrl = site.abbreviation + feedUri + addParameterIfSkipCache();
    }
    else if (mostviewed !== null) {
        webApiUrl = site.abbreviation + "/webapi/1.0/" + feedUri + ".json" + addParameterIfSkipCache();
    }
    else {
        var jsPrefix = prefix || "/webapi/1.0/blogs/";
        webApiUrl = site.abbreviation + prefix + length.toString() + '?feedUrl=' + encodeURIComponent(reverse(feedUri)) + getParameterIfSkipCache();
    }


    // parsing json object
    function displayFeed(panel, data) {
        data.heading = heading;

        // data.params is a container object for any optional parameters passed to onLoadJson
        data.params = args || {}; // add extra paramaters if passed to onLoadJson

        // extend params with quoteBySearchParams if they are available in this call
        if (typeof quoteBySearchParams == "object") {
            jQuery.extend(data.params, quoteBySearchParams);
        }

        jQuery('.' + panel + '_feed').html(tmpl(jsTemplate, data));
        // console.log(data);
    }

    // config parameters
    var options = {
        type: "GET",
        url: webApiUrl,
        dataType: "json",
        timeout: 60000, // 6 seconds
        success: function(data, textStatus) {
            if ((typeof data.entries == "object" && data.entries.length > 0) || (typeof data.articles == "object")) {    // only display if there is something to show
                displayFeed(panel, data);
            } else if (typeof console == "object") {
                console.log(data.title + " is hidden because it returned no results. It's an " + typeof data.entries);
            } // otherwise show what there is for debugging
        },
        error: function(xhr, textStatus, errorThrown) {
            //console.log(webApiUrl+ ' returned error: ' +errorThrown + '\n and status:' + textStatus + ' ' + xhr.responseText);
        },
        complete: function(xhr, textStatus) {
            //console.log(webApiUrl+ '\n complete - returned status: '+' ' +textStatus);
        }
    };

    // fetch json
    jQuery.ajax(options);


}

//json volume handler
function jsonVolumesEventHandler() {
    jQuery('.jsonVolumeLoader').unbind();
    jQuery('.jsonVolumeLoader').bind('click', function(event) {

        var volumeObj = jQuery(this);
        var volume = jQuery(this).attr('id');
        event.preventDefault();

        var webApiUrl = site.abbreviation + "/browseVolume.json?volume=" + volume + getParameterIfSkipCache();

        var options = {
            type: "GET",
            url: webApiUrl,
            dataType: "json",
            timeout: 60000, // 6 seconds
            beforeSend: function (XMLHttpRequest) {
                // startAjaxSpinner();
            },
            success : function(data, textStatus) {
                var volumeNumber = data.articleCollectionDataList[0].volumeNumber;
                updateVolumeList(volumeNumber, data);
                jQuery("#" + volumeNumber).children('h3').addClass("active");
                jQuery('div.volume_' + volumeNumber).show();
                //stopAjaxSpinner();
            },
            error : function (XMLHttpRequest, textStatus, errorThrown) {
                // jQuery('.ajax-error').slideDown("fast").fadeOut(6000);
            },
            complete: function (XMLHttpRequest, textStatus) {
                //stopAjaxSpinner();
            }
        };
        //if (jQuery.trim(jQuery("div.volume_" +  volume).html()) != "") {
        if (jQuery(this).children('h3').hasClass("active")) {
            jQuery("div.volume_" + volume).html("");
            jQuery(this).children('h3').removeClass("active");

        }
        else {
            jQuery.ajax(options);

        }
    });


    function startAjaxSpinner() {
        jQuery('.ajax-spinner').html("<img src=\"/images/icons/ajax-loader.gif\" alt=\"\" />").show();
    }

    function stopAjaxSpinner() {
        jQuery('.ajax-spinner').hide();
    }

    function updateVolumeList(vol, data) {
        jQuery("div.volume_" + vol).html(tmpl("render_issue_volume", data));
    }

}

 function recordOutboundLink(link, category, action) {
    _gat._getTrackerByName()._trackEvent(category, action);
    setTimeout('document.location = "' + link.href + '"', 100);
  }

//json archive handler
function jsonArchiveEventHandler() {
    jQuery('.jsonArchiveLoader').unbind();
    jQuery('.jsonArchiveLoader').bind('click', function(event) {
        var volumeNumber = jQuery(this).attr('id');
        event.preventDefault();

        var webApiUrl = site.abbreviation + "/browseVolume.json?volume=" + volumeNumber + getParameterIfSkipCache();
        var options = {
            type: "GET",
            url: webApiUrl,
            dataType: "json",
            timeout: 15000, // 6 seconds
            beforeSend: function (XMLHttpRequest) {
                // startAjaxSpinner();
            },
            success : function(data, textStatus) {
                // var yearOfPublicationNumber = data.year;
                updateVolumeList(volumeNumber, data);
                jQuery("#" + volumeNumber).children('h3').addClass("active");
                jQuery('div.archive_' + volumeNumber).show();
                //stopAjaxSpinner();
            },
            error : function (XMLHttpRequest, textStatus, errorThrown) {
                // jQuery('.ajax-error').slideDown("fast").fadeOut(6000);
            },
            complete: function (XMLHttpRequest, textStatus) {
                //stopAjaxSpinner();
            }
        };

        if (jQuery.trim(jQuery("div.archive_" + volumeNumber).html()) != "") {
            jQuery("div.archive_" + volumeNumber).html("");
            jQuery(this).children('h3').removeClass("active");
        }
        else {
            jQuery.ajax(options);
        }
    });


    function startAjaxSpinner() {
        jQuery('.ajax-spinner').html("<img src=\"/images/icons/ajax-loader.gif\" alt=\"\" />").show();
    }

    function stopAjaxSpinner() {
        jQuery('.ajax-spinner').hide();
    }

    function updateVolumeList(volumeNumber, data) {
        jQuery("div.archive_" + volumeNumber).html(tmpl("render_archive_volume", data));
    }

}

//json volume decade handler
function jsonDecadeEventHandler() {
    jQuery('.jsonIssueDecadeLoader').unbind();
    jQuery('.jsonIssueDecadeLoader').bind('click', function(event) {
        var decade = jQuery(this).attr('id');
        event.preventDefault();

        var webApiUrl = site.abbreviation + "/browseDecade.json?decadeStart=" + decade + getParameterIfSkipCache();

        var options = {
            type: "GET",
            url: webApiUrl,
            dataType: "json",
            timeout: 15000, // 6 seconds
            beforeSend: function (XMLHttpRequest) {
                // startAjaxSpinner();
            },
            success : function(data, textStatus) {
                var decadeNumber = Math.floor(data.volumes[0].startYear / 10) + "0";
                updateDecadeList(decadeNumber, data);
                jsonVolumesEventHandler();
                jsonArchiveEventHandler();
                jQuery("#" + decadeNumber).children('h2').addClass("active");
                //stopAjaxSpinner();
            },
            error : function (XMLHttpRequest, textStatus, errorThrown) {
                // jQuery('.ajax-error').slideDown("fast").fadeOut(6000);
            },
            complete: function (XMLHttpRequest, textStatus) {
                //stopAjaxSpinner();
            }
        };

        if (jQuery.trim(jQuery("div.decade_" + decade).html()) != "") {
            jQuery("div.decade_" + decade).html("");
            jQuery(this).children('h2').removeClass("active");
        }
        else {
            jQuery.ajax(options);
        }
    });


    function startAjaxSpinner() {
        jQuery('.ajax-spinner').html("<img src=\"/images/icons/ajax-loader.gif\" alt=\"\" />").show();
    }

    function stopAjaxSpinner() {
        jQuery('.ajax-spinner').hide();
    }

    function updateDecadeList(decade, data) {
        jQuery("div.decade_" + decade).html(tmpl("render_decade", data));
    }

}

function jsonEventHandler() {
    var cache = {};
    jQuery('.jsonloader').bind('click', function(event) {
        var preCacheKey = jQuery('#article-pane-nav').find('.current').children().attr('id');
        if (!cache[preCacheKey]) {
            cache[preCacheKey] = jQuery('#articles').html();
        }
        linkId = jQuery(this).attr('id');
        var parameters = jQuery(this).attr('jsonParams');
        event.preventDefault();
        var webApiUrl = site.abbreviation + "/webapi/1.0/" + linkId + ".json" + addParameterIfSkipCache();
        if (parameters) {
            webApiUrl += "?" + parameters;
        }
        var options = {
            type: "GET",
            url: webApiUrl,
            dataType: "json",
            timeout: 6000, // 6 seconds
            success : function(data, textStatus) {
                update(linkId, data, null);
            },
            error : function (XMLHttpRequest, textStatus, errorThrown) {
                jQuery('.ajax-error').slideDown("fast").fadeOut(6000);
            }
        };
        if (cache[linkId]) {
            update(linkId, null, cache[linkId]);
        } else {
            jQuery.ajax(options);
        }
    });

    function update(container, data, html) {
        displayRss();
        updateArticleList(container, data, html);
        makeTabCurrent(container);
    }

    function displayRss() {
        jQuery('ul#article-pane-nav li').find('a.rss').hide();
        jQuery('#' + linkId).siblings().children('a.rss').show();
    }

    function makeTabCurrent(linkId) {
        jQuery('.article-panel-tabs').removeClass('current');
        jQuery('#' + linkId).parent().addClass('current');
    }

    function updateArticleList(linkId, data, html) {
        if (!html) {
            cache[linkId] = tmpl(linkId + "_template", data);
        }
        jQuery('#articles').html(cache[linkId]);
        return html;
    }

}


// Hide all rss icons apart from first
function hideRssIcons() {
    jQuery('ul#article-pane-nav li').eq(0).siblings().find('a.rss').hide();
}

// Advanced Search
jQuery(function() {
    var optionsToggler = jQuery('p.options a.options-toggler');

    optionsToggler.click(
            function() {
                jQuery(this).add(jQuery("i", this)).toggleClass('active');
            });
});

// IE 6 and 7 input:focus
jQuery(document).ready(function() {
    jQuery("input[type='text']:not(.placeholder)").focus(function() {
        jQuery("input:[text]").css('color', '#000000');
    });
});


function initialiseScrollable() {


    // if .random class present gallery items will be shuffled
    //--------------------------------------------------------
    if (jQuery("div.scrollable").hasClass("random")) {

        // grab and randomise order of gallery items
        var gall = jQuery('div#thumbs div');
        gall.sort(function() {
            return 0.5 - Math.random()
        });
        gall.sort(function() {
            return 0.5 - Math.random()
        });

        // remove existing unshuffled items
        jQuery('div#thumbs div').remove();

        // add shuffled items
        for (var i = 0; i < gall.length; i++) {
            jQuery('div#thumbs').prepend(gall[i]);
        }

        // display gallery
        jQuery("div.scrollable").css("visibility", "visible");

    }

    // initialize scrollable
    jQuery("div.scrollable").scrollable({
        size: 1,
        items: '#thumbs',
        hoverClass: 'hover',
        loop: true,
        circular: true
    }).navigator({
                     // show dots
                     navi: ".navi"
                 }).autoscroll({
                                   autoplay: true,
                                   interval: 10000
                               });

    // arrow show/hide behaviour
    $('.scrollable-container').bind('mouseover',
            function() {
                $(this).children('a.left, a.right, div.navi').removeClass('disabled');
            }).bind('mouseout', function() {
        $(this).children('a.left, a.right, div.navi').addClass('disabled');
    });

}

// Andrew Urquhart : CountDownPro Timer : www.andrewu.co.uk/clj/countdown/pro/
function CD_M(strTagId) {
    var objMeta = document.getElementsByTagName("meta");
    if (objMeta && objMeta.length) {
        for (var i = 0; i < objMeta.length; ++i) {
            if (objMeta.item(i).scheme == strTagId) {
                var name = objMeta.item(i).name;
                var content = objMeta.item(i).content;
                if (name.indexOf("mindigits") > 0 || name.indexOf("hidezero") > 0) {
                    window[strTagId][name] = parseInt(content, 10)
                } else {
                    window[strTagId][name] = content
                }
            }
        }
    }
}
;
function CD_UD(strContent, objW) {
    objW.node.innerHTML = strContent
}
;
function CD_T(strTagId) {
    var objNow = new Date();
    var objW = window[strTagId];
    if (objW.msoffset) {
        objNow.setMilliseconds(objNow.getMilliseconds() + objW.msoffset)
    }
    ;
    CD_C(objNow, objW);
    if (objW.intEvntDte <= objNow.valueOf()) {
        if (objW.event_functionhandler && typeof window[objW.event_functionhandler] == "function") {
            window[objW.event_functionhandler](new Date(objW.intEvntDte));
            objW.event_functionhandler = ""
        }
        if (objW.event_msg || objW.event_redirecturl) {
            var msg = "<span id=\"" + strTagId + "_complete\">" + objW.event_msg + "</span>";
            if (objW.event_redirecturl) {
                location.href = objW.event_redirecturl
            } else if (objW.event_audio_src) {
                var strMimeType = objW.event_audio_mimetype;
                var audioObject = "<object style=\"visibility:hidden;\" id=\"MediaPlayer\" width=\"2\" height=\"2\" data=\"" + objW.event_audio_src + "\" type=\"" + strMimeType + "\"></object>";
                CD_UD(msg + audioObject, objW)
            } else {
                CD_UD(msg, objW)
            }
            ;
            return
        }
    }
    ;
    setTimeout("if(typeof CD_T=='function'){CD_T(\"" + strTagId + "\")}", 1100 - objNow.getMilliseconds())
}
;
function CD_C(objNow, objW) {
    var intMS = objW.intEvntDte - objNow.valueOf();
    if (intMS <= 0) {
        intMS *= -1
    }
    ;
    var intD = Math.floor(intMS / 864E5);
    intMS = intMS - (intD * 864E5);
    var intH = Math.floor(intMS / 36E5);
    intMS = intMS - (intH * 36E5);
    var intM = Math.floor(intMS / 6E4);
    intMS = intMS - (intM * 6E4);
    var intS = Math.floor(intMS / 1E3);
    var strTmp = CD_F(intD, "d", objW) + CD_F(intH, "h", objW) + CD_F(intM, "m", objW) + CD_F(intS, "s", objW);
    CD_UD(strTmp, objW)
}
;
function CD_F(intData, strPrefix, objW) {
    if (intData == 0 && objW[strPrefix + "_hidezero"]) {
        return ""
    }
    ;
    var strResult = "" + intData;
    var intMinDigits = objW[strPrefix + "_mindigits"];
    if (intData.toString().length < intMinDigits) {
        strResult = "0000000000" + strResult;
        strResult = strResult.substring(strResult.length, strResult.length - intMinDigits)
    }
    if (intData != 1) {
        strResult += objW[strPrefix + "_units"]
    } else {
        strResult += objW[strPrefix + "_unit"]
    }
    ;
    return objW[strPrefix + "_before"] + strResult + objW[strPrefix + "_after"]
}
;
function CD_Parse(strDate) {
    var objReDte = /(\d{4})\-(\d{1,2})\-(\d{1,2})\s+(\d{1,2}):(\d{1,2}):(\d{0,2})\s+GMT([+\-])(\d{1,2}):?(\d{1,2})?/;
    if (strDate.match(objReDte)) {
        var d = new Date(0);
        d.setUTCFullYear(+RegExp.$1, +RegExp.$2 - 1, +RegExp.$3);
        d.setUTCHours(+RegExp.$4, +RegExp.$5, +RegExp.$6);
        var tzs = (RegExp.$7 == "-" ? -1 : 1);
        var tzh = +RegExp.$8;
        var tzm = +RegExp.$9;
        if (tzh) {
            d.setUTCHours(d.getUTCHours() - tzh * tzs)
        }
        if (tzm) {
            d.setUTCMinutes(d.getUTCMinutes() - tzm * tzs)
        }
        ;
        return d
    } else {
        return NaN
    }
}
;
function CD_Init() {
    var strTagPrefix = "countdown";
    var objElem = true;
    if (document.getElementById) {
        for (var i = 1; objElem; ++i) {
            var strTagId = strTagPrefix + i;
            objElem = document.getElementById(strTagId);
            if (objElem && (typeof objElem.innerHTML) != 'undefined') {
                var strDate = objElem.innerHTML;
                var objDate = CD_Parse(strDate);
                if (!isNaN(objDate)) {
                    var objW = window[strTagId] = new Object();
                    objW.intEvntDte = objDate.valueOf();
                    objW.node = objElem;
                    objW.servertime = "";
                    objW.d_mindigits = 1;
                    objW.d_unit = " day";
                    objW.d_units = " days";
                    objW.d_before = "";
                    objW.d_after = " ";
                    objW.d_hidezero = 0;
                    objW.h_mindigits = 2;
                    objW.h_unit = "h";
                    objW.h_units = "h";
                    objW.h_before = "";
                    objW.h_after = " ";
                    objW.h_hidezero = 0;
                    objW.m_mindigits = 2;
                    objW.m_unit = "m";
                    objW.m_units = "m";
                    objW.m_before = "";
                    objW.m_after = " ";
                    objW.m_hidezero = 0;
                    objW.s_mindigits = 2;
                    objW.s_unit = "s";
                    objW.s_units = "s";
                    objW.s_before = "";
                    objW.s_after = " ";
                    objW.s_hidezero = 0;
                    objW.event_msg = "";
                    objW.event_audio_src = "";
                    objW.event_audio_mimetype = "";
                    objW.event_redirecturl = "";
                    objW.event_functionhandler = "";
                    CD_M(strTagId);
                    if (objW.servertime) {
                        var objSrvrTm = CD_Parse(objW.servertime);
                        if (isNaN(objSrvrTm)) {
                            objElem.innerHTML = strDate + "**";
                            continue
                        } else {
                            objW.msoffset = parseInt((objSrvrTm.valueOf() - (new Date()).valueOf()) / 1000, 10) * 1000
                        }
                    } else {
                        objW.msoffset = 0
                    }
                    ;
                    CD_T(strTagId);
                    if (objElem.style) {
                        objElem.style.visibility = "visible"
                    }
                } else {
                    objElem.innerHTML = strDate + "<a href=\"http://andrewu.co.uk/clj/countdown/pro/\" title=\"CountdownPro Error:Invalid date format used,check documentation (see link)\">*</a>"
                }
            }
        }
    }
}
if (window.attachEvent) {
    window.attachEvent('onload', CD_Init)
} else if (window.addEventListener) {
    window.addEventListener("load", CD_Init, false)
} else {
    window.onload = CD_Init
}
;


// detect zoom event - http://mlntn.com/2008/12/11/javascript-jquery-zoom-event-plugin/
jQuery.fn.zoom = function(fn) {
    // Set handler for keyboard zooming in Firefox, IE, Opera, Safari.
    // This is the only valid case of browser-specific code I've ever seen -JM
    jQuery(document).keydown(function(e) {
        switch (true) {
            case jQuery.browser.mozilla || jQuery.browser.msie :
                if (e.ctrlKey && (
                        e.which == 187 || // =/+ (zoom in [FF, IE])
                                e.which == 189 || // -   (zoom out [FF, IE])
                                e.which == 107 || // +   (numpad) (zoom in [FF, IE])
                                e.which == 109 || // -   (numpad) (zoom out [FF, IE])
                                e.which == 96 || // 0   (reset zoom [FF, IE])
                                e.which == 48     // 0   (numpad) (reset zoom [IE, FF, Opera])
                        )) fn();
                break;
            case jQuery.browser.opera :
                // Opera requires CTRL to be pressed for reset (using num 0)
                if (
                        e.which == 43 || // +   (numpad) (zoom in [Opera, Safari])
                                e.which == 45 || // -   (numpad) (zoom out [Opera, Safari])
                                e.which == 42 || // *   (numpad) (reset zoom [Opera])
                                (e.ctrlKey && e.which == 48) // 0   (numpad) (reset zoom [FF, IE, Opera])
                        ) fn();
                break;
            case jQuery.browser.safari :
                // Use e.metaKey for the Apple key
                if (e.metaKey && (
                        e.charCode == 43 || // +   (numpad) (zoom in [Opera, Safari])
                                e.charCode == 45    // -   (numpad) (zoom out [Opera, Safari])
                        )) fn();
                break;
        }
        return;
    });

    // Set handler for scrollwheel zooming in IE
    jQuery(document).bind('mousewheel', function(e) {
        if (e.ctrlKey) fn();
    });

    // Set handler for scrollwheel zooming in Firefox
    jQuery(document).bind('DOMMouseScroll', function(e) {
        if (e.ctrlKey) fn();
    });
};

function quickSearchBoxResize() {

    // ascertain free width
    var input = jQuery('input#searchTerms').width();
    var text = jQuery('fieldset.search span').width();
    var newwidth = 355 - text;

    // add extra width to input panel
    jQuery('.branding-inner input#searchTerms').width(newwidth + 'px');
}

function uploadFileField() {
    // used to simulate file upload input field

    $('input.upload-field').wrap('<div class="upload-container right">');
    $('.upload-container').before('<input class="file text"/>');

    $('input#file').change(function() {
        $('input.file.text').attr('value', $('input#file').attr('value').replace('C:\\fakepath\\', ''))
    });

    $('input.file.text').focus(function() {
        $('input#file').click();
    });

    $('input.upload-field').css('display', 'block');
}

/* function for handling drop down flash ads which need to overlay content */
function popOverBannerAd(popOverAd) {
    if ($.browser.msie && ($.browser.version == "7.0" || $.browser.version == "6.0")) {
        $(popOverAd).mouseover(function() {
            $(this).css({'overflow' : 'visible'});
        })

        $('body').mousemove(function(e) {
            if (e.pageY > 300 || e.pageX < 250 || e.pageX > 1000) {
                $(popOverAd).css({'overflow' : 'hidden'});
            }
        });
    }
    else if ($.browser.mozilla) {
        $('#branding').prepend('<div id="ff-hitarea"></div>');

        $('#ff-hitarea').mouseover(
                function() {
                    $(popOverAd).addClass('popover');
                    $(popOverAd).parent('dl').css('height', '90px');
                }).mouseout(function() {
            $(popOverAd).removeClass('popover');
        });
    }
    else {
        $(popOverAd).mouseover(
                function() {
                    $(this).addClass('popover');
                    $(this).parent('dl').css('height', '90px');
                }).mouseout(function() {
            $(this).removeClass('popover');
        });

    }

}

function toggleList() {
    if (jQuery('.collapser').siblings('ul').attr('class') != 'hidebeforeload') {
        jQuery('.collapser').siblings('ul').toggle(); // show list if js is disabled
    }
    jQuery('.collapser').click(function() {
        jQuery(this).siblings('ul').toggle();
        jQuery(this).children('i').toggleClass('active');

        if (site.page == "microsite") {
            jQuery('#showmore').css('display', 'none');
        }
    });
}

function updatesPanel() {
    jQuery('#twitter_updates_tab').bind('click', function() {
        jQuery(this).addClass('current');
        jQuery('#fromtheblog_tab').removeClass('current');
        jQuery('#twitter_updates').css('display', 'block');
        jQuery('#fromtheblog').css('display', 'none');
    });

    jQuery('#fromtheblog_tab').bind('click', function() {
        jQuery(this).addClass('current');
        jQuery('#twitter_updates_tab').removeClass('current');
        jQuery('#twitter_updates').css('display', 'none');
        jQuery('#fromtheblog').css('display', 'block');
    });
}

	function citationArticlesAjax () {
		//ajax for citation articles
		var ajaxArticleDiv = jQuery("#citations_biomedcentral_articles");
		ajaxArticleDiv.hide();

		jQuery("#about-citedon-biomed-link").click(function() {
			jQuery(this).parent().click();
			return false;
		});

		jQuery("#citations_biomedcentral").css("cursor", "pointer");
		jQuery("#citations_biomedcentral").click(function() {
			if (ajaxArticleDiv.hasClass("article_loaded")) {
				ajaxArticleDiv.toggle();
				ajaxArticleDiv.css('display','block');
				return false;
			}
			var url = $("#urlForAjax").html();
			jQuery.ajax({
				url: url,
				timeout:300000,
				beforeSend:function() {
					ajaxArticleDiv.html('<img src="/images/loading.gif" alt="loading"/>');
					ajaxArticleDiv.show();
				},
				error:function(XMLHttpRequest, textStatus, errorThrown) {
					ajaxArticleDiv.html('Sorry, we cannot load the articles at the moment. Please try later.');
					console.log(errorThrown);
				},
				success: function(data) {
					ajaxArticleDiv.html(data);
					ajaxArticleDiv.addClass("article_loaded");
					if(jQuery('a.summary').length > 0) {
						   jQuery('a.summary').click(function(){
							var summaryToggled=jQuery(this).toggleClass('active').parents('.nav').eq(0).next('div.summary-toggled').eq(0);
							var self=this;
							summaryToggled.slideToggle('fast');
							return false;
						});
				}
				}
			});
		});
		
		
		
	}


//	on Load
jQuery(document).ready(function() {
    if (site.portal != true) { // don't resize SO searchbox
        quickSearchBoxResize();
    }

    if (site.page == "microsite") {
        updatesPanel();
    }

    scrollToTop();
    toggleList();
    hideRssIcons();
    addTextAreaMaxLengthListener();
    // ajax
    if (site.section == "home") { // run on homepage only

        if (quoteSearchUri) {

            if (typeof heading == "undefined") {
                onLoadJson(quoteSearchUri, 0, 'quote_by_search', '', 'quotes_by_search_template', '/webapi/1.0/search/');
            }
            else if (site.id == 3001 || site.id == 3008 || site.id == 10184) { // petsko's column and musings on GM
                onLoadJson(quoteSearchUri, 0, 'quote_by_search', heading, 'custom_quote_by_search_column', '/webapi/1.0/search/');
            }
            else {
                onLoadJson(quoteSearchUri, 0, 'quote_by_search', heading, 'quotes_by_search_template', '/webapi/1.0/search/');
            }
        }

        ieSelectExpand('select#journalDropList', '217px', '370px');

    }


    if (jQuery('.scrollable').offset()) {
        initialiseScrollable();
    }
    if (site.section == "journals") {
        toggler('.toggler');
    }

    if (site.page == "indexing" || site.page == "article_stats") {
		if(site.page == "article_stats") {
			initializeAccordion({hideAll: true });
			citationArticlesAjax ();
		} else {
        initializeAccordion();
    }
    }

    if (site.page == "ordinst_form" || site.page == "free_trials" || site.page == "advancedsearch" || site.page == "quick_reg_contact") {
        toggleCheckBox();
    }
	
	if (site.page == "advancedsearch") {
        advancedSearchToggleCheck();
    }

    if (site.page == "biography") {
        uploadFileField();
    }

    jsonEventHandler();
    jsonVolumesEventHandler();
    jsonArchiveEventHandler();
    jsonDecadeEventHandler();
    // function needs to be modified for archive page
    if (site.page != "archive") {
        accordionHover();
    }
});

// webkit cannot handle document.ready with width() or height()
jQuery(window).load(function() {
    hideAdverts();

    // if there is a collapsing banner ad
    if (parseInt($('.google-ad.wide #OAS_RMF_Top_FLASH').attr('height')) > 90) {
        popOverBannerAd(('.google-ad.wide dd'));
    }

    // resize pop-up windows (chrome has issue with resizing and doc.load)
    if (jQuery("body").attr('id') == "popup") {
        resizeWindow();
    }
})

function loadPanelByJson(configs) {
    for (var i = 0; i < configs.length; i++) {
        onLoadJson(configs[i].feedUri, configs[i].feedLength, configs[i].panel, configs[i].heading, configs[i].template, configs[i].prefix, configs[i].args);
    }
}

function renderCollapsable(header) {
    var isActive = header.hasClass('active');
    var collapseBody = header.next(".collapse-body");
    if (isActive) {
        collapseBody.show();
    } else {
        collapseBody.hide();
    }
}
function initializeUserProfilePage() {
    jQuery('.collapse-header').click(function() {
        var collapsableHeader = $(this);
        collapsableHeader.toggleClass('active');
        renderCollapsable(collapsableHeader);
    });

    $('.collapse-header').each(function(index) {
        renderCollapsable($(this));
    });
}

function toggleContactDetails(contactStatus, contactDetails) {
    var checked = $("input[name=" + contactStatus + "]").is(':checked');
    $("input[name=" + contactDetails + "]").attr('disabled', !checked);
}

/*
function submitManuscript(ac) {
    jou_id = document.getElementById('journalId').value;
    if (ac == 'submit' && jou_id == '10280') document.submit_manuscript.action = 'mailto:comc@connected.ly';
    else if (ac == 'instructions' && jou_id == '10280') document.submit_manuscript.action = "#";
}*/

function submitform() {
    document.submit_manuscript.action = '/authors/instructions/#submitManuscript';
    var currentElement = document.createElement("input");
    currentElement.setAttribute("type", "hidden");
    currentElement.setAttribute("name", "actionPerformed");
    currentElement.setAttribute("value", "viewScope");
    document.getElementById('submit_manuscript').appendChild(currentElement);
    document.getElementById('submit_manuscript').submit();
}

function LoadInParent(link) {

	$('li' + link).css('background-color','#f2f2f2');
   	window.location = link;
	window.focus();
}

function initializeJumBrowseForm() {
    $('#jumpBrowse').submit(function() {
        if ($('#jumpToVolume').attr('value') == '') {
            $('#showMandatoryVolumeErrorMessage').show();
            return false;
        }
    });
}


function initializeInterestsForm() {
    $('h2.active').removeClass('active').siblings('.wrap-in').css('display', 'none');
    $('h2.expanded').addClass('active').siblings('.wrap-in').css('display', 'block');
    $('h2.active').removeClass('expanded');
}

function initializeLightbox() {
	/* Fancy box for IP /libraries/free_trials*/
 $("a#whatismyip").fancybox();

    /*
     *   Group Images and Navigation within Lightbox
     */

    $("a[rel=photos_group]").fancybox({
        'transitionIn'        : 'none',
        'transitionOut'        : 'none',
        'titlePosition'     : 'over',
        'titleFormat'        : function(title, currentArray, currentIndex, currentOpts) {
            return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
        }
    });

    console.log('lightbox has run');
}

function loadJournalSection() { 
	$("#journalSectionId").change(function() { 
		jQuery.ajax({
			url : "/author/manuscript/details/sectionDescription",
			dataType: "html",
			data : {
				"journalSectionId" : $("#journalSectionId").val()
			},
			success : function(data) {
			    $("#sectiondescription_result").show();
			    $("#sectiondescription_result").html(data);
				$("#subsectiondescription_result").hide();

				},
			error : function(request, errorType, errorThrown) {
				$("#sectiondescription_result").html('<h4 class="error">Sorry, an error occurred: ' + errorType + '</h4>');
			},
			cache : false,
			timeout : 60000
		});
	});

    $("#sectiondescription_result").show();
    $("#loadSubsections").hide();
	$("#scope").hide();
	$("#viewScope").hide();
}

function loadJournalSubSectionDescription() {
	$("#journalSubSectionId").change(function() {
		jQuery.ajax({
			url : "/author/manuscript/details/subSectionDescription",
			dataType: "html",
			data : {
				"journalSubSectionId" : $("#journalSubSectionId").val()
			},
			success : function(data) {
				$("#subsectiondescription_result").html(data);
				$("#subsectiondescription_result").show();
				},
			error : function(request, errorType, errorThrown) {
				$("#subsectiondescription_result").html('<h4 class="error">Sorry, an error occurred: ' + errorType + '</h4>');
			},
			cache : false,
			timeout : 60000
		});
	});

    $("#subsectiondescription_result").show();
    $("#loadSubsections").hide();
    $("#scope").hide();
	$("#viewSubsectionScope").hide();
}

function loadJournalSubSection() {
    $("#journalSectionId").change(function() {
		jQuery.ajax({
			url : "/author/manuscript/details/subSections",
			dataType: "html",
			data : {
				"journalSectionId" : $("#journalSectionId").val()
			},
			success : function(data) {
				$("#journalSubSectionId").html(data);
	        	if  ($('#journalSubSectionId option').size() <= 1) {
	 			    $("#journalSubSectionId").hide();
				} else {
            		  $("#journalSubSectionId").show();
				}
			},
			error : function(request, errorType, errorThrown) {
				alert("Error while loading subsections")
			},
			cache : false,
			timeout : 60000
		});
	});
	if  ($('#journalSubSectionId option').size() <= 1) {
	    $("#journalSubSectionId").hide();
	}

     $("#loadSubsections").hide();
	 $("#scope").hide();
}


/* FAQ and browse/articles scroll up/down to refactor as a function (greg) */
jQuery('a.options-toggler').click(function() {
    jQuery('.checkbox-toggle').toggle();
    jQuery(this).toggleClass('active').parents('.options').eq(0).next().slideToggle({complete:function() {
        jQuery('.display-controls').toggle();
    }});
    return false;
});

/* browse by subject anchor toggler */
function toggleAnchorAccordion() {
	if(jQuery(location.hash).length > 0) {
		$(location.hash).children('h2').toggleClass('active').siblings('ul:hidden').show();
	}
}

jQuery(document).ready(function() {
    loadPanelByJson(jsonLoaders.list());
    jQuery("#journalListId").css('width', '334px');
    if (site.page == "emailPreferences" || site.page == "details") {
        initializeInterestsForm();    //for profile/my_interests_form.vm and user_interests_form.vm
    }
    initializeJumBrowseForm();
    toggleContactDetails('globalContactStatus', 'globalContactDetails');
    toggleContactDetails('journalContactStatus', 'journalContactDetails');
    initializeUserProfilePage();
    setInputConscious('placeholder', 'slept', 'awaken');
    if (site.page == "indexing" || site.page == "article_stats") {
        collapseAccordionByAnchor();
    }

    // FAQ / browse articles scroll
    jQuery('p.options a.options-toggler').each(function () {
        jQuery(this).removeClass('active').parents('.options').eq(0).next().hide()
    });


    if (jQuery('a[rel="photos_group"]').length != 0) {
        initializeLightbox();
    }
		 if ($("a#whatismyip").length != 0) {
        initializeLightbox();
    }

    if ($("#flowplayer").offset()) {
        videoPlaylist(video_args);
    }

    if (site.page == "videos" || site.page == "ourauthors") {
        singleVideo("myPlayer");
    }
    
    if (site.page == "submission") {
     $("#subsection_dropdown").hide();

     if ($('#journalSubSectionId option').size() <= 1) {

	 		$("#journalSubSectionId").hide();
	 } else {

          $("#journalSubSectionId").show();
	 }

    	loadJournalSection();
    	loadJournalSubSection();
    	loadJournalSubSectionDescription();
    }
    if (site.id == "3001" && site.page == "home") {
        flowplayer("audio", "/flash/flowplayer/flowplayer-3.2.7.swf", {
            clip: {autoPlay: false},
            plugins: {
                controls: {fullscreen: false, autoHide: false, mute: false, volume: true}
            }
        });
    }
	
	/* render video article flowplayer */
	if($("#videoarticle").length > 0) {
		$f("videoarticle", "/flash/flowplayer/flowplayer-3.2.7.swf", {
		  buffering: true,
		  clip: {
			autoPlay: true,
			autoBuffering: true,
			bufferLength: '3', 
			scaling: 'fit'
		  }      
		}).ipad();
	}
	
	/* pop-up window for tracleer ad */
	if($('a[href*="Tracleer"]').length > 0) {
		$('a[href*="Tracleer"]').click(function(e) {
			e.preventDefault();
			window.open("http://"+site.url+"/advertising/tracleerpi.html","Tracleer","location=0,status=0,scrollbars=1, width=600,height=800", false)
		});
	}

    jQuery("#citations_biomedcentral").click();
});
