﻿window.onscroll=scall;
window.onresize=resize;
function scall()
{
  if($("#MessageBox").length>0)
  {
     var h=document.documentElement.scrollTop+130;
     $("#MessageBox").css("top",h+"px");
  }
}
function resize()
{
  if($("#PageCover").length>0)
  {
    var h=document.documentElement.scrollHeight;
    var w=document.documentElement.scrollWidth;
    document.getElementById('PageCover').style.height=h+'px';
    document.getElementById('PageCover').style.width=w+'px';
  }
}
function MemberRegister()
{
   window.location="/UserCenter/Register.Aspx?url="+document.location.href;
}
function MemberLoginCheck(){
  var html="<div id=\"PageCover\"></div>";
  html+="<div id=\"MessageBox\"> <iframe Id=\"LoginPage\" name=\"LoginPage\" frameborder=\"0\" scrolling=\"no\" width=\"391\"  height=\"241\"></iframe></div>";
 if(!$("#MessageDiv").length>0)
 {
      html="<div id=\"MessageDiv\">"+html+"</div>";
      $("body").append(html);
 }
 else
 {
    $("#MessageDiv").append(html);
 }
  var h=document.documentElement.scrollHeight;
  document.getElementById('PageCover').style.height=h+'px';
  document.MemberLogin.submit();
}
function MemberLoginShow(){
$(document).ready(function(){
     var html="<div id=\"PageCover\"></div>";
     html+="<div id=\"MessageBox\"><iframe Id=\"LoginPage\" src=\"/UserCenter/MemberAction.aspx\" frameborder=\"0\" scrolling=\"no\" width=\"391\"  height=\"241\"></iframe></div>";
     if(!$("#MessageDiv").length>0)
     {
          html="<div id=\"MessageDiv\">"+html+"</div>";
          $("body").append(html);
     }
     else
     {
        $("#MessageDiv").append(html);
     }
     var h=document.documentElement.scrollHeight;
     document.getElementById('PageCover').style.height=h+'px';
 });
}
function MemberLogout()
{
 $(document).ready(function(){
     var html="<div id=\"PageCover\"></div>";
     html+="<div id=\"MessageBox\"><iframe Id=\"LoginPage\" src=\"/UserCenter/MemberAction.aspx?action=LoginOut\" frameborder=\"0\" scrolling=\"no\" width=\"391\"  height=\"241\"></iframe></div>";
     if(!$("#MessageDiv").length>0)
     {
          html="<div id=\"MessageDiv\">"+html+"</div>";
          $("body").append(html);
     }
     else
     {
        $("#MessageDiv").append(html);
     }
      var h=document.documentElement.scrollHeight;
      document.getElementById('PageCover').style.height=h+'px';
  });
}
function changeCheckNum()
{
   document.getElementById('checkNumImg').src="/CheckNum.aspx?rnd="+Math.random();
}
function Loginclose()
{
   $("#MessageDiv").html('');
}
function MessageBox(msgType,msgTitle,msgContext,msgUrl)
{
   $(document).ready(function(){
       var html="<div id=\"PageCover\"></div>";
       html+="<div id=\"MessageBox\" style=\"height:200px;\" ><div id=\"MessageAlert\">";
       html+="<h3><span>"+msgTitle+"</span><a href=\"javascript:Loginclose();\"><img src=\"/Images/Common/close.gif\" border=\"0\" /></a></h3>";
       html+="<hr /><div><img src=\"/Images/Common/"+msgType+"_big.gif\" border=\"0\" /></div>";
       html+="<ul><li>"+msgContext+"</li>";
       html+="<li><a href=\"javascript:window.location='"+msgUrl+"';\">如果页面没有反应,请点这里跳转!</a></li></ul>";
       html+="</div></div>";
      if(!$("#MessageDiv").length>0)
      {
          html="<div id=\"MessageDiv\">"+html+"</div>";
          $("body").append(html);
      }
      else
      {
          $("#MessageDiv").append(html);
      }
      var h=document.documentElement.scrollHeight;
      document.getElementById('PageCover').style.height=h+'px';
      if(msgType=="success")
      {
        setTimeout("window.location=('"+msgUrl+"');",5000);
      }
  });
}
function addCollect(type,dataid)
{
     var parms=type+"-"+dataid;
     $.ajax({ type: "GET", url: '/Ajax/Ajax_MemberAction.aspx?Action=0&parms='+parms+'&rnd='+Math.random(), 
     success: function(xml) {
           var result=$(xml).find('result').text();
           if(result=="Success")
             MessageBox('success','成功提示','恭喜您,您已经成功收藏!',document.URL);
           else if(result=="NoLogin")
             MemberLoginShow();
           else
             MessageBox('error','错误提示','对不起,收藏商家操作失败!',document.URL);
          }
      });
}
function TaoBaoMenuSelect(channelId)
{
      $(".TMenu a").each(function(index){
        if(index==channelId)
        {
           
           $(this).addClass("selected");
        }
      });
}
function SearchAction()
{
   var searchVal=$("#KeyWord").val();
   if(searchVal=="请输入要查询的关键字")
   {
      return false;
   }
   return true;
}
function KeyWordFocus()
{
    var txtval=$('#KeyWord').val();
    if(txtval=='')
    {
       $('#KeyWord').val('请输入要查询的关键字');
    }
    else if(txtval=='请输入要查询的关键字')
    {
       $('#KeyWord').val('');
    }
}