
function getCookie(c_name)
{
    var i,x,y,ARRcookies=document.cookie.split(";");
    for (i=0;i<ARRcookies.length;i++)
    {
      x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
      y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
      x=x.replace(/^\s+|\s+$/g,"");
      if (x==c_name)
        {
            return unescape(y);
        }
    }
}        
        
         
function setUserInfo()
{
    var cookies = getCookie("InfomineSubscriptionUserInfo");
    if(typeof cookies == 'undefined')  
    {
        imUserId = "undefined";
        imPackageName = "undefined";
    }
    else
    {
        var arr = cookies.split('&');
        for(var i = 0; i < arr.length; i++)
        {
            if(arr[i].indexOf("UID") != -1)
                imUserId = arr[i].replace("UID=","");
                
            if(arr[i].indexOf("UserGroups") != -1)
                imPackageName = arr[i].replace("UserGroups=","");    
        }
    }
        
    return;
}


  var imUserId;
  var imPackageName;   

  setUserInfo();

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-443319-4']);
  
  _gaq.push(['_setCustomVar', 1, 'UserId', imUserId, 1 ]); 
  _gaq.push(['_setCustomVar', 2, 'PackageName', imPackageName, 1 ]); 
  
  _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 s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();



$(document).ready(function(){
    $('a').each(function(){
        var url = $(this).attr("href");
        if(url)
        {
            $(this).click(function(){
	        if (url.toLowerCase().match(/\.(doc|pdf|xls|ppt|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mp3)$/))
            _gaq.push(['_trackPageview', url]);		
            });
        }
    });
});



