$(document).ready(function(){



 $("a[href^='/glossary.cfm?gid=']").each(function (i){

	 var pageToLoad = this.href + "&ajaxCall=true";
	   $(this).bt({
		  ajaxPath: pageToLoad,
		  padding: 10,
		  spikeLength: 20,
		  spikeGirth: 20,
		  cornerRadius: 20,
		  fill: 'rgba(0, 0, 0, .8)',
		  strokeWidth: 1,
		  strokeStyle: '#CC0',
		  cssStyles: {color: '#FFF', fontWeight: 'bold'},
		  shadow: true,
		  shadowOffsetX: 10,
		  shadowOffsetY: 10,
		  shadowBlur: 3,
		  shadowColor: "#000"
			//trigger: 'hoverIntent',
			//hoverIntentOpts: {interval: 10, timeout: 2000}
		});
		//disable click on the anchor				
	    $(this).click(function(){
			return false;
	    });
 	});
	
	//====================================
	var ajaxPath = "/ajax/";
	
	 $("a[class^='compaignMaterialLrgImg']").click(function (i){
		
		var lrgImagePath = ajaxPath + "libraryAsset.cfm";
		var pAssetID = $(this).attr('href').substring(31);
	
		$.get(lrgImagePath, {assetID:pAssetID}, function(data){
			
			if(data.length){
				$.modal(data,{position: ["1%","25%"]});
			}else{
				alert("Larger image is not available at the moment");
			}
		});
		
		return false;
 	});
	
	
	//====================================
	// make sure when the page is loaded that the first tab is selected
	$(".podTab .js a", ".podWrapper").each(function(i){
		// create the default index location
		var index = 0;
		// if url hash exsists in the wrapper, then use the index of that tab
		if(window.location.hash == $(this).attr("href")){
			index = $(this).parent().index();
		}
		
		// call the activate pod function
		activatePod($(this).parents(".podWrapper"), index);
	});

	$(".podWrapper .js li a").click(function(event){
		// prevent the link from running when javascrpt tab is clicked
		event.preventDefault();
		// find the wrapper and the positions of the li (index) reletive to its siblings
		var wrapper = $(this).parents(".podWrapper").get();
		
		
		var parentItemClass = $(this).parent().attr("id");
		
		$("li[id^='podMenu']").each(function(i){
			
			if($(this).attr("id") == parentItemClass){
				
				index = $("li[id^='podMenu']").index(this);
			}
			
		});
		
		//alert(index);
		// call the activate pod function
		activatePod(wrapper, index);
	});
	
	function activatePod(wrapper, index){
		// loop throught that tabs and content and setting the relevent classes (hide/show)
		
		$(".podTab li", wrapper).each(function(i){
			
			if(i == index){
				$(this).addClass("selected");
				$(".pod:eq(" + i + ")", wrapper).show();
			}else{
				$(this).removeClass("selected");
				$(".pod:eq(" + i + ")", wrapper).hide();
			}
		});
	}
	
 });
 




