var _gaq = _gaq || [];
var _gaq_AccountName;
var _gaq_WebsiteCodes="";
var _gaq_currentWebsite ='/';


var _gaq_currentURL;

_gaq_AccountName= 'UA-22845428-1';

_gaq.push(['_setAccount', _gaq_AccountName]);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var gs = document.getElementsByTagName('script')[0]; gs.parentNode.insertBefore(ga, gs);
})();



$(document).ready(function() {
	_gaq_WebsiteCodes =  s.dynamicAccountList;
	_gaq_currentWebsite = gaGetWebsiteName();
    _gaq_currentWebsite = _gaq_currentWebsite.replace("/","");
	_gaq_currentWebsite = _gaq_currentWebsite.replace("/","");
});





function gaFundXplorerTabRecord(tabName,FundType)
{
	 var _ga_info;
	_ga_info = '/'+_gaq_currentWebsite+'/fundexplorer/'+FundType+'/'+tabName;
	_gaq.push(['_setAccount', _gaq_AccountName]);
	_gaq.push(['_trackPageview',_ga_info ]);
	
	
}

function gaRecordOnPDFClick(PDFName)
{

	var _ga_info;
	_ga_info = '/'+_gaq_currentWebsite+'/'+PDFName;
	_gaq.push(['_setAccount', _gaq_AccountName]);
	_gaq.push(['_trackPageview',_ga_info ]);
	
	
}


function gaGetWebsiteName()
{
    if(_gaq_currentWebsite != "") {return _gaq_currentWebsite;}
    if (_gaq_WebsiteCodes == undefined || _gaq_WebsiteCodes == "") {return "jpmuknown";}
    
    _gaq_currentURL =  window.location.href;
    _gaq_currentURL = _gaq_currentURL.toLowerCase();
    _gaq_currentURL = _gaq_currentURL.replace("www","");
    _gaq_currentURL = _gaq_currentURL.replace("http://","");
    
    
   var currentURLDir;
   currentURLDir = _gaq_currentURL.split("/");

   var websitesList = _gaq_WebsiteCodes.split(";");
    
     $.each(websitesList, function(itemNo, item) 
            {
                    item = item.toLowerCase();
                    
                    var thisWebsite=item.split("=");
                    var totalDir = currentURLDir.length;
                    
                    for(i=0; i < totalDir; i++ )
                    {
                        if(i==2){break;}
                        
                        if(currentURLDir[i].indexOf(thisWebsite[1]) != -1)
                        {
                            _gaq_currentWebsite = thisWebsite[1];
                        }
                        
                    }
                    
                    if(_gaq_currentWebsite!=""){return false;}
                    
            });
    
   
    if(_gaq_currentWebsite=="") {
                _gaq_currentWebsite = "jpmuknown";
                }
                
                return _gaq_currentWebsite;
}
		  


function ga_WatchList_Add(FundName)
{
	_gaq.push(['_trackEvent','Watchlist','Add Fund to watchlist',FundName]);
}

function ga_WatchList_Remove()
{
	_gaq.push(['_trackEvent','Watchlist','Remove Fund from watchlist']);
}
 

function ga_Apply(ApplyFor)
{
	_gaq.push(['_trackEvent','Apply',ApplyFor]);
}
 
function ga_ManagePortfolio(Action)
{
	_gaq.push(['_trackEvent','Manage Portfolio',Action]);
}
 

function ga_TrackPageView(URLToTrack)
{

	if(URLToTrack == undefined || URLToTrack == "") {return;}

	_gaq.push(['_trackPageview',URLToTrack]);
}
 
 

