
   function setUrl(id)
  {
        var pathArray = window.location.pathname.split( '/' );
		var newPathname = "";
		for ( i = 1; i < pathArray.length-1; i++ ) 
		{
			//alert(pathArray[i]);
			newPathname += "/";
			if(pathArray[i] != "")
			{
				newPathname += pathArray[i];
			}
		}
				
	   newPathname = newPathname +"/makeup_remove_06.php?uid="+id;	
	   var newURL = window.location.protocol + "//" + window.location.host + newPathname;
	   //window.location = newURL;
      return newURL;
  }
  
  
   function getImageUrl()
  {
        var pathArray = window.location.pathname.split( '/' );
		var newPathname = "";
		for ( i = 1; i < pathArray.length-1; i++ ) 
		{
			//alert(pathArray[i]);
			newPathname += "/";
			if(pathArray[i] != "")
			{
				newPathname += pathArray[i];
			}
		}
					
	   var newURL = window.location.protocol + "//" + window.location.host + newPathname;
	   //window.location = newURL;
      return newURL;
  }
  
  
  

function callShare(type,id, name)
{
		 
			 var title = "貝德瑪“舒妍潔膚液”免費試用 ";
		     var content= name+" 剛剛申請了貝德瑪BIODERMA“舒妍潔膚液20ml”免費試用，您都來參加吧！"; 
           //  var url = location.href +"?uid="+id; //get current url;
		   
		    var url = setUrl(id);
			//alert(url);
			var imageUrl = getImageUrl();
			//alert(imageUrl);
			var thumbnail = "user_"+id+"_40.jpg";
		    if(type =="msn")
		   {
				
			window.open("http://profile.live.com/badge?url="+encodeURIComponent(url)+"&title="+encodeURIComponent(title)+"&description="+encodeURIComponent(content)+"&screenshot="+encodeURIComponent(imageUrl+'/images/comment/'+thumbnail),'_blank');
			  
		   }
		   else if(type =="qq")
		   {
				window.open("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url="+encodeURIComponent(url)+"&title="
				+encodeURIComponent(title), "_blank"); //qq will check url exist and get the default page title for this url
		   }
		   else if(type =="renren")
		   {
			 window.open("http://share.renren.com/share/buttonshare.do?link=?"+encodeURIComponent(url)+"&title="+encodeURIComponent(title) ,'_blank');       //doesn't have title
		   }
		  else if(type=='sina')
		   {
			 var title = title +" "+ content;
			 window.open('http://v.t.sina.com.cn/share/share.php?title='+encodeURIComponent(title)+'&url='+encodeURIComponent(url)+'&source=bookmark','_blank'); //link is the content, doesn't have title on it 
		   }
		   else if(type=='happy')
		   {
				  window.open('http://www.kaixin001.com/~repaste/repaste.php?&amp;rurl='+escape(url)+'&amp;rtitle='+escape(title)+'&amp;rcontent='+escape(content),'_blank');　　//can add content
			
	       }
}