/* Glossary footer component scripts */

function initGlossary()
			{

				$('.glossary_term_list').change(function() {

					getGlossaryContent($(this).val());
				});


				$('#alphabet a').click(function() {

					 
					/* Find Letter Value */
					var letter = $(this).text().toLowerCase();

					$('.glossary_term_list option').attr("selected", "");

					var isFound = false; 

					/* Slide */
					if($('#alphabet').next().is(':hidden'))
					{
				   		$('#alphabet').next().slideToggle('fast', function() { $('.glossary_term_details').html($('.glossary_term_details').html()); });

					}

					$('.glossary_term_list option').each(
						function(intIndex){

							var glossaryTerm = $(this).text().toLowerCase();
							
							if (glossaryTerm.indexOf(letter) == 0) {

								$(this).attr("selected", "selected");

								$('glossary_term_list').focus();

								getGlossaryContent($(this).val());
								isFound = true;
					
								return false;

							}

							

						}
					);

					if (!isFound)
					{	
						$('.glossary_term_list')[0].selectedIndex  = -1;
						$('.glossary_term_details').html("");
					}	




					return false;
								
				});


				/* Close Toggle */
				$('.close').click(function() {
					$('.inner').slideToggle();
					return false;
				});

			}


			function glossaryLinkClicked(glossaryUrl)
			{
				$('.glossary_term_list option').each(
					function(intIndex){

						var listUrl = $(this).val().toLowerCase();						
														
						if (glossaryUrl.toLowerCase() == listUrl) {
							$(this).attr("selected", "selected");							
							getGlossaryContent(glossaryUrl);						
							return false;
						}
					}
				);
			}

			function getGlossaryContent(url)
			{

				var fullurl = "/glossary.aspx?altTemplate=GetGlossaryItemAsXml&forFooter=true&item=" + url;
		
	
				$.ajax({
    				url: fullurl,
					type: 'GET',
					dataType: 'html',
					timeout: 1000,
					error: function(err){
						alert(err.responseText);
					},
		
					success: function(myhtml){
					   
						var container = document.createElement("div");
    						container.innerHTML = myhtml;

    						var anchors = container.getElementsByTagName("a");
    					
    						for (var i = 0; i < anchors.length; i++) {
    							var lnk = anchors[i];
    							if (lnk.href.indexOf("/glossary/") > -1)	
    							{
    								lnk.className = 'dotted_link';
								lnk.title = '';
								lnk.href = "javascript:glossaryLinkClicked('" + lnk.href.substring(lnk.href.indexOf("/glossary/")) + "')";
    						 	}
    						}
					       
					       
						$('.glossary_term_details').html(container.innerHTML);

					}
				});
			}