﻿function GetPath2()
{
var strPath2="";
if(location.pathname.indexOf('web')==-1)
{
strPath2=location.protocol+"//"+location.host
}
else
{
strPath2=location.protocol+"//"+location.host+"/"+"web"
}
return strPath2; 

}


function clickPersion(pid)
{
 // $('ul.the_menu').slideToggle('medium');
  $('ul.the_menu').show();
}
function outclickPersion(pid)
{
$('ul.the_menu').hide();
}


var mess1="";
day = new Date( )
hr = day.getHours( )
if (( hr >= 0 ) && (hr <= 4 ))
mess1="深夜了！"
if (( hr >= 4 ) && (hr < 7))
mess1="早上好!"
if (( hr >= 7 ) && (hr < 12))
mess1="早上好!"
if (( hr >= 12) && (hr <= 13))
mess1="早上好!"
if (( hr >= 13) && (hr <= 17))
mess1="下午好!"
if (( hr >= 17) && (hr <= 18))
mess1="晚上好！"
if ((hr >= 18) && (hr <= 19))
mess1="晚上好！"
if ((hr >= 19) && (hr <= 23))
mess1="晚上好！"

document.write("<div id='top_bg' >");
document.write("<div id='top_bga'>");
document.write("<div id='top_bga1'>");
document.write("<div class='pp' id='userlogin' >");


document.write("</div>");
document.write("<div id='top_bga1_ri'>");


document.write("<div id='button' class='titelbutton'>");
//document.write("<img src='miages/logo_1.jpg' width='121' height='38' class='menu_class' alt='' />");
//document.write("<ul class='the_menu'>");
//document.write("<li><a href='../member/Order.aspx'>我的订单</a></li>");
//document.write("<li><a href='LenovoShop_ShopCart.aspx'>我的购物车</a></li>");
//document.write("</ul>");
document.write("</div>");
document.write("<div class='top_ri1' >");
document.write("<ul class='ulr'>");
document.write("<li style='background:none;'><a href='"+GetPath2()+"/Lenovo_help.aspx?typeid=83&infoid=502'>网上购物指南</a></li>");
document.write("<li><a href='http://www.lenovo.com.cn'>返回联想首页</a></li>");
document.write("<li class='a1'><a href='javascript:AddFavorite();' target='_self'>收藏本页</a></li>");
document.write("</ul>");
document.write("</div>");
document.write("</div>");
document.write("</div>");
document.write("<div class='top_bgdom'>");
document.write("<div class='logo'>");
document.write("<img src='"+GetPath2()+"/shop/miages/logo.jpg' width='242' height='50' alt=''  usemap='#Map2' />");
document.write("<map name='Map2' id='Map2'>");
document.write("<area shape='rect' coords='0,12,241,44' href='http://www.lenovo.com.cn/' />");
document.write("<area shape='rect' coords='101,43,200,63' href='http://appserver.lenovo.com.cn/shop/index.aspx' />");
document.write("<area shape='rect' coords='174,45,175,48' href='#' />");
document.write("</map>");
document.write("</div>");
document.write("<div class='hotline'>");
document.write("<img src='"+GetPath2()+"/shop/miages/hot_x.jpg' width='271' height='70' alt='' /></div>");
document.write("</div>");
document.write("</div>");
document.write("</div>");


//新页头
$(document).ready(function(){
    var mess2="";
   mess2+="<img src='"+GetPath2()+"/shop/miages/logo_1.jpg' width='121' height='38' class='menu_class' alt=''  />";
   mess2+="<ul class='the_menu'>";
   mess2+="<li><a href='"+GetPath2()+"/member/Order.aspx'>我的订单</a></li>";
   mess2+="<li><a href='"+GetPath2()+"/shop/LenovoShop_ShopCart.aspx'>我的购物车</a></li>";
   mess2+="</ul>";
   
    var mess3="";
    mess3+="<p class='p1' >";
    mess3+="&nbsp;"
    mess3+=mess1;
    mess3+="欢迎您来到联想官方网站!</p>";
    mess3+="<p class='p2'>";
    mess3+="<a href='"+GetPath2()+"/member/login.aspx'>[请登录]，</a></p>";
    mess3+="<p class='p3'>";
    mess3+="<a href='"+GetPath2()+"/member/login.aspx'>新用户？</a></p>";
    mess3+="<p class='p4'>";
    mess3+="<a href='"+GetPath2()+"/member/login.aspx'>[免费注册]</a></p>";
    

    $.ajax({
      url: GetPath()+"/shop/LenovoShop02_UserLogin.ashx?actioncode=0&date="+new Date().getTime(),
      cache: false,
      success: function(data){
      var Login_Html="";
        if(data!=-1&&data!="")
        {
           $("#button").html(mess2);
           GetLoginInfo();
        }
        else
        {
           $("#button").html("");
           $("#userlogin").html(mess3);
           
        }
      }
    }); 
});

$(document).ready(function () {
    $('#button').mouseover(function () {
	    //$('ul.the_menu').slideToggle('medium');
	    $('ul.the_menu').show();
    });
     $('#button').mouseout(function () {
	    //$('ul.the_menu').slideToggle('medium');
	    $('ul.the_menu').hide();
    });
});




function GetLoginInfo()
{
$.ajax({
  url: GetPath()+"/shop/LenovoShop02_UserLogin.ashx?actioncode=0&date="+new Date().getTime(),
  cache: false,
  success: function(data){
  var Login_Html="";
    if(data!=-1&&data!="")
    {
    Login_Html="<p class='p1' >"+data+"&nbsp;"+mess1+"&nbsp;<a href='#' onclick='loginout()'>退出登录</a></p>"
    $("#userlogin").html(Login_Html);
    }
    else
    {
    }
  }
}); 



}
function loginout()
{

$.ajax({
  url: GetPath()+"/shop/LenovoShop02_UserLogin.ashx?actioncode=1&date="+new Date().getTime(),
  cache: false,
  success: function(data){
  var Login_Html="";
    if(data!=-1&&data!="")
    {
   window.location.href=GetPath()+"/member/login.aspx";
    }
    else
    {
    }
  }
}); 


}

function AddFavorite()
{
    var sURL= 'http://'+document.location.host+'/';
    var sTitle='联想商城';
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
