if (typeof jQuery !== 'undefined') {
    $(document).ready(function(){
    	// takes care of creating SUPERFISH menu functionality
        $(".nav ul#main-links").supersubs({
            minWidth:    10,   // minimum width of sub-menus in em units 
            maxWidth:    50   // maximum width of sub-menus in em units 
        }).superfish({
            autoArrows:     false,
            dropShadows:    false
        }).find('ul').bgIframe();
        
        // takes care of giving all tables an "odd"/"even" class on each row
        $("table").each(function() {
        	$(this).find("tr:even").addClass('evenRow');
        	$(this).find("tr:odd").addClass('oddRow');
        });
        
        // takes care of RegTemp_Tabbed_WYSIWYG setup
        $("div.Tabbed_WYSIWYG div.tab-content:not(:eq(0))").hide();
        $("div.Tabbed_WYSIWYG ul li a").click(function(){
        	var intIndex = $(this).parent().index();
        	$("div.Tabbed_WYSIWYG ul li.active").removeClass("active");
        	$(this).parent().addClass("active");
        	$("div.Tabbed_WYSIWYG div.tab-content").hide();
        	$("div.Tabbed_WYSIWYG div.tab-content:eq(" + intIndex + ")").show();
        });
        
        // if we're on the homepage, split out the funds drop down
        //		can we check the existance of a UCM variable and value here? g_ssSourcdNodeId?
        if ($("body").attr("id") == "nodeId377") {quickFundDD();}
        
        // this should be moved to robots.txt once that is working correctly - no need for a search engine to see this link
        $('div.nav#main-nav ul#quick-links li a[href*="DefaultSite"]').attr("rel","nofollow");
    });
    
	function showFootnote(f,fsc) {
		// to improve this function, we could pass in some kind of 
		//   "website root" so the image doesnt have to use the service, and so the 
		//   the .load() will work on all environments.
	
		//add loading image, remove on callback of load()
		$("div#footnotes").empty();
		$("div#footnotes").append(
			'<div class="ajaxLoading"><img src="/idc/idcplg?IdcService=GET_FILE&dDocName=AJAX_loading_icon&RevisionSelectionMethod=LatestReleased" alt="loading animation"></div>'
		);
		$("div#footnotes").load("/ws/index.htm?service=SubTemp_WS_Footnotes&f=" + f + "&fsc=" + fsc + " .footnotes p.footnote", 
			function() {
				//remove loading image
				$("div#footnotes .ajaxLoading").remove();
			}
		);
	}
	
	function quickFundDD() {
		$("#quickfund form select")
			.clone(false)
			.attr("id","temp-quickFundDD")
			.attr("style","display:none;")
			.appendTo("body");
	
		var aOption = [];
		var aType = [];
		$("#quickfund form select option").each(function(index, option) {
			aOption.push(option);
			aType.push($(option).attr("class").replace("fundType-",""));
		});
	
		$("#quickfund form select").before('<span class="mf"><input id="mf" type="radio" name="fType" value="1" checked="checked" /><label for="mf">Mutual Funds</label></span>');
		$("#quickfund form select").before('<span class="cef"><input id="cef" type="radio" name="fType" value="4" /><label for="cef">Closed End Funds</label></span>');
		$("#quickfund form select").before('<span class="rp"><input id="rp" type="radio" name="fType" value="2" /><label for="rp">Retirement Portfolios</label></span>');
	
		$("#quickfund form select option:gt(0)").remove();	
		$("#quickfund form select")[0].options.length = 1;
		
		$("#temp-quickFundDD option").each(function() {
			if ($(this).attr("class").replace("fundType-","") == 1) {
				$("#quickfund form select").append($(this).clone());
			}
		});
		
		$("input:radio[name=fType]").change(function() {
			var tmpVal = $(this).val();
			$("#quickfund form select option:gt(0)").remove();
			$("#quickfund form select")[0].options.length = 1;

			$("#temp-quickFundDD option").each(function() {
				if ($(this).attr("class").replace("fundType-","") == tmpVal) {
					$("#quickfund form select").append($(this).clone());
				}
			});
		});
	}
}

function change_parent_url(url) {	    
	document.location=url;
}

function popup(theURL,winName,features) {
  var wChild = window.open(theURL,winName,features);
  wChild.opener = self;
}
