 

  function getUrlKv(){
    var validDays = 7;
    var past = new Date(2007, 1, 1);
    var ukvre = new RegExp(/[\?&]([^=]*?)=([^&$]+)/g);
    var ckvre = new RegExp(/([^=; &]+?)=([^;= &]+)/g);
    var matches;
    var kcount = 0;
    var kv = "";
    var expDate = new Date();
    var testDate = new Date(2020, 1, 1);
    var acceptCookies = false;
    try{    
      document.cookie = "tvtest=1; path=/; expires=" + 
        testDate.toGMTString() + ';';
      var cks = document.cookie.split(';');
      var i = 0;
      for(i = 0; i < cks.length; i++){
        if(cks[i].replace(' ', '') == "tvtest=1"){
          acceptCookies = true;
          document.cookie = 'tvtest=""; expires=' + past.toGMTString() +
            "; path=/;";
          break;
        }
      }
    }catch(E){
      alert('Exception ' + E.toString());
      acceptCookies = false;
    }

    if(acceptCookies){
      expDate.setDate(expDate.getDate() + validDays);
      matches = ukvre.exec(location.href);
      while(matches != null){
        //document.cookie = matches[1] + '=""; expires=' + past.toGMTString() +
        //  ';';
        document.cookie = matches[1] + '=' + matches[2] + ';' + ' path=/;' +
          ' expires=' + expDate.toGMTString() + ';';
        matches = ukvre.exec(location.href);
      }
      var cs = document.cookie;
      matches = ckvre.exec(cs);
      while(matches != null){
        if(matches[1] != 'path' && matches[1] != 'tvtest' && 
          matches[1].charAt(0) != '_' && matches[1].charAt(0) != '(' &&
          matches[1].substring(0, 7) != 'tvUser_'){
          kv += '&' + matches[1] + "=" + matches[2].substring(0, 128);
        }
        matches = ckvre.exec(cs);
      }
    }else{   // no cookies
      matches = ukvre.exec(location.href);
      while(matches != null){
        kv += '&' + matches[1] + "=" + matches[2].substring(0, 128);
        matches = ukvre.exec(location.href);
      }
    }// else acceptCookies
    kv += '&preLpUrl=' + escape(location.href);
    if(document.referer != null)
      kv += '&preRefUrl=' + escape(document.referer);
    return kv;
  }

 

  function setTvFrameSource(id){
    var x = document.getElementById(id);
    x.src = caServer + 'c2t/calls/html/static/topLevel/' + topLevel + 
      '?identifier=' + identifier + getUrlKv();
    return false;
  }

  function setTvFrameSource2(id){
    var x = document.getElementById(id);
    x.src = topLevel + '?identifier=' + identifier + getUrlKv();
    return false;
  }

