// SET GLOBAL VARS
var js_host;
if (js_host == undefined) {
  js_host = "http://graphics8.nytimes.com/js/app/analytics/";
}
var wt_url        = document.URL;
var wt_domain     = document.domain;
var wt_path       = window.location.pathname;
var wt_dcsidArray = {"Homepage":"dcsa5pgfq10000c9zuysqk0lm_6i8y",
                     "World":"dcspjt2na00000wcnvo8wdaeo_7q9o",
                     "US":"dcsypfq3j00000gsclwfljaeo_6i3w",
                     "NY/Region":"dcsj5tb4n100000sl76culaeo_4f3w",
                     "Business":"dcsc32upj10000c58n7kgpaeo_8i3g",
                     "Technology":"dcs591klg00000c97pblfraeo_7p3p",
                     "Science":"dcsaon9rw0000008ifmgqtaeo_2f9c",
                     "Health":"dcsfj6l0t100008ijt0irzaeo_2k8f",
                     "Sports":"dcss4vytr000000kbuy6j8beo_6f7s",
                     "Opinion":"dcs5ydwfq100008me456mabeo_1z2v",
                     "Books":"dcss90tjf00000knzmux6hbeo_8r8y",
                     "Dance":"dcs9ihxq600000w842mebkbeo_9r6q",
                     "Movies":"dcsyoaqvl00000wc34qfambeo_4q3b",
                     "Music":"dcsrioyse100000kjghaqubeo_2d4x",
                     "TV":"dcsghn1j900000gs8yfgfwbeo_3r9l",
                     "Theater":"dcsxl9f4810000oub8mfiybeo_5l8v",
                     "Arts":"dcsnu1k8n00000oi2prv9fbeo_2w5s",
                     "T:Style":"dcs31c2fd10000w8wjmo22ceo_5x6n",
                     "Style":"dcs2dla2i00000431qkl70ceo_3j4r",
                     "Travel":"dcsktwey810000kfp9nsv3ceo_6n1r",
                     "Jobs":"dcsxmnyde100000oerlyk5ceo_6k5k",
                     "Real Estate":"dcsuvvccp000000sdtpzj7ceo_3j2x",
                     "Autos":"dcs3i2ttw0000043xyk839ceo_2v6n",
                     "Classifieds":"dcso5eb2r10000cpz9bq5cceo_3j5e",
                     "Video":"dcs1j460r100008uw7es2eceo_6c4w",
                     "TimesSelect":"dcsqdkcdj100004zt5huzfceo_3b7v",
                     "TimesTopics":"dcs3baftr1000008q5oxvjceo_4r9g",
                     "Member Center":"dcst9xior10000wo45l9anceo_4u9e",
                     "Crosswords/Games":"dcsepujaa100000s5bq9bpceo_7w6k",
                     "Sunday Magazine":"dcsrmsj6n10000wok933qrceo_1x8d",
                     "Most Popular":"dcsvmgcs910000o2ubv1z1deo_8b5s",
                     "Learning Network":"dcslh0e4x00000ggzmnn3ldeo_6f8k",
                     "Knowledge Network":"dcs69r7oi100004nscorwmdeo_7r4i",
                     "Week In Review":"dcsvfceih10000o610i65qdeo_7y5r",
                     "Weather":"dcsker4wf10000wszj8b32eeo_4m7u",
                     "Newstracker":"dcsa1h2mn00000oacf4of5eeo_5f2m",
                     "Multimedia":"dcsvs34dy000000chtbmk7eeo_3f9p",
                     "Cartoons":"dcsc1dh4600000oiajcqd9eeo_9l2m",
                     "AP/Reuters":"dcs15dnk9100004r7jamfwu0p_3v8n",
                     "Search":"dcsmcntzl00000wwyhty30deo_8o2v" } 


// POPULATE META TAGS
// Set content group
var incFile = "";
var wt_contentGroup = getContentGroup();
if (getMetaTag("WT.cg_n") == "") {
  addMetaTag("WT.cg_n", wt_contentGroup);
}

// Set gdcsid
gdcsid = wt_dcsidArray[getMetaTag("WT.cg_n")];

// Set dcsvid
var dcsvid;
if (getMetaTag("WT.dcsvid") == "") {
  addMetaTag("WT.dcsvid", dcsvid);
}

// Set registration status
var regstatus;
if (getMetaTag("WT.rv") == "") {
  addMetaTag("WT.rv", (regstatus == "registered") ? 1 : 0);
}

// Set ad and campaign information
addMetaTag("WT.ad", getAdNames());
addMetaTag("WT.mc_id", getCampaignIds());

// Set the click tracking variable for specific pages
setTrackEvents();

// Set article information
var metaTom = getMetaTag("tom");
if (metaTom == "News") {
  addMetaTag("WT.z_pt", "Article");
  addMetaTag("WT.z_pst", "News");
  addMetaTag("WT.z_pud", getMetaTag("pdate"));
  addMetaTag("WT.z_hdl", getMetaTag("hdl")); 
  addMetaTag("WT.z_aid", getMetaTag("articleid"));

  var pageWanted = getQueryParameter("pagewanted");
  if (pageWanted == "") {
    addMetaTag("WT.z_puv", "Normal"); 
  } else {
    addMetaTag("WT.z_puv", pageWanted);
  }
  addMetaTag("WT.z_put", "web");
  addMetaTag("WT.z_pua", "free");
}

// Set search engine tracking
//if (/WT\.srch=1/.test(wt_path)) {
//  addMetaTag("WT.srch", "1");
//} else {
//  addMetaTag("WT.srch", "0");
//}

// Set onsite search information
//setSearchInfo();

// Call javascript file based on content group
if (incFile != "") {
  incFile = js_host+"content/"+incFile;
  var contentJS = document.createElement('script');
  contentJS.setAttribute('language', 'javascriptcontent');
  contentJS.setAttribute('type', 'text/javascript');
  contentJS.setAttribute('src', incFile);
  document.getElementsByTagName('head').item(0).appendChild(contentJS);
}

// Call WebTrends javascript files
var wtjs = document.createElement('script');
wtjs.setAttribute('language', 'javascript');
wtjs.setAttribute('type', 'text/javascript');
wtjs.setAttribute('src', js_host+'wtinit.js');
document.getElementsByTagName('head').item(0).appendChild(wtjs);

script_filename = "wtbase_test.js";
wtjs = document.createElement('script');
wtjs.setAttribute('language', 'javascript');
wtjs.setAttribute('type', 'text/javascript');
wtjs.setAttribute('src', js_host+'wtbase.js');
document.getElementsByTagName('head').item(0).appendChild(wtjs);

// FUNCTIONS
function getContentGroup() {

  var contentGroup = getMetaTag("contentGroup");
  if (contentGroup == "") {

    // this should be ordered by popularity
    if(/^http:\/\/(www\.)?nytimes\.com\/(\/|index.html)?$/.test(wt_url)) {
      contentGroup = "Homepage";
      gtrackevents = true;
  
    // world
    } else if (/^\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/world\//.test(wt_path)
            || /^\/(slideshow\/)?[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/world\//.test(wt_path)
            || /^\/\b(pages|ref|reuters|aponline|cfr)\b\/world\//.test(wt_path)) {
      contentGroup = "World";

    // us
    } else if (/^\/(slideshow\/)?[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/\b(us|washington|politics|education)\b\//.test(wt_path)
            || /^\/pages\/\b(politics|education|washington|national)\b\//.test(wt_path)
	         || /^\/aponline\/us\//.test(wt_path)
	         || /^\/ref\/\b(us|politics|washington)\b\//.test(wt_path)
            || /^\/cq\//.test(wt_path)) {
      contentGroup = "US";

    // ny region - check this before opinion
    } else if (/^\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/nyregion\//.test(wt_path)
            || /^\/packages\/khtml\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/nyregion\//.test(wt_path)
            || /^\/pages\/nyregion\//.test(wt_path)) {
      contentGroup = "NY/Region";

    // business
    } else if (/^\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/business\//.test(wt_path)
            || /^\/pages\/business\//.test(wt_path)
            || /^\/aponline\/business\//.test(wt_path)
            || /^\/reuters\/business\//.test(wt_path)
            || /^\/ref\/business\//.test(wt_path)
            || /^\/allbusiness\//.test(wt_path)
            || /^\/inc_com\//.test(wt_path)    
            || /^\/slideshow\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/business\//.test(wt_path)) {
 
      contentGroup = "Business";

    // technology
    } else if (wt_domain == "tech.nytimes.com"
            || wt_domain == "tech2.nytimes.com"
            || wt_domain == "download.nytimes.com"    
            || /^\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/technology\//.test(wt_path)
            || /^\/pages\/technology\//.test(wt_path)
            || /^\/tech\//.test(wt_path)
            || /^\/aponline\/technology\//.test(wt_path)
            || /^\/reuters\/technology\//.test(wt_path)
            || /^\/ref\/technology\//.test(wt_path)
            || /^\/pages\/cnet\//.test(wt_path)
            || /^\/cnet\//.test(wt_path)
				|| /^\/gst\/fullpage\.html\?sec\=technology/.test(wt_path)) {

		contentGroup = "Technology";

    // science
    } else if (/\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/science\//.test(wt_path)
            || /^\/ref\/science\//.test(wt_path)
            || /^\/pages\/science\//.test(wt_path)
            || /^\/indexes\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/science\//.test(wt_path)
            || /^\/slideshow\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/science\//.test(wt_path)) {
      contentGroup = "Science";
  
    // health
    } else if (wt_domain == "health.nytimes.com"
            || /\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/health\//.test(wt_path)
            || /^\/pages\/health\//.test(wt_path)
            || /^\/aponline\/health\//.test(wt_path)
            || /^\/ref\/health\//.test(wt_path)) {
      contentGroup = "Health";
  
    // sports
    } else if (/\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/sports\//.test(wt_path)
            || /^\/pages\/sports\//.test(wt_path)
            || /^\/aponline\/sports\//.test(wt_path)
            || /^\/reuters\/sports\//.test(wt_path)) {
      contentGroup = "Sports";
  
    // opinion
    } else if (/\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/opinion\//.test(wt_path)
            || /^\/pages\/opinion\//.test(wt_path)
            || /^\/pages\/readersopinions\//.test(wt_path)
            || /^\/opinion\//.test(wt_path)
            || /^\/top\/opinion\//.test(wt_path)
            || /^\/ref\/opinion\//.test(wt_path)) {
      contentGroup = "Opinion";
  
    // books
    } else if (/\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/books\//.test(wt_path)
            || /^\/pages\/books\//.test(wt_path)
            || /^\/ref\/books\//.test(wt_path)) {
      contentGroup = "Books";
  
    // dance
    } else if (/\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/arts\/dance\//.test(wt_path)
            || /^\/pages\/arts\/dance\//.test(wt_path)) {
      contentGroup = "Dance";
  
    // movies
    } else if (wt_domain == "movies.nytimes.com"
            || wt_domain == "movies2.nytimes.com"
            || /\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/movies\//.test(wt_path)
            || /^\/indexes\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/movies\//.test(wt_path)
            || /^\/pages\/movies\//.test(wt_path)
            || /^\/ref\/movies\//.test(wt_path)
            || /^\/packages\/khtml\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/movies\//.test(wt_path)) {
      contentGroup = "Movies";
  
    // music
    } else if (/\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/arts\/music\//.test(wt_path)
            || /^\/pages\/arts\/music\//.test(wt_path)) {
      contentGroup = "Music";
  
    // television
    } else if (/\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/arts\/television\//.test(wt_path)
            || /^\/pages\/arts\/television\//.test(wt_path)) {
      contentGroup = "TV";
  
    // theater
    } else if (wt_domain == "theater.nytimes.com"
            || wt_domain == "theater2.nytimes.com"
            || /\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/theater\//.test(wt_path)
            || /^\/pages\/theater\//.test(wt_path)
            || /^\/readersreviews\/theater\//.test(wt_path)
            || /^\/slideshow\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/theater\//.test(wt_path)) {
      contentGroup = "Theater";
    
    // art - must appear after subsections
    } else if (/\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/arts\//.test(wt_path)
            || /^\/pages\/arts\//.test(wt_path)) {
      contentGroup = "Arts";
  
    // tstyle - check this before style
    } else if (/\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/style\/t\//.test(wt_path)
            || /\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/style\/tmagazine\//.test(wt_path)
            || /^\/pages\/style\/t\//.test(wt_path)
            || /^\/pages\/style\/tmagazine\//.test(wt_path)) {
      contentGroup = "T:Style";
 
    // style
    } else if (/\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/style\//.test(wt_path)
            || /\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/fashion\//.test(wt_path)
            || /\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/dining\//.test(wt_path)
            || /\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/garden\//.test(wt_path)
	         || /^\/pages\/style\//.test(wt_path)
            || /^\/pages\/fashion\//.test(wt_path)
            || /^\/pages\/dining\//.test(wt_path)
            || /^\/pages\/garden\//.test(wt_path)
            || /^\/ref\/fashion\//.test(wt_path)) {
      contentGroup = "Style";
  
    // travel
    } else if (wt_domain == "travel.nytimes.com"
            || wt_domain == "travel2.nytimes.com"
            || /^\/(slideshow\/)?[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/travel\//.test(wt_path)
            || /^\/pages\/travel\//.test(wt_path)
            || /^\/travel\//.test(wt_path)
            || /^\/packages\/html\/travel\//.test(wt_path)
            || /^\/gst\/fullpage\.html\?sec\=travel/.test(wt_path)) {
      contentGroup = "Travel";
		incFile = "travel.js";
  
    // jobs
    } else if (wt_domain == "jobmarket.nytimes.com"
            || wt_domain == "salary.nytimes.com"
            || /^\/pages\/jobs\//.test(wt_path)
            || /^\/marketing\/jobmarket\//.test(wt_path)) {
      contentGroup = "Jobs";
  
    // realestate
    } else if (wt_domain == "realestate.nytimes.com"
            || /\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/realestate\//.test(wt_path)
            || /^\/pages\/realestate\//.test(wt_path)
            || /^\/ref\/realestate\//.test(wt_path)
            || /^\/pages\/greathomes\//.test(wt_path)
            || /^\/slideshow\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/realestate\//.test(wt_path)
            || /^\/packages\/khtml\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/realestate\//.test(wt_path)) {
      contentGroup = "Real Estate";
    
    // autos
    } else if (wt_domain == "autos.nytimes.com"
            || wt_domain == "collectiblecars.nytimes.com"
            || /^\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/automobiles\//.test(wt_path)
            || /^\/pages\/automobiles\//.test(wt_path)
            || /^\/ref\/automobiles\//.test(wt_path)
            || /^\/automobiles\//.test(wt_path)
            || /^\/autos\//.test(wt_path)
            || /^\/packages\/khtml\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/automobiles\//.test(wt_path)
            || /^\/packages\/html\/automobiles\//.test(wt_path)) {
      contentGroup = "Autos";
  
    // search 
    } else if (/^\/search\/query/.test(wt_path)) {
      contentGroup = "Search";

    // classifieds
    } else if (wt_domain == "listings.nytimes.com"
            || wt_domain == "placead.nytimes.com"
            || /^\/top\/classifieds\//.test(wt_path)
            || /^\/gst\/personals.html/.test(wt_path)) {
      contentGroup = "Classifieds";
  
    // video
    } else if (wt_domain == "video.on.nytimes.com") {
      contentGroup = "Video";
    
    // timesselect
    } else if (wt_domain == "select.nytimes.com"
            || /\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/opinion\//.test(wt_path)
            || /^\/pages\/timesselect\//.test(wt_path)
            || /^\/products\/timesselect\//.test(wt_path)) {
      contentGroup = "TimesSelect";
  
    // timestopics
    } else if (wt_domain == "topics.nytimes.com"
            || /^\/top\/reference\/timestopics\//.test(wt_path)) {
      contentGroup = "TimesTopics";
    
    // membercenter
    } else if (/^\/membercenter\//.test(wt_path)
            || /^\/mem\//.test(wt_path)
            || /^\/ref\/membercenter\//.test(wt_path)
            || /^\/gst\/purchase_gc.html/.test(wt_path)) {
      contentGroup = "Member Center";
  
    // crosswordsgames
    } else if (/^\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/crosswords\//.test(wt_path)
            || /^\/pages\/crosswords\//.test(wt_path)
            || /^\/ref\/crosswords\//.test(wt_path)
            || /^\/premium\/xword\//.test(wt_path)
            || /^\/premiumproducts\/crosswords\/index.html/.test(wt_path)) {
      contentGroup = "Crosswords/Games";
  
    // sundaymagazine
    } else if (/\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/magazine\//.test(wt_path)
            || /^\/pages\/magazine\//.test(wt_path)
            || /^\/ref\/magazine\//.test(wt_path)
            || /^\/packages\/html\/magazine\//.test(wt_path)
            || /^\/slideshow\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/magazine\//.test(wt_path)) {
      contentGroup = "Sunday Magazine";
    
    // mostpopular
    } else if (/^\/gst\/mostpopular.html/.test(wt_path)
	         || /^\/gst\/mostemailed.html/.test(wt_path)
            || /^\/gst\/mostblogged.html/.test(wt_path)
            || /^\/gst\/mostsearched.html/.test(wt_path)
            || /^\/gst\/mostpopularmovies.html/.test(wt_path)) {
      contentGroup = "Most Popular";
    
    // learningnetwork
    } else if (/^\/learning\//.test(wt_path)) {
      contentGroup = "Learning Network";
  
    // knowledgenetwork
    } else if (wt_domain == "college.nytimes.com"
            || /^\/college\//.test(wt_path)
            || /^\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/college\//.test(wt_path)) {
      contentGroup = "Knowledge Network";
  
    // weekinreview
    } else if (/^\/[0-9][0-9][0-9][0-9]\/[0-1][0-9]\/[0-3][0-9]\/weekinreview\//.test(wt_path)
            || /^\/weekinreview\//.test(wt_path)) {
      contentGroup = "Week In Review";
  
    // weather
    } else if (/^\/weather/.test(wt_path)
            || /^\/weather\//.test(wt_path)) {
      contentGroup = "Weather";
  
    // multimedia
    } else if (/^\/pages\/multimedia\//.test(wt_path)
            || /^\/ref\/multimedia\//.test(wt_path)) {
      contentGroup = "Multimedia";
  
    // cartoons
    } else if (/^\/pages\/cartoons\//.test(wt_path)) {
      contentGroup = "Cartoons";
 
    // personalization
    //} else if (wt_domain == "timesfile.nytimes.com") {
    //  contentGroup = "newstracker";
    //} else if (/^\/mem\/tnt.html\//.test(wt_path)) {
    //  contentGroup = "newstracker";

    // apreuters
    } else if (/^\/pages\/aponline\//.test(wt_path)
            || /^\/pages\/reuters\//.test(wt_path)) {
      contentGroup = "AP/Reuters";

    // default to Homepage 
    } else {
      contentGroup = "Homepage";
    }

  }

  return contentGroup;

}

function getAdNames() {
  return "";
}

function getCampaignIds() {
  return "";
}

function setSearchInfo() {

  var searchResults;
  var wt_oss = "";
  var wt_oss_r = "";
  
  // for global searches
  if (/^\/search\/query\//.test(wt_path)) {
    wt_oss = getQueryParameter("query");
    searchResults = document.getElementById("sortBy");
  }

  // for travel search only
  if (wt_domain == "travel.nytimes.com" && /\/gst\/travel\/travsearch.html/.test(wt_path)) {
    wt_oss = getQueryParameter("term");
    searchResults = document.getElementById("noResults");
  }
  
  // for tech search only
  if (/\/gst\/technology\/techsearch.html/.test(wt_path)) {
    wt_oss = getQueryParameter("query");
    searchResults = document.getElementById("productSearchResults");
  }

  // for movie search only
  if (/\/gst\/movies\/msearch.html/.test(wt_path)) {
    wt_oss = getQueryParameter("query");
    searchResults = document.getElementById("nr");
  }

  if (null == searchResults) {
    wt_oss_r = "0";
  } else {
    wt_oss_r = "1";
  }

  addMetaTag("WT.oss", wt_oss);
  addMetaTag("WT.oss_r", wt_oss_r);

}

function setTrackEvents() {

  if (/^\/pages\/technology\/index.html/.test(wt_path)
   || /^\/pages\/automobiles\/index.html/.test(wt_path)) {
    gtrackevents = true;
  }

}

// helper functions used by this and other content javascript files
function addMetaTag(tagName, tagContent) {

  var newMetaTag = document.createElement('meta');
  newMetaTag.name = tagName;
  newMetaTag.content = tagContent;
  document.getElementsByTagName('head').item(0).appendChild(newMetaTag);

}

function getMetaTag(tagName) {

  var metaTags=document.getElementsByTagName("meta");
  for(var i in metaTags){ 
    if(metaTags[i].name == tagName) {
      return metaTags[i].content;
    }
  }
  return "";

}

function getQueryParameter(name) {

  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null ) {
    return "";
  } else {
    return results[1];
  }

}

function formatString(value) {
  value = value.replace(";", "%3B");
  return value;
}


