function retweet_or_reply(arg, user, type, id, tiptype) 
{
 	if(type==1||type==3)
 	{
		//alert('infn');
		//alert(sitepath+' ::: '+tiptop_url);
		var text = arg.parentNode.parentNode.parentNode.parentNode.innerHTML;
		//var text = arg;
		//alert(text);
		text 	 = text.split('&nbsp;');
		var retwt_txt = text[0];
		
		var in_s = retwt_txt.toUpperCase().lastIndexOf('GREENCLR');			
		//var firefox_s = retwt_txt.toUpperCase().lastIndexOf('<SPAN CLASS="GREENCLR"');	
		if(in_s!='-1')
		{
			retwt_txt = retwt_txt.substring(0,in_s);		
		}
		var out_s = text[0].toUpperCase().lastIndexOf('</SPAN>');
		if(out_s!='-1')
		{
			var leng = text[0].length;
			retwt_txt_rem = text[0].substring(out_s,leng);				
		}
		else
			retwt_txt_rem = '';		
		retwt_txt_full = retwt_txt+retwt_txt_rem;	
		var full_tweet=retwt_txt_full;
		var urlMatch = /<A\s+[^>]*href=\"([^\"]*)\"[^>]*>(.*)<\/A>/i.exec(full_tweet);
		if(urlMatch!=null)
		{
			var smallUrl=urlMatch[0];
			smallUrl=smallUrl.replace(/<A/g,'<a');
			smallUrl=smallUrl.replace(/A>/g,'a>');
			full_tweet=full_tweet.replace(urlMatch[0],smallUrl);
		}	
		while(full_tweet.indexOf('<a')!=-1)
		{
			urlmatch=full_tweet.substring(full_tweet.indexOf('<a'),(full_tweet.indexOf('/a>')+3));
			if(full_tweet.indexOf('<span id=\"sp')!=-1)
			{
				if(full_tweet.indexOf('<span id=\"sp')<full_tweet.indexOf('<a'))
				{
					full_tweet=full_tweet.substring(full_tweet.indexOf('/a>')+3);
					continue;
				}
			}
			var match = /<a\s+[^>]*href=\"([^\"]*)\"[^>]*>(.*)<\/a>/i.exec(urlmatch);
			if(match!=null)
			{
				var urlhref = match[1]; 
				var urltext = match[2];		
				if((urltext.match('@')==null)&&(urltext!=''))
				{
					retwt_txt_full=retwt_txt_full.replace(urltext,urlhref);					
				}					
			}
			full_tweet=full_tweet.substring(full_tweet.indexOf('/a>')+3);			
		}
		text = retwt_txt_full.replace(/<\/?[^>]+(>|$)/g, '');	
		//alert(text);		
	}
	if(type==1) 
	{	
		//text = escape(text);
		text = encodeString.encode(text);//added by teena for special charcater encoding
		//for opera.
		textpos = text.indexOf('Re-Tip');
		//alert(textpos+'textpos');
		if(textpos!= '-1')
		{
			//alert('abc');
			text = text.substring(0,textpos);
		}
		
		//alert(text);	
		text_atmsg = text+' (via http://FeelTipTop.com) ';
		var retweet_code = 'RT @'+user+' ';
		var retweet_text = retweet_code+text;
		//alert(retweet_text);
		var count_text = retweet_text.length;										
		if(count_text>140){
		 //	alert('count_text>140');
			var param = 'home?status='+encodeURIComponent(retweet_code)+text+'&in_reply_to_status_id='+id+'&in_reply_to='+user;	
			var tweetShare=window.open('http://twitter.com/'+param, 'Retweet', 'toolbar=0,status=0,width=626,height=436');
			tweetShare.focus();
		}
		else
		{
		 //	alert('count_text<140 else loop');
			twitterurl='http://twitter.com/'+user+'/statuses/'+id;
			var longurls = twitterurl ;
			RecursiveRetweetURL(user,id,longurls,retweet_text);
			if(true == bitlyWorked)
			{
				retweet_length = retweet_status.length;
			 //	alert(retweet_length);
				if(retweet_length<171)
				{
				 //	alert('retweet_status<140');
					var tweetShare=window.open(retweet_status, 'Retweet', 'toolbar=0,status=0,width=626,height=436');
					tweetShare.focus();
					return;
				}
				else
				{
					//alert('retweet_length>140 else loop');
					var param = 'home?status='+encodeURIComponent(retweet_code)+text_atmsg+'&in_reply_to_status_id='+id+'&in_reply_to='+user;	
					var tweetShare=window.open('http://twitter.com/'+param, 'Retweet', 'toolbar=0,status=0,width=626,height=436');
					tweetShare.focus();
				}
			}
		}
	}
	else if(type==2) 
	{
		var reply_code = '@'+user+' (via http://FeelTipTop.com) ';
		
		var param = 'home?status='+encodeURIComponent(reply_code)+'&in_reply_to_status_id='+id+'&in_reply_to='+user;
		
		var tweetShare=window.open('http://twitter.com/'+param, 'Reply', 'toolbar=0,status=0,width=626,height=436');
		tweetShare.focus();
	}
	else if(type==3)
	{
		//alert('retip'+tiptop_url);
		var view_code = '@'+user+' ';
		//var tiptop_url = '".$pageUrl."'+'/';
		twitter_url='http://twitter.com/'+user+'/statuses/'+id;
		var long_urls = twitter_url+'<=>'+escape(tiptop_url);
		//alert(long_urls);
		//alert(queryTerm);
		getBitlyAndRecirsiveUrls(user,id,long_urls,queryTerm,text);
		if(true == bitlyWorked){	
			//alert(retip_status);		 	
			retip_status=retip_status.replace('#','%23');
			var tweetShare=window.open(retip_status, 'retip', 'toolbar=0,status=0,width=626,height=436');
			tweetShare.focus();
			return;
		}else{
					//var vicon_url = 'I really like your tweet '+twitter_url+' as a top tip in TipTop at '+tiptop_url;encodeURIComponent(view_code)+
					var vicon_url = 'I like @'+user+'\'s \"'+text+'\" tip '+twitter_url+' in TipTop at '+tiptop_url+' for \"'+queryTerm+'\"';
					vicon_url = vicon_url.replace('\"\"','\"');
					msgLength = (unescape(vicon_url)).length;
					if(msgLength>138){
						queryLength = queryTerm.length;
						tweetLength = text.length;
						lengthMinimumRequired = (msgLength-tweetLength)-queryLength;
						if(queryLength>25){
							vicon_url = 'I like @'+user+'\'s \"'+text.substring(0,((138-25)-(lengthMinimumRequired+3)))+'...\" tip '+twitter_url+' in TipTop at '+tiptop_url+' for \"'+queryTerm.substring(0,22)+'...\"';
						}
						else{
							vicon_url = 'I like @'+user+'\'s \"'+text.substring(0,((138-queryLength)-(lengthMinimumRequired+3)))+'...\" tip '+twitter_url+' in TipTop at '+tiptop_url+' for \"'+queryTerm+'\"';	
							msgLength = (unescape(vicon_url)).length;
							if(msgLength>138){
								if(lengthMinimumRequired>138){
									vicon_url = 'I like @'+user+'\'s tip '+twitter_url+' in TipTop at '+tiptop_url;
								}
								else{
									vicon_url = 'I like @'+user+'\'s tip '+twitter_url+' in TipTop at '+tiptop_url+' for \"'+queryTerm.substring(0,(138-(lengthMinimumRequired+3)))+'...\"';
								}
							}
						}
					}	
					var paramRetip = 'home?status='+escape(vicon_url)+'&in_reply_to_status_id='+id+'&in_reply_to='+user;			
					var twitterStatus = 'http://twitter.com/'+paramRetip;
					var tweetShare=window.open(twitterStatus, 'retip', 'toolbar=0,status=0,width=626,height=436');
					tweetShare.focus();
		}	
		
	}
}