str = navigator.appName.toUpperCase();
if (str.indexOf("NETSCAPE") >= 0){
document.write('<link rel="stylesheet" href="/css/style_nn.css" type="text/css" />');
}

function backToTop() {
  var x1 = x2 = x3 = 0;
  var y1 = y2 = y3 = 0;
  if (document.documentElement) {
      x1 = document.documentElement.scrollLeft || 0;
      y1 = document.documentElement.scrollTop || 0;
  }
  if (document.body) {
      x2 = document.body.scrollLeft || 0;
      y2 = document.body.scrollTop || 0;
  }
  x3 = window.scrollX || 0;
  y3 = window.scrollY || 0;
  var x = Math.max(x1, Math.max(x2, x3));
  var y = Math.max(y1, Math.max(y2, y3));
  window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));
  if (x > 0 || y > 0) {
      window.setTimeout("backToTop()", 25);
  }
}

function sbookmarks(){
    str = location.href;
    if(str.match(/^https/)){
		var imgfld = 'https://www.affiliateportal.net/js/socialBookMarks/';
		str = str.replace("https", "http");
    }else{
		 var imgfld = 'http://www.affiliateportal.net/js/socialBookMarks/';
    }
	var e = new socialBookMarks({
		imgDir : imgfld
	});
	document.write(e.getBoxElement().innerHTML);
}
/**
 * ブックマーク登録を行うJS
 */
var socialBookMarks = function(conf){
	this.conf = {
		imgDir : "./img/",
		tableClassName : "socialBookMarksTb",
		linkURL : location.href,
		linkText : document.title
	};
	this.setConf(conf);
};
socialBookMarks.prototype.setConf = function(conf){
	for(var i in conf){
		this.conf[i] = conf[i];
	}
};
socialBookMarks.prototype.writeElement = function(targetId){
	var e = document.getElementById(targetId);
	if(e){
		var box = this.getBoxElement();
		//e.appendChild(box);
		e.innerHTML = box.innerHTML;
	}
};
socialBookMarks.prototype.getBoxElement = function(){
	var btnClickFnc = function(){
		return true;	
	};
	var createBox = function(src,alt,href,fn){
		var a = document.createElement("a");
		a.href = href;
		a.onclick = fn;
		var im = document.createElement("img");
		im.src = src;
		im.alt = alt;
		a.appendChild(im);
		return a;
	}
	var bb = document.createElement("div");
	
	var box = document.createElement("table");
	box.className = this.conf.tableClassName;
	box.cellspacing = 0;
	box.border = 0;
	box.cellpadding = 0;
	
	var tr = document.createElement("tr");
	
	//yahoo
	var td = document.createElement("td");
	td.style.verticalAlign = "middle";
	var h = "http://bookmarks.yahoo.co.jp/bookmarklet/showpopup?ei=UTF-8&u=" + encodeURIComponent(this.conf.linkURL) + "&t=" + encodeURIComponent(this.conf.linkText);
	td.appendChild(createBox(this.conf.imgDir + "yahoo_ico.gif",'Yahooブックマーク',h , btnClickFnc));
	tr.appendChild(td);
	
	var td = document.createElement("td");
	td.style.verticalAlign = "middle";
	var h = "http://www.google.com/bookmarks/mark?op=add&bkmk=" + encodeURIComponent(this.conf.linkURL)+"&title="+encodeURIComponent(this.conf.linkText);
	td.appendChild(createBox(this.conf.imgDir + "google_ico.gif",'Googleブックマーク',h , btnClickFnc));
	tr.appendChild(td);

	var td = document.createElement("td");
	td.style.verticalAlign = "middle";
	var h = "http://b.hatena.ne.jp/add?mode=confirm&url=" + encodeURIComponent(this.conf.linkURL)+"&title="+encodeURIComponent(this.conf.linkText);
	td.appendChild(createBox(this.conf.imgDir + "hatena_ico.gif",'はてなブックマーク',h , btnClickFnc));
	tr.appendChild(td);

	var td = document.createElement("td");
	td.style.verticalAlign = "middle";
	var h = "http://clip.livedoor.com/redirect?link=" + encodeURIComponent(this.conf.linkURL)+"&title="+encodeURIComponent(this.conf.linkText);
	td.appendChild(createBox(this.conf.imgDir + "livedoor_ico.gif",'livedoorクリップ',h , btnClickFnc));
	tr.appendChild(td);

	var td = document.createElement("td");
	td.style.verticalAlign = "middle";
	var h = "http://del.icio.us/post?url=" + encodeURIComponent(this.conf.linkURL)+"&title="+encodeURIComponent(this.conf.linkText);
	td.appendChild(createBox(this.conf.imgDir + "delicious_ico.gif",'del.icio.us',h , btnClickFnc));
	tr.appendChild(td);

	var td = document.createElement("td");
	td.style.verticalAlign = "middle";
	var h = "http://buzzurl.jp/config/add/confirm?url=" + encodeURIComponent(this.conf.linkURL)+"&title="+encodeURIComponent(this.conf.linkText);
	td.appendChild(createBox(this.conf.imgDir + "buzzurl_ico.gif",'buzzurl',h , btnClickFnc));
	tr.appendChild(td);

	var td = document.createElement("td");
	td.style.verticalAlign = "middle";
	var h = "http://www.google.com/buzz/post?url=" + encodeURIComponent(this.conf.linkURL)+"&message="+encodeURIComponent(this.conf.linkText)+"&hl=ja";
	td.appendChild(createBox(this.conf.imgDir + "buzz_ico.gif",'buzz',h , btnClickFnc));
	tr.appendChild(td);

	box.appendChild(tr);
	bb.appendChild(box);
	return bb;
};
