//Debug variables
var blnAlert = false;
var statSeq = 0;

function getReferral()
{
   var refKey1 = "?ref=";
   var refKey2 = "&ref=";
   var ref;

   if ((ref = getSearchParameter(refKey1)) == "") {
      if ((ref = getSearchParameter(refKey2)) == "") {
         if ((window.document.referrer != "") && (window.document.referrer != "-")) {
            if (!(navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) < 4) ) {
               ref = window.document.referrer;
            }
         }
      }
   }
   return ref;
}

function getSearchParameter (key)
{
   var searchString = location.search;
   var startIdx;
   var endIdx

   if ((startIdx = searchString.indexOf(key)) == -1)
       return "";

	if ((endIdx = searchString.indexOf("&", startIdx + key.length)) == -1)
      return searchString.substring(startIdx + key.length);
   else
      return searchString.substring(startIdx + key.length, endIdx);
}

function createPageViewTag( page_name,strSection,strChannel, inLangNum)
{
    //alert( "createPageViewTag: " + page_name + "|" + strSection + "|" + strChannel + "|" + inLangNum);

   //strLang = getTagLanguage( parseInt( inLangNum));

   //s_channel=channel;
   //s_pageName=pagename;
   //language = getTagLanguage(language);
   //s_prop1 = language;
   //s_prop15 = language;
   //s_prop18 = sectionname;


   s_events = "";
   s_products = "";
   strSubSection = "";
   strRegion = "ap";
   strSubRegion = "ap";
   strLang = "chi";
   strLocale = "zh_cn";

   s_pageName = page_name;
   s_prop13 = strRegion;
   s_prop14 = strSubRegion;
   s_prop15 = strLang;
   s_channel = strChannel; //Break down by standard Nike Channel definitions
   s_prop4 = strSection; //This supplies a breakdown of section popularity by actual section name
   s_prop5 = strSubSection;
   s_prop6 = strLocale;

   if (s_channel == null || s_channel =="") s_channel = "undefined";
   if (s_server == null || s_server =="") s_server = "undefined";
   if (s_prop14 == null || s_prop14 =="") s_prop14 = "undefined";
   if (s_prop15 == null || s_prop15 =="") s_prop15 = "undefined";

   void(sendAnalyticsEvent(''));//SiteCatalyst specific
   if (blnAlert) printTagVariables(); // un-comment this function if you want to do some debugging on the information being sent
}

function createLinkEventTag( page_name,strSection,strChannel,strlinkName,inLangNum)
{
   //alert( "createLinkEventTag: " + page_name + "|" + strSection + "|" + strChannel + "|" + strlinkName + "|" + inLangNum);

   //strLang = getTagLanguage( parseInt( inLangNum));

   s_events = "";
   s_products = "";
   strSubSection = "";

   strRegion = "us";
   strSubRegion = "us";
   strLang = "eng";
   strLocale = "en_us";
   s_pageName = page_name;
   s_prop13 = strRegion;
   s_prop14 = strSubRegion;
   s_prop15 = strLang;
   s_channel = strChannel; //Break down by standard Nike Channel definitions
   s_prop4 = strSection; //This supplies a breakdown of section popularity by actual section name
   s_prop5 = strSubSection;
   s_prop6 = strLocale;

   if (s_channel == null || s_channel =="") s_channel = "undefined";
   if (s_server == null || s_server =="") s_server = "undefined";
   if (s_prop14 == null || s_prop14 =="") s_prop14 = "undefined";
   if (s_prop15 == null || s_prop15 =="") s_prop15 = "undefined";


   void(sendLinkEvent('',strlinkName));//SiteCatalyst specific
   if (blnAlert) printTagVariables(); // un-comment this function if you want to do some debugging on the information being sent
}

function createCommerceTag(page_name,strLang,strRegion,strSubRegion,strLocale,strSection,strSubSection,strChannel,strEvents,strProducts)
{
   s_pageName = page_name;
   s_prop13 = strRegion;
   s_prop14 = strSubRegion;
   s_prop15 = strLang;
   s_channel = strChannel; //Break down by standard Nike Channel definitions
   s_prop4 = strSection; //This supplies a breakdown of section popularity by actual section name
   s_prop5 = strSubSection;
   s_prop6 = strLocale;

   s_events = strEvents;
   s_products = strProducts;

   if (s_channel == null || s_channel =="") s_channel = "undefined";
   if (s_server == null || s_server =="") s_server = "undefined";
   if (s_prop14 == null || s_prop14 =="") s_prop14 = "undefined";
   if (s_prop15 == null || s_prop15 =="") s_prop15 = "undefined";

   void(sendAnalyticsEvent(''));//SiteCatalyst specific
   if (blnAlert) printTagVariables(); // un-comment this function if you want to do some debugging on the information being sent
}

function printTagVariables()
{
	statSeq+=1; //This offsets multiple catalyst debug windows!
	var statWinNm = "stats_debugger" + Math.round(Math.random()*10000);
	void(window.open("",statWinNm,"width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1,top=" + statSeq * 10 + ",left="  + statSeq * 10).document.write("<script language=\"JavaScript\" src=\"http://192.168.112.2O7.net/stats_debugger.php\"></"+"script>"));
}

// Bowerman specific function. Ensure this remains when updates to this file are required!

//Do not delete - required functions below
function getTagLanguage(what) {
        lan = "";
        s_account=org_s_account;
        s_prop13="emea";//Region
        if (what == 1) { lan = "eng_uk"; }
        if (what == 2) { lan = "ger"; }
        if (what == 3) { lan = "spa"; }
        if (what == 4) { lan = "ita"; }
        if (what == 5) { lan = "fre"; }
        if (what == 6) { lan = "por"; }
        if (what == 8) { lan = "por_bra"; s_account=latem_s_account;s_prop13="amer";}
        if (what == 9) { lan = "eng_us"; s_account=us_s_account;s_prop13="us";}
        if (what == 10) { lan = "spa_lat"; s_account=latem_s_account;s_prop13="amer";}
        if (what == 11) { lan = "tur"; }
        if (what == 12) { lan = "pol"; }
        if (what == 21) { lan = "chi_hk"; s_account=hk_s_account;s_prop13="ap";}
        if (what == 22) { lan = "jap"; s_account=jap_s_account;s_prop13="ap";}
        if (what == 23) { lan = "kor"; s_account=kor_s_account;s_prop13="ap";}
        if (what == 24) { lan = "zho"; s_account=chi_s_account;s_prop13="ap";}
        return lan;
}
