var g_Type="0";
var g_Top="30";
var g_MemId="";
var g_Id="";


function GetParam(){
 var pos=0;
 var str="";
 str = window.location.href;
 pos = str.indexOf("=");
 if (pos>0) {
   var tmpId=str.substring(pos+1,str.length);
   if (tmpId.indexOf("#"))    {
     var tmpArray=tmpId.split("#");
     g_Id=tmpArray[0];
    }
   else g_Id=tmpId;
  } 
}

function GetAllData(){
  GetArticleList("10","0");
  GetMaginzeList("4");
  GetSubDescList("10");
  GetGuestOrchidList('12','6','V','VipOList');
  GetParam();
  GetQandAList(g_Top,1,'1',0);
  ShowLayer(0);
}

function GetGuestOrchidList(pNtop,pVtop,pType,pTag){
 var Res=neworchid.AjaxHomeLib.GetServerGuestXml(pNtop,pVtop,pType);
 g_xmDoc.loadXML(Res.value);
 ShowGuestOrchidList(pTag);
}

function ShowGuestOrchidList(pTag){
 Strhtm="";
 NodeList= g_xmDoc.getElementsByTagName(pTag);
 var CurrList=NodeList.item(0).childNodes;
 if(CurrList.length>0){ 
  for (var i=0; i<CurrList.length; i++) {
   var _Did   =CurrList.item(i).getAttribute("Did");
   var _CName =CurrList.item(i).getAttribute("OName");
   var _Image =CurrList.item(i).getAttribute("LImg");
   var _MId =CurrList.item(i).getAttribute("CNo");
   var _WebUrl="ShowNewOrchid.aspx?Id="+_Did;
   Strhtm+="<div class='box_9_1'><a href=javascript:OpenGuestWin('"+_WebUrl+"');>";
   Strhtm+="<img src="+_Image+" width='80' height='78' border='0'></a>";
   Strhtm+="<br><a href=javascript:OpenGuestWin('"+_WebUrl+"');>"+_CName+"</a></div>";
  }
   document.getElementById("divNewOrchid").innerHTML=Strhtm; 
  }
}

function ShowLayer(pId){
if (pId==0){
      document.all.DivTopList.style.display="block";
      document.all.DivTopDetail.style.display="none";
      document.all.DivMemDetail.style.display="none";
      document.all.DivRequest.style.display="none";
         
 }
if (pId==1){
      document.all.DivTopList.style.display="none";
      document.all.DivTopDetail.style.display="block";
      document.all.DivMemDetail.style.display="none";
      document.all.DivRequest.style.display="none";
     

  }
if (pId==2){
      document.all.DivTopList.style.display="none";
      document.all.DivTopDetail.style.display="none";
      document.all.DivMemDetail.style.display="none";
      document.all.DivRequest.style.display="block";
  }
if (pId==3){
      document.all.DivTopList.style.display="none";
      document.all.DivTopDetail.style.display="none";
      document.all.DivMemDetail.style.display="block";
      document.all.DivRequest.style.display="none";
  }
}

function SetClassName_1(t,n){
for (var i=1;i<=n;i++){
  var obj=eval("V"+i);
   if (obj.id==t.id)
      obj.className="Active";
  else  obj.className="Active_no";
  }
}


function GetMemBaseInfo(pId){
 var ObjMemBase=null;
 var Res=neworchid.AjaxHomeLib.GetServerMemBaseInfo(pId);
 if ((!Res.error) && (Res.value!=null)){
    ObjMemBase=Res.value;
    ShowMemBase(ObjMemBase);
    ShowLayer(3);
   }
}

function ShowMemBase(Obj){
 Strhtm="<div style='width:487px; border:1px #cccccc solid'>";
 Strhtm+="<ul class=ul>";
 Strhtm+="<li>·兰友姓名:&nbsp;&nbsp;&nbsp;"+Obj.MemName+"</li>";
 Strhtm+="<li>·所在省份:&nbsp;&nbsp;&nbsp;"+Obj.Province+"</li>";
 Strhtm+="<li>·所在城市:&nbsp;&nbsp;&nbsp;"+Obj.Area+"</li>";
 Strhtm+="<li>·联系地址:&nbsp;&nbsp;&nbsp;"+Obj.Address+"</li>";
 Strhtm+="<li>·联系电话:&nbsp;&nbsp;&nbsp;"+Obj.MemTel+"</li>";
 Strhtm+="<li>·邮箱地址:&nbsp;&nbsp;&nbsp;"+Obj.MemEmail+"</li>";
 Strhtm+="<li>·兰友QQ&nbsp;:&nbsp;&nbsp;&nbsp;"+Obj.QQ+"</li>";
 Strhtm+="<li>·兰友msn&nbsp;:&nbsp;&nbsp;&nbsp;"+Obj.Msn+"</li>";
 Strhtm+="<li>·互宝通  :&nbsp;&nbsp;&nbsp;"+Obj.Gid+"</li>";
 Strhtm+="<li>·兰友星级:&nbsp;&nbsp;&nbsp;"+Obj.Star+"</li>";
 Strhtm+="<li>·自我介绍:</li>";
 Strhtm+="<li class=box_Text>"+Obj.OwnDesc+"</li>";
 Strhtm+="</ul></div>";
 document.getElementById("DivMemDetail").innerHTML=Strhtm;  
 SetClassName_1(V4,4);
 }

function GetQandAList(pTop,pNum,pType,pReDid){
  var Res=neworchid.AjaxHomeLib.GetQandAXmlPage(pTop,pNum,pType,pReDid);
  g_xmDoc.loadXML(Res.value);
  var NodeList= g_xmDoc.getElementsByTagName("li");
  var CurrList=NodeList.item(0).childNodes;
  if (CurrList.length>0){
   Strhtm="<ul class=ul>";
   for (var i=0; i<CurrList.length; i++) {
    var _Did       =CurrList.item(i).getAttribute("Did");
    var _Question  =CurrList.item(i).getAttribute("Question");
    var _MemId     =CurrList.item(i).getAttribute("MemId");
    var _CreateDate=CurrList.item(i).getAttribute("CreateDate");
    var _ViewNum   =CurrList.item(i).getAttribute("ViewNum");
    Strhtm+="<li>·<a href=javascript:GetQandADetail('"+_Did+"')>"+_Question+"</a>";
    Strhtm+="<span class='td'>("+_CreateDate+")--[浏览:"+_ViewNum+"]</span></li>"; 
   }
   Strhtm+="</ul>";
  document.getElementById("DivQnadAList").innerHTML=Strhtm; 
 }
}

function GetQandADetail(pId){
 var Obj=null;
 var Res=neworchid.AjaxHomeLib.GetQandA(pId);
 if ((!Res.error) && (Res.value!=null)){
    Obj=Res.value;
    ShowQandA(Obj);
    ShowLayer(1);
    SetClassName_1(V2,4);
    GetAnswerList(pId);
    g_Id=pId;
   }
}

function ShowQandA(pObj){
 Strhtm="<div style='font-size:12px;'>";
 Strhtm+="<ul class=ul>";
 Strhtm+="<li>·兰友:&nbsp;&nbsp;&nbsp;<a href=javascript:GetMemBaseInfo('"+pObj.MemId+"')>详细</a></li>";
 var d = new Date(pObj.CreateDate);
 Strhtm+="<li>·日期:&nbsp;&nbsp;&nbsp;"+d.format('yyyy年MM月dd日hh时mm分ss秒')+"</li>";
 Strhtm+="<li>·主题:&nbsp;&nbsp;&nbsp;"+pObj.Question+"(ViewNum:"+pObj.ViewNum+")</li>";
 document.all.rTitle.value="Re:"+pObj.Question;
 g_Type=pObj.QType;
 g_Id  =pObj.Did;
 Strhtm+="<li>·问题描述:</li>";
 if (pObj.ImageUrl!=""){
    var tmpimg=new Image();
    tmpimg.src=pObj.ImageUrl;
    if (tmpimg.width>550)
       tmpimg.style.width=550;
  Strhtm+="<li><a href="+tmpimg.src+" target='_blank'><img src="+tmpimg.src+" border=1 style=width:"+tmpimg.style.width+"></a></li>";
 }
 Strhtm+="<li class=box_Text>"+pObj.Answer+"</li>";
 Strhtm+="</ul></div>";
 document.getElementById("DivAnswerDetail").innerHTML=Strhtm;  
 g_MemId=pObj.MemId;
}

function GetAnswerList(pId){
  var ObjList=new Array();
  var Res=neworchid.AjaxHomeLib.GetQandAList(pId);
  if ((!Res.error) && (Res.value!=null)){
    ObjList=Res.value;
    Strhtm="<ul class=ul>";
    for (var i=0; i<ObjList.length; i++) {
    var _Did        =ObjList[i].Did;
    var _Notes      =ObjList[i].Answer;
    var _MemId      =ObjList[i].MemId;
    var _CreateDate=ObjList[i].CreateDate;
    var d = new Date(_CreateDate);
    Strhtm+="<li>··兰友:<a href=javascript:GetMemBaseInfo('"+_MemId+"');>···查看信息";
    Strhtm+="<img src='img/i_ico21_060708.gif' border=0></a>"+d.format('yyyy年MM月dd日hh时mm分ss秒')+"</li>"; 
    Strhtm+="<li class=Box_text>"+_Notes+"</li>";
   }
  Strhtm+="</ul>";
  document.getElementById("DivFeedList").innerHTML=Strhtm;  
  }  
}

function SaveAnswer(){
 var p=document.all.AnsType 
 var _Title=document.getElementById("pTitle").value;
  if ((_Title.length==0) || (_Title=="")){
    alert("标题不能为空！！！");return ;
  }
  if (p.selectedIndex==0){
    alert("请选择类型！！！");return ;
  }
 var _Content=document.getElementById("pNotes").value;
 var Obj=new Object();
   Obj.Question=_Title;
   Obj.Answer  =_Content;
   Obj.QType   =p.options[p.selectedIndex].value;
   Obj.ReDid   =0;
   Obj.ViewNum =0;
   Obj.Visibled='1';
   Obj.ImageUrl=document.getElementById("pImage").value
  var ObjList=new Array();
  var Res=neworchid.AjaxHomeLib.GetAuthInfo();
     ObjList=Res.value;
   if (ObjList[0]!=""){
      Obj.MemId=ObjList[0];
      Res=neworchid.AjaxHomeLib.SaveQandA(Obj,'ADD');
      if (!Res.error) {
       alert("恭喜您提交问题成功!!!");
       ShowLayer(0);
       SetClassName_1(V1,4);
       GetQandAList(g_Top,1,Obj.QType,0);
       document.getElementById("pTitle").value="";
     }
   }
  else {
     alert("您还未登陆,系统不能提交您的问题!!!\n\r如果您不是成员，请注册");
   } 
}

function ApplayAnswe(){
  var _Title=document.getElementById("rTitle").value;
  if ((_Title.length==0) || (_Title=="")){
    alert("标题不能为空！！！");return ;
  }
  var _Content=document.all.Content.value;
   if ((_Content.length==0) || (_Content=="")){
    alert("回答内容不能为空！！！");return ;
  }
  var Obj=new Object();
   Obj.Question=_Title;
   Obj.Answer  =_Content;
   Obj.QType   =g_Type;
   Obj.ReDid   =g_Id;
   Obj.ViewNum =0;
   Obj.Visibled='1';
   Obj.ImageUrl='';
  var ObjList=new Array();
  var Res=neworchid.AjaxHomeLib.GetAuthInfo();
     ObjList=Res.value;
   if (ObjList[0]!=""){
      Obj.MemId=ObjList[0];
      Res=neworchid.AjaxHomeLib.SaveQandA(Obj,'ADD');
      if (!Res.error) {
       alert("恭喜您提交答复成功!!!");
      // ShowLayer(0);
       SetClassName_1(V1,4);
       GetAnswerList(g_Id);
       document.getElementById("rTitle").value="";
       document.all.Content.value ="";
      }
   }
  else {
     alert("您还未登陆,系统不能提交您的问题!!!\n\r如果您不是成员，请注册");
   } 

}









