function gologin() {
  location.href='https://sems.shoeisha.com/users/login/selectbox?ref='+escape(location.href)
}


var scUri =  function (str) {
  this.url = str;
  this.options = {
    strictMode: false,
    key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
    q:   {
      name:   "queryKey",
      parser: /(?:^|&)([^&=]*)=?([^&]*)/g
    },
    parser: {
      strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
      loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
    }
  }
  
  this.parse = function(){
    var o   = this.options,
      m   = o.parser[o.strictMode ? "strict" : "loose"].exec(this.url),
      uri = {},
      i   = 14;

    while (i--) uri[o.key[i]] = m[i] || "";

    uri[o.q.name] = {};
    uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
      if ($1) uri[o.q.name][$1] = $2;
    });

    return uri;
  }
  
  this.hier = function(strD){
    var u = strD;
    var c = u.split('/');
    c[0] = 'home';
    for(i = 0; i < c.length; i++){
     if(c[i].length == 0){
      c.splice(i,1);
     }
    }
    if (c[c.length - 1].match(/[^0-9]/g)) {
    }else{
      c.splice(c.length - 1,1);
    }
    return c.join(':');
    
  }

  this.type = function(strD){
    var u = strD;
    var c = u.split('/');
    c[0] = 'home';
    for(i = 0; i < c.length; i++){
     if(c[i].length == 0){
      c.splice(i,1);
     }
    }
    return 
    
  }

  
  this.itemID = function(strD){
    var u = strD;
    var c = u.split('/');
    c.reverse();
    for(i = 0; i < c.length; i++){
     if(c[i].length == 0){
      c.splice(i,1);
     }
    }
    if (c[0].match(/[^0-9]/g)) {
      return '';
      }else{
      return c[0];
    }
  }
  
};

// ダウンロード開始
function download_click(id){
  var s=s_gi(s_account);
  // 二重カウント防止（session）：idが異なればカウントOK
  var event_id  = 'event11';
  var new_id = s.getValOnce(id, event_id+'_'+id, 0);
  if(new_id){
    s.linkTrackVars='products,eVar23,events';
    s.linkTrackEvents=event_id;
    s.events=event_id;
    s.eVar23=new_id;
    s.tl(this,'o','Download Click');
  }
}
// ダウンロード終了
function download_finish(id){
  var s=s_gi(s_account);
  // 二重カウント防止（session）：idが異なればカウントOK
  var event_id  = 'event12';
  var new_id = s.getValOnce(id, event_id+'_'+id, 0);
  if(new_id){
    s.linkTrackVars='products,eVar23,events';
    s.linkTrackEvents=event_id;
    s.events=event_id;
    s.eVar23=id;
    s.tl(this,'o','Download Finish');
  }
}


// ユーザ取得
function sc_user(){
  var jx=jQuery.ajax({
    url: "/api/user",
    dataType: "json",
    async: false
   }).responseText;
  var result = eval('(' + jx + ')');
  return result.shopper_id;
}
// リファラードメイン取得
function sc_referrer(){
  if(document.referrer.replace(/http[s]?:\/\/([^\/]+?)\/.*/i,"$1") == location.hostname){
    return "";
  }
  return document.referrer.replace(/http[s]?:\/\/([^\/]+?)\/.*/i,"$1");
}


function ov_click_count(v1, v2, v3) {
  var s=s_gi(s_account);
  s.linkTrackVars='products,eVar19,eVar20,events';
  s.linkTrackEvents='event4';
  s.events='event4';
  s.products = 'ov;' + v1;
  s.eVar19= v2;
  s.eVar20= v3;
  s.tl(this,'o','Overture Click');
}

