function loginPrompt(promptWords){
   //alert('wUrl:'+wUrl);
   var pWords = "在这操作前您需要先登录!";
   if(typeof(wUrl)   ==   "undefined")
      alert("you must define variable wUrl in somwhere like user/consult_template.jspf");
   //wUrl = 'just/user/ajaxLogin.jsp?width=280&height=130';
   if(promptWords)
    pWords = promptWords;
   //if(windowUrl)
  // wUrl = windowUrl;
   TB_show(pWords, wUrl, false);
}

function login(loginCallBack) {
  if(document.getElementById('loginStatus'))//only for prompt  window
		   document.getElementById('loginStatus').style.display = '';
   var username = document.getElementById('username').value;
   var password = document.getElementById('password').value;   
   var remberMeInCookie = document.getElementById('remberMeInCookie').checked;   
   var refreshDiv = 'topLogin';
   doLogin(username, password, remberMeInCookie, refreshDiv, loginCallBack); 
 }

 function doLogin(username, password, remberMeInCookie, refreshDiv, callBack) { 
    var ajaxReqObj = {templateDom: 'controlPanel_jst',
                 refreshDom: refreshDiv,
                 dwrClass: 'userAccessBean',
                 dwrFuntion: 'login',
                 params: [username, password, remberMeInCookie],
                 callback: callBack};
  TrimPath.callAjax(ajaxReqObj);
  }
  
  
 function sessionExam(callBack) {
 	var  callbackFuncition = callBack?callBack:null;
    var ajaxReqObj = {templateDom: 'controlPanel_jst',
                 refreshDom: 'topLogin',
                 dwrClass: 'userAccessBean',
                 dwrFuntion: 'sessionExam',
                 params: [],
                 callback:callbackFuncition};
  TrimPath.callAjax(ajaxReqObj);
  }
  
  function searchPrompt(searchText, host, contextPath){
   //alert('dddddd');
   var pWords = "搜索结果!";
   if(searchText==null||searchText.length==0){
   	 alert("请输入要搜索的内容!");
   	 return;
   }
   //var wUrl = 'http://www.baidu.com/s?ie=gb2312&bs=%C9%AD%C2%ED+site%3A'+host+'&sr=&z=&cl=3&f=8&tn=baidu&wd='+searchText+'+site%3A'+host+'&ct=0?TB_iframe=true&width=280&height=130';
   //var wUrl = 'http://www.baidu.com/s?tn=baiduadv&bs=%D7%F7%C6%B7+site%3A'+host+'&ie=gb2312&sr=&z=&cl=3&f=8&wd='+searchText+'site%3A'+host+'&width=280&height=130';
   //var wUrl = 'http://'+host+contextPath+'search/list/'+searchText+'.html?width=480&height=330';
   // var wUrl = 'http://www.youdao.com/search?lq=site%3A'+host+'&ue=utf8&keyfrom=web.top&q='+searchText+'+site%3A'+host+'&btnSearchTop=%E6%90%9C+%E7%B4%A2?TB_iframe=true&width=280&height=130';
  var wUrl = contextPath+'search/list/'+searchText+'.html?TB_iframe=true&width=530&height=430';
   //alert(wUrl);
   TB_show(pWords, wUrl, false);
}

function sendInviteMail(receipterName, receipterAdress, senderName, content) {
  var ajaxReqObj = {templateDom: 'msg_content',
                 refreshDom: 'mailSendSpan',
                 dwrClass: 'msgAccessBean',
                 dwrFuntion: 'sendInviteMail',
                 params: [receipterName, receipterAdress, senderName, content]};
  TrimPath.callAjax(ajaxReqObj);
}


function sendSimpleMail(receipterAdress, title, content) {
  var ajaxReqObj = {templateDom: 'msg_content',
                 refreshDom: 'mailSendSpan',
                 dwrClass: 'msgAccessBean',
                 dwrFuntion: 'sendSimpleMail',
                 params: [receipterAdress, title, content]};
  TrimPath.callAjax(ajaxReqObj);
}

function sendSiteMessageByMail(receipterAdress, titleName, contentName) {
  var ajaxReqObj = {templateDom: 'msg_content',
                 refreshDom: 'mailSendSpan',
                 dwrClass: 'msgAccessBean',
                 dwrFuntion: 'sendSiteMessageByMail',
                 params: [receipterAdress, titleName, contentName]};
  TrimPath.callAjax(ajaxReqObj);
}

function toEditText(msg){
//	        $('#'+msg+'_TextDisplay').hide();
//	        $("#"+msg+"_Edit").show();
//	        $("#"+msg+"_Display").hide();
//	        $("#"+msg+"_animation").html('');
	       // $("#"+msg+"_Text").val($("#"+msg+"_TextData").val());
	        
	        
            document.getElementById(msg+"_TextDisplay").style.display = "none";
            document.getElementById(msg+"_Edit").style.display = "";
              document.getElementById(msg+"_Display").style.display = "none";
              document.getElementById(msg+"_animation").innerHTML = "";
              return false;
}           


var dropEdit = function(msg){
	
//	        $("#"+msg+"_TextDisplay").show();
//	        $("#"+msg+"_Edit").hide();
//	        $("#"+msg+"_Display").show();
	        
//             document.getElementById(msg+"_Text").value = document.getElementById(msg+"_TextDisplay").innerHTML;
             document.getElementById(msg+"_Edit").style.display = "none";
             document.getElementById(msg+"_Display").style.display = "";
             document.getElementById(msg+"_TextDisplay").style.display = "";
}

function saveEditText(msg) {
             var content = document.getElementById(msg+"_Text").value;
             //alert(content);
             var callback = function(){
             	//alert(content);
                document.getElementById(msg+"_TextDisplay").innerHTML = content;
                document.getElementById(msg+"_Text").value = content;
                //document.getElementById(msg+"_animation").innerHTML = "";
                document.getElementById(msg+"_Edit").style.display = "none";
             //alert(content);
                document.getElementById(msg+"_Display").style.display = "";
              }
              var ajaxReqObj = {templateDom: 'msg_content',
                 refreshDom: msg+"_animation",
                 dwrClass: 'msgAccessBean',
                 dwrFuntion: 'saveEditText',
                 params: [msg, content],
                 callback: callback};
               TrimPath.callAjax(ajaxReqObj);
}


function saveEditField(msg, recordId,  dwrClass, dwrFuntion) {
             var content = document.getElementById(msg+"_Text").value;
             //alert(content);
             var callback = function(){
             	//alert(content);
                document.getElementById(msg+"_TextDisplay").style.display = "";
                document.getElementById(msg+"_TextDisplay").innerHTML = this.affectedObject;
                document.getElementById(msg+"_Text").value = content;
                //document.getElementById(msg+"_animation").innerHTML = "";
                document.getElementById(msg+"_Edit").style.display = "none";
             //alert(content);
                document.getElementById(msg+"_Display").style.display = "";
              }
              var ajaxReqObj = {templateDom: 'msg_content',
                 refreshDom: msg+"_animation",
                 dwrClass: dwrClass,
                 dwrFuntion: dwrFuntion,
                 params: [recordId, content],
                 callback: callback};
               TrimPath.callAjax(ajaxReqObj);
}


function deleteItem(itemId, refreshDomPrefix, confirmWords) {
  if(!confirm(confirmWords))
    return;
  var ajaxReqObj = {templateDom: 'msg_content',
                 refreshDom: refreshDomPrefix+itemId,
                 dwrClass: 'itemAccesssBean',
                 dwrFuntion: 'deleteItem',
                 params: [itemId]};
  TrimPath.callAjax(ajaxReqObj);
}


function deletePost(postId, refreshDomPrefix, confirmWords,  dwrClass, dwrFuntion) {
  if(!confirm(confirmWords))
    return;
  var ajaxReqObj = {templateDom: 'msg_content',
                 refreshDom: refreshDomPrefix+postId,
                 dwrClass: dwrClass,
                 dwrFuntion: dwrFuntion,
                 params: [postId]};
  TrimPath.callAjax(ajaxReqObj);
}
