fav = function(){
};

fav.pop = function(url,title,width,height){
		window.open(url,title,'scrollbars=no,width='+width+',height='+height+',left='+(screen.width-width)/2+',top='+(screen.height-height)/2+',status=yes,resizable=yes');
}

fav.open = function(site){
	var url;
	var d=parent.document;
	var c_href=d.location.href;
	var c_title=d.title;
	var c_sel;
	
	if (d.selection){
		c_sel = d.selection.type!='None'?d.selection.createRange().text:''
	}else{
		c_sel = d.getSelection?d.getSelection():'';
	}
	if (c_sel.length>1500){
		c_sel=c_sel.substr(0,1500);
	}
	
	switch(site){
		case "delicious" :
			url="http://www.delicious.com/post?v=4&noui&jump=close&url="+escape(c_href)+"&title="+ encodeURI(c_title);
			fav.pop(url,'delicious',500,450);
			break;
		case "google" :
			url="http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk="+ escape(c_href) +"&title="+ encodeURI(c_title);
			//window.open(url,'google');
			fav.pop(url,'google',550,450);
			break;
		case "baidu" :
			url="http://cang.baidu.com/do/add?it="+ encodeURI(c_title) +"&iu="+ escape(c_href) +"&dc="+ encodeURI(c_sel) +"&fr=ien#nw=1";
			fav.pop(url,'baidu',600,450);
			break;
		case "vivi" :
			url="http://vivi.sina.com.cn/collect/icollect.php?pid=28&title="+escape(c_title)+"&url="+escape(c_href)+"&desc="+escape(c_sel);
			fav.pop(url,'vivi',480,520);
			break;
		case "hexun" :
			url="http://bookmark.hexun.com/post.aspx?title="+escape(c_title)+"&url="+escape(c_href)+"&excerpt="+escape(c_sel);
			fav.pop(url,'hexun',900,600);
			break;
		case "poco" :
			url="http://my.poco.cn/fav/storeIt.php?t="+escape(c_title)+"&u="+escape(c_href)+"&c="+escape(c_sel);
			fav.pop(url,'poco',500,600);
			break;
		case "qq" :
			url="http://shuqian.qq.com/post?from=3&title="+encodeURI(c_title)+"&uri="+escape(c_href)+"&jumpback=2&noui=1";
			fav.pop(url,'qq',950,550);
			break;
		case "mister-wong" :
			url="http://www.mister-wong.cn/index.php?action=addurl&bm_url="+escape(c_href)+"&bm_description="+encodeURI(c_title)+"&bm_notice="+encodeURI(c_sel);
			fav.pop(url,'misterwong',800,600);
			break;
		case "live" :
			url="https://office.live.com/sharefavorite.aspx%2f.SharedFavorites??mkt=zh-cn&url="+escape(c_href)+"&title="+encodeURI(c_title)+"&top=1";
			fav.pop(url,'live',900,600);
			break;
		case "digg" :
			url="http://digg.com/submit?phase=2&url="+escape(c_href);
			fav.pop(url,'digg',1000,500);
			break;
		case "diglog" :
			url="http://www.diglog.com/submit.aspx?title="+escape(c_title)+"&url="+escape(c_href)+"&description="+escape(c_sel);
			fav.pop(url,'diglog',800,800);
			break;
		case "sina" :
			url="http://v.t.sina.com.cn/share/share.php?url="+encodeURI(c_href)+"&title="+encodeURI(c_title);
			fav.pop(url,'sina',620,450);
			break;
		case "douban" :
			url="http://www.douban.com/recommend/?url="+encodeURI(c_href)+"&title="+encodeURI(c_title)+"&sel=&v=1";
			fav.pop(url,'qzone',500,350);
			break;
		case "renren" :
			url="http://share.renren.com/share/buttonshare.do?link="+encodeURI(c_href)+"&title="+encodeURI(c_title);
			fav.pop(url,'renren',500,350);
			break;
		case "kaixin" :
			url="http://www.kaixin001.com/repaste/share.php?rurl="+encodeURI(c_href)+"&rcontent="+encodeURI(c_sel)+"&rtitle="+encodeURI(c_title);
			fav.pop(url,'renren',530,350);
			break;
		case "chouti" :
			url="http://dig.chouti.com/digg.action?newsURL="+encodeURI(c_href)+"&title="+encodeURI(c_title);
			fav.pop(url,'renren',990,560);
			break;
		case "xianguo" :
			url="http://xianguo.com/service/submitdigg/?link="+encodeURI(c_href)+"&title="+encodeURI(c_title);
			fav.pop(url,'renren',650,450);
			break;
		
	}
};
