function SearchOnfocu(id){
  var text = document.getElementById(id).value ;
  if(text=='search' || text=='在此输入关键词进行搜索'){
    document.getElementById(id).value='';
  }
}


function _onclick(){
  	  document.getElementById("div_bgDiv").innerHTML="";
	  document.getElementById("div_msgDiv").innerHTML="";
	  document.getElementById("div_msgDiv").style.zIndex="-1";
	  document.getElementById("div_bgDiv").style.zIndex="-1";
}

function ssAlert()
{

var msgw,msgh,bordercolor,titlecolor,lefttitle; 
msgw=268;//提示窗口的宽度 
msgh=276;//提示窗口的高度 
titleheight=32 //提示窗口标题高度 
bordercolor="#4573BA";//提示窗口的边框颜色 
titlecolor="#626365";//提示窗口的标题颜色 
titlecolor_top="#626365";//提示窗口的标题颜色 
lefttitle=" 登录" 
var sWidth,sHeight; 
sWidth=document.body.clientWidth; 
sHeight=document.body.clientHeight; 
//progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75);
var bgDiv ="<div id='bgDiv' style='position:absolute;top:0; background:#A8D3E0;  filter: Alpha(opacity=60); -moz-opacity:.6;  opacity:0.6;z-index:10000;width:"+sWidth + "px;height:"+sHeight + "px;"+"'></div>";

var msgDiv ="<div id='msgDiv'>";

//msgDiv+="<h4 id='msgTitle' onClick='_onclick()'>&nbsp;  </h4>";

var stri="<p style='margin:1em 0;' id='msgTxt' >";
//stri+="<div class='mainContent' style='position:absolute;z-index:10012;width:100px;height:100px;border:5px solid red;'>";
stri+=" <div class='jb1' style='background:none #FFF;position:absolute;z-index:10013;left:30%;width:410px;border: 1px solid #A9CDEF; top:200px;height:auto;overflow:hidden'>";
stri+="    <div class='title'  onClick='_onclick()' style='text-align:left;cursor:pointer;width:400px;line-height:25px;border:1px solid #FFF;'><span style='background:#e8795f;color=#fff;font:bold 12px/15px Arial; float:right;width:15px;text-align:center;margin:4px;border:1px solid #FFF;' title='取消'><b>×</b></span>登录</div>";
stri+="    <div style='padding:15px  0 15px  100px;'>";
stri+="      <iframe frameborder='0' scrolling='no' src='/index/login.jsp' width='100%' height='160' marginwidth='0' marginheight='0' allowtransparency='true'></iframe>";
stri+="   </div>";
stri+="</div>";
//stri+="</div>";
stri+="</p>";

//stri="<iframe frameborder='0' scrolling='no' src='login.jsp' width='100%' height='160' marginwidth='0' marginheight='0' allowtransparency='true'></iframe>";

msgDiv+=stri;
msgDiv+="</div>";

//alert(bgDiv);
//alert(msgDiv);
try{
//alert(1);

document.getElementById("div_bgDiv").innerHTML=bgDiv;
document.getElementById("div_bgDiv").style.zIndex="10000";
//alert(2);
document.getElementById("div_msgDiv").innerHTML=msgDiv;
document.getElementById("div_msgDiv").style.zIndex="10001";


//alert(3);
//alert(100);
}catch(e) { alert(e) ; }

}

function sAlert(str){ 
var msgw,msgh,bordercolor,titlecolor,lefttitle; 
msgw=268;//提示窗口的宽度 
msgh=276;//提示窗口的高度 
titleheight=32 //提示窗口标题高度 
bordercolor="#4573BA";//提示窗口的边框颜色 
titlecolor="#626365";//提示窗口的标题颜色 
titlecolor_top="#626365";//提示窗口的标题颜色 
lefttitle=" 登录" 
var sWidth,sHeight; 
sWidth=document.body.clientWidth; 
sHeight=document.body.clientHeight; 

var bgObj=document.createElement("div"); 
bgObj.setAttribute('id','bgDiv'); 
bgObj.style.position="absolute"; 
bgObj.style.top="0"; 
bgObj.style.background="#A8D3E0 "; 
bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75"; 
bgObj.style.opacity="0.6"; 
bgObj.style.left="0"; 
bgObj.style.width=sWidth + "px"; 
bgObj.style.height=sHeight + "px"; 
bgObj.style.zIndex = "10000"; 
document.body.appendChild(bgObj); 

var msgObj=document.createElement("div") 
msgObj.setAttribute("id","msgDiv"); 
msgObj.setAttribute("align","center"); 
msgObj.style.background="#FFFFFF"; 
msgObj.style.border="3px solid " + bordercolor; 
msgObj.style.position = "absolute"; 
msgObj.style.left = "50%"; 
msgObj.style.top = "100px"; 
msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif"; 
msgObj.style.marginLeft = "-130px" ; 
msgObj.style.marginTop = -60+document.documentElement.scrollTop+"px"; 
msgObj.style.width = msgw + "px"; 
msgObj.style.height =msgh + "px"; 
msgObj.style.textAlign = "center"; 
msgObj.style.lineHeight ="25px"; 
msgObj.style.zIndex = "10001"; 

var title=document.createElement("h4"); 
title.setAttribute("id","msgTitle"); 
title.setAttribute("align","right"); 
title.style.margin="0"; 
title.style.padding="3px"; 
title.style.background=bordercolor; 
//title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);"; 
title.style.opacity="0.75"; 
title.style.border="1px solid " + bordercolor; 
title.style.height="18px"; 
title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif"; 
title.style.color="white"; 
title.style.cursor="pointer"; 
title.innerHTML="<b>"+lefttitle+"</b>"+"&nbsp;&nbsp;&nbsp;&nbsp;<span style='background:#e8795f;color=#fff; border:#fff solid 1px;margin 2px 2px' title='取消'><b>×</b></span>"; 
title.onclick=function()
	{ 
	  document.body.removeChild(bgObj); 
	  document.getElementById("msgDiv").removeChild(title); 
	  document.body.removeChild(msgObj); 
	} 
document.body.appendChild(msgObj); 
document.getElementById("msgDiv").appendChild(title); 
var txt=document.createElement("p"); 
txt.style.margin="1em 0" 
txt.setAttribute("id","msgTxt"); 
txt.innerHTML=str; 
document.getElementById("msgDiv").appendChild(txt); 
} 




if (typeof Question == "undefined") {
	var Question ={};
}

//分类问题
Question.IndexCategoryQuestion = function(div,style,jsMethod,pageSize,cid){
   var callback = {
    	success:function(o){ document.getElementById(div).innerHTML = o.responseText;   },
  		failure:function(){}
  };
  Question.IndexCategoryQuestion.superclass.constructor.call(this, "/IndexlistCategoryQuestion.action", div, callback); 
  this.setParam("jsMethod",jsMethod);
  this.setParam("style",style);
  this.setParam("cid",cid);
  this.setParam("pageSize",pageSize);
  
  
};
Globals.extend(Question.IndexCategoryQuestion,Globals.Pager);


/** 最新回复问题**/
Question.IndexlistNewRemarkQuestion = function(div,style,jsMethod,pageSize,cid){
   var callback = {
    	success:function(o){ document.getElementById(div).innerHTML = o.responseText;   },
  		failure:function(){}
  };
  Question.IndexlistNewRemarkQuestion.superclass.constructor.call(this, "/IndexlistNewRemarkQuestion.action", div, callback); 
  this.setParam("jsMethod",jsMethod);
  this.setParam("style",style);
  this.setParam("cid",cid);
  this.setParam("pageSize",pageSize);
  
  
};
Globals.extend(Question.IndexlistNewRemarkQuestion,Globals.Pager);

/** 投票中问题**/
Question.IndexlistVoteQuestion = function(div,style,jsMethod,pageSize,cid){
   var callback = {
    	success:function(o){ document.getElementById(div).innerHTML = o.responseText;   },
  		failure:function(){}
  };
  Question.IndexlistVoteQuestion.superclass.constructor.call(this, "/IndexlistVoteQuestion.action", div, callback); 
  this.setParam("jsMethod",jsMethod);
  this.setParam("style",style);
  this.setParam("cid",cid);
  this.setParam("pageSize",pageSize);
  
  
};
Globals.extend(Question.IndexlistVoteQuestion,Globals.Pager);




/** 回答提交 div=post_answer_content_rs_div **/
Question.answerOperate = function(qid,content,reference,div){
  var callback = {
    	success:function(o){ 
    	    var action= YAHOO.lang.JSON.parse(o.responseText);
    		if(action.message=='noLogin'){
    		    $(div).innerHTML="<div style='text-align:center;padding:0 50px 0 0;color:#ff0000'>您还没有登录，请<a href='/user/'>登录</a></div>";
 				return ;
    		}
    		
    	   if(action.message=='userNoCheck'){
    			$(div).innerHTML="<div style='text-align:center;padding:0 50px 0 0;color:#ff0000'>您的帐户还没有激活，请激活!</div>";
    			return ;
    		}
    		
    		if(action.message=='userIsBlock'){
    			$(div).innerHTML="<div style='text-align:center;padding:0 50px 0 0;color:#ff0000'>对不起，你的帐户被锁定，请与管理员联系！</div>";
    			return ;
    		}
    		
    		if(action.message=='userIsRegistererIp'){
    			$(div).innerHTML="<div style='text-align:center;padding:0 50px 0 0;color:#ff0000'>您的IP被锁定，请与管理员联系！</div>";
    			return ;
    		}
    		
    	   if(action.message=='notNull'){
    			$(div).innerHTML="<div style='text-align:center;padding:0 50px 0 0;color:#ff0000'>内容不能为空</div>";
    			return ;
    		}
    		
    		if(action.message=='haveLimitWord'){
    			$(div).innerHTML="<div style='text-align:center;padding:0 50px 0 0;color:#ff0000'>包含限制词</div>";
    			return ;
    		}
    		
    		
    		if(action.message=='succeed'){
    		     $(div).innerHTML="<div style='text-align:center;padding:0 50px 0 0;color:#ff0000'>回答提交成功!</div>";
    			return ;
    		}
    		if(action.message=='NotAnswerOwnQuestion'){
    			$(div).innerHTML="<div style='text-align:center;padding:0 50px 0 0;color:#ff0000'>自己不能回答自己的问题</div>";
    			return ;
    		}
    	},
  		failure:function(){}
  };
  if(content==''){
    alert("请输入回答内容,内容不能为空!");
    return ;
  }
  YAHOO.util.Connect.asyncRequest('post', "/answerOperate.action",callback,"qid="+qid+"&reference="+reference+"&content="+content);
};


