﻿
function CreateTracking()
{
  //debugger;
    var sUrl = window.location.href.toLowerCase();
  //var sUrl = "http://homeware.24studio.co.uk/home-ware/tile-transfers.aspx:";
  
  var myvar = sUrl.split("/")
  var sSection = "";
  var sCat = "";
  var sSubCat = "";
  if (myvar[2].substring(0,myvar[2].indexOf(".")) != null)
  {
    sSection = myvar[2].substring(0,myvar[2].indexOf("."));
  }
  
  if (myvar[3] != null)
  { sCat = myvar[3]; }
  
  if (myvar[4] != null)
  { sSubCat = myvar[4]; }
  
  var sOutput = "";

  if (myvar[4] == null)
  {
  sOutput = "/S/" + sSection;
  cmCreatePageviewTag("/S/" + sSection, 'S:SEO');
  }
  else {
    
       //cmCreatePageviewTag('/S/[subdomain/category/filename]', 'S:SEO');
      if (sSubCat.length > 0 && sSubCat.indexOf('cm_mmc') > 0) {
          if (sSubCat.indexOf("?") > 0) {
              sSubCat = sSubCat.substring(0, sSubCat.indexOf("?"));
          }
          sOutput = "'/S/" + sSection + "/" + sCat + "/" + sSubCat + "','S:SEOP'";
          cmCreatePageviewTag("/S/" + sSection + "/" + sCat + "/" + sSubCat, 'S:SEOP');
      }
      else {
          if (sSubCat.indexOf("?") > 0) {
              sSubCat = sSubCat.substring(0, sSubCat.indexOf("?"));
          }
          sOutput = "'/S/" + sSection + "/" + sCat + "/" + sSubCat + "','S:SEO'";
          cmCreatePageviewTag("/S/" + sSection + "/" + sCat + "/" + sSubCat, 'S:SEO');
     }

  }

  return sOutput;

}


function noerror()
{
    function noError(){return true;}
    window.onerror = noError;

}

function removeSession() {



}
//function WriteToStream(sMassage) {
//    FB_RequireFeatures(["Connect"], function () {
//        FB.init(api_key, channel_path);
//        FB.ensureInit(function () {
//            //FB.Connect.streamPublish();
//            var user_message = 'jackson11 ' + sMassage;
//            var attachment = { 'name': 'Golden Ticket Hunt', 'caption': 'The cool game from Studio24 ', 'description': 'Studio24 has come up with an exciting game which when you play enables you to win great prizes!!' };
//            var action_links = { 'text': 'Code', 'href': 'http://goldenticket.24studio.co.uk/' };
//            var user_message_prompt = 'Share Golden Ticket ';
//            FB.Connect.streamPublish(user_message, attachment, action_links, null, user_message_prompt, null, true, null);
//        });
//    });
//}
