	LeadGen = window.LeadGen || {};
	LeadGen.Tracking = LeadGen.Tracking || {};
	LeadGen.Tracking = function() {
		var emptyStr = 'na';
		var dlm = '_';
		return {
		   siteCode: emptyStr,
                   storyType: emptyStr,
                   pageType: emptyStr,
                   taxonomy: emptyStr,
                   author: emptyStr,
                   moduleName: emptyStr,
                   ref: document.referrer,
		   domain: '',
		   sourceParam: '',
		   setDomain:function(){
			if(this.ref != null){
			   var tempdomain = this.ref.match('\/\/.*?\/');
			   if(tempdomain) this.domain = tempdomain[0].substring(2,tempdomain[0].length -1);
			   if(this.domain.indexOf('www.') > -1) this.domain = this.domain.substring(4);
			}
			if(this.domain == null || this.domain.length == 0) this.domain = emptyStr;
		   },
		   addSourceCode:function(_siteCode, _moduleCode, _element){
			if(_siteCode != null && _siteCode.length > 0) siteCode = _siteCode;
			if(_moduleCode != null && _moduleCode.length > 0) moduleCode = _moduleCode;	
			//var _sourceParam = siteCode + dlm + sourceParam + dlm + moduleCode;
			var _sourceParam = 'ciosite' + dlm + sourceParam + dlm + moduleCode;

			if(_element){
			    var sep = '?';
			    if(_element.href.indexOf('?') > -1) sep = '&'; 
                            var newloc = _element.href + sep + 'idglg=' + _sourceParam;
			    window.location = _element.href + sep + 'idglg=' + _sourceParam;
			}			
		   },
		   init:function(){
			LeadGen.Tracking.setDomain();
		   	if(typeof(s_prop5) != 'undefined' && s_prop5 != null && s_prop5.length > 0) this.storyType = s_prop5;
			if(typeof(s_prop14) != 'undefined' && s_prop14 != null && s_prop14.length > 0) this.pageType = s_prop14;
			if(typeof(s_prop2) != 'undefined' && s_prop2 != null && s_prop2.length > 0) this.taxonomy = s_prop2;
			if(typeof(s_prop4) != 'undefined' && s_prop4 != null && s_prop4.length > 0) this.author = s_prop4;
			//only take the first and last taxonomy
                        var taxonomies = this.taxonomy.split(":");
                        if (taxonomies.length>1)
			  {
			    this.taxonomy = taxonomies[0] + ":" + taxonomies[taxonomies.length-1];
                          }
			sourceParam = this.storyType + dlm + this.pageType + dlm + this.taxonomy + dlm + this.author + dlm + this.domain;
			//get rid of html entity in sourceParam
                         var re = new RegExp("&#.*;", "g");
			 sourceParam = sourceParam.replace(re,"");
		   }
		 }
	}();
	LeadGen.Tracking.init();

        
