﻿
(function()
{

	$.fn.FlyoutNav = function(options)
	{

		// Saving scope of this
		$this = this;

		// Defaults
		var defaults = {
	};

	var options = $.extend(defaults, options);

	function init()
	{
		attachEvents();
	}

	function attachEvents()
	{
		var timer;

		$this.mouseenter(function()
		{
			var el = $(this);
			$(this).children("a.mnav-lnk").addClass("hover")
			timer = setTimeout(function()
			{
				el.children("div.flyout").show(200);
			}, 100);
		});

		$this.mouseleave(function()
		{
			$(this).children("ul").stop();
			clearTimeout(timer);
			$(this).children("a.mnav-lnk").removeClass("hover")
			$(this).children("div.flyout").hide(100);
		});

		// remove event listeners when user leaves the page for memory efficiency
		$(window).unload(function()
		{
			removeEvents();
		});
	}

	// remove event listeners if need be
	function removeEvents()
	{
		$this.unbind("mouseenter")
		$this.unbind("mouseleave");
	}

	// loop through all selectors and initialize
	return this.each(function(i)
	{
		init();
	});
};

$.fn.RotateGallery = function()
{

 

 $("div#gallery div.widgetnav span.tabnav").tabs("div#gallery > div.panel", {

 

  // enable "cross-fading" effect
  effect: 'fade',
  fadeOutSpeed: "slow",

 

  // start from the beginning after the last tab
  rotate: true,

 

  // start on a random slide

  initialIndex: Math.floor(Math.random()*$("div#gallery > div.panel").length)

 

  // use the slideshow plugin. It accepts its own configuration
 }).slideshow({ autoplay: true, interval: 7000 });

 

 //$("div#gallery div.widgetnav a").click(function() { $("div#gallery div.widgetnav span.tabnav").tabs().stop(); alert('stop!'); });

 

};



$.fn.IndexTabs = function()
{

	$("div#indexes div.indextabs").tabs("div#indexes div.panels > div.panel", {


})

};


$.fn.PulldownLinks = function()
{


	var trigger = $("div#indexes div.pulldownlinks dl dt a.trigger");

	var target = $("div#indexes div.pulldownlinks dl");

	trigger.click(function()
	{

		target.toggleClass('activated');

		return false;

	});


};

$.fn.StartNewsTicker = function(){
    this.each(function(){
        var ticker = $(this);
        var delayInput = ticker.find("input[name=delay]");
        var delay = (delayInput.get(0) ? 1000 * delayInput.val() : 5000);
        var ticker = $(this);
        ticker.find(".ContentItem:first").show();
        function scrollTicker(){
            ticker.find(".ContentItem:first")
                .fadeOut('slow', function() {
                    var p = $(this).parent();
                    $(this).hide().remove();
                    p.append(this);
                    p.find(".ContentItem:first").fadeIn('slow');
                });
        }
        setInterval(scrollTicker, delay);
    });
};

})(jQuery);

// construct on dom ready
$(function()
{
	$(".change-location").FlyoutNav();
//	$("#mainnav > li").FlyoutNav();
	$("#mainnav > li").not('#mnav_Solutions').not('#mnav_Research').FlyoutNav();
	$("#mainnav_alt > li").FlyoutNav();
	$('#gallery').RotateGallery();
	$('#indexes').IndexTabs();
	$('#indexes').PulldownLinks();
	$('.newsticker').StartNewsTicker();
	$(".cli").FlyoutNav();
});

var _qs;
	function parseQuerystring()
	{
		_qs = new Object();
		if (location.search && location.search.length > 1)
		{
			var srch = location.search.substring(1).split('&');
			for (var i = 0; i < srch.length; i++)
			{
				var pr = srch[i].split('=');
				if (pr.length >= 2 && pr[0].length > 0)
				{
					_qs[pr[0]] = pr[1];
				}
			}
		}
	}

function GetQuerystring(key)
	{
		if (!_qs) parseQuerystring();
		return _qs[key];
	}

$(document).ready(function() {
    // Clear out default 'Search'
    $("#q").click(function() {
        $(this).val('');
    });
});

// compliance requirement for leaving r.com.
function clickleaveSite(d) {
	leaveSite(d);
	return false;
}

function leaveSite(d) {

	boolConfirmResponse = confirm("You are now leaving Russell.com. The following link may contain information concerning investments other than those offered by Russell Investments, its affiliates or subsidiaries. Neither Russell Investments nor its affiliates are responsible for investment decisions made with respect to such investments or for the accuracy or completeness of information about such investments. The material available on this site has been produced by independent providers that are not affiliated with Russell Investments. Descriptions of, references to, or links to products or publications within any linked web site does not imply endorsement of that product or publication by Russell Investments. Any opinions or recommendations expressed are solely those of the independent providers and are not the opinions or recommendations of Russell Investments, which is not responsible for any inaccuracies or errors.");

    if(boolConfirmResponse)
		{
		window.open(d);
		}
}

function PrintPage()
{
	window.print();
	return false;
}
