var Class = {
  create: function() {
    return function() {
      this.initialize.apply(this, arguments);
    }
  }
}

var BookMark = Class.create();
BookMark.prototype = {
	name : "",
	isMember: false,
	reloadPage: false,
	initialize: function() {
		
	},
	setMember: function(status) {
		this.isMember = status;
	},
	openFaceBook: function() {
	    u=location.href;
	    t=document.title;
	    //window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
        var url = "http://www.facebook.com/sharer.php?u="+encodeURIComponent(u)+"&t="+encodeURIComponent(t);
		this.popupCenter(url);
	    //return false;
    },
	openHemidemi: function() {
		desc='';
		via='';
		if(document.referrer) {
			via=document.referrer;
		}
		if(typeof(_ref)!='undefined') {
			via=_ref;
		}
		
		if(window.getSelection) {
			desc=window.getSelection();
		}
		if(document.getSelection) {
			desc=document.getSelection();
		}
		if(document.selection) {
			desc=document.selection.createRange().text;
		}
		var url = "http://www.hemidemi.com/user_bookmark/new?title=" + encodeURIComponent(document.title) + "&url=" + encodeURIComponent(location.href) + "&description=" + encodeURIComponent(desc) + "&via=" + encodeURIComponent(via);
		this.popupCenter(url);
	},
	openFunp: function() {
		desc='';
		if(window.getSelection) {
			desc=window.getSelection();
		}
		if(document.getSelection) {
			desc=document.getSelection();
		}
		if(document.selection) {
			desc=document.selection.createRange().text;
		}
		var url = "http://funp.com/pages/submit/add.php?url=" + encodeURIComponent(location.href) + "&s=" + encodeURIComponent(document.title) + "&t=" + encodeURIComponent(desc) + "&tags[]=%E7%B6%B2%E7%AB%99&tags[]=%E6%96%B0%E8%81%9E&tags[]=%E9%81%8B%E5%8B%95&tags[]=%E6%97%85%E8%A1%8C&tags[]=%E9%A3%9F%E8%A8%98&tags[]=%E6%9B%B8%E7%B1%8D&tags[]=%E5%81%A5%E5%BA%B7&tags[]=%E9%86%AB%E7%99%82&via=tools&via=tools";
		this.popupCenter(url);
	},
	openMyshare: function() {
		contents='';
		if(window.getSelection){
			contents=window.getSelection()
		}
		if(document.getSelection){
			contents=document.getSelection();
		}
		if(document.selection){
			contents=document.selection.createRange().text;
		}
		var url = "http://myshare.url.com.tw/index.php?func=newurl&from=mysharepop&NewsMaster=1&url=" + encodeURIComponent(location.href) + "&desc=" + escape(document.title) + "&contents=" + escape(contents);
		this.popupCenter(url);
	},
	openTwitThis: function() {
		contents='';
		if(window.getSelection){
			contents=window.getSelection()
		}
		if(document.getSelection){
			contents=document.getSelection();
		}
		if(document.selection){
			contents=document.selection.createRange().text;
		}
		var url = "http://twitthis.com/twit?url=" + encodeURIComponent(location.href) + "&title=" + ((document.title) ? encodeURIComponent(document.title.replace(/^\s*|\s*$/g,'')) : "");
		this.popupCenter(url);
	},
	openPlurk: function() {
		contents='';
		if(window.getSelection){
			contents=window.getSelection()
		}
		if(document.getSelection){
			contents=document.getSelection();
		}
		if(document.selection){
			contents=document.selection.createRange().text;
		}
		var url = "http://plurk.com/?status=" + encodeURIComponent(location.href) + " " + "(" + ((document.title) ? encodeURIComponent(document.title.replace(/^\s*|\s*$/g,'')) : "") + ")";
		this.popupCenter(url);
	},
	openUdn: function() {
		contents='';
		if(window.getSelection){
			contents=window.getSelection()
		}
		if(document.getSelection){
			contents=document.getSelection();
		}
		if(document.selection){
			contents=document.selection.createRange().text;
		}
		var url = "http://bookmark.udn.com/add?via=&f_URL=" + encodeURIComponent(location.href) + "&f_TITLE=" + escape(document.title) + "&f_DIGEST=" + escape(contents);
		this.popupCenter(url);
	},
	openYahoo: function() {
		contents='';
		if(window.getSelection){
			contents=window.getSelection()
		}
		if(document.getSelection){
			contents=document.getSelection();
		}
		if(document.selection){
			contents=document.selection.createRange().text;
		}
		var url = "http://myweb2.search.yahoo.com/myresults/bookmarklet?u=" + encodeURIComponent(location.href) + "&t=" + escape(document.title) + "&ei=UTF-8";
		this.popupCenter(url);
	},
	popupCenter: function(url) {
		var width = "800";
		var height = "600";
		var top=(screen.height-height)/2;
		var left=(screen.width-width)/2;
		window.open(url, "" ,"status=1,location=1,resizable=1,scrollbars=1,top=" +top+ ",left="+left+",width="+width+",height="+height);
	},	
	handleMember: function(reason, linkid, bookmark) {

		var args = {action: "add", reason: "", linkid: "", bookmark: ""};
		args["reason"] = (reason) ? reason : "";
		args["linkid"] = (linkid) ? linkid : "";
		args["bookmark"] = (bookmark) ? bookmark : "";
		
		// 需載入 jquery
		if (typeof(jQuery) != "undefined"){
			$.post("/Member20/MemberScoreHandle.ashx", args, function(data){
				//alert(data);
			}, "text");
		}
		else
		{ alert("jQuery must be included");}
	},	
	empty: function() {

	}
}
BookMark = new BookMark();

