/* Popular Stories - DWB/PSX/KR/GN version */
/*  050206 */
var script_index;if(script_index>=0)script_index++;else script_index=0;scr_start(script_index);
var default_mp_var1,override_mp_var1;mp_var1=override_decide(override_mp_var1,default_mp_var1);/* Variable for the URL of the story */
var default_mp_var2,override_mp_var2;mp_var2=override_decide(override_mp_var2,default_mp_var2);/* Variable for the story number and headline */
s_prop_maxlength=100;delim="|";
var reserve_popular_stories;
if(reserve_popular_stories==true){
 eval('override_'+mp_var1+'="";');eval('override_'+mp_var2+'="";');
 }
var measure_popularity,pubsys;
known_pagelevel=override_decide(override_pagelevel,default_pagelevel)
if(measure_popularity==true&&known_pagelevel=="story-detail"){
 if(pubsys=="PSX"||pubsys=="DWB"||pubsys=="KR"||pubsys=="GN"){
  path_delim="\/";story_link_full=document.URL;link_delim="://";
  link_head=story_link_full.search(link_delim)+link_delim.length;
  story_link_trim=story_link_full.slice(link_head,story_link_full.length);
  var popular_root_url1,popular_root_url2;
  story_link=story_link_trim.replace(popular_root_url1,"");
  story_link=story_link.replace(popular_root_url2,"");
  if(pubsys=="GN"){
   gn_query="AID=";var query_string;
   if(query_string){
    if(query_string.search(gn_query)==-1){pc_code="NA";}
    else{
     path_delim="\/";story_link=query_string.replace("\?"+gn_query,"");
     pc_path=query_string;pc_for_path=new Array();pc_for_path=pc_path.split(path_delim);pc_code=pc_for_path[3];
     }
    }
   else{pc_code="NA";}
   }
   else{var filename;pc_code=filename;}
  if(pubsys=="DWB")validated_code=pc_code.match(/\d{5,10}?p-\d{5,10}?c/);
  else if(pubsys=="PSX")validated_code=pc_code.match(/\d{1,10}/);/* This assumes that the story number in PSX is unique on the site */
  else if(pubsys=="KR")validated_code=pc_code.match(/\d{6,10}/);/* This assumes that the story number in KR is unique on the site */
  else if(pubsys=="GN")validated_code=pc_code.match(/\d{6,10}/);/* This assumes that the story number in GN is unique on the site */
  if(validated_code==null||validated_code==0){eval('override_'+mp_var1+'="";');eval('override_'+mp_var2+'="";');}
  else{
   if(pubsys=="DWB"){
    pair_array=new Array();pair_array=validated_code.toString().split("-");
    package_number=pair_array[0];content_number=pair_array[1];
    }
   else if(pubsys="PSX"||pubsys=="KR"||pubsys=="GN"){content_number=validated_code;}
   var popular_headline;if(!popular_headline)popular_headline=override_decide(override_pageName,default_pageName);
   headline_full=popular_headline;
   var popular_headline_min_length;if(!popular_headline_min_length)popular_headline_min_length=1;
   headline_maxlength=s_prop_maxlength-content_number.length-delim.length;
   headline=headline_full.substr(0,headline_maxlength);
   if(headline.length>=popular_headline_min_length||popular_headline.length==headline.length){
    eval('override_'+mp_var2+'=content_number+delim+headline;');
    if(story_link.length<=s_prop_maxlength)eval('override_'+mp_var1+'=story_link;');
    else eval('override_'+mp_var1+'="";');
    }
   else{eval('override_'+mp_var1+'="";');eval('override_'+mp_var2+'="";');} 
   }
  }
 }
n[script_index]="stats_measure_popularity.js (for "+pubsys+")";scr_end(script_index);
