var g_Type="0";
var g_Top="32";
var g_MemId="";
var g_Img="";
var g_Id="";
var BuySellObj=null;

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();
  if (g_Id==""){
     ShowLayer(0);
     GetTransList(g_Top,1,g_Type,0);
     }
  else{
       GetBuySellDetail(g_Id);
       ShowLayer(1);
     }
}

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.DivBuySellList.style.display="block";
      document.all.DivTopDetail.style.display="none";
      document.all.DivMemDetail.style.display="none";
      document.all.DivBuySell.style.display="none";   
 }
if (pId==1){
      document.all.DivBuySellList.style.display="none";
      document.all.DivTopDetail.style.display="block";
      document.all.DivMemDetail.style.display="none";
      document.all.DivBuySell.style.display="none";

  }
if (pId==2){
      document.all.DivBuySellList.style.display="none";
      document.all.DivTopDetail.style.display="none";
      document.all.DivMemDetail.style.display="block";
      document.all.DivBuySell.style.display="none";
  }
if (pId==3){
      document.all.DivBuySellList.style.display="none";
      document.all.DivTopDetail.style.display="none";
      document.all.DivMemDetail.style.display="none";
      document.all.DivBuySell.style.display="block";
      document.all.pType.selectedIndex=0;
  }
}

function GetTransList(pTop,pNum,pType,pRedid){
 var Res=neworchid.AjaxHomeLib.GetBuySellXmlByPage(pTop,pNum,pType,pRedid);
 g_xmDoc.loadXML(Res.value);
 ShowBuySellList();
 ShowLayer(0);
 if (pType=="0")    
    SetClassName_1(V1,6);
 else SetClassName_1(V2,6);
  
}

function ShowBuySellList(){
var Imgarray=new Array();
var Otarray =new Array();var TId=new Array();
var m=0;
var len=0;
var ImgHtm="";
 NodeList= g_xmDoc.getElementsByTagName("li");
 var CurrList=NodeList.item(0).childNodes;
 if (CurrList.length>0){
 Strhtm="";
//"<div id='DivBuySellImg' class='rightImg' ></div>";
 //Strhtm+="<ul class=ul>";
 for (var i=0; i<CurrList.length; i++) {
   var _Did       =CurrList.item(i).getAttribute("Did");
   var _Subject   =CurrList.item(i).getAttribute("Subject");
   var _Image     =CurrList.item(i).getAttribute("ImageUrl");
   var _OrchidType=CurrList.item(i).getAttribute("OrchidType");
   var _Price     =CurrList.item(i).getAttribute("Price");
   if (_Subject.length>=8)
    _Subject=_Subject.substring(0,6)+"..";
   Strhtm+="<div class='Box_11_b'>";
   if (_Image.length>6)
    Strhtm+="<a href=javascript:GetBuySellDetail('"+_Did+"')><img src="+_Image+" width=145 height=135 border=0></a>";
   else Strhtm+="<img src=img/no.gif width=130 height=135 border=0>";
   Strhtm+="<br><a href=javascript:GetBuySellDetail('"+_Did+"')><font size=1>"+_Subject+"("+_Price+")</font></a></div>"; 
  // if (_Image!=""){
  //  Imgarray[m]=_Image;
  //   Otarray[m]=_OrchidType;
   //  TId[m]=_Did;
   //  m++;
   // } 
  }
  //Strhtm+="</ul>";
  document.getElementById("DivBuySellList").innerHTML=Strhtm;  
  //if (Imgarray.length>5)
   // len=5
  //else len=Imgarray.length;
 // for (var i=0; i<len; i++) {
  // if (Imgarray[i])
  //  ImgHtm+="<div  class='Box_10'><a href=javascript:GetBuySellDetail('"+TId[i]+"')>";
  //  ImgHtm+="<img src="+Imgarray[i]+" width=120 height=110 border=0></a>";
  //  ImgHtm+="<br>"+Otarray[i]+"</div> ";
  // }
  // document.getElementById("DivBuySellImg").innerHTML=ImgHtm;  
  }
}


function GetBuySellDetail(pId){
 var Res=neworchid.AjaxHomeLib.GetBuySellFeedDetail(pId);
 if ((!Res.error) && (Res.value!=null)){
   ShowLayer(1);
   BuySellObj=Res.value;
   Strhtm="<div id='DivOneImg' class='ImgBox'></div>";
   Strhtm+="<ul class=ul>";
   var _Did       =BuySellObj.Did;
   var _Subject   =BuySellObj.Subject;
   var _Image     =BuySellObj.ImageUrl;
   var _OrchidType=BuySellObj.OrchidType;
   var _Notes     =BuySellObj.Notes;
   var _MemId     =BuySellObj.MemId;//
   var _LastDate  =BuySellObj.LastDate;//
   var _PlaceName =BuySellObj.PlaceName;//
   var _ViewNum =BuySellObj.ViewNum;//
   g_MemId=_MemId;
   Strhtm+="<li>·主  题:"+_Subject+"</li>";
   Strhtm+="<li>·兰  花:"+_OrchidType+"</li>";
   Strhtm+="<li>·产  地:"+_PlaceName+"</li>";
   Strhtm+="<li>·浏  览:"+_ViewNum+"</li>";
   var d = new Date(_LastDate);
   Strhtm+="<li>·有效期:"+d.format('yyyy年MM月dd日')+"</li>";
   Strhtm+="<li>·兰　主:<a href=javascript:GetMemBaseInfo('"+_MemId+"');>···查看";
   Strhtm+="<img src='img/i_ico21_060708.gif' border=0></a></li>";
   Strhtm+="<li>·交易信息:</li>";
   Strhtm+="<li class=Box_text>"+_Notes+"</li>";
   Strhtm+="</ul>";
   Strhtm+="<div style='height:25;font-size:12px;border:1px solid #000000;background-color:#FFCC00;'>信息反馈";
   Strhtm+="<div id='divfeedlist'></div></div>";
   g_Id =_Did;
   g_Img=_Image;
   document.getElementById("DivDetail").innerHTML=Strhtm;  
   document.getElementById("DivOneImg").innerHTML="<a href=javascript:ShowLargeImg('"+_Image+"')><img src="+_Image+" width=150 height=130 border=0></a>"; 
   ShowBuySellFeedList();
   SetClassName_1(V3,6);
 }
}

function ShowLargeImg(pImg){
 document.getElementById("DivMemDetail").innerHTML="<div class='imgLarge'><img src="+pImg+" width=430 height=400 border=0></div>";
 SetClassName_1(V5,6);
 ShowLayer(2);
}

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(2);
   }
}

function ShowMemBase(Obj){
 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>";
 document.getElementById("DivMemDetail").innerHTML=Strhtm;  
 SetClassName_1(V4,6);
 }
 
 function ShowBuySellFeedList(){
 var ObjList=new Array();
  var Res=neworchid.AjaxHomeLib.GetBuySellFeedList(g_Id);
 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 _Subject=ObjList[i].Subject;
    var _Notes  =ObjList[i].Notes;
    var _MemId  =ObjList[i].MemId;
    Strhtm+="<li>··"+_Subject+"(兰友:<a href=javascript:GetMemBaseInfo('"+_MemId+"');>···查看";
    Strhtm+="<img src='img/i_ico21_060708.gif' border=0></a>)</li>"; 
    Strhtm+="<li class=Box_text>"+_Notes+"</li>";
   }
  Strhtm+="</ul>";
  document.getElementById("divfeedlist").innerHTML=Strhtm;  
  }  
 }
 
 function ShowImg(pSrc){
  if (pSrc!="")
  document.all.prvImg.innerHTML="<img src="+pSrc+" width='150' height='130'>";
 }
 
 function SaveBuySell(){
  if (CheckBuySell()){
    o=document.all.pOrchidType;
    p=document.all.pPlaceName;
    t=document.all.pType;
    var Obj=new Object();
    Obj.Did       ="1";
    Obj.Subject   =document.all.pSubject.value;
    Obj.Notes     =document.all.pNotes.value;
    Obj.IsBuy     =t.options[t.selectedIndex].value;
    Obj.ReDid     ="0";
    Obj.PostDate  ="2006-01-01";
    Obj.ViewNum   ="0";
    Obj.Price     =document.all.pPrice.value;
    Obj.ImageUrl  =document.all.pImage.value;
    Obj.LastDate  =document.all.pLastDate.value;
    Obj.OrchidType=o.options[o.selectedIndex].text;
    Obj.PlaceName =p.options[p.selectedIndex].text;
    
    var ObjList=new Array();
    var Res=neworchid.AjaxHomeLib.GetAuthInfo();
     ObjList=Res.value;
    if (ObjList[0]!=""){
      Obj.MemId=ObjList[0];
      var StrInput=Obj.MemId+"|"+Obj.Subject+"|"+Obj.Notes+"|"+Obj.IsBuy+"|"+Obj.ReDid;
          StrInput+="|"+Obj.PostDate+"|"+Obj.Price+"|"+Obj.ImageUrl+"|";
          StrInput+=Obj.LastDate+"|"+Obj.OrchidType+"|"+Obj.PlaceName;
     //  var mRes=neworchid.AjaxHomeLib.SaveMemberTrans(StrInput,"ADD");
       var mRes=neworchid.AjaxHomeLib.SaveMemberTrans(Obj,"ADD");
       if (!mRes.error) {
       alert("恭喜您提交交易信息成功!!!");
       ClearData();
       ShowLayer(0);
      }
      else {
           alert("您提交的交易信息未成功!!!");
           }
     }
    else alert("您还未登陆,系统不能提交您的交易信息!!!\n\r如果您不是成员，请注册");
   }
}
 
 function ApplaySell(){
  if (CheckBuySell_1()){
    var Obj=new Object();
    Obj.Did       ="1";
    Obj.Subject   =document.all.Title.value;
    Obj.Notes     =document.all.Content.value;
    Obj.IsBuy     ="0";
    Obj.ReDid     =g_Id;
    Obj.PostDate  ="2006-01-01";
    Obj.ViewNum   ="0";
    Obj.Price     ="0.00";
    Obj.ImageUrl  ="";
    Obj.LastDate  ="2006-01-01";
    Obj.OrchidType="";
    Obj.PlaceName ="";
    
    var ObjList=new Array();
    var Res=neworchid.AjaxHomeLib.GetAuthInfo();
     ObjList=Res.value;
    if (ObjList[0]!=""){
      Obj.MemId=ObjList[0];
      var StrInput=Obj.MemId+"|"+Obj.Subject+"|"+Obj.Notes+"|"+Obj.IsBuy+"|"+Obj.ReDid;
          StrInput+="|"+Obj.PostDate+"|"+Obj.Price+"|"+Obj.ImageUrl+"|";
          StrInput+=Obj.LastDate+"|"+Obj.OrchidType+"|"+Obj.PlaceName;
     //  var mRes=neworchid.AjaxHomeLib.SaveMemberTrans(StrInput,"ADD");
       var mRes=neworchid.AjaxHomeLib.SaveMemberTrans(Obj,"ADD");
       if (!mRes.error) {
       alert("恭喜您提交信息成功!!!");
       ClearData();
       ShowLayer(0);
      }
      else {
           alert("您提交的信息未成功!!!");
           }
     }
    else alert("您还未登陆,系统不能提交您的交易信息!!!\n\r如果您不是成员，请注册");
   }
}
 
 function CheckBuySell_1(){
 
  var strSubject = document.all.Title.value; 
    if (strSubject.length==0)  
    {  
        alert("请输入标题!");  
        document.all.Title.focus();  
        return false;  
    }  
 }
 
 function CheckBuySell(){
  var strSubject = document.all.pSubject.value; 
    if (strSubject.length==0)  
    {  
        alert("请输入买卖主题!");  
        document.all.pSubject.focus();  
        return false;  
    }  

    if (document.all.pOrchidType.selectedIndex ==0)
		{
		alert("请选择兰花类别!");
		document.all.pOrchidType.focus();
		return false;
		}

    if (document.all.pPlaceName.selectedIndex ==0)
		{
		alert("请选择兰花产地!");
		document.all.pPlaceName.focus();
		return false;
	}
  
   if (document.all.pLastDate.value.length==0)
		{
		alert("请确定有效期!");
		document.all.pLastDate.focus();
		return false;
	}
	
	if (!verifyDate(document.all.pLastDate))
		{
		alert("请输入正确的时间格式!");
		document.all.pLastDate.focus();
		return false;
	}
 
  if (document.all.pPrice.value.length==0)
		{
		alert("请输入期望的价格!!");
		document.all.pPrice.focus();
		return false;
	}

   if (document.all.pType.selectedIndex==0)
		{
		alert("请输入选择交易类型!!");
		document.all.pType.focus();
		return false;
	}
	
 // if (document.all.pImage.value.length==0)
//		{
//		alert("请提交您的兰花图片!!");
//		document.all.pImage.focus();
////		return false;
//	}
  if (document.all.pNotes.value.length==0)
		{
		alert("请提交您的交易信息!!");
		document.all.pNotes.focus();
		return false;
	}
 									
	return true;  
  }







