

var glossary_terms='';
//window.load=getGlossaryTerms();

$(document).ready(function(){
	
	
listString = "";
  	//for (var word in glossary_terms_js)
    //listString += word+",";
	//listString="\""+listString+"\"";

	

	

	//to get the list of words with selected alaphabet and to make the alphabet as selected in top and bottom lists
		var prevclicked='';
				jQuery(".term").click(function(){
 
 				var term_letter=jQuery(this).attr("innerHTML");
				jQuery('.all').removeClass("active");
				
				jQuery(prevclicked).removeClass("active");
				
				jQuery(".term").each(function()
				  {
					 jQuery(this).removeClass("active"); 
					  if(jQuery(this).attr("innerHTML") == term_letter)
					  jQuery(this).addClass("active");
					  
					  if(prevclicked != term_letter)
					  {
						  if(jQuery(this).attr("innerHTML") == prevclicked)
						  jQuery(this).removeClass("active");
					  }
				  });
				
				
				jQuery.ajax(
				{
					url:w3_fe_site_url+"glossary_terms.php",
					type:'POST',
					data:"search_term="+term_letter,
					success: function(msg) 
					{
						document.getElementById("glossary_content_list").innerHTML=msg;
					},
					error: function()
					{
						alert('Error occured');	
					}
			
				});
					prevclicked=term_letter;
					return false;
								
				});
		
		/* End of Glossary */

	
});

//For tooltip Glossory


//function for displaying the tool tip on hover
function displayTooltip()
{				

   jQuery(".hilite").hover(function (e) { 
			glossary_term=jQuery(this).attr("innerHTML");
			jQuery(this).append("<font class='tooltip_content' id='glossary_short_description'><img src='../../_images/ajax-loader-tooltip.gif' width='22' height='22' /></font>");
			glossary_term=glossary_term.toLowerCase();
			document.getElementById("glossary_short_description").innerHTML=glossary_terms_js[glossary_term];
			 },
      function (e) {
      	jQuery("#glossary_short_description").remove();
      	jQuery(this).attr("innerHTML",jQuery(this).attr("innerHTML"));
	  });
  
}


function displayTooltip_ajax()
{				

   jQuery(".hilite").hover(function (e) { 

			glossary_term=jQuery(this).attr("innerHTML");
			jQuery(this).append("<font class='tooltip_content' id='glossary_short_description'><img src='../../_images/ajax-loader-tooltip.gif' width='22' height='22' /></font>");
				jQuery.ajax(
				{
					url:w3_fe_site_url+"glossary_desc.inc.php",
					type:'POST',
					data:"glossary_term="+glossary_term,
					success: function(msg) 
					{
						if(document.getElementById("glossary_short_description"))
						document.getElementById("glossary_short_description").innerHTML=msg;
					},
					error: function()
					{

						alert('Error occured');	
					}
			
				});
			
			 },
      function (e) {
      jQuery("#glossary_short_description").remove();
      	jQuery(this).attr("innerHTML",jQuery(this).attr("innerHTML"));
	  });
   
      
   
}


	//getting the position and appending the tooltip at that position		
function point_it(event,obj) {
	x = (window.Event) ? event.pageX : event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
	y = (window.Event) ? event.pageY : event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
	jQuery("#supernote-note-demo4").css("left",x-40+'px');
	jQuery("#supernote-note-demo4").css("top",y-5+'px');
	jQuery("#supernote-note-demo4").animate({opacity: "show", top: y+'px',left:x-40+'px'}, "normal");
}


function getGlossaryTerms()
{
		jQuery.ajax(
		{
			url:w3_fe_site_url+"glossary.inc.php",
			type:'POST',
			data:"glossary_term=glossary",
			success: function(msg) 
			{
				glossary_terms=msg.split("+").join(",");
				jQuery.each(glossary_terms, function(i,val) { 
				});// 
				var options = {
						exact:"exact", //exact, whole, partial
						style_name_suffix:false,
						highlight:".short_description p, .left_container p, .glossary_top_list,.testimonial_img",
						nohighlight:"",
						keys:glossary_terms
					  }
					//to highlight the words
			 		jQuery(document).SearchHighlight(options);
					//for displaying the tooltip 
					displayTooltip_ajax();	

			},
			error: function()
			{
				//alert('Error occured at Glossary');	
			}
			
	
		});
	
	

}
