var deepLinks = [
"LifeTime Recovery Service",
"CAR Collar Tag",
"Family Dog Magazine",
"Pet Healthcare Plan",
"Agility and Obedience Events",
"Official Decree of Dog Fun",
"Canine Partners Decal"];

//version11
$(document).ready(function() {

    $(document).pngFix(); 
 
	$(".news").toggle(
		function(){
			$(this).attr("src", "images/less_news.jpg");
			$(this).next().show();
		},
		function(){
			$(this).attr("src", "images/more_news.jpg");
			$(this).next().hide();
		}
	);
	
	$('.benefits').click(function(){
		$(".popup").each(function(){$(this).hide();}); //close all the other pop ups
		var id = $(this).attr('id');
		var popup = $('#pop'+id);
		var offset = $(this).offset();
		
		pageTracker._trackEvent('Drill Link',deepLinks[id-1]); // tracking
		
		popup.css({'top' : (offset.top-(popup.height()/2)-15)+'px', 'left' : (offset.left+250)+'px'});
		popup.show();
	});
	
	$('.close').click(function(){
		$(this).parent().hide();
		
		return false;
	});
	
	var init = $('#news').size();
	if(init != 0){
		var article_id = $.getUrlVar('article_id');
		$('.article_'+article_id+' .news_content').show();
		$('.article_'+article_id+' .news').attr("src", "images/less_news.jpg");
	}
	
});


$.extend({
	getUrlVars: function(){
		var vars = [], hash;
		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
		for(var i = 0; i < hashes.length; i++){
			hash = hashes[i].split('=');
			vars.push(hash[0]);
			vars[hash[0]] = hash[1];
		}
		return vars;
	},
	getUrlVar: function(name){
		return $.getUrlVars()[name];
	}
});
