﻿var xmlHttp=null    
function CreateXmlHttp()
{
if(window.ActiveXObject)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp=new XMLHttpRequest();
}



}


//发表评论
function GetUrl(typeid,paramid,loadtype)
{
    var url1="http://www.topyoo.net/ashx/Comment.ashx?nickname="+escape(document.getElementById('nickName').value)+"&cominfo="+escape(document.getElementById('cominfo').value);
    url1+="&typeid="+typeid+"&paramid="+paramid+"&loadtype="+loadtype+"&temptime="+new Date().getTime();
    return url1;
}

function SendCommentRequest(typeid,paramid,control,loadtype)
{
   if(loadtype==1)
   {
   if(document.getElementById("nickName").value=="")
   {
      alert("昵称不能为空！");
      document.getElementById("nickName").focus();
   }
   else
   {
     if(document.getElementById("cominfo").value=="")
     {
       alert("内容不能为空！");
       document.getElementById("cominfo").focus();
      }
     else
     {
       var url= GetUrl(typeid,paramid,loadtype);
       CreateXmlHttp();
       xmlHttp.open("get",url);
       xmlHttp.onreadystatechange=function(){CommentMethod(control,loadtype)};
       xmlHttp.send();
     }
   }
   }
   else
   {
       var url= GetUrl(typeid,paramid,loadtype);
       CreateXmlHttp();
       xmlHttp.open("get",url);
       xmlHttp.onreadystatechange=function(){CommentMethod(control,loadtype)};
       xmlHttp.send();
       }
   
}


function CommentMethod(control,loadtype)
{
   var id = document.getElementById(control);
   id.style.display="";
   if(xmlHttp.readyState==4)
   {
      if(xmlHttp.status==200)
      {
          if(loadtype==1)
          {
          id.innerHTML="发布评论成功！";
          document.getElementById("Num").innerText=parseInt(document.getElementById("Num").innerText)+1+"";
          document.getElementById("cominfo").value="";
          }
          else
          {
            id.innerHTML="";
          }
          var xmldoc = xmlHttp.responseXML;
          createFromXmlDoc(xmldoc,loadtype);
          setTimeout(function(){HideDiv(id);},1000);    
      }
   }
   else
      {
        id.innerHTML="<img src=../images/ajax-loader.gif>";
      }
}

function HideDiv(obj)
{
   obj.style.display = "none";
}

function createFromXmlDoc(xmldoc,loadtype)
{
   
   var comments = xmldoc.getElementsByTagName("Comment");
   for(var i=0;i<comments.length;i++)
   {
      createCommentDiv(comments[i].childNodes[0].childNodes[0].nodeValue,
                       comments[i].childNodes[2].childNodes[0].nodeValue,
                       comments[i].childNodes[1].childNodes[0].nodeValue,
                       loadtype
                       );
   }
    
}
  
function createCommentDiv(comusername,cominfo,comtime,loadtype)
{
   var parentDiv = document.getElementById("commentlist"); 
   var comdiv = document.createElement("div"); 
   comdiv.className='info';
   var comh2=document.createElement("span");
   comh2.className='tt_';
   var comimg = document.createElement("img");
   comimg.className='ic';
   comimg.setAttribute("src",'../images/ic8_.gif');
   var comname = document.createTextNode("评论者:"+comusername);
   var comspan = document.createElement("span");
   comspan.className='r';
   var comtimetext = document.createTextNode("时间:"+comtime);
   comspan.appendChild(comtimetext);
   comh2.appendChild(comimg);
   comh2.appendChild(comname);
   comh2.appendChild(comspan);
   var cominfodiv = document.createElement("div");
   cominfodiv.className='ct_';
   var cominfotext = document.createTextNode(cominfo);
   cominfodiv.appendChild(cominfotext);
   comdiv.appendChild(comh2);
   comdiv.appendChild(cominfodiv);  
   if(loadtype==0)
   {
   parentDiv.appendChild(comdiv);
   }
   else
   {
      parentDiv.parentNode.insertBefore(comdiv,parentDiv);
   }
   
}
   
   
   
   
//发表评论结束

//处理 丢鸡蛋 砸鲜花 开始
function SendFlowerAndEgg(url,control)
{
   CreateXmlHttp();
   url=url+"&temptime="+new Date().getTime();
   xmlHttp.open("get",url);
   xmlHttp.onreadystatechange=function(){ShowFlowerAndEgg(control)};
   xmlHttp.send();
}

function ShowFlowerAndEgg(control)
{
  var id = document.getElementById(control);
 //var num = parseInt(id.innerText);
  if(xmlHttp.readyState==4)
  {
     if(xmlHttp.status==200)
     {
         id.innerText=xmlHttp.responseText;
         alert("投票成功！");
        
     }
   
   }
   
     else
   {
        id.innerText="正在执行...";
   }
   
}
     
//处理 丢鸡蛋 砸鲜花 结束
   
//创建公会
function SendGuildInfo(type,gdvalue)
{ 
   CreateXmlHttp();
   var url="";
   var values = document.getElementById(gdvalue);
   var gdvalues=escape(values.value);
   url="Ashx/CheckCreatGuild.ashx?gdvalue="+gdvalues+"&type="+type+"&temptime="+new Date().getTime();
   xmlHttp.open("get",url);
   xmlHttp.onreadystatechange=function(){CheckGuildMethod(type)};
   xmlHttp.send();
}

function CheckGuildMethod(type)
{
   var obj=null
   if(type==1)
   {
     obj = document.getElementById("gdname");
   }
   else
   {
     obj = document.getElementById("gddomin");
   }
   
   if(xmlHttp.readyState==4)
   {
       if(xmlHttp.status==200)
       {
          
               if(xmlHttp.responseText=="1")
               {
                  obj.innerHTML="<font color=0066cc>此名字可以用！</font>";
                  document.getElementById("myid").value="1";
               }
               else
               {
                  obj.innerHTML="此名字已经注册！";
                  document.getElementById("myid").value="0";
               }
           

       }
   }
   else
   {
     obj.innerHTML="<img src='images/loading.gif'>";
   }
}
       
//创建公会 END
   

//用户登陆
function UserLogin()
{
   var username = document.getElementById("Username");
   username = escape(username.value);
   var pwd = document.getElementById("Password").value;
   if(username=="")
   {
     alert("请输入用户名!");
   }
   else
   {
     if(pwd=="")
     {
       alert("请输入密码!");
     }
     else
     { 
        CreateXmlHttp();
        var url="http://www.topyoo.net/ashx/CheckLogin.ashx?username="+username+"&pwd="+pwd+"&timess="+new Date().getTime();
        xmlHttp.open("get",url);
        xmlHttp.onreadystatechange =CheckLogin;
        xmlHttp.send();  
      }
     
   }
   
  
}

function CheckLogin()
{
   var loginobj = document.getElementById("TopYoo_UserLogin_HasLogin");
   var notloginobj = document.getElementById("TopYoo_UserLogin_NotLogin");
   if(xmlHttp.readyState==4)
   {
      if(xmlHttp.status==200)
      {
         if(xmlHttp.responseText!="-1")
         {
            loginobj.style.display="";
            notloginobj.style.display="none";
            document.getElementById("TopYoo_UserLogin_username").innerText=xmlHttp.responseText;
            document.onkeydown=null;
         }
         else
         {
            document.getElementById("loading").innerHTML='<font color=red>用户名或密码错误！</font>';
         }
      }
    }
    else
    {
        document.getElementById("loading").innerHTML="<img src='http://www.topyoo.net/images/loginld.gif'>正在登陆，请稍后...";
    }   
}

//用户登陆结束





function SendNextPreRequest(url,objimg,namelbl,a1,a2)
{
   CreateXmlHttp();
   xmlHttp.open("get",url);
   xmlHttp.onreadystatechange = function(){PicMethod(objimg,namelbl,a1,a2);};
   xmlHttp.send();
}


function PicMethod(objimg,namelbl,a1,a2)
{
   
   var imgid = document.getElementById(objimg);
   var name = document.getElementById(namelbl);
   var prea = document.getElementById(a1);
   var nexta=document.getElementById(a2);
   var obj = document.getElementById("Suc");
   if(xmlHttp.readyState==4)
   {
      if(xmlHttp.status==200)
      {
        var xmldoc = xmlHttp.responseXML;
        var photo = xmldoc.getElementsByTagName("Photos")[0];
        name.innerText=photo.childNodes[2].childNodes[0].nodeValue;
        imgid.src = "../Admin/"+photo.childNodes[1].childNodes[0].nodeValue;
        var id = photo.childNodes[0].childNodes[0].nodeValue;
        prea.onclick=function(){SendNextPreRequest("PhotoNextOrPre.ashx?PhotoID="+id,objimg,namelbl,a1,a2);};
        nexta.onclick=function(){SendNextPreRequest("Next.ashx?PhotoID="+id,objimg,namelbl,a1,a2);}
        obj.style.display="none";
      }
     
   }
   else
   {
     obj.innerHTML="<img src='../images/ajax1.gif' />正在加载 请稍等...";
   }
        
     
}
function AddOnKeyDown()
{
  document.onkeydown=EnterKey;
}

function EnterKey()
{
  
   if(window.event)
   {
   if(event.keyCode==13||event.keyCode==32)
   {
      UserLogin();
   }
   }
   else
   {
     if(event.witch==13||event.witch==32)
   {
      UserLogin();
   }
   }

}



//新闻感觉投票
function sendFeelRequest(type,newsid)
{
  CreateXmlHttp();
  var obj=document.getElementById("feel"+type);
  var url = "http://www.topyoo.net/ashx/Mood.ashx?Type="+type+"&NewsID="+newsid+"&timess="+new Date().getTime();;
  xmlHttp.open("get",url);
  xmlHttp.onreadystatechange = function(){upDateFeel(obj);};
  xmlHttp.send();
}


function upDateFeel(obj)
{
    if(xmlHttp.readyState==4)
    {
       if(xmlHttp.status==200)
       {
           if(xmlHttp.responseText=="1")
           {
              alert("投票成功，谢谢您的参与！");
              obj.innerText=parseInt(obj.innerText)+1+"";
              
           }
           else
           {
              alert("您已经投过票，请不要反复投票");
           }
        }
     }
}
  

//创建会员
function CreateUsers(type,infoId)
{
   CreateXmlHttp();
   var url="";
   var values = document.getElementById(infoId);
   var infovalue=escape(values.value);
   url="http://www.topyoo.net/ashx/CheckRegister.ashx?infovalue="+infovalue+"&type="+type+"&temptime="+new Date().getTime();
   xmlHttp.open("get",url);
   xmlHttp.onreadystatechange=function(){ReturnCheckUsers(type)};
   xmlHttp.send();
}

function ReturnCheckUsers(type)
{
   var obj=null;
   switch(type)
   {case 1:
    
         obj = document.getElementById("namespan");
         break;
    case 2:
    
          obj= document.getElementById("emailspan");
         break;
    case 3:
    
         obj = document.getElementById("codespan");
         break;
   }
   obj.style.display="";
   if(xmlHttp.readyState==4)
   {
       if(xmlHttp.status==200)
       {
          
               if(xmlHttp.responseText=="1")
               {
                  obj.style.border="1px solid #0054fe";
                  obj.style.backgroundColor="#164bb7";
                  obj.style.color="#ffffff";
                  if(type==1)
                  {
                    obj.innerHTML="此用户名可以用";
                    document.getElementById("myid").value="1";

                  }
                  if(type==2)
                  {
                    obj.innerHTML="此EMAIL地址可以用！";
                    document.getElementById("myid1").value="1";
                  }
                   if(type==3)
                  {
                    obj.innerHTML="输入正确！";
                    document.getElementById("myid2").value="1";
                  }

               }
               else
               {
                  obj.style.border="1px solid #ff1d06";
                  obj.style.backgroundColor="#ff0600";
                  obj.style.color="#ffffff";
                  if(type==1)
                  {
                    obj.innerHTML="此用户名已经注册！";
                  }
                  if(type==2)
                  {
                    obj.innerHTML="此Email地址已经注册！";
                  }
                  if(type==3)
                  {
                    obj.innerHTML="验证码输入错误！";
                  }
               }

       }
   }
   else
   {
     obj.innerHTML="<img src='images/loading.gif'>";
   }
}

//判断注册用户是否填写都正确
function CheckForm()
{
  if(document.getElementById("myid").value=="1" && document.getElementById("myid2").value=="1" && document.getElementById("myid1").value=="1")
  {
    return true;
  }
  return false;
}

//创建会员结束



//==================================
//征婚首页内容动态创建 开始
//==================================
function CreateLove(type,paramid,cid,login,uid)
{
    var ccid = document.getElementById(cid);
    CreateXmlHttp();
    if(type==1)
    {
    var url="http://www.topyoo.net/ashx/TypeLove.ashx?Type="+type+"&ParamID="+paramid+"&timess="+new Date().getTime();
    }
    if(type==2)
    {
    var url="http://www.topyoo.net/ashx/TypeLove.ashx?Type="+type+"&ParamID="+paramid+"&timett="+new Date().getTime();
    }
    xmlHttp.open("get",url);
    xmlHttp.onreadystatechange=function(){BackReqLove(ccid,type,login,uid)};
    xmlHttp.send();
}

function PageLoad(login,uid)
{
  CreateLove(2,177,'GameLoveDiv',login,uid);
  //CreateParty('LoveRecomDiv',login,uid);
}
function BackReqLove(cid,type,login,uid)
{
  
  cid.innerHTML="";
  if(xmlHttp.readyState==4)
   {
      if(xmlHttp.status==200)
      {
          var xmldoc = xmlHttp.responseXML;
          createLoveXmlDoc(xmldoc,cid,type,login,uid);
      }
   }
   else
   {
     cid.innerHTML="<div style='height:68%;background-color:#F9F8E1;width:98%; color:#C4BCBC; padding-top:150px;text-align:center;'><img src='images/ajax.gif'><br><br>正在加载，请稍后...</div>";
   }
}

//创建DIV 给DIV赋值
function CreateDivOfLove(cname,ltext,fid)
{
   var gamenamediv = document.createElement("div");
   gamenamediv.className=cname;
   var gamenametext1 = document.createTextNode(ltext);
   gamenamediv.appendChild(gamenametext1);
   fid.appendChild(gamenamediv);
}

//创建内容
function CreateLoveHtml(type,obj,lovenickname,lovegamename,lovegamearea,lovegameusername,loveid,lovesmallpicurl,userid,login,uid)
{
   //var parentDiv = document.getElementById(obj);
   var fdiv = document.createElement("div");
   fdiv.className="info";
   var lovea = document.createElement("a");
   lovea.href="LoveInfo.aspx?LvID="+loveid;
   lovea.className="img";
   var loveimg = document.createElement("img");
   loveimg.src="http://www.topyoo.net/admin/"+lovesmallpicurl;
   lovea.appendChild(loveimg);
   fdiv.appendChild(lovea);
   
   var ncdiv=document.createElement("div");
   ncdiv.className="dt";
   ncdiv.style.marginTop="5px";
   var ncname = document.createTextNode("昵称:"+lovenickname.substring(0,4));
   ncdiv.appendChild(ncname);
   fdiv.appendChild(ncdiv);
   
   CreateDivOfLove("dt","所在游戏:",fdiv);
   CreateDivOfLove("dl",lovegamename.substring(0,5),fdiv);
   CreateDivOfLove("dt","游戏服务器:",fdiv);
   CreateDivOfLove("dl",lovegamearea.substring(0,5),fdiv);
   CreateDivOfLove("dt","游戏昵称:",fdiv);
   CreateDivOfLove("dl",lovegameusername.substring(0,5),fdiv);
   
   var subdiv = document.createElement("div");
   subdiv.className="bt";
   if(type==1)
   {
   var subinput = document.createElement("input");
   subinput.type="button";
   if(login=="true")
   {
   subinput.onclick=function(){ShowLoveApplyDiv(400,300,'back',loveid,uid)};
   }
   else
   {
    subinput.onclick=function(){NotLoginShowLoveApplyDiv(400,80,'back')};
   }
   
   subdiv.appendChild(subinput);
   }
   if(type==2)
   {

   var input1 = document.createElement("input");
   input1.type="button";
   input1.className="bt_1";
    if(login=="true")
   {
   input1.onclick=function(){ ShowLoveApplyDiv(400,300,'back',loveid,uid)};
   }
   else
   {
    input1.onclick=function(){NotLoginShowLoveApplyDiv(400,80,'back')};
   }
   
   var input2 = document.createElement("input");
   input2.type="button";
   input2.className="bt_2";
   if(login=="true")
   {
   input2.onclick=function(){ ShowPartyDiv(uid,userid,400,300,'back')};
   }
   else
   {
    input2.onclick=function(){NotLoginShowLoveApplyDiv(400,80,'back')};
   }
   

   subdiv.appendChild(input1);
   subdiv.appendChild(input2);
   }
    
   fdiv.appendChild(subdiv);
   
   obj.appendChild(fdiv);
   
}


function createLoveXmlDoc(xmldoc,cid,type,login,uid)
{
  
   var comments = xmldoc.getElementsByTagName("Love");
   for(var i=0;i<comments.length;i++)
   {
     if(type==1)
     {
        CreateLoveHtml(type,cid,comments[i].childNodes[0].childNodes[0].nodeValue,
                       comments[i].childNodes[1].childNodes[0].nodeValue,
                       comments[i].childNodes[2].childNodes[0].nodeValue,
                       comments[i].childNodes[3].childNodes[0].nodeValue,
                       comments[i].childNodes[4].childNodes[0].nodeValue,
                       comments[i].childNodes[5].childNodes[0].nodeValue,
                       11,login,uid
                       );
     }
     if(type==2)
     {
         CreateLoveHtml(type,cid,comments[i].childNodes[0].childNodes[0].nodeValue,
                       comments[i].childNodes[1].childNodes[0].nodeValue,
                       comments[i].childNodes[2].childNodes[0].nodeValue,
                       comments[i].childNodes[3].childNodes[0].nodeValue,
                       comments[i].childNodes[4].childNodes[0].nodeValue,
                       comments[i].childNodes[6].childNodes[0].nodeValue,
                       comments[i].childNodes[5].childNodes[0].nodeValue,login,uid
                       );
     }

       
   }
    
}

//弹出应征窗口
function ShowLoveApplyDiv(owidth,oheight,objid,lvid,uid)
{
   var str="<div class='OpenLayer'>应征方式选择&nbsp;&nbsp;<a onclick='javascript:closeLayer();'><img src=images/del.gif title='关闭'/></a></div>";
   str+="<p class='lovesel'><input type=radio name='bzselect' checked  id='bzselect1' value='1'/>铺子币方式应征</p>";
   str+="<p class='lovetext'>提示:需要消耗5铺子币</p>";
   str+="<p class='lovesel'><input type=radio name='bzselect' id='bzselect2' value='2'/>拉进会员方式</p>";
   str+="<p class='lovetext'>提示:至少拉入2名会员</p>";
   str+="<div id='loading' style='color:#333333;'></div>";
   str+="<p class='lovetext'><a onclick='javascript:SendLoveApplySelect(GetRadioValue(),"+lvid+","+uid+");'><img src=images/sub.jpg></a></p>";
   openLayer(objid,str,owidth,oheight);
}


function GetRadioValue()
{
for(var i=1;i<=2;i++)
{
  if(document.getElementById('bzselect'+i).checked)
  {
    return document.getElementById('bzselect'+i).value;
  }
}
}

//弹出应征窗口
function NotLoginShowLoveApplyDiv(owidth,oheight,objid)
{
   var str="<div class='OpenLayer'>温馨提示&nbsp;&nbsp;<a onclick='javascript:closeLayer();'><img src=images/del.gif title='关闭'/></a></div>";
   str+="<p class='lovetext'>您还没有<a href='http://www.topyoo.net/user/login.aspx'>登陆</a>或者<a href='http://www.topyoo.net/user/register.aspx'>注册</a>！</p>";
   openLayer(objid,str,owidth,oheight);
}

function SendLoveApplySelect(type,lvid,uid)
{
    //var ccid = document.getElementById(cid);
    CreateXmlHttp();
    var url="http://www.topyoo.net/ashx/LoveApply.ashx?Type="+type+"&LvId="+lvid+"&Uid="+uid+"&timess="+new Date().getTime();
    xmlHttp.open("get",url);
    xmlHttp.onreadystatechange=function(){BackLoveApplaySelect()};
    xmlHttp.send();
}

function BackLoveApplaySelect()
{
  var cid = document.getElementById('popupAddr');
  var ld = document.getElementById('loading');
  if(xmlHttp.readyState==4)
   {
      if(xmlHttp.status==200)
      {
          //var xmldoc = xmlHttp.responseXML;
          //createLoveXmlDoc(xmldoc,cid);
          cid.innerHTML=xmlHttp.responseText;
      }
   }
   else
   {
     ld.innerHTML="<img src='images/ld2.gif'>正在处理，请稍后...";
   }
}


function SendLoveAddApplySelect(uid,lvid)
{
    var wish=document.getElementById("wishbox").value;
    var ans = document.getElementById("asnbox").value;
    if(document.getElementById('wishbox').value=="")
    {
      alert("请填写给对方的祝福!");
    }
    else
    {
    //var ccid = document.getElementById(cid);
    CreateXmlHttp();
    var url="http://www.topyoo.net/ashx/LoveApplyAdd.ashx?Uid="+uid+"&LvID="+lvid+"&Ans="+escape(ans)+"&Wish="+escape(wish)+"&timess="+new Date().getTime();
    xmlHttp.open("get",url);
    xmlHttp.onreadystatechange=function(){BackLoveAddApplaySelect()};
    xmlHttp.send();
    }
}

function BackLoveAddApplaySelect()
{
  var ld = document.getElementById('loading');
  if(xmlHttp.readyState==4)
   {
      if(xmlHttp.status==200)
      {
          //var xmldoc = xmlHttp.responseXML;
          //createLoveXmlDoc(xmldoc,cid);
          ld.innerHTML=xmlHttp.responseText;
          setTimeout("closeLayer()",2000);
      }
   }
   else
   {
     ld.innerHTML="<img src='images/ld2.gif'>正在处理，请稍后...";
   }
}

//==================================
//征婚首页内容动态创建结束
//==================================
   


//应征者评分 开始
function PressScore(laid,scoreid,presdiv,lvid)
{
    var score = document.getElementById(scoreid);
   
    CreateXmlHttp();
    var url="http://www.topyoo.net/ashx/uppresscore.ashx?LaID="+laid+"&LvID="+lvid+"&Score="+score.value+"&timess="+new Date().getTime();
    xmlHttp.open("get",url);
    xmlHttp.onreadystatechange=function(){ShowSucPress(score,presdiv)};
    xmlHttp.send();
}

function ShowSucPress(score,presdiv)
{

  var pdiv = document.getElementById(presdiv);
  if(xmlHttp.readyState==4)
   {
      if(xmlHttp.status==200)
      {
           var str="<div style='text-align:center;line-height:40px'>评分成功！</div>";
           openLayer('back',str,200,40);
           setTimeout("closeLayer()",2000);
           pdiv.innerHTML='您给TA的评分:'+score.value+"分";
      }
   }
   else
   {
     var str="<div style='text-align:center;line-height:40px'><img src='../images/ld2.gif'>正在处理，请稍后...</div>";
     openLayer('back',str,200,40);
   }
}

//应征者评分结束


//同意或者不同意应征者 开始
function LoveSuc(laid,addspan)
{
    //var ccid = document.getElementById(cid);
    CreateXmlHttp();
    var url="http://www.topyoo.net/ashx/ApplySuc.ashx?LaID="+laid+"&timess="+new Date().getTime();
    xmlHttp.open("get",url);
    xmlHttp.onreadystatechange=function(){ShowLoveSuc(addspan)};
    xmlHttp.send();
}

function ShowLoveSuc(addspan)
{

  if(xmlHttp.readyState==4)
   {
      if(xmlHttp.status==200)
      {
           var str="<div style='text-align:center;line-height:60px'><p>您已经同意开始跟她（他），</p><p>你们从现在开始已经进入恋爱状态</p>游戏铺子全程记录你们的恋爱历程并真诚祝福！</div>";
           openLayer('back',str,200,60);
           setTimeout("closeLayer()",5000);
           document.getElementById(addspan).innerHTML='您已经同意此应征，开始进入恋爱状态';
      }
   }
   else
   {
     var str="<div style='text-align:center;line-height:60px'><img src='../images/ld2.gif'>正在处理，请稍后...</div>";
     openLayer('back',str,200,60);
   }
}

//同意或者不同意应征者结束


//回应恋爱指数请求 开始
function LoveNum(tlid,mes,rlid,lvobj)
{
    var mestext = document.getElementById(mes).value;
    if(mestext=="")
    {
       alert("请输入回复内容！");
    }
    else
    {
    CreateXmlHttp();
    var url="http://www.topyoo.net/ashx/UpLoveNum.ashx?TlID="+tlid+"&LvWish="+escape(mestext)+"&RlID="+rlid+"&timess="+new Date().getTime();
    xmlHttp.open("get",url);
    xmlHttp.onreadystatechange=function(){ShowLoveNum(lvobj)};
    xmlHttp.send();
    }
}

function ShowLoveNum(lvobj)
{
  var obj = document.getElementById(lvobj);
  if(xmlHttp.readyState==4)
   {
      if(xmlHttp.status==200)
      {
           obj.innerHTML="<div class='li' style='margin-top:5px;padding-top:10px;border:1px solid #ff6600;background-color:#ffff99; height:100px; padding-left:20px;'>(我的回复):"+xmlHttp.responseText+"</div>";
      }
   }
   else
   {
     obj.innerHTML="<img src='../images/ld2.gif'>正在处理，请稍后...";
   }
}

//回应恋爱指数请求 结束


//增加恋爱指数数目 开始
function AddLoveNum(tlid,rlid,numid,lovenumdiv)
{ 
    var numobj = document.getElementById(numid);
    if(parseInt(numobj.innerHTML)>=10)
    {
      alert("恋爱指数为10,请等待对方发送求婚请求！");
    }
    else
    {
    CreateXmlHttp();
    var url="http://www.topyoo.net/ashx/LoveNumAdd.ashx?TlID="+tlid+"&RlID="+rlid+"&timess="+new Date().getTime();
    xmlHttp.open("get",url);
    xmlHttp.onreadystatechange=function(){var num=numobj.innerHTML;
    num1=parseInt(num)+1
  var lnd = document.getElementById(lovenumdiv);
  if(xmlHttp.readyState==4)
   {
      if(xmlHttp.status==200)
      {    
           lnd.innerHTML="<div style='border:1px solid #ff6600;background-color:#ffff99;'>结婚恋爱指数是10 <br>此次恋爱指数提高成功-->继续加油</div>";
      }
   }
   else
   {
     lnd.innerHTML="<img src='../images/ld2.gif'>正在处理，请稍后...";
   }};
    xmlHttp.send();
    }
    
}


//增加恋爱指数数目 结束



//约会信息提交 结束
function ShowPartyDiv(sendid,recid,owidth,oheight,objid)
{
   var str="<div class='OpenLayer'>单独约会信息&nbsp;&nbsp;<a onclick='javascript:closeLayer();'><img src=images/del.gif title='关闭'/></a></div>";
   str+="<p class='partyP'><span>约会主题:</span><input type='text' id='partytitle' class='input' onfocus='InputOver(this.id);'  onblur='InputOut(this.id)' /></p>";
   str+="<p class='partyP'><span>约会介绍:</span><input type='text' id='partyinfo' class='input' onfocus='InputOver(this.id);'  onblur='InputOut(this.id)' /></p>";
   str+="<p class='partyP'><span>联系电话:</span><input type='text' id='partyphone' class='input' onfocus='InputOver(this.id);'  onblur='InputOut(this.id)' /></p>";
   str+="<p class='partyP'><span>联系邮箱:</span><input type='text' id='partyemail' class='input' onfocus='InputOver(this.id);'  onblur='InputOut(this.id)' /></p>";
   str+="<p class='partyP'><span>QQ/MSN&nbsp;:</span><input type='text' id='partyqq' class='input' onfocus='InputOver(this.id);'  onblur='InputOut(this.id)' /></p>";
   str+="<div id='loading' style='color:#333333;'></div>";
   str+="<p class='lovetext'><a  onclick='PartyApply("+sendid+","+recid+");'><img src=images/sub.jpg></a></p>";
   openLayer(objid,str,owidth,oheight);
}


function PartyApply(sendid,recid)
{ 
    var pttitle = document.getElementById('partytitle');
    var ptinfo = document.getElementById('partyinfo');
    var ptphone = document.getElementById('partyphone');
    var ptemail = document.getElementById('partyemail');
    var ptqq = document.getElementById('partyqq');
    if(pttitle.value=="")
    {
      alert("约会标题不能为空！");
      return;
    }
    if(ptinfo.value=="")
    {
      alert("约会介绍不能为空！");
      return;
    }
    if(ptphone.value=="")
    {
      alert("联系电话不能为空！");
      return;
    }
    if(ptemail.value=="")
    {
      alert("联系邮箱不能为空！");
      return;
    }
    if(ptqq.value=="")
    {
      alert("QQ/MSN不能为空！");
      return;
    }
    
    CreateXmlHttp();
    var url="http://www.topyoo.net/ashx/PartyApply.ashx?SendID="+sendid+"&RecID="+recid+"&pttitle="+escape(pttitle.value)+"&ptinfo="+escape(ptinfo.value)+"&ptqq="+escape(ptqq.value)+"&ptemail="+escape(ptemail.value)+"&ptphone="+escape(ptphone.value)+"&timess="+new Date().getTime();
    xmlHttp.open("get",url);
    xmlHttp.onreadystatechange=function(){ShowBackLoveNum()};
    xmlHttp.send();
    
    
}

function ShowBackLoveNum()
{
  var lnd = document.getElementById('loading');
  if(xmlHttp.readyState==4)
   {
      if(xmlHttp.status==200)
      {    
           lnd.innerHTML=xmlHttp.responseText;
           setTimeout("closeLayer()",2000);
      }
   }
   else
   {
     lnd.innerHTML="<img src='images/ld2.gif'>正在处理，请稍后...";
   }
}

//约会信息提交 结束 

//收到的单独约会操作 开始

function RecPartyApply(ptid,index,obj)
{ 
   
    CreateXmlHttp();
    var url="http://www.topyoo.net/ashx/RecPartyCon.ashx?ptid="+ptid+"&index="+index+"&timess="+new Date().getTime();
    xmlHttp.open("get",url);
    xmlHttp.onreadystatechange=function(){ShowRecParty(obj)};
    xmlHttp.send();
    
    
}

function ShowRecParty(obj)
{
  var lnd = document.getElementById(obj);
  if(xmlHttp.readyState==4)
   {
      if(xmlHttp.status==200)
      {    
           lnd.innerHTML=xmlHttp.responseText;
      }
   }
   else
   {
     lnd.innerHTML="<img src='../images/ld2.gif'>正在处理，请稍后...";
   }
} 
    
//收到的单独约会操作 结束 






//征婚首页最新约会动态创建开始
function CreateParty(cid,login,uid)
{
    var ccid = document.getElementById(cid);
    CreateXmlHttp();
    var url="http://www.topyoo.net/ashx/TypeParty.ashx?timess="+new Date().getTime();
    xmlHttp.open("get",url);
    xmlHttp.onreadystatechange=function(){BackReqParty(ccid,login,uid)};
    xmlHttp.send();
}

function BackReqParty(cid,login,uid)
{
  
  cid.innerHTML="";
  if(xmlHttp.readyState==4)
   {
      if(xmlHttp.status==200)
      {
          var xmldoc = xmlHttp.responseXML;
          createPartyXmlDoc(xmldoc,cid,login,uid);
      }
   }
   else
   {
     cid.innerHTML="<div style='height:68%;background-color:#F9F8E1;width:98%; color:#C4BCBC; padding-top:150px;text-align:center;'><img src='images/ajax.gif'><br><br>正在加载，请稍后...</div>";
   }
}

//创建内容
function CreatePartyHtml(obj,username,ptgamename,ptgamearea,ptsex,ptid,avatar,userid,login,uid)
{
   //var parentDiv = document.getElementById(obj);
   var fdiv = document.createElement("div");
   fdiv.className="info";
   var lovea = document.createElement("a");
   lovea.href="PartyInfo.aspx?PtID="+ptid;
   lovea.className="img";
   var loveimg = document.createElement("img");
   loveimg.src="http://bbs.topyoo.net/"+avatar;
   lovea.appendChild(loveimg);
   fdiv.appendChild(lovea);
   
   var ncdiv=document.createElement("div");
   ncdiv.className="dt";
   ncdiv.style.marginTop="5px";
   var ncname = document.createTextNode("会员名:"+username.substring(0,4));
   ncdiv.appendChild(ncname);
   fdiv.appendChild(ncdiv);
   
   CreateDivOfLove("dt","所在游戏:",fdiv);
   CreateDivOfLove("dl",ptgamename.substring(0,5),fdiv);
   CreateDivOfLove("dt","游戏服务器:",fdiv);
   CreateDivOfLove("dl",ptgamearea.substring(0,5),fdiv);
   CreateDivOfLove("dt","性别:",fdiv);
   CreateDivOfLove("dl",ptsex,fdiv);
   
   var subdiv = document.createElement("div");
   subdiv.className="bt";
   var subinput = document.createElement("input");
   subinput.type="button";
   if(login=="true")
   {
   subinput.onclick=function(){SendPartyApplySelect(uid,ptid)};
   }
   else
   {
    subinput.onclick=function(){NotLoginShowLoveApplyDiv(400,80,'back')};
   }
   subdiv.appendChild(subinput);

   fdiv.appendChild(subdiv);
   
   obj.appendChild(fdiv);
   
}


function createPartyXmlDoc(xmldoc,cid,login,uid)
{
  
   var comments = xmldoc.getElementsByTagName("Party");
   for(var i=0;i<comments.length;i++)
   {

    
         CreatePartyHtml(cid,comments[i].childNodes[0].childNodes[0].nodeValue,
                       comments[i].childNodes[1].childNodes[0].nodeValue,
                       comments[i].childNodes[2].childNodes[0].nodeValue,
                       comments[i].childNodes[3].childNodes[0].nodeValue,
                       comments[i].childNodes[4].childNodes[0].nodeValue,
                       comments[i].childNodes[5].childNodes[0].nodeValue,
                       comments[i].childNodes[6].childNodes[0].nodeValue,login,uid
                       );
     

       
   }
    
}


function SendPartyApplySelect(userid,ptid)
{
    //var ccid = document.getElementById(cid);
    CreateXmlHttp();
    var url="http://www.topyoo.net/ashx/publicparty.ashx?userid="+userid+"&ptid="+ptid+"&timess="+new Date().getTime();
    xmlHttp.open("get",url);
    xmlHttp.onreadystatechange=function(){BackPartyApplaySelect()};
    xmlHttp.send();
}

function BackPartyApplaySelect()
{
  if(xmlHttp.readyState==4)
   {
      if(xmlHttp.status==200)
      {
          //var xmldoc = xmlHttp.responseXML;
          //createLoveXmlDoc(xmldoc,cid);
          openLayer('back',xmlHttp.responseText,300,50);
          setTimeout("closeLayer()",2000);
      }
   }
   else
   {
    openLayer('back',"<img src='images/ld2.gif'>正在处理，请稍后...",200,50);
   }
}

//征婚首页最新约会结束  



//处理结婚请求

function MarryApply(tlid,userid,mdiv)
{
   CreateXmlHttp();
   var url="http://www.topyoo.net/ashx/marry.ashx?tlid="+tlid+"&userid="+userid+"&timess="+new Date().getTime();
   xmlHttp.open("get",url);
   xmlHttp.onreadystatechange=function(){ShowMarryBack(mdiv)};
   xmlHttp.send();
}

function ShowMarryBack(control)
{
  var id = document.getElementById(control);
 //var num = parseInt(id.innerText);
  if(xmlHttp.readyState==4)
  {
     if(xmlHttp.status==200)
     {
         if(xmlHttp.responseText=="1")
         {
          id.innerText="请求出错";
           alert("您已经结婚了，不能再结婚了，您真的好花心哟！");
           
         }
         else
         {
            id.innerHTML="结婚成功游戏铺子真诚祝福！";
         }
     }
   
   }
   
     else
   {
        id.innerText="正在执行...";
   }
   
}
//处理结婚请求结束
        

        
   
function DrawImage(ImgD,w){ 

   var image=new Image(); 
   image.src=ImgD.src; 
   if(image.width>0 && image.height>0){ 
   
         if(image.width>w)
         {
            ImgD.width=w; 
            imgD.height=(image.height/(image.width/w));
         }else if(image.height>w)
         {
            ImgD.width=image.width/(image.height/w);
            imgD.height=w;
         
         }
        
    } 
}  
 

