var disableTip=false;
var ua      = navigator.userAgent;
var opera   = /opera [56789]|opera\/[56789]/i.test(ua);
var ie      = !opera && /msie [56789]/i.test(ua);       // preventing opera to be identified as ie
var mozilla = !opera && /mozilla\/[56789]/i.test(ua);   // preventing opera to be identified as mz

//添加事件方法
if(!window.attachEvent && window.addEventListener)
{
  window.attachEvent = HTMLElement.prototype.attachEvent=
  document.attachEvent = function(en, func, cancelBubble)
  {
    var cb = cancelBubble ? true : false;
    this.addEventListener(en.toLowerCase().substr(2), func, cb);
  };
}

if(mozilla) {
//添加firefox支持even
	Event.prototype.__defineGetter__("fromElement",   function   ()   {   
	          var   node;   
	          if   (this.type   ==   "mouseover")   
	              node   =   this.relatedTarget;   
	          else   if   (this.type   ==   "mouseout")   
	              node   =   this.target;   
	          if   (!node)   return;   
	          while   (node.nodeType   !=   1)   node   =   node.parentNode;   
	          return   node;   
	});   
	Event.prototype.__defineGetter__("toElement",   function   ()   {   
	          var   node;   
	          if   (this.type   ==   "mouseout")   
	              node   =   this.relatedTarget;   
	          else   if   (this.type   ==   "mouseover")   
	              node   =   this.target;   
	          if   (!node)   return;   
	          while   (node.nodeType   !=   1)   node   =   node.parentNode;   
	          return   node;   
	});
}

function $(id) {return document.getElementById(id)}
function $Tag(obj,tag) {return obj.getElementsByTagName(tag)}

function getObjectById(id)   
{   
      if   (typeof(id)   !=   "string"   ||   id   ==   "")   return   null;   
      if   (document.all)   return   document.all(id);   
      if   (document.getElementById)   return   document.getElementById(id);   
      try   {return   eval(id);}   catch(e){   return   null;}   
}

function initMainClip()
{
	var _MainClipShow=$("MainClipShow")
	var _MainClipShow_Spans=$Tag(_MainClipShow,"a")		
	attachScript(_MainClipShow_Spans);	
}
function initEliteClip()
{		
	var _EliteClipShow=$("EliteClipShow");
	var _EliteClipShow_Spans=$Tag(_EliteClipShow,"a");
	attachScriptElite(_EliteClipShow_Spans);	
}
function attachScript(obj_arr)
{
	for(var i=0;i<obj_arr.length;i++)
		{		
			obj_arr[i].onmouseover=function()
			{	
				var  bl_tip_id="BL_M_TIP_"+this.id;					
				if (!disableTip){
					//关闭其它MainClip的DIV
					var _MainClipShow=$("MainClipShow")
					var _MainClipShow_Spans=$Tag(_MainClipShow,"a")		
					var v_bl_tip_id="";
					for(var j=0;j<_MainClipShow_Spans.length;j++)
					{				
						v_bl_tip_id="BL_M_TIP_"+_MainClipShow_Spans[j].id;	
						if(v_bl_tip_id!=bl_tip_id)									
						$(v_bl_tip_id).style.display='none';
					}
									
					$(bl_tip_id).className="tipLayerShow";
					show(this,$(bl_tip_id));					
				}				
			}
		}	
}
function attachScriptElite(obj_arr)
{
	for(var i=0;i<obj_arr.length;i++)
		{		
			obj_arr[i].onmouseover=function()
			{	
				var  bl_tip_id="BL_HL_TIP_"+this.id;					
				if (!disableTip){
				
					//关闭其它Elite_tip的DIV
					var _EliteClipShow=$("EliteClipShow");
					var _EliteClipShow_Spans=$Tag(_EliteClipShow,"a");
					var v_bl_tip_id="";
					for(var j=0;j<_EliteClipShow_Spans.length;j++)
					{				
						v_bl_tip_id="BL_HL_TIP_"+_EliteClipShow_Spans[j].id;	
						if(v_bl_tip_id!=bl_tip_id)									
						$(v_bl_tip_id).style.display='none';
					}
								
					$(bl_tip_id).className="tipLayerShow";
					show_HL(this,$(bl_tip_id));					
				}				
			}
		}	
}

//实现向setTimout传递对象
var _st = window.setTimeout;
window.setTimeout = function(fRef, mDelay)
{
 if(typeof fRef == 'function')
 {
   var argu = Array.prototype.slice.call(arguments,2);
   var f = (function()
   { fRef.apply(null, argu); 
   });
 return _st(f, mDelay); 
}
return _st(fRef,mDelay);
}

function hiddenTip(o)
{	
	if(mozilla) return false;//not ie
	var obj = event.toElement;
    while( obj!=null && obj.id!=o.id ){
        obj = obj.parentElement;
    }
    if( obj==null ){    
	window.setTimeout(hiddenDiv,50,o);
	}	
}
//删除祝福预览div
function hiddenYuLandiv(){
	if($("BL_TIP_YULAN")==null) return ;	
	$("BL_TIP_YULAN").style.display='none';
	document.body.removeChild($("BL_TIP_YULAN"));
}
function hiddenDiv(o){
	o.style.display='none';
}

function show(o,s)
{
		var eT=o.offsetTop,eL=o.offsetLeft,p=o.offsetParent;
		var sT=document.body.scrollTop,sL=document.body.scrollLeft;
		var eH=s.offsetHeight,eW=s.offsetWidth;
		var oH=o.offsetHeight,oW=o.offsetWidth;
		while(p&&p.tagName!="BODY")
		{
			eT+=p.offsetTop;
			eL+=p.offsetLeft;
			p=p.offsetParent;
		}
		//s.style.top=eT-eH/2;
		s.style.top=eT+'px';
		var v_left=eL+oW+5;
		s.style.left=v_left+'px';	
		s.style.display='block';
		//s.style.visibility='visible';
}

//显示精彩div
function show_HL(o,s)
{
		var eT=o.offsetTop,eL=o.offsetLeft,p=o.offsetParent;
		var sT=document.body.scrollTop,sL=document.body.scrollLeft;
		var eH=s.offsetHeight,eW=s.offsetWidth;
		var oH=o.offsetHeight,oW=o.offsetWidth;
		while(p&&p.tagName!="BODY")
		{
			eT+=p.offsetTop;
			eL+=p.offsetLeft;
			p=p.offsetParent;
		}
		//s.style.top=eT-eH/2;			
		s.style.top=eT+'px';
		//s.style.left=eL+oW+5;
		var v_left=eL+oW-15-141;
		s.style.left=v_left+'px';		
		s.style.display='block';
		//s.style.visibility='visible';
}
//查询关键词
function querykey(){
	var subkey = new HiddenSubmit('bless.biz.bizBL_KeyWord_WebQuery');	
	if (subkey.submitForm(document.key_form)) {	
		var result = subkey.getValue("root/data/resultinfo");		
		if(result==1)
		{	
			var BL_KEY=subkey.getValues('root/data/list[@type="BL_KEYWORDS"]/BL_KEYWORDS/KEYWORD');
			$("keyWordsField").value = BL_KEY;
		}
	}
}
/**显示祝福div*/
function ShowPost()
{
	var _PostLayer=$("PostLayer")
	_PostLayer.style.left=document.body.clientWidth/2-166
	_PostLayer.style.top=document.body.clientHeight/2-100
	_PostLayer.className="PostLayerShow";
}
/**关闭祝福div*/
function ColsePost()
{
	var _PostLayer=$("PostLayer");	
	_PostLayer.className="PostLayerClose";	
	hiddenYuLandiv();
}

function ColseInfoLayer()
{	
	var _InfoLayer=$("InfoLayer");	
	_InfoLayer.className="infoLayer";
}

//判断祝福标题只能输入中文
function onlychinese(evt) 
{
	if ((evt.keyCode >=32) && (evt.keyCode <= 126)){
		$("BL_BLESS/TITLE_").value="";
		$("InfoLayer").className="infoLayerShow";
		$("imageInfo").src="/internet/bless_img/success.gif";
		$("imageInfo").title="祝福标题只能是中文!...";
		$("spanInfo").innerHTML="祝福标题只能是中文!请切换到中文输入法！";
		setTimeout("ColseInfoLayer()",5000);  
		if(!mozilla)evt.keyCode = 0 ;
	}
} 

//检查输入中文函数
function ischinese(s)
{
	var errorChar;
	var badChar = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789><,[]{}?/+=|\\'\":;~!#$%()`";
	var i,c;
	for (i = 0; i < s.length; i++)
	{   
	  c = s.charAt(i);
	  if (badChar.indexOf(c) > -1) 
	        return false;
	 }	  
    return true;
}

function yanshe(){
	var contentColor= $("BL_BLESS/BG_COLOR").value;
	if(contentColor=="")contentColor="#f2e5c8";
	$("BL_BLESS/CONTENT_").style.background=contentColor;
	$("BL_BLESS/TITLE_").style.background="#f2e5c8";
	$("BL_BLESS/USER_NAME").style.background="#f2e5c8";
	$("randomid").style.background="#f2e5c8";
}
function yanzheng(){
	var content=$("BL_BLESS/CONTENT_").value;
	var title  =$("BL_BLESS/TITLE_").value;
	var name = $("BL_BLESS/USER_NAME").value;
	var icon = $("BL_BLESS/ICON_").value;
	var imgradom = $("randomid").value;
	var tit_length =title.length;
		
	if(icon==""){
		$("BL_BLESS/ICON_").value="icon2.png";
	
	}
	if(trim(content)==""){
		$("BL_BLESS/CONTENT_").focus();
		$("InfoLayer").className="infoLayerShow";
		$("imageInfo").src="/internet/bless_img/fail.gif";
		$("imageInfo").title="祝福内容不能为空!...";
		$("spanInfo").innerHTML="祝福内容不能为空!";
		$("BL_BLESS/CONTENT_").style.background="#FF0000";   
		setTimeout("ColseInfoLayer()",5000);  
		return false;
	}if(trim(title)==""){
		$("BL_BLESS/TITLE_").focus();
		$("InfoLayer").className="infoLayerShow";
		$("imageInfo").src="/internet/bless_img/fail.gif";
		$("imageInfo").title="祝福标题不能为空!...";
		$("spanInfo").innerHTML="祝福标题不能为空!";
		$("BL_BLESS/TITLE_").style.background="#FF0000"; 
		setTimeout("ColseInfoLayer()",5000);  
		return false;
	}
	if(!ischinese(title))
	{
		$("BL_BLESS/TITLE_").focus();
		$("InfoLayer").className="infoLayerShow";
		$("imageInfo").src="/internet/bless_img/fail.gif";
		$("imageInfo").title="祝福标题只能是中文!...";
		$("spanInfo").innerHTML="祝福标题只能是中文!";
		$("BL_BLESS/TITLE_").style.background="#FF0000"; 
		setTimeout("ColseInfoLayer()",5000);  
		return false;
	}
	
	if(trim(name)==""){
		$("BL_BLESS/USER_NAME").focus();
		$("InfoLayer").className="infoLayerShow";
		$("imageInfo").src="/internet/bless_img/fail.gif";
		$("imageInfo").title="发帖人不能为空!...";
		$("spanInfo").innerHTML="发帖人不能为空!";
		$("BL_BLESS/USER_NAME").style.background="#FF0000"; 
		setTimeout("ColseInfoLayer()",5000);  
		return false;
	}if((imgradom)==""){
		$("randomid").focus();
		$("InfoLayer").className="infoLayerShow";
		$("imageInfo").src="/internet/bless_img/fail.gif";
		$("imageInfo").title="验证码不能为空!...";
		$("spanInfo").innerHTML="验证码不能为空!";
		$("randomid").style.background="#FF0000"; 
		setTimeout("ColseInfoLayer()",5000);  
		return false;
	}
	var keywords = $("keyWordsField").value;
	if(keywords==null || keywords=="") return true;
	 keywords=keywords.split("|");
	for (i=0;i<keywords.length;i++){
		if (content.indexOf(keywords[i])!=-1){
			$("InfoLayer").className="infoLayerShow";
			$("imageInfo").src="/internet/bless_img/fail.gif";
			$("imageInfo").title="祝福内容中包含有关键字!...";
			$("spanInfo").innerHTML="祝福内容中包含有关键字<font color='red'>  "+keywords[i]+"  </font>!";
			$("BL_BLESS/CONTENT_").style.background="#FF0000";
			setTimeout("ColseInfoLayer()",5000);  
		    return false;
		}
	}	
	return true;
}
function dosubmitForm() {
  
	if(yanzheng()==true){
	
	var sub = new HiddenSubmit('bless.biz.bizBL_BLESSInsert');
	hiddenYuLandiv();//删除预览
	$("InfoLayer").className="infoLayerShow";
	$("imageInfo").src="/internet/bless_img/loading.gif";
	$("imageInfo").title="Loading...";
	$("spanInfo").innerHTML="正在发表祝福,请稍候....";
	
	if (sub.submitForm(document.add_form)) {	
		var ret = sub.getValue("root/data/messageinfo");	
		var result = sub.getValue("root/data/resultinfo");	
		
		if(result==1)
		{	
		$("InfoLayer").className="infoLayerShow";
		$("imageInfo").src="/internet/bless_img/success.gif";
		$("imageInfo").title="发表祝福成功!";		
		$("spanInfo").innerHTML=ret;
		ColsePost();
		$("add_form").reset();
		}else 
		{		
		$("InfoLayer").className="infoLayerShow";
		$("imageInfo").src="/internet/bless_img/fail.gif";
		$("imageInfo").title="发表祝福失败!";		
		$("spanInfo").innerHTML=ret;
		}
	}	
	setTimeout("ColseInfoLayer()",4500);  
	}
	return false;
}
function blessvote(id){
	var subvote = new HiddenSubmit('bless.biz.bizBL_BLESSVoteInsert');
	subvote.add('BL_BLESS_VOTE/BLESS_ID',id);
	if(subvote.submit()){
		var retvalue = subvote.getValue("root/data/retvalue");
		var result = subvote.getValue("root/data/resultinfo");	
		if(result==1)
		{	
		$("InfoLayer").className="infoLayerShow";
		$("imageInfo").src="/internet/bless_img/success.gif";
		$("imageInfo").title="success...";		
		$("spanInfo").innerHTML=retvalue;
		$("voteNum"+id).innerHTML="【投票成功】";
		}else
		{
		$("InfoLayer").className="infoLayerShow";
		$("imageInfo").src="/internet/bless_img/fail.gif";
		$("imageInfo").title="fail...";		
		$("spanInfo").innerHTML=retvalue;
		$("voteNum"+id).innerHTML="【投票失败】";		
		}		
		setTimeout("ColseInfoLayer()",2000);  
	}
}

function submitEliteForm() {
	var sub = new HiddenSubmit('bless.biz.bizBL_HL_BLESS');
		
	$("InfoLayer").className="infoLayerShow";	
	$("spanInfo").innerHTML="正在查询精彩祝福....";
	if (sub.submitForm(document.queryBlessForm)) {	
		var ret = sub.getValue("root/data/messageinfo");	
		var result = sub.getValue("root/data/resultinfo");	
		
		if(result==1)
		{	
			$("InfoLayer").className="infoLayerShow";
			$("imageInfo").src="/internet/bless_img/success.gif";
			$("imageInfo").title="查询精彩祝福成功!";		
			$("spanInfo").innerHTML=ret;	
					        				
			var BL_ID=sub.getValues('root/data/list[@type="QueryBL_HL_BLESS"]/QueryBL_HL_BLESS/ID');
			var BL_SORT_ID=sub.getValues('root/data/list[@type="QueryBL_HL_BLESS"]/QueryBL_HL_BLESS/SORT_ID');
			var BL_USER_NAME=sub.getValues('root/data/list[@type="QueryBL_HL_BLESS"]/QueryBL_HL_BLESS/USER_NAME');
			var BL_TITLE_=sub.getValues('root/data/list[@type="QueryBL_HL_BLESS"]/QueryBL_HL_BLESS/TITLE_');
			var BL_ICON_=sub.getValues('root/data/list[@type="QueryBL_HL_BLESS"]/QueryBL_HL_BLESS/ICON_');
			var BL_BG_COLOR=sub.getValues('root/data/list[@type="QueryBL_HL_BLESS"]/QueryBL_HL_BLESS/BG_COLOR');
			var BL_CREATE_DATE=sub.getValues('root/data/list[@type="QueryBL_HL_BLESS"]/QueryBL_HL_BLESS/CREATE_DATE');
			var BL_CONTENT_=sub.getValues('root/data/list[@type="QueryBL_HL_BLESS"]/QueryBL_HL_BLESS/CONTENT_');
			var BL_USER_IP=sub.getValues('root/data/list[@type="QueryBL_HL_BLESS"]/QueryBL_HL_BLESS/USER_IP');			
			
			var _EliteClipShow=$("EliteClipShow");			
			var div_title;	
			var div_titleText="";			
			for (var i=0; i<BL_ID.length; i++) {			
				
				if(i%3==0)//换行div
	   			{	
	   				div_titleText="";
	   				div_title = document.createElement("div");
	   			}	   	  		
	   	  		
				div_titleText +="<img src=/internet/bless_img/space.gif vspace=1  border=0 /><a id="+BL_ID[i]+" href='javascript:;'>"+BL_TITLE_[i]+"</a>";
				
				if(i%3==2 || i==BL_ID.length-1)//插入div	
				{	
					div_title.innerHTML=div_titleText;
					_EliteClipShow.appendChild(div_title);	
				}
			
				var div_bless_content = document.createElement("div");
				div_bless_content.id="BL_HL_TIP_"+BL_ID[i];
				div_bless_content.className="tipLayer";	
				div_bless_content.onmouseout=function(){hiddenTip(this);};
				var div_bless_html=tipCreate(BL_ID[i],BL_CONTENT_[i],BL_BG_COLOR[i],BL_USER_NAME[i],BL_SORT_ID[i],BL_CREATE_DATE[i],"BL_HL_TIP_"+BL_ID[i]);
				div_bless_content.innerHTML +=div_bless_html.join("");
				
				document.body.appendChild(div_bless_content);	
			}			
			initEliteClip();
					
		}else 
		{		
		$("InfoLayer").className="infoLayerShow";
		$("imageInfo").src="/internet/bless_img/fail.gif";
		$("imageInfo").title="查询精彩祝福失败";		
		$("spanInfo").innerHTML=ret;
		}
	}	
	setTimeout("ColseInfoLayer()",1000);  
}

function go(page)
{
	var inputLen = parseInt($("PageCond/length").value); 
	var total = Math.floor($("PageCond/count").value/$("PageCond/length").value);	  
	if ($("PageCond/count").value % $("PageCond/length").value != 0) {
       total++;
     }     
    var gono = page;
    if (gono<1)
   	{
     $("InfoLayer").className="infoLayerShow";
	 $("imageInfo").src="/internet/bless_img/fail.gif";	
	 $("spanInfo").innerHTML="已经到达首页!";
     setTimeout("ColseInfoLayer()",1000);  
     return false;     
    }     
   
    
   if(gono>total)
    {
     $("InfoLayer").className="infoLayerShow";
	 $("imageInfo").src="/internet/bless_img/fail.gif";	
	 $("spanInfo").innerHTML="已经到达尾页!";
     setTimeout("ColseInfoLayer()",1000);  
    return false;  
    }    
    
   $("PageCond/begin").value = (gono - 1) * inputLen;
    return true;      		
}
function nextBless()
{
    var current = Math.floor($("PageCond/begin").value/$("PageCond/length").value) + 1;	
	if(go(current+1))
	{
		submitMainForm();
	}
}
function preBless()
{
    var current = Math.floor($("PageCond/begin").value/$("PageCond/length").value) + 1;
	if(go(current-1))
	{
		submitMainForm();
	}
}

function submitMainForm() {
	var sub = new HiddenSubmit('bless.biz.bizBL_BLESSVoteQuery');
		
	$("InfoLayer").className="infoLayerShow";
	$("imageInfo").src="/internet/bless_img/loading.gif";
	$("imageInfo").title="Loading...";
	$("spanInfo").innerHTML="正在查询祝福,请稍候....";
	
	if (sub.submitForm(document.queryMainForm)) {	
		var ret = sub.getValue("root/data/messageinfo");	
		var result = sub.getValue("root/data/resultinfo");			
		if(result==1)
		{	
			$("InfoLayer").className="infoLayerShow";
			$("imageInfo").src="/internet/bless_img/success.gif";
			$("imageInfo").title="查询祝福成功!";		
			$("spanInfo").innerHTML=ret;	
						
			//分页对象
			sub.setObjectValue($("PageCond/count"), "PageCond/count");	
			sub.setObjectValue($("PageCond/length"), "PageCond/length");		
			sub.setObjectValue($("PageCond/begin"), "PageCond/begin");	
			
			//alert($("PageCond/count").value);  
			        				
			var BL_ID=sub.getValues('root/data/list[@type="QueryBL_BLESSVote"]/QueryBL_BLESSVote/ID');
			var BL_SORT_ID=sub.getValues('root/data/list[@type="QueryBL_BLESSVote"]/QueryBL_BLESSVote/SORT_ID');
			var BL_USER_NAME=sub.getValues('root/data/list[@type="QueryBL_BLESSVote"]/QueryBL_BLESSVote/USER_NAME');
			var BL_TITLE_=sub.getValues('root/data/list[@type="QueryBL_BLESSVote"]/QueryBL_BLESSVote/TITLE_');
			var BL_ICON_=sub.getValues('root/data/list[@type="QueryBL_BLESSVote"]/QueryBL_BLESSVote/ICON_');
			var BL_BG_COLOR=sub.getValues('root/data/list[@type="QueryBL_BLESSVote"]/QueryBL_BLESSVote/BG_COLOR');
			var BL_CREATE_DATE=sub.getValues('root/data/list[@type="QueryBL_BLESSVote"]/QueryBL_BLESSVote/CREATE_DATE');
			var BL_CONTENT_=sub.getValues('root/data/list[@type="QueryBL_BLESSVote"]/QueryBL_BLESSVote/CONTENT_');
			var BL_USER_IP=sub.getValues('root/data/list[@type="QueryBL_BLESSVote"]/QueryBL_BLESSVote/USER_IP');
			
			
			var _MainClipShow=$("MainClipShow");
			//删除已有nodes
			var _MainClipShow_Spans=$Tag(_MainClipShow,"a");
			var bl_tip_id="";
			for(var i=0;i<_MainClipShow_Spans.length;i++)
			{				
				bl_tip_id="BL_M_TIP_"+_MainClipShow_Spans[i].id;										
				document.body.removeChild($(bl_tip_id));
			}
			_MainClipShow.innerHTML="";			
			
				
			var div_title;	
			var div_titleText="";			
			for (var i=0; i<BL_ID.length; i++) {			
				
				if(i%3==0)//换行div
	   			{	
	   				div_titleText="";
	   				div_title = document.createElement("div");
	   			}	   	  		
	   	  		if(BL_ICON_[i]=="")
	   	  			BL_ICON_[i]="icon4.png";
				div_titleText +="<img src=/internet/bless_img/face/"+BL_ICON_[i]+" vspace=4  border=0 /><a id="+BL_ID[i]+" href='javascript:;'>"+BL_TITLE_[i]+"</a>";
				
				if(i%3==2 || i==BL_ID.length-1)//插入div	
				{	
					div_title.innerHTML=div_titleText;
					_MainClipShow.appendChild(div_title);	
				}
			
				var div_bless_content = document.createElement("div");
				div_bless_content.id="BL_M_TIP_"+BL_ID[i];
				div_bless_content.className="tipLayer";
				div_bless_content.onmouseout=function(){hiddenTip(this);};	
				var div_bless_html=tipCreate(BL_ID[i],BL_CONTENT_[i],BL_BG_COLOR[i],BL_USER_NAME[i],BL_SORT_ID[i],BL_CREATE_DATE[i],"BL_M_TIP_"+BL_ID[i]);
				div_bless_content.innerHTML +=div_bless_html.join("");
				
				document.body.appendChild(div_bless_content);	
			}
			initMainClip();
		}else 
		{		
		$("InfoLayer").className="infoLayerShow";
		$("imageInfo").src="/internet/bless_img/fail.gif";
		$("imageInfo").title="查询祝福失败";		
		$("spanInfo").innerHTML=ret;
		}
	}	
	setTimeout("ColseInfoLayer()",1000);  
}
//查询祝福
function submitSearchForm() {
	var content=$("keywords").value;
	if(trim(content)==""){
		$("keywords").focus();
		$("InfoLayer").className="infoLayerShow";
		$("imageInfo").src="/internet/bless_img/fail.gif";
		$("imageInfo").title="查询关键字不能为空!...";
		$("spanInfo").innerHTML="查询关键字不能为空!";
		$("keywords").style.background="#FF0000";   
		setTimeout("ColseInfoLayer()",5000);  
		return false;
	}
	
	var sub = new HiddenSubmit('bless.biz.bizBL_BLESSSearch');
		
	$("InfoLayer").className="infoLayerShow";
	$("imageInfo").src="/internet/bless_img/loading.gif";
	$("imageInfo").title="Loading...";
	$("spanInfo").innerHTML="正在查询祝福,请稍候....";
	
	var _MainClipShow=$("MainClipShow");
			//删除已有nodes
			var _MainClipShow_Spans=$Tag(_MainClipShow,"a");
			var bl_tip_id="";
			for(var i=0;i<_MainClipShow_Spans.length;i++)
			{				
				bl_tip_id="BL_M_TIP_"+_MainClipShow_Spans[i].id;										
				document.body.removeChild($(bl_tip_id));
			}
			_MainClipShow.innerHTML="";			
	
	if (sub.submitForm(document.searchForm)) {	
		var ret = sub.getValue("root/data/messageinfo");	
		var result = sub.getValue("root/data/resultinfo");			
		if(result==1)
		{	
			$("InfoLayer").className="infoLayerShow";
			$("imageInfo").src="/internet/bless_img/success.gif";
			$("imageInfo").title="查询祝福成功!";		
			$("spanInfo").innerHTML=ret;	
												        				
			var BL_ID=sub.getValues('root/data/list[@type="QueryBL_BLESSVote"]/QueryBL_BLESSVote/ID');
			var BL_SORT_ID=sub.getValues('root/data/list[@type="QueryBL_BLESSVote"]/QueryBL_BLESSVote/SORT_ID');
			var BL_USER_NAME=sub.getValues('root/data/list[@type="QueryBL_BLESSVote"]/QueryBL_BLESSVote/USER_NAME');
			var BL_TITLE_=sub.getValues('root/data/list[@type="QueryBL_BLESSVote"]/QueryBL_BLESSVote/TITLE_');
			var BL_ICON_=sub.getValues('root/data/list[@type="QueryBL_BLESSVote"]/QueryBL_BLESSVote/ICON_');
			var BL_BG_COLOR=sub.getValues('root/data/list[@type="QueryBL_BLESSVote"]/QueryBL_BLESSVote/BG_COLOR');
			var BL_CREATE_DATE=sub.getValues('root/data/list[@type="QueryBL_BLESSVote"]/QueryBL_BLESSVote/CREATE_DATE');
			var BL_CONTENT_=sub.getValues('root/data/list[@type="QueryBL_BLESSVote"]/QueryBL_BLESSVote/CONTENT_');
			var BL_USER_IP=sub.getValues('root/data/list[@type="QueryBL_BLESSVote"]/QueryBL_BLESSVote/USER_IP');
							
			var div_title;	
			var div_titleText="";			
			for (var i=0; i<BL_ID.length; i++) {			
				
				if(i>60) break;//大于60条时候退出
				
				if(i%3==0)//换行div
	   			{	
	   				div_titleText="";
	   				div_title = document.createElement("div");
	   			}	   	  		
	   	  		if(BL_ICON_[i]=="")
	   	  			BL_ICON_[i]="5.png";
				div_titleText +="<img src=/internet/bless_img/face/"+BL_ICON_[i]+" vspace=4  border=0 /><a id="+BL_ID[i]+" href='javascript:;'>"+BL_TITLE_[i]+"</a>";
				
				if(i%3==2 || i==BL_ID.length-1)//插入div	
				{	
					div_title.innerHTML=div_titleText;
					_MainClipShow.appendChild(div_title);	
				}
			
				var div_bless_content = document.createElement("div");
				div_bless_content.id="BL_M_TIP_"+BL_ID[i];
				div_bless_content.className="tipLayer";
				div_bless_content.onmouseout=function(){hiddenTip(this);};	
				var div_bless_html=tipCreate(BL_ID[i],BL_CONTENT_[i],BL_BG_COLOR[i],BL_USER_NAME[i],BL_SORT_ID[i],BL_CREATE_DATE[i],"BL_M_TIP_"+BL_ID[i]);
				div_bless_content.innerHTML +=div_bless_html.join("");
				
				document.body.appendChild(div_bless_content);	
			}
			initMainClip();
		}else 
		{		
		$("InfoLayer").className="infoLayerShow";
		$("imageInfo").src="/internet/bless_img/fail.gif";
		$("imageInfo").title="查询祝福失败";		
		$("spanInfo").innerHTML=ret;
		}
	}	
	setTimeout("ColseInfoLayer()",1000);  
}

function closetip(id){
	if(id==null)return;
	id.style.display="none";
	id.className="PostLayerClose";
}

////////祝福预览////////////////
function tipyulan(content_,bgcolor_,username_,createdate_){
	var bufferHtml= new Array();
	var bufferCount=0;	
	bufferHtml[bufferCount++]='<table width="141" border="0" cellpadding="0" cellspacing="0">';
	bufferHtml[bufferCount++]='<tr><td style="text-indent:127px;background-image:url(/internet/bless_img/tip_03.png);" width="141" height="23"><img alt="关闭" class="HandCursor" src="/internet/bless_img/tip_close.png"/></td></tr>';
	bufferHtml[bufferCount++]='<tr><td background="/internet/bless_img/tip_06.png" class="tipContent">';
	bufferHtml[bufferCount++]='<div class="tip"><p style="background-color:';
	bufferHtml[bufferCount++]=bgcolor_;
	bufferHtml[bufferCount++]='">';
	bufferHtml[bufferCount++]=content_;
	bufferHtml[bufferCount++]='</div></td></tr>';
	bufferHtml[bufferCount++]='<tr><td align="center"  style="background-image:url(/internet/bless_img/tip_06.png);background-repeat:repeat-y; background-position:center;">';
	bufferHtml[bufferCount++]='<div><img src="/internet/bless_img/tip_09.png" width="126" height="5" /></div>';
	bufferHtml[bufferCount++]='<div class="tipSupport">';
	bufferHtml[bufferCount++]='</div><div class="tipAuthor">';
	bufferHtml[bufferCount++]=username_;
	bufferHtml[bufferCount++]='</div><div class="tipDate">';
	bufferHtml[bufferCount++]=createdate_;
	bufferHtml[bufferCount++]='</div><div class="tipClick">人气:';
	bufferHtml[bufferCount++]=0;
	bufferHtml[bufferCount++]='</div></td></tr><tr><td class="tipBG" valign="top"></td></tr></table>';
	return bufferHtml;
}
function yulan(){
	
	//清除"BL_TIP_YULAN" div
	if(document.getElementById("BL_TIP_YULAN")!=null)
		document.body.removeChild($("BL_TIP_YULAN"));
	
	var div_bless_content = document.createElement("div");
	div_bless_content.id="BL_TIP_YULAN";	
	div_bless_content.className="tipLayeryulan";	
	//div_bless_content.onClick=function(){hiddenYuLandiv();};	
	//div_bless_content.onmouseout=function(){hiddenTip(this);};
	var BL_CONTENT = $("BL_BLESS/CONTENT_").value;
	var BL_BG_COLOR = $("BL_BLESS/BG_COLOR").value;
	var BL_USER_NAME = $("BL_BLESS/USER_NAME").value;
	
	var div_bless_html=tipyulan(BL_CONTENT,BL_BG_COLOR,BL_USER_NAME,_getToday());
	div_bless_content.innerHTML +=div_bless_html.join("");	
	div_bless_html=null;
	document.body.appendChild(div_bless_content);		
	$("BL_TIP_YULAN").attachEvent('onclick', hiddenYuLandiv);//添加事件
}
////////////////////////
//获取当前的系统时间
function _getToday()
{	
	var now = new Date();	
	var yy = now.getFullYear(); //截取年 	
 	var mm = (now.getMonth()+1<10)?("0"+(now.getMonth()+1)):(now.getMonth()+1); //截取月
 	var dd = (now.getDate()<10)?("0"+now.getDate()):(now.getDate()); //截取日
  	var _today=yy+"-"+mm+"-"+dd;
 	return _today;
} 
//创建Bless Tip
function tipCreate(id,content_,bgcolor_,username_,sortid_,createdate_,tipid){
	var bufferHtml= new Array();
	var bufferCount=0;
	bufferHtml[bufferCount++]='<table width="141" border="0" cellpadding="0" cellspacing="0">';
	bufferHtml[bufferCount++]='<tr><td style="text-indent:127px;background-image:url(/internet/bless_img/tip_03.png);" width="141" height="23"><img alt="关闭" class="HandCursor" onClick="closetip('+tipid+');" src="/internet/bless_img/tip_close.png"/></td></tr>';
	bufferHtml[bufferCount++]='<tr><td background="/internet/bless_img/tip_06.png" class="tipContent">';	
	bufferHtml[bufferCount++]='<div class="tip"><p style="background-color:';
	bufferHtml[bufferCount++]=bgcolor_;
	bufferHtml[bufferCount++]='">';
	bufferHtml[bufferCount++]=content_;
	bufferHtml[bufferCount++]='</div></td></tr>';
	bufferHtml[bufferCount++]='<tr><td align="center"  style="background-image:url(/internet/bless_img/tip_06.png);background-repeat:repeat-y; background-position:center;">';
	bufferHtml[bufferCount++]='<div><img src="/internet/bless_img/tip_09.png" width="126" height="5" /></div>';
	bufferHtml[bufferCount++]='<div id=voteNum'+id+' class="tipSupport">';
	bufferHtml[bufferCount++]='<a class="tipSupport" href="javascript:blessvote('+id+');">';
	bufferHtml[bufferCount++]='【支持本贴】';
	bufferHtml[bufferCount++]='</a>';
	bufferHtml[bufferCount++]='</div><div class="tipAuthor">';
	bufferHtml[bufferCount++]=username_;
	bufferHtml[bufferCount++]='</div><div class="tipDate">';
	bufferHtml[bufferCount++]=createdate_;
	bufferHtml[bufferCount++]='</div><div class="tipClick">人气:';
	bufferHtml[bufferCount++]=sortid_;
	bufferHtml[bufferCount++]='</div></td></tr><tr><td class="tipBG" valign="top"></td></tr></table>';
	return bufferHtml;
}
//显示选择图标
function changeIcon()
{
	$("IconLayer").style.display='block';	
	$("IconLayer").className="iconLayerShow";	
}
function selectIconFile(iconName)
{
	$("IconLayer").style.display='none';	
	$("IconLayer").className="iconLayer";
	if(iconName!=null && iconName!="")
	{
		$("BL_BLESS/ICON_").value=iconName;
		$("selectIcon").src="/internet/bless_img/face/"+iconName;
	}
	else
	{	
		$("BL_BLESS/ICON_").value="4.png";
		$("selectIcon").src="/internet/bless_img/face/4.png";
	}	
}
function ColseIconLayer(){
	$("IconLayer").style.display='none';	
}

//显示选择颜色
function selectColor()
{
	$("ColorLayer").style.display='block';	
	$("ColorLayer").className="colorLayerShow";	
}
function returnColor(color)
{
	$("ColorLayer").style.display='none';	
	$("ColorLayer").className="colorLayer";
	if(color!=null && color!="")
	{
		$("BL_BLESS/BG_COLOR").value=color;
		$("BL_BLESS/CONTENT_").style.background=color; 
	}
	else
	{	
		$("BL_BLESS/BG_COLOR").value="transparent";
		$("BL_BLESS/CONTENT_").style.background=""; 
	}	
}
function ColseColorLayer(){
	$("ColorLayer").style.display='none';	
}
/*****以下代码为限制TextArea的长度限制，包括中文字符***********************/
/*obj为textarea，objlen为长度span,可以为空。<span id="tno"></span>调用方法为onpropertychange="checklen(this,tno)"*/
function checklen(objstr,objlen){
var obj = $(objstr);
var lenMax = obj.getAttribute? parseInt(obj.getAttribute("maxlength")):"";  
var lenE = obj.value.length;
var lenC = 0;
var CJK = obj.value.match(/[\u4E00-\u9FA5\uF900-\uFA2D]/g);
if (CJK != null) lenC += CJK.length;

if(objlen!=null)
$(objlen).innerHTML = lenMax - lenC - lenE ;
if ($(objlen)!=null && $(objlen).innerHTML < 0) {
var tmp = 0
var cut = obj.value.substring(0, lenMax);
for (var i=0; i<cut.length; i++){
tmp += /[\u4E00-\u9FA5\uF900-\uFA2D]/.test(cut.charAt(i)) ? 2 : 1;
if (tmp > lenMax) break;
}
obj.value = cut.substring(0, i);
}
}	