/*  共享書籤使用, version 1.0
 *  (c) 2007 Ying-Chun Chen
 *
 *  此檔案設計目的是讓udn網群之書籤功能統一
 *  提供[udn書籤]、[hemidemi]、[myshare]、[yahoo]、[del.icio.us]、[fURI]
 *
/*--------------------------------------------------------------------------*/

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

/*
	函數說明：
		加入google書籤
 	參數說明：
 		
*/
function addGoogleBkmk() {
	desc='';
	if(window.getSelection)desc=window.getSelection();
	if(document.getSelection)desc=document.getSelection();
	if(document.selection)desc=document.selection.createRange().text;
	void(open('http://www.google.com/bookmarks/mark?op=add&bkmk='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)+'&annotation='+encodeURIComponent(desc)));
}
/*
	函數說明：
		加入udn書籤
 	參數說明：
 		
*/
function addUDNBookmark() {
	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;
	if(location.href.indexOf("http://udn.com/NEWS/") > -1 ){
	substart = location.href.lastIndexOf("/");
	subend = location.href.lastIndexOf("."); 	
	archiveUrl = 'http://forum.udn.com/forum/NewsLetter/NewsPreview?Encode=big5&NewsID='+location.href.substring(substart+1,subend);
	void(open('http://bookmark.udn.com/add?f_TITLE='+encodeURIComponent(document.title)+'&f_URL='+encodeURIComponent(archiveUrl)+'&f_DIGEST='+encodeURIComponent(desc)+'&via='+encodeURIComponent(via)));
        }else{
        void(open('http://bookmark.udn.com/add?f_TITLE='+encodeURIComponent(document.title)+'&f_URL='+encodeURIComponent(location.href)+'&f_DIGEST='+encodeURIComponent(desc)+'&via='+encodeURIComponent(via)));
        }
}
/*
	函數說明：
		加入hemidemi書籤
 	參數說明：
 		
*/
function addHemidemiBookmark() {
	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;
	if(location.href.indexOf("http://udn.com/NEWS/") > -1 ){
	substart = location.href.lastIndexOf("/");
	subend = location.href.lastIndexOf("."); 	
	archiveUrl = 'http://forum.udn.com/forum/NewsLetter/NewsPreview?Encode=big5&NewsID='+location.href.substring(substart+1,subend);	
	void(open('http://www.hemidemi.com/user_bookmark/new?url='+encodeURIComponent(archiveUrl)+'&title='+encodeURIComponent(document.title)));
        }else{	
		void(open('http://www.hemidemi.com/user_bookmark/new?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)));
		}
}
/*
	函數說明：
		加入myshare書籤
 	參數說明：
 		
*/
function addMyshareBookmark() {
	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;	
	if(location.href.indexOf("http://udn.com/NEWS/") > -1 ){
	substart = location.href.lastIndexOf("/");
	subend = location.href.lastIndexOf("."); 	
	archiveUrl = 'http://forum.udn.com/forum/NewsLetter/NewsPreview?Encode=big5&NewsID='+location.href.substring(substart+1,subend);	
	void(open('http://myshare.url.com.tw/index.php?func=newurl&from=mysharepop&NewsMaster=1&url='+encodeURIComponent(archiveUrl)+'&desc='+encodeURIComponent(document.title)));
        }else{	
		void(open('http://myshare.url.com.tw/index.php?func=newurl&from=mysharepop&NewsMaster=1&url='+encodeURIComponent(location.href)+'&desc='+encodeURIComponent(document.title)));
		}
}
/*
	函數說明：
		加入yahoo書籤
 	參數說明：
 		
*/
function addYahooBookmark() {
	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;
	if(location.href.indexOf("http://udn.com/NEWS/") > -1 ){
	substart = location.href.lastIndexOf("/");
	subend = location.href.lastIndexOf("."); 	
	archiveUrl = 'http://forum.udn.com/forum/NewsLetter/NewsPreview?Encode=big5&NewsID='+location.href.substring(substart+1,subend);	
	void(open('http://tw.myweb2.search.yahoo.com/myresults/bookmarklet?u='+encodeURIComponent(archiveUrl)+'&ei=UTF-8&t='+encodeURIComponent(document.title)));
        }else{		
		void(open('http://tw.myweb2.search.yahoo.com/myresults/bookmarklet?u='+encodeURIComponent(location.href)+'&ei=UTF-8&t='+encodeURIComponent(document.title)));
		}
}
/*
	函數說明：
		加入del.icio.us書籤
 	參數說明：
 		
*/
function addDeliciousBookmark() {
	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;
	if(location.href.indexOf("http://udn.com/NEWS/") > -1 ){
	substart = location.href.lastIndexOf("/");
	subend = location.href.lastIndexOf("."); 	
	archiveUrl = 'http://forum.udn.com/forum/NewsLetter/NewsPreview?Encode=big5&NewsID='+location.href.substring(substart+1,subend);	
	void(open('https://secure.del.icio.us/login?url='+encodeURIComponent(archiveUrl)+'&title='+encodeURIComponent(document.title)));
        }else{		
		void(open('https://secure.del.icio.us/login?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)));
		}
}
/*
	函數說明：
		加入fURI書籤
 	參數說明：
 		
*/
function addfURIBookmark() {
	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;
	if(location.href.indexOf("http://udn.com/NEWS/") > -1 ){
	substart = location.href.lastIndexOf("/");
	subend = location.href.lastIndexOf("."); 	
	archiveUrl = 'http://forum.udn.com/forum/NewsLetter/NewsPreview?Encode=big5&NewsID='+location.href.substring(substart+1,subend);	
	void(open('http://www.furl.net/storeIt.jsp?u='+encodeURIComponent(archiveUrl)+'&t='+encodeURIComponent(document.title)));
        }else{			
		void(open('http://www.furl.net/storeIt.jsp?u='+encodeURIComponent(location.href)+'&t='+encodeURIComponent(document.title)));
		}
}
/*
	函數說明：
		加入fURI書籤
 	參數說明：
 		
*/
function addfFunPBookmark() {
	
}
/*
	函數說明：
		顯示可加入的書籤下拉清單
 	參數說明：
 		
*/
function displayBookmarkMenu() {
document.write("<style type='text/css'>"); 
document.write("<!--"); 
document.write("#menus_1 {"); 
document.write("	position: relative;");
document.write("	width: 53;"); 
document.write("}"); 
document.write("#bookmark_1 {"); 
document.write("	position:absolute;"); 
document.write("	width: 90px;");
document.write("	visibility: hidden;"); 
document.write("}"); 
document.write("-->"); 
document.write("</style>"); 	
	
	document.write("<div style='clear:both' id='menus_1'><a href='http://bookmark.udn.com' target=_blank onMouseOver='MM_showHideLayers(\"bookmark_1\",\"\",\"show\")' onMouseOut='MM_showHideLayers(\"bookmark_1\",\"\",\"hide\")'><img src='../images_new/replay_o_02.gif' alt='書籤' border='0' align='absmiddle'></a></div><div id='bookmark_1' onMouseOver='MM_showHideLayers(\"bookmark_1\",\"\",\"show\")' onMouseOut='MM_showHideLayers(\"bookmark_1\",\"\",\"hide\")'>");
  document.write("<table width='150' border='0' cellspacing='1' cellpadding='1'  bgcolor='#CCCCCC'>");
    document.write("<tr>");
      document.write("<td bgcolor='#FFFFFF'><table width='100%' border='0' cellpadding='5' cellspacing='0'>");
        document.write("<tr>");
          document.write("<td valign='top' nowrap bgcolor='#FFFFFF' class='s'><a href='javascript:;' onclick='addGoogleBkmk()'><img src='../images_new/4.jpg' align='absmiddle' border='0'> Google</a></td>");
          document.write("</tr>");
        document.write("<tr>");
          document.write("<td valign='top' nowrap bgcolor='#FFFFFF' class='s'><a href='javascript:;' onclick='addHemidemiBookmark()'><img src='../images_new/HD.gif' align='absmiddle' border='0'> hemidemi</a></td>");
          document.write("</tr>");
        document.write("<tr>");
          document.write("<td valign='top' nowrap bgcolor='#FFFFFF' class='s'><a href='javascript:;' onclick='addMyshareBookmark()'><img src='../images_new/myshare.jpg' align='absmiddle' border='0'> myshare</a></td>");
        document.write("</tr>");
        document.write("<tr>");
          document.write("<td valign='top' nowrap bgcolor='#FFFFFF' class='s'><a href='javascript:;' onclick='addYahooBookmark()'><img src='../images_new/yahoo.gif' align='absmiddle' border='0'> yahoo!奇摩</a></td>");
          document.write("</tr>");
        document.write("<tr>");
          document.write("<td valign='top' nowrap bgcolor='#FFFFFF' class='s'><a href='javascript:;' onclick='addDeliciousBookmark()'><img src='../images_new/delicious.gif' border='0'> del.icio.us</a></td>");
        document.write("</tr>");
        document.write("<tr>");
          document.write("<td valign='top' nowrap bgcolor='#FFFFFF' class='s'><a href='javascript:;' onclick='addfURIBookmark()'><img src='../images_new/lil_furl_butt.gif' align='absmiddle' border='0'> fURl</a></td>");
        document.write("</tr>");
		document.write("<tr>");
          document.write("<td valign='top' nowrap bgcolor='#FFFFFF' class='s'><a href='javascript:;' onclick='addUDNBookmark()'><img src='../images_new/udn.gif' align='absmiddle' border='0'> UDN</a></td>");
        document.write("</tr>");
		document.write("<tr>");
          document.write("<td valign='top' nowrap bgcolor='#FFFFFF' class='s'><a href='http://funp.com/push/submit/add.php?&via=tools' ><img src='../images_new/funp.gif' align='absmiddle' border='0'> 貼到推推王</a></td>");
        document.write("</tr>");
      document.write("</table></td>");
    document.write("</tr>");
  document.write("</table>");
  document.write("</div>");
  /*document.write("<div id='menus_1'><a href='http://bookmark.udn.com' target=_blank onMouseOver='MM_showHideLayers(\"bookmark_1\",\"\",\"show\")' onMouseOut='MM_showHideLayers(\"bookmark_1\",\"\",\"hide\")'><img src='http://g.udn.com/bookmark/news/images/icon_bookmark.gif' alt='書籤' width='42' height='18' border='0' align='absmiddle'></a></div>");*/
}
/*
	函數說明：
		於網路城邦顯示可加入的書籤下拉清單
 	參數說明：
 		
*/
function displayCityBookmarkMenu() {
	
document.write("<style type='text/css'>"); 
document.write("<!--"); 
document.write("#menus_2 {"); 
document.write("	position: relative;"); 
document.write("	width: 53;"); 
document.write("}"); 

document.write("#bookmark_2 {"); 
document.write("	position:absolute;"); 
document.write("	top: -172px;"); 
document.write("	left: 0px;"); 
document.write("	width: 90px;");
document.write("	visibility: hidden;"); 
document.write("}"); 
document.write("-->"); 
document.write("</style>"); 
	
	document.write("<span id='menus_2'><div id='bookmark_2' onMouseOver='MM_showHideLayers(\"bookmark_2\",\"\",\"show\")' onMouseOut='MM_showHideLayers(\"bookmark_2\",\"\",\"hide\")'>");
  document.write("<table width='100%' border='0' cellspacing='0' cellpadding='0'>");
    document.write("<tr>");
      document.write("<td><table width='100%' border='0' cellpadding='5' cellspacing='1' class='chapter'>");        
        document.write("<tr>");
          document.write("<td height='27' valign='top' nowrap><a href='javascript:;' onclick='addHemidemiBookmark()' class='chapter-text'><img src='http://g.udn.com/bookmark/city/images/HD.gif' width='16' height='16' align='absmiddle' border='0'> hemidemi</a></td>");
          document.write("</tr>");
        document.write("<tr>");
          document.write("<td height='27' valign='top' nowrap><a href='javascript:;' onclick='addMyshareBookmark()' class='chapter-text'><img src='http://g.udn.com/bookmark/city/images/myshare.jpg' width='16' height='16' align='absmiddle' border='0'> myshare</a></td>");
        document.write("</tr>");
        document.write("<tr>");
          document.write("<td height='29' valign='top' nowrap><a href='javascript:;' onclick='addYahooBookmark()' class='chapter-text'><img src='http://g.udn.com/bookmark/city/images/yahoo.gif' width='18' height='18' align='absmiddle' border='0'> yahoo!奇摩</a></td>");
          document.write("</tr>");
        document.write("<tr>");
          document.write("<td height='29' valign='top' nowrap><a href='javascript:;' onclick='addDeliciousBookmark()' class='chapter-text'><img src='http://g.udn.com/bookmark/city/images/delicious.gif' width='16' height='16' border='0'> del.icio.us</a></td>");
        document.write("</tr>");
        document.write("<tr>");
          document.write("<td height='27' valign='top' nowrap><a href='javascript:;' onclick='addfURIBookmark()' class='chapter-text'><img src='http://g.udn.com/bookmark/city/images/lil_furl_butt.gif' width='16' height='16' align='absmiddle' border='0'> fURl</a></td>");
        document.write("</tr>");
        document.write("<tr>");
          document.write("<td height='27' valign='top' nowrap><a href='javascript:;' onclick='addUDNBookmark()' class='chapter-text'><img src='http://g.udn.com/bookmark/city/images/udn.gif' width='16' height='16' align='absmiddle' border='0'> +udn書籤</a></td>");
        document.write("</tr>");
      document.write("</table></td>");
    document.write("</tr>");
  document.write("</table>");
  document.write("</div><a href='http://bookmark.udn.com' target=_blank onMouseOver='MM_showHideLayers(\"bookmark_2\",\"\",\"show\")' onMouseOut='MM_showHideLayers(\"bookmark_2\",\"\",\"hide\")'><img src='http://g.udn.com/community/img/common_all_2007/func_bookmark.gif' alt='書籤' width='42' height='14' border='0'></a></span>");
}

/*
	函數說明：
		於stars顯示可加入的書籤下拉清單
 	參數說明：
 		
*/
function displayStarsBookmarkMenu() {
document.write("<div align='right'><img src='http://g.udn.com/bookmark/stars/images/bookmark.gif' width='16' height='15'><span class='note'> 加入書籤：</span>");
document.write("<a href='javascript:;' onclick='addUDNBookmark()'><img src='http://g.udn.com/bookmark/stars/images/bookmark_b.gif' width='80' height='18' border='0' align='absmiddle' alt='+udn書籤'></a> ");
document.write("<a href='javascript:;' onclick='addHemidemiBookmark()'><img src='http://g.udn.com/bookmark/stars/images/HD.gif' width='16' height='16' border='0' align='absmiddle' alt='hemidemi'></a> ");
document.write("<a href='javascript:;' onclick='addMyshareBookmark()'><img src='http://g.udn.com/bookmark/stars/images/myshare.jpg' width='16' height='16' border='0' align='absmiddle' alt='myshare'></a> "); 
document.write("<a href='javascript:;' onclick='addYahooBookmark()'><img src='http://g.udn.com/bookmark/stars/images/yahoo.gif' width='18' height='18' border='0' align='absmiddle' alt='yahoo!奇摩'></a> ");
document.write("<a href='javascript:;' onclick='addDeliciousBookmark()'><img src='http://g.udn.com/bookmark/stars/images/delicious.gif' width='16' height='16' border='0' align='absmiddle' alt='del.icio.us'></a> "); 
document.write("<a href='javascript:;' onclick='addfURIBookmark()'><img src='http://g.udn.com/bookmark/stars/images/lil_furl_butt.gif' width='16' height='16' border='0' align='absmiddle' alt='fURl'></a> ");
document.write("</div>");
}
