// WebTrends functions for tracking NYP Activity


function createMeta(metaName,metaContent){
 var meta = document.createElement('meta');
 meta.name = metaName;
 meta.content = metaContent;
 document.getElementsByTagName('head')[0].appendChild(meta);
}

function dcsSendEvent(name, url, action) {
  if (typeof(_tag) != "undefined") {
      _tag.dcsMultiTrack("DCS.dcssip",location.hostname,"DCS.dcsuri",url,"WT.ti","Flash:"+name,"WT.dl","21","WT.z_flashevent",action);
    _tag.DCS.dcssip=_tag.DCS.dcsuri=_tag.WT.ti=_tag.WT.dl=_tag.WT.z_flashevent="";
     return "Tag sent";
   }
}


function dcsSetSubGroup(value) {

  var selected = value;
  if (typeof(selected) == "undefined") {
    var  subGroup = document.getElementById("nav-selected");
    if (subGroup) {
        var selectedText = subGroup.innerText || subGroup.textContent;
        selected = selectedText.replace(/^\s+|\s+$/g,"");
    }
  }
  if (selected == null) {
      createMeta("WT.cg_s","No subgroup specified");
 	//alert("creating cg_s with No subgroup specified");
  } else {
  //alert("selected --> " + selected);
	 if (selected && selected != "") {
 	   createMeta("WT.cg_s",selected);
 	//alert("creating cg_s with --> " + selected);
 	 } else {
      createMeta("WT.cg_s","Home");
 	//alert("creating cg_s with Home");
  	 }
  }
}

function dcsGetSectionName(sectionhead) {
  var section;
  if (typeof(sectionName)=="object"&& sectionhead && sectionhead!="") {
  		// check for semicolon delimited values
  		if (sectionhead.indexOf(";") > 0) {
  			var tmp_sh = sectionhead;
  			while (tmp_sh.indexOf(";") > 0) {
  				var i = tmp_sh.indexOf(";");
  				section += sectionName[tmp_sh.substring(0, i)];
  				//alert(tmp_sh.substring(0, i) + " --> " + section);
  				tmp_sh = tmp_sh.substring(i+1);
  				if (tmp_sh.indexOf(";") < 0) {
  					section += sectionName[tmp_sh];
  					////alert("last one --> " + tmp_sh + " with section --> " + section);
  				}
  			}
  		} else {
 			section = sectionName[sectionhead];
 			////alert("section for a single value --> " + section);
 		}
 	}
 	
  if (section == null && sectionhead == null) {
 	createMeta("WT.cg_n","No content group specified");
 	//alert("creating cg_n with no content group specified");
  } else {
  	if (section) {
 	   createMeta("WT.cg_n",section);
 		//alert("creating cg_n with --> " + section);
   	} else {
   		createMeta("WT.cg_n",sectionhead);
   		
 		//alert("creating cg_n with --> " + sectionhead);
   	}
 }
}

function jmlGetSubgroups(numToGet) {
	    var  subGroup = document.getElementById("active");
	    if (!subGroup) {
		   subGroup = document.getElementById("nav-selected");
		}
	        var selectedText = subGroup.innerText || subGroup.textContent;
	        selected = selectedText.replace(/^\s+|\s+$/g,"");
    
    // at the moment there are only 2 
    var x = parseInt(numToGet, 10);
    
    var tmp = "";
    for (var i = 0; i < x; i++) {
    	tmp += selected + ";";
    }
    
    // remove trailing semicolon
    selected = tmp.substring(0, tmp.lastIndexOf(";"));
    
    
    return selected;
}
// END OF WEB TRENDS VARIABLES 
