if (typeof console == "undefined") {
    this.console = {log: function() {}};
}

var ADS = ADS || {};                  

ADS.init = function() {
              
	$('.ad a').live('click', function(event) {	                           
		 var link = $(this),
			 span = link.parent('.ad').find('span.info'),
			 category = 'Ad Tracking | ' + span.text();	                 			
		// category, action, label, value 
		_gaq.push(['_trackEvent', category, 'click', link[0].href]);
	});
	
	$('div.flash object').live('click', function(event) {
		var object = $(this),
			 span = object.parents('div.flash').find('span.info'),
			 category = 'Ad Tracking | ' + span.text();             
		// category, action, label, value 		
		try {
			_gaq.push(['_trackEvent', category, 'click', $(this).find('param[name=movie]').attr('value')]);
		} catch(e) {}
	});
	
};     

$(function() {
   ADS.init();
});

jQuery(document).ready(function() {


	//menu hover effect 
	
	//init
	$("#menu ul").append("<li id='menubg' class='rounded_corners'></li>");
	var Org = $("#menu li.selected");
	var menuClicked = false;
	//if (Org.html() == null) {var Org = $("#menu #home"); Org.addClass("selected").children("a").addClass("selected");}
	if (Org.html() != null) {
		var wOrg = Org.width();
		var lOrg = Org.position().left;
		var $menubg = $("#menubg");
		$menubg.css("width", wOrg).css("left", lOrg);				
	}
	
	//event
	$("#menu li:not(#menubg)").hover(function () {
		if (!$menubg) {return;}
		$(this).siblings().removeClass("selected")
			.children().removeClass("selected");
		$(this).addClass("selected")
			.children().addClass("selected");
		w = $(this).width();
		l = $(this).position().left;
		$menubg.stop().animate({
			left: l,
			width: w
		}, {
			easing : "swing"
		});
	}, function () {
		if (!$menubg) {return;}
		if (!menuClicked) {
			$(Org).siblings().removeClass("selected")
				.children().removeClass("selected");
			$(Org).addClass("selected")
				.children().addClass("selected");
			$menubg.stop().animate({
				left: lOrg,
				width: wOrg
			}, {
				easing : "swing"
			});
		}
	});


	$("#menu a").click (function () {
		// $menubg.stop();
		menuClicked = true;
	});







	//clear search txtbox value on click
	$("#search #keywords").click(function () {
		$(this).val("");
	});

	//clear newsletter txtbox value on click
	$("#mailinglist_form input.text").click(function () {
		$(this).val("");
	});
	
	//photoset fancy box
	$("#multimedia-photos a.set, a.video-thumb, a.photo-thumb, .featured a, #home-images li a, #home-videos li a").fancybox({
		'overlayOpacity'	:	0.8,
		'overlayColor'	:	'#000'
	});

	// carousels
	
	$('#issue-carousel-ul').jcarousel({
        // Configuration goes here
    });




	/* !Photo List Fancybox */
	// $('div.latestVideo a, ul.videoList a, ul.photoList a')
	$('ul.photoList a').fancybox({
			'height'          : 500,
			'padding'         : 0,
			'showCloseButton' : true,
			'width'           : 665
		});

	/* !Video List Fancybox */
	$("a.youtubeLink").click(function() {
		$.fancybox({
			'padding'         : 0,
			'autoScale'       : false,
			'showCloseButton' : true,
			'transitionIn'    : 'none',
			'transitionOut'   : 'none',
			'title'           : this.title,
			'width'           : 680,
			'height'          : 495,
			'href'            : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'            : 'swf',
			'swf'             : {
				'wmode'		        : 'transparent',
				'allowfullscreen'	: 'true'
			}
		});
		return false;
	});





	//validate advertise form
	$("form#advertise").validate();

	
});

	
