var Strhtm="";
var NodeList=null;
var ObjDescList=new Array();
var ObjVoteList=new Array();
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 GetSubReportList(pTop){
 var Res=neworchid.AjaxHomeLib.GetSubReportXml(pTop);
 g_xmDoc.loadXML(Res.value);
 ShowSubReportList();
}

function ShowSubReportList(){
 NodeList= g_xmDoc.getElementsByTagName("SDList");
 Strhtm="<ul class=ul>";
 var CurrList=NodeList.item(0).childNodes;
 if (CurrList.length>0){
  for (var i=0; i<CurrList.length; i++) {
   var _O_Id     =CurrList.item(i).getAttribute("Did");
   var _O_Title  =CurrList.item(i).getAttribute("O_Name");
   var _O_Date   =CurrList.item(i).getAttribute("O_Date");
    Strhtm+="<li>·<a href=javascript:ShowSubDesc('"+_O_Id+"');>"+_O_Title+"("+_O_Date+")</a></li>";
  }
   Strhtm+="</ul>";
   document.getElementById("DivReptList").innerHTML=Strhtm; 
  }
}

function ShowSubDesc(pId){
 Strhtm="<ul class=ul>";
 var Res=neworchid.AjaxHomeLib.GetServerSubDetail(pId);
  if ((!Res.error) && (Res.value!=null)){
     ObjDescList=Res.value;
     for (var i=0;i<ObjDescList.length;i++){
       var _Id        =ObjDescList[i].Id;
       var _O_Id      =ObjDescList[i].O_Id;
       var _Title     =ObjDescList[i].O_Title;
       var _O_CreateDate=ObjDescList[i].O_CreateDate;
       var WebUrl="ShowReportDetail.aspx?Id="+_Id;
      var d = new Date(_O_CreateDate);
      Strhtm+="<li>·<a href=javascript:OpenReportWin('"+WebUrl+"');>"+_Title+"</a>";
      Strhtm+="("+d.format('yyyy年MM月dd日')+")</li>";
      }
      Strhtm+="</ul>";
      document.getElementById("DivDescList").innerHTML=Strhtm;  
      g_Id=pId;
      Showvoteimage();
      SetClassName(V2,5);
      ShowLayer(1);
     
    }
}

function Showvoteimage(){
 var Strhtm=""; 
 var Res=neworchid.AjaxHomeLib.GetVoteorchidByPage(30,1,g_Id);
 //var Res=neworchid.AjaxHomeLib.GetVoteorchidByPage(pTop,pNum,pId);
  if ((!Res.error) && (Res.value!=null)){
   g_xmDoc.loadXML(Res.value);
   NodeList= g_xmDoc.getElementsByTagName("li");
   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 _ImageUrl   =CurrList.item(i).getAttribute("ImageUrl");
   var _OrchidName =CurrList.item(i).getAttribute("OrchidName");
   var _Web_Num    =CurrList.item(i).getAttribute("Web_Num");
   var _Mob_Num    =CurrList.item(i).getAttribute("Mob_Num");
   Strhtm+="<div class='box_10_1'><a href=javascript:ShowImageDetail('"+_Did+"');>";
   Strhtm+="<img src="+_ImageUrl+" width='120' height='120' border='0' alt='点击就可参与投票'></a>";
   Strhtm+="<br><a href=javascript:ShowImageDetail('"+_Did+"');>"+_OrchidName;
   Strhtm+="("+_Web_Num+")</a></div>";
   }
   document.getElementById("DivVoteList").innerHTML=Strhtm;  
 }
}
}

function SetClassName(t,n){
for (var i=1;i<=n;i++){
  var obj=eval("V"+i);
   if (obj.id==t.id) 
      obj.className="btnActive";
  else  obj.className="btnActive_no";
  }
}

function ShowLayer(pId){
 if (pId==0){
      document.all.DivReptList.style.display="block";
      document.all.DivDescImageList.style.display="block";
      document.all.divtop.style.display="block";
      document.all.DivDescList.style.display="none";
      document.all.DivVoteList.style.display="none";
      document.all.DivVoteImage.style.display="none";
      document.all.DivVoteSort.style.display="none";
 }
if (pId==1){
      document.all.DivReptList.style.display="none";
      document.all.DivDescImageList.style.display="block";
      document.all.DivDescList.style.display="block";
      document.all.DivVoteList.style.display="block";
      document.all.divtop.style.display="block";
      document.all.DivVoteImage.style.display="none";
      document.all.DivVoteSort.style.display="none";
      
 }
if (pId==2){
      document.all.DivReptList.style.display="none";
      document.all.DivDescImageList.style.display="none";
      document.all.divtop.style.display="none";
      document.all.DivDescList.style.display="none";
      document.all.DivVoteList.style.display="block";
      document.all.DivVoteImage.style.display="none";
      document.all.DivVoteSort.style.display="none";
 }
if (pId==3){
      document.all.DivReptList.style.display="none";
      document.all.DivDescImageList.style.display="none";
      document.all.divtop.style.display="none";
      document.all.DivDescList.style.display="none";
      document.all.DivVoteList.style.display="none";
      document.all.DivVoteImage.style.display="block";
      document.all.DivVoteSort.style.display="none";
 }
 if (pId==4){
      document.all.DivReptList.style.display="none";
      document.all.DivDescImageList.style.display="none";
      document.all.divtop.style.display="none";
      document.all.DivDescList.style.display="none";
      document.all.DivVoteList.style.display="none";
      document.all.DivVoteImage.style.display="none";
      document.all.DivVoteSort.style.display="block";
      GetSubVoteSortList(g_Id);
 }

}

function GetSubVoteList(pTop,pNum,pId){
  var Strhtm="";
  if (g_Id==""){
     alert("请先选择展会!!!");return;
   }
  var Res=neworchid.AjaxHomeLib.GetVoteorchidByPage(pTop,pNum,pId);
  if ((!Res.error) && (Res.value!=null)){
   g_xmDoc.loadXML(Res.value);
   NodeList= g_xmDoc.getElementsByTagName("li");
   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 _ImageUrl   =CurrList.item(i).getAttribute("ImageUrl");
   var _OrchidName =CurrList.item(i).getAttribute("OrchidName");
   var _Web_Num    =CurrList.item(i).getAttribute("Web_Num");
   var _Mob_Num    =CurrList.item(i).getAttribute("Mob_Num");
   Strhtm+="<div class='box_10_1'><a href=javascript:ShowImageDetail('"+_Did+"');>";
   Strhtm+="<img src="+_ImageUrl+" width='120' height='120' border='0' alt='点击就可参与投票'></a>";
   Strhtm+="<br><a href=javascript:ShowImageDetail('"+_Did+"');>"+_OrchidName;
   Strhtm+="("+_Web_Num+")</a></div>";
   }
   document.getElementById("DivVoteList").innerHTML=Strhtm;  
   ShowLayer(2);
   SetClassName(V3,5);
  }  
 }  
}

function ShowImageDetail(pId){
  var voteObj=null; 
   if (g_Id==""){
     alert("请先选择展会!!!");return;
   }
  var Res=neworchid.AjaxHomeLib.GetVoteImage(pId);
  if ((!Res.error) && (Res.value!=null)){
   voteObj=Res.value;
   document.getElementById("DivImg").innerHTML="<img src="+voteObj.ImageUrl+" width=350 height=400>";
   Strhtm ="<ul class='ul'>";
   var VoteName=voteObj.OrchidName;
   var pNo=VoteName.split(".");
   Strhtm+="<li>兰花编号:"+pNo[0]+"</li>";
   Strhtm+="<li>兰花名称:"+pNo[1]+"</li>";
   Strhtm+="<li>网络投票:<span id=w_num>"+voteObj.Web_Num+"</span></li>";
   Strhtm+="<li>手机投票:"+voteObj.Mob_Num+"</li>";
   Strhtm+="<li>兰花简介:</li>";
   Strhtm+="<li class='box_Text'>"+voteObj.OrchidDesc+"</li>";
   Strhtm+="<li style='dash'></li>";
   Strhtm+="<li><img src='img/q_expe_060703.gif' border=1>";
   Strhtm+="<a href=javascript:GoVoteImgae('"+voteObj.Did+"')>[我要投它一票]</a></li>";
   document.getElementById("DivDetail").innerHTML=Strhtm;
   ShowLayer(3);
   SetClassName(V4,5);
  }
}

function GoVoteImgae(pId){
 if (confirm("您确定给它投一票吗?")){
  var pIp=document.all.UserIp.value;
  var Res=neworchid.AjaxHomeLib.SaveVoteImage(pId,pIp);
  if (!Res.error){
    var revalue=Res.value;
    if (revalue=="OK"){
      alert("恭喜您投票成功,感谢您对国兰在线的支持!!!");
      var Num=document.all.w_num.innerText;
      document.all.w_num.innerText=parseInt(Num)+1;
     }
    else
     alert("您的机器已经投了该兰花一票,不能重复投票!!!"); 
  }
  else alert("sorry,您投票失败,请与网站系统管理员联系!!");
 }
}


function GetSubVoteSortList(pId){
  Strhtm="";var pNo=new Array();
  var m=0;
  if (g_Id==""){
     alert("请先选择展会!!!");return;
   }
  Strhtm=" <table width='98%'  border='1' cellspacing='0' cellpadding='0' class='box_3'>";
  Strhtm+="<tr align=center class=bg_1><td width=10%>排名</td>";
  Strhtm+="<td width=10%>兰花编号</td>";
  Strhtm+="<td width=40%>兰花名称</td>";
  Strhtm+="<td width=15%>网络投票</td>";
  Strhtm+="<td width=15%>手机投票</td>";
  Strhtm+="<td>..</td></tr>";
  var Res=neworchid.AjaxHomeLib.GetVoteSortList(pId);
  if ((!Res.error) && (Res.value!=null)){
   g_xmDoc.loadXML(Res.value);
   NodeList= g_xmDoc.getElementsByTagName("li");
   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 _ImageUrl   =CurrList.item(i).getAttribute("ImageUrl");
   var _OrchidName =CurrList.item(i).getAttribute("OrchidName");
   var _Web_Num    =CurrList.item(i).getAttribute("Web_Num");
   var _Mob_Num    =CurrList.item(i).getAttribute("Mob_Num");
    m=i+1;
    pNo=_OrchidName.split(".");
    Strhtm+="<tr align=center><td style='font-size:14px;font-weight:bold'>"+m+"</td>";
    Strhtm+="<td style='font-size:14px;font-weight:bold'>"+pNo[0]+"</td>";
    Strhtm+="<td><a href=javascript:ShowImageDetail('"+_Did+"');>"+pNo[1]+"</a></td>";
    Strhtm+="<td style='font-size:14px;font-weight:bold'>"+_Web_Num+"&nbsp;</td>";
    Strhtm+="<td>"+_Mob_Num+"&nbsp;</td>";
    Strhtm+="<td><a href=javascript:ShowImageDetail('"+_Did+"');>详细</a></td></tr>";
   }
   Strhtm+="</table>";
   document.getElementById("DivVoteSort").innerHTML=Strhtm;  
   SetClassName(V5,5);
  }  
 }  
}



function GetAllData(){
 GetMaginzeList("4");
 GetNewMember("10");
 GetSubReportList("30");
 GetParam();
 if (g_Id=="")
    ShowLayer(0);
 else 
   {
   ShowLayer(1);
   ShowSubDesc(g_Id);
   }
}







