// 导航下拉隐现
$(document).ready(function() {
	$('.drop-box').hover(function() {
		$(this).find('ul').fadeIn('fast');							  
	}, function() {
		$(this).find('ul').hide();	
	})					   
});
var Twioo = {};
Twioo.focusblur=function(event,el,txt)
{
	txt=txt||"搜索其他话题...";
	event=event||window.event;
	if(event.type=="focus")
	{
		   if(el.value==txt)
		    {el.value=""}
	 }
	 if(event.type=="blur")
	 {
		 if(el.value=="")
		    {el.value=txt}
	 }
};

Twioo.focuskeyup=function(el)
{
	 if(el.value.length>0)
	 {
		 $("#listForm").show();
		 GetId('list_content_blog').innerHTML=el.value.length>8?el.value.slice(1,8)+"..":el.value;
		 GetId('list_content_author').innerHTML=el.value.length>8?el.value.slice(1,8)+"..":el.value;
		 GetId('list_content_stock').innerHTML=el.value.length>8?el.value.slice(1,8)+"..":el.value;
	 }
	 else
	 {
		 GetId("listForm").style.display="none";
		 GetId('list_content_blog').innerHTML="";
		 GetId('list_content_author').innerHTML="";
		 GetId('list_content_stock').innerHTML="";
	 }
}

Twioo.key_down=function(event)
{
	if((event.keyCode==38||event.keyCode==40)&&(GetId("listForm").style.display!="none"))
	{
		Twioo.focusFocus(event.keyCode);
	}
	else if((event.keyCode==13)&&(GetId("listForm").style.display!="none")&&(GetId("s").value.length>0))
	{
		Twioo.search(GetId("s").value);
	}
}

Twioo.setcolor=function(obj)
{
  list1.className ="listdown";
  list2.className="listdown";
  list3.className="listdown";
  obj.className="listup";
}

Twioo.Click=function()
{
    if((GetId("listForm").style.display!="none")&&(GetId("s").value.length>0))
	{
		Twioo.search(GetId("s").value);
	}
	//插入股票操作
	else if(GetId("ubb_stock1") && GetId("ubb_stock1").style.display==''){
		navigate('13',  null, "results1", "keyIndex1");
	}
}


String.prototype.len   = function(){return   this.replace(/[^\x00-\xff]/g,"**").length;}   

Twioo.focusFocus=function(code)
{
	if(code==38)
	{
		if(list1.className=="listup")
		{
			Twioo.setcolor(list3);
		}
		else if(list2.className=="listup")
		{
			Twioo.setcolor(list1);
		}
		else
		{
			Twioo.setcolor(list2);
		}
	}
	else
	{
		if(list1.className=="listup")
		{
			Twioo.setcolor(list2);
		}
		else if(list2.className=="listup")
		{
			Twioo.setcolor(list3);
		}
		else
		{
			Twioo.setcolor(list1);
		}
	}
}

Twioo.search=function(txt)
{	
	var searchform = GetId('searchForm');
	if($('#s').val().length==1)
	{
		 var str=",.?;:'\"!@#$%^&*()";
		 if(str.indexOf($('#s').val())>=0)
		 {
          	ymPrompt.alert({message:'不能搜索单个字符！',handler:null});
			return;
		 }
	}
	if(list1.className=="listup")
	{	
	    searchform.action=webaddr+"/op.php?act=search&op=search&HitSearch=1&stype=1";
	}
	else if(list2.className=="listup")  
	{
		searchform.action=webaddr+"/op.php?act=search&op=search&HitSearch=1&stype=0";
	}
	else
	{
		searchform.action=webaddr+"/search/"+$('#s').val();
	}
	searchform.submit();
}


function searchblog(eventtype)
{	
   var searchform = GetId('searchForm');
   var txt =GetId("s").value;
   if(txt.length>0)
   {
		if(txt.length==1)
		{
			 var str=",.?;:'\"!@#$%^&*()";
			 if(str.indexOf(txt)>=0)
			 {
				ymPrompt.alert({message:'不能搜索单个字符！',handler:null});
				return;
			 }
		}
	   
	   if(eventtype==1)
	   {
	     searchform.action=webaddr+"/op/search&HitSearch=1&stype=1";
	   }
	   else if(eventtype==2)
	   {
	   	 searchform.action=webaddr+"/op/search&HitSearch=1&stype=0";
	   }
	   else
	   {
	      searchform.action=webaddr+"/search/"+txt;
	   }
	   searchform.submit();
   }
}


function check_CheckpromptNum(follownum,commentnum,msgnum,repliesnum){
	tishiDiv.innerHTML="";
	if(follownum>0)
	{  
		 tishiContent.style.display="";
		 tishiDiv.innerHTML=tishiDiv.innerHTML+"<li><a   href=\""+webaddr+"/"+user_id+"/fans\"  class=\"tslink\">你有<span>"+follownum+"</span>位新粉丝</a></li>";
	}
	else
	{	
		 tishiContent.style.display="none";
	}
	if(commentnum>0)
	{  
		 tishiContent.style.display="";
		 tishiDiv.innerHTML=tishiDiv.innerHTML+"<li><a href=\"javascript:void(0)\"  onclick=\"tishiclose('comment',this)\" class=\"tslink\">你有<span>"+commentnum+"</span>条评论</a></li>";
	}
	if(msgnum>0)
	{  
		 tishiContent.style.display="";
		 tishiDiv.innerHTML=tishiDiv.innerHTML+"<li><a   href=\"javascript:void(0)\"  onclick=\"tishiclose('privatemsg',this)\" class=\"tslink\">你有<span>"+msgnum+"</span>条私信</a></li>";
	}
	
	if(repliesnum>0)
	{  
		 tishiContent.style.display="";
		 tishiDiv.innerHTML=tishiDiv.innerHTML+"<li><a   href=\"javascript:void(0)\"  onclick=\"tishiclose('replies',this)\" class=\"tslink\"><span>"+repliesnum+"</span>条微博提到你</a></li>";
	}

}


function ClosetishiContent()
{
	var parameterMap={
		"op":"checknum", 
		"act":"CheckALLNum", 	
		"rnd":Math.random()
	};
	$.post("/op.php", parameterMap,
			function(data){
				if(data=="ok")
				{  
					  tishiContent.style.display="none";
				}
			});
}

function  AttentionTopic(topcontent,obj)
{
    $.post("/op.php",{"op":"checknum","act":"AttentionTopic","Topcontent":topcontent,"rnd":Math.random()},function(date)
			{
			  if(date=="exists"){
				  ymPrompt.alert({message:'已经关注了！',handler:null});
				  return;
			  }
			  else if(date=="isnotlogin")
			  {
			      	GoLogin();
               }
		      $('#successprompt').css("display", "");
			   $('#topichit').html('<span style=\"color:#333333; font-size:12px;\" id=\"successprompt\">已关注成功</span><span onclick="CancelAttentionTopic(\''+topcontent+'\',this);" ><a href="javascript:void(0);">(取消关注)</a></span>' )
			  // obj.outerHTML='<span onclick="CancelAttentionTopic(\''+topcontent+'\',this);"><a href="javascript:void(0);">(取消关注)</a></span>' ;
		  });
}

//取消关注话题
function CancelAttentionTopic(topcontent,obj)
{
    $.post("/op.php",{"op":"checknum","act":"CancelAttentionTopic","Topcontent":topcontent,"rnd":Math.random()},function(date)
			{
			  if(date=="notexists"){
				ymPrompt.alert({message:'你没有关注该话题！',handler:null});
				return;
			  }
			  else if(date=="isnotlogin")
			  {
			      	GoLogin();
               }
			  $('#successprompt').css("display", "none");
			   //obj.innerHTML='<a href=\"javascript:void(0)\" >关注该话题</a>';
			    $('#topichit').html('<span style=\"color:#333333; font-size:12px;display:none\" id=\"successprompt\">已关注成功</span><span onclick="AttentionTopic(\''+topcontent+'\',this);" ><a href="javascript:void(0);">关注该话题</a></span>' )
			  // obj.outerHTML='<span onclick="AttentionTopic(\''+topcontent+'\',this);"><a href="javascript:void(0);">关注该话题</a></span>' ;

		  });
}

//加关注话题 引号处理
function  AttentionTopicQuote(obj)
{
    $.post("/op.php",{"op":"checknum","act":"AttentionTopic","Topcontent":searchKey,"rnd":Math.random()},function(date)
			{
			  if(date=="exists"){
				  ymPrompt.alert({message:'已经关注了！',handler:null});
				  return;
			  }
			  else if(date=="isnotlogin")
			  {
			      	ymPrompt.alert({message:'你还没有登录！',handler:function(){GoLogin();}});
					return;
               }
		      $('#successprompt').css("display", "");
			   $('#topichit').html('<span style=\"color:#333333; font-size:12px;\" id=\"successprompt\">已关注成功</span><span onclick="CancelAttentionTopicQuote(this);" ><a href="javascript:void(0);">(取消关注)</a></span>' )
		  });
}

//取消关注话题 引号处理
function CancelAttentionTopicQuote(obj)
{
    $.post("/op.php",{"op":"checknum","act":"CancelAttentionTopic","Topcontent":searchKey,"rnd":Math.random()},function(date)
			{
			  if(date=="notexists"){
				ymPrompt.alert({message:'你没有关注该话题！',handler:null});
				return;
			  }
			  else if(date=="isnotlogin")
			  {
			      	ymPrompt.alert({message:'你还没有登录！',handler:function(){GoLogin();}});
					return;
               }
			  $('#successprompt').css("display", "none");
			    $('#topichit').html('<span style=\"color:#333333; font-size:12px;display:none\" id=\"successprompt\">已关注成功</span><span onclick="AttentionTopicQuote(this);" ><a href="javascript:void(0);">关注该话题</a></span>' )

		  });
}

//举报不良信息
function badInfoReport(userId){
	if(userId==''||userId==null){
		parent.window.location=webaddr+"/op/login&tip=36";
		return;
	}
	window.open('/op/otheroperate&act=badInfoReport&user_id='+userId, '举报不良信息', 'height=800, width=700, top=100, left=200, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
}




