/* DEPENDS ON:
		jQuery 1.3+ (as j$)
    ntpagetag.js (Unica https+://analytics.glgroup.com/ntpagetag.js)
    GLGUI.Analytics.js
*/	

if (!GLGUI) {var GLGUI = {};}
if (!GLGUI.Analytics) {GLGUI.Analytics = {};}
if (!GLGUI.Analytics.Portal) {GLGUI.Analytics.Portal = {};}

GLGUI.Analytics.Portal.AddTrackingToOutBoundLinks = function(){
	j$('a').each(function(a){
		if(!RegExp(location.host).test(this.href) && /http/.test(this.href))
			j$(this).click(GLGUI.Analytics.OutBoundLinkClickHandler);
	});
}

j$(document).ready(function() {	

	GLGUI.Analytics.Portal.AddTrackingToOutBoundLinks();
	
	j$('#Button-RequestLeaderConsult').click(function() { ntptEventTag( "ev=RequestLeaderConsult&pv=0");});
	
	j$('.summary').click(function() { ntptEventTag( "ev=source-article-tab&pv=0");});
	
	j$('#News_Most_widget_Expert_Anaylses_handle').click(function() { ntptEventTag( "ev=expert-analysis-tab&pv=0");});
	
	j$('.requestAnalysis').click(function() { ntptEventTag( "ev=RequestLeaderConsult&pv=0");});
	
	j$('#AddAuthorHyperlink').click(function() { ntptEventTag( "ev=request-analysis-link&pv=0");});
	
	j$('.AddAuthorHyperlink').click(function() { ntptEventTag( "ev=Add-Author-Hyperlink&pv=0");});	
	
	j$('.AddTaxonomyHyperlink').click(function() { ntptEventTag( "ev=Add-Taxonomy-Hyperlink&pv=0");});	
	
// Homepage
	
   var btnPrimary = document.getElementById('btnPrimary');
   if (btnPrimary != null) {
   btnPrimary.onclick = function() { 
	 return ntptLinkTag(this,'pv=0&ev=hp-modal-client');
												};	 	
											}
   var btnSecondary = document.getElementById('btnSecondary');	
   if (btnSecondary != null) {										
   btnSecondary.onclick = function() { 
	 return ntptLinkTag(this, 'pv=0&ev=hp-modal-CM');
												};
											}
												
		j$('.jqmClose').click(function() {  ntptEventTag('pv=0&ev=hp-modal-close');  });
			
		j$('#hp-hero').click(function() {  ntptEventTag('pv=0&ev=hp-modal-open');  });
			
	  j$('a.browse').click(function(){ 	
	    	var column = j$(this).attr('rel').substr(1); 
        ntptEventTag('pv=0&ev=cluetip-' + column); 
      });	
	
    j$('#module-news .bottomLink').click(function(){ 	
        ntptEventTag('pv=0&ev=all-glg-news-link'); 
       });	

		j$('.cm-info-hp h3 a').click(function() {
				var index = j$('.cm-info-hp h3 a').index(this);
			  index = index + 1; 
				ntptEventTag('pv=0&lk=1&hp-expert-item=' + index);
	 			GLGUI.Analytics.Defer();
   			return;
		});

		j$('.getStarted a').click(function() {
	 			var index = j$('.getStarted a').index(this);
	 		  index = index + 1; 
	 			ntptEventTag('pv=0&lk=1&hp-expert-item=' + index);
	 			GLGUI.Analytics.Defer();
   			return;
		});

		j$('#module-news .pa-label a').click(function() {
	 			var index = j$('#module-news .pa-label a').index(this);
	 			index = index + 1;
	 			ntptEventTag('pv=0&lk=1&hp-news-item=' + index);
	 			GLGUI.Analytics.Defer();
   			return;
		});

		j$('.item a').click(function() {
	 		var index = j$('.item a').index(this);
	 		index = index + 1; 
	 		ntptEventTag('pv=0&lk=1&hp-news-item=' + index);
	 		GLGUI.Analytics.Defer();
   		return;
		});

		j$('.reviewer .fn').click(function() { var index = j$('.reviewer .fn').index(this); 
			index = index + 1; ntptEventTag('pv=0&lk=1&hp-news-item=' + index); 
			GLGUI.Analytics.Defer(); 
			return; 
		});

		j$('#module-webcasts .pa-label a').click(function() {
	 		var index = j$('#module-webcasts .pa-label a').index(this);
	 		index = index + 1;
	 		ntptEventTag('pv=0&lk=1&hp-event-item=' + index);
	 		GLGUI.Analytics.Defer();
   		return;
		});

		j$('.summary a').click(function() {
	 		var index = j$('.summary a').index(this);
	 		index = index + 1;
	 		ntptEventTag('pv=0&lk=1&hp-event-item=' + index);
	 		GLGUI.Analytics.Defer();
   		return;
		});

		j$('.meetingRSVP a').click(function() {
	 		var index = j$('.meetingRSVP a').index(this);
	 		index = index + 1;
	 		ntptEventTag('pv=0&lk=1&hp-event-item=' + index);
	 		GLGUI.Analytics.Defer();
   		return;
		});
			
// Tabs	
		j$('#tabs a[href=#tab1]').click(function() {
				ntptEventTag('pv=0&ev=expert-analysis-tab');
			});	
		j$('#tabs a[href=#tab2]').click(function() {
				ntptEventTag('pv=0&ev=source-article-tab');
			});	

//	Search box
		var searchSubmit = document.getElementById('SeachSubmit');
			if (searchSubmit) {
				searchSubmit.parentNode.onsubmit = function() {
					return ntptSubmitTag(this, 'pv=0&ev=search&keyword=' + this.keyword.value);
				};
			}
});
	
// Lead capture include	
	
function submitAndTrack(formName)  {
	return ntptSubmitTag(document.getElementById(formName), 'pv=0&ev=' + formName);
	}
