/* ====================================================================
 *
 *   sbm.js - Aladdin JavaScript for Social Bookmark
 *
 *   All Rights Reserved, Copyright (c) 2008. Commerce Link Inc.
 *
 * ==================================================================== */

var SBM_URL;
var SBM_TITLE;

/* Write sbms
----------------------------------------------------------------------- */
function write_sbms( func ) {
	var sbms = {
		hatena    : 'ϤƤʥ֥åޡ',
		livedoor  : 'livedoorå'  ,
		yahoo     : 'Yahoo!֥åޡ',
		delicious : 'del.icio.us'       ,
		pookmark  : 'POOKMARK Airlines' ,
		google    : 'Google֥åޡ',
		nifty     : '@niftyåצ'
	};

	DW( '<ul>\n' );
	for( var id in sbms ) {
		var name = 'js-sbm-' + id;
		var text = sbms[id] + 'ɲ';
		DW( '<li>' );
		DWAJS( name,
			' title="' + text + '" onclick="return add_sbm(\'' + id + '\');"' );
		DW( '<img src="/images/sbm/' + id + '.gif" alt="' + text + '" />' );
		DW( '</a></li>\n' );
	}
	DW( '</ul>\n' );
}

/* Add sbm
----------------------------------------------------------------------- */
function add_sbm( id ) {
	var url = document.URL;
	var title = document.title;
	if( SBM_URL != undefined ) {
		url = SBM_URL;
	}
	if( SBM_TITLE != undefined ) {
		title = SBM_TITLE;
	}

	switch( id ) {
	case "delicious":
		var sbm  = 'http://delicious.com/save';
			sbm += '?url=' + encodeURIComponent( url );
			sbm += '&title=' + encodeURIComponent( title );
			sbm += '&v=5';
		window.open( sbm );
		break;
	case "google":
		var sbm  = 'http://www.google.com/bookmarks/mark'
			sbm += '?op=edit';
			sbm += '&bkmk=' + encodeURIComponent( url );
			sbm += '&title=' + encodeURIComponent( title );
		window.open( sbm );
		break;
	case "hatena":
		var sbm  = 'http://b.hatena.ne.jp/add'
			sbm += '?mode=confirm';
			sbm += '&title=' + escape( title );
			sbm += '&url=' + escape( url );
		window.open( sbm );
		break;
	case "livedoor":
		var sbm  = 'http://clip.livedoor.com/redirect';
			sbm += '?link=' + encodeURIComponent( url );
			sbm += '&title=' + encodeURIComponent( title );
		window.open( sbm );
		break;
	case "nifty":
		var sbm  = 'http://clip.nifty.com/create';
			sbm += '?url=' + encodeURIComponent( url );
			sbm += '&title=' + encodeURIComponent( title );
		window.open( sbm );
		break;
	case "pookmark":
		var sbm  = 'http://pookmark.jp/post';
			sbm += '?url=' + encodeURIComponent( url );
			sbm += '&title=' + encodeURIComponent( title );
		window.open( sbm );
		break;
	case "yahoo":
		var sbm  = 'http://bookmarks.yahoo.co.jp/bookmarklet/showpopup';
			sbm += '?t=' + encodeURIComponent( title );
			sbm += '&u=' + encodeURIComponent( url );
			sbm += '&opener=bm&ei=UTF-8';
		window.open( sbm );
		break;
		
	case "minna":
		var sbm  = 'http://minna.topics.yahoo.co.jp/pu_list';
			sbm += '?url=' + encodeURIComponent( url );
			sbm += '&title=' + encodeURIComponent( title );
			sbm += '&opener=bm&ei=UTF-8';
		window.open( sbm );
		break;
	case "goo":
		var sbm  = 'http://bookmark.goo.ne.jp/add/detail';
			sbm += '?url=' + encodeURIComponent( url );
		window.open( sbm );
		break;

	case "buzzurl":
		var sbm  = 'http://buzzurl.jp/entry/';
			sbm += url;
		window.open( sbm );
		break;
	case "fc2":
		var sbm  = 'http://bookmark.fc2.com/user/post';
			sbm += '?url=' + encodeURIComponent( url );
			sbm += '&title=' + encodeURIComponent( title );
			window.open( sbm );
		break;
	case "iza":
		var sbm  = 'http://www.iza.ne.jp/bookmark/add/regist/back/';
			sbm +=escape( url );
			window.open( sbm );
		break;
	case "newsing":
		var sbm  = 'http://newsing.jp/add';
			sbm += '&title=' + encodeURIComponent( title );
			sbm += '?url=' + encodeURIComponent( url );
			window.open( sbm );
		break;

	case "facebook":
		var sbm  = 'http://www.facebook.com/sharer.php';
			sbm += '&t=' + encodeURIComponent( title );
			sbm += '?u=' + encodeURIComponent( url );
			window.open( sbm );
		break;


	case "blinklist":
		var sbm  = 'http://www.blinklist.com/index.php?Action=Blink/addblink.php';
			sbm += '&Title=' + encodeURIComponent( title );
			sbm += '?Url=' + encodeURIComponent( url );
			window.open( sbm );
		break;


	default:
		break;
	}

	return false;
}

function showSbPane(whichPane,flag){
	var thisPane = whichPane + 'Pane';
	var thisBtn = whichPane + 'Btn';
	var btnPath =YAHOO.util.Dom.get(thisBtn);
	
	if(flag===1){
		YAHOO.util.Dom.removeClass(thisPane, 'sorthide');
		YAHOO.util.Dom.addClass(thisPane, 'sortshow');
		btnPath.innerHTML =  '<a href="javascript:showSbPane(\''+whichPane+'\',0);"><img alt="閉じる" src="/images/icon_off.gif" width="27" height="15" /></a>';
	}else{
		YAHOO.util.Dom.removeClass(thisPane, 'sortshow');
		YAHOO.util.Dom.addClass(thisPane, 'sorthide');
		btnPath.innerHTML =  '<a href="javascript:showSbPane(\''+whichPane+'\',1);"><img alt="もっと" src="/images/icon_more.gif" width="27" height="15" /></a>';
	}
}

/* END */
