﻿
function GetShopCartNum()
{
      $.ajax(
        {
            url: '/Ajax/Ajax_GetCookies.Aspx?Action=1&Rnd='+Math.random(),
            type: 'get',
        //    dataType: 'html',
        //    data:{Name:"ylm",Pwd:"144"},
        //    timeout: 1000
            success: function(xml)
                {
                    $("#shopCartNum").html(xml);    
                },
                beforeSend: function()
                {
                    $("#shopCartNum").html("Loading...");
                }
            }
        );
}
function GetShopCartPrice()
{
     $.ajax(
        {
            url: '/Ajax/AjaxGuti.Aspx?Action=2&Rnd='+Math.random(),
            type: 'get',
        //    dataType: 'html',
        //    data:{Name:"ylm",Pwd:"144"},
        //    timeout: 1000
            success: function(xml)
                {
                    $("#cartprice").html(xml);    
                },
            beforeSend: function()
                {
                    $("#cartprice").html("Loading...");
                }
            }
        );
}

function GetIsLogin()
{
    $("#aSignOut").hide(); 
    $.ajax
    (
        
        {
        url: '/Ajax/Ajax_GetCookies.Aspx?Action=2&Rnd='+Math.random(),
        type: 'get',
    //    dataType: 'html',
    //    data:{Name:"ylm",Pwd:"144"},
    //    timeout: 1000
        success: function(xml)
            {
                axml=new Array();
                axml=xml.split('|');
                if(axml[0].toString ()=="true")
                {
                    $("#aUserLogin").hide(); 
                    $("#login_spilt").hide();
                    $("#aUserReg").hide(); 
                    $("#aSignOut").show(); 
                    $("#spName").text(axml[1]);
                }
                else if(axml[0].toString ()=="false")
                {
                    $("#aUserLogin").show(); 
                    $("#login_spilt").show();
                    $("#aUserReg").show();  
                }
            }
//            beforeSend: function()
//            {
//                $("#shopCartNum").html("Loading...");
//            }
        }
    );
 
}


function GetSearchWordList()
{
     $.ajax(
    {
        url: '/Ajax/Ajax_ProductInfo.aspx?Action=8&Rnd='+Math.random(),
        type: 'get',success:function(xml){                
     
                 $('#spSearchWord').html(' '); 
			     var searchHtml='';
                 $(xml).find('KeyWord').each(function() {
                     var _title = $(this).attr('key');
                     var _link = $(this).attr('link');
                     searchHtml+="<a href="+_link+" style=\"color:#6c6c6c;\">"+_title+"</a>&nbsp;";                    
                 })   
                         
                $("#spSearchWord").html(searchHtml);    
            }
        }
    );
}

 $(function(){ 
 	 GetShopCartNum();
	 GetIsLogin();
	 GetSearchWordList();
	 function scroll(){
		var scrolltop=document.body.scrollTop||document.documentElement.scrollTop;
		var obj_kefu=$('#online_kehu');
		var innerW=$(window).width();
		var innerH=$(window).height();
		var l=parseInt((innerW-960)/2)-80+'px';
		var t=(innerH-obj_kefu.height())/2+scrolltop+'px';
		obj_kefu[0].style.right=l;
		obj_kefu[0].style.top=t;
		obj_kefu[0].style.display="block";
		}
	var JLib={};
	JLib.Brower=(function(ua){
	  var b={
		 ie:/msie/.test(ua)&&!/opera/.test(ua),
		 opera:/opera/.test(ua),
		 firefox:/firefox/.test(ua),
		 safari:/webkit/.test(ua)&&!/chrome/.test(ua),
		 chrome:/chrome/.test(ua)
		};
	  var vMark = "";
	  for (var i in b) {
		 if (b[i]) { vMark = "safari" == i ? "version" : i; break; }
	  }
	  b.version = vMark && RegExp("(?:" + vMark + ")[\\/: ]([\\d.]+)").test(ua) ?parseInt(RegExp.$1,10) : "0";
	  return b;
	 })(navigator.userAgent.toLowerCase());
	  if (JLib.Brower.version==6) {window.onscroll=scroll;}
	scroll();
	window.onresize=scroll;
	initMarquee();
 })
var marqueeContent=new Array();   //滚动新闻
marqueeContent[0]='<a style="color:#fff;text-decoration: none;font-size:12px;line-height:20px;height:20px" href="http://www.yzl.com.cn/special/winter.aspx" target="_blank">年终大促，五折封顶！200减20，500减60，800减90</a><br>';
marqueeContent[1]='<a style="color:#fff;text-decoration: none;font-size:12px;line-height:20px;height:20px" href="http://www.yzl.com.cn/special/winter.aspx" target="_blank">俞兆林加厚保暖黄金甲系列，极寒冬必备</a><br>';
marqueeContent[2]='<a style="color:#fff;text-decoration: none;font-size:12px;line-height:20px;height:20px" href="http://www.yzl.com.cn/product-997.html" target="_blank">莫代尔系列，人体的第二层皮肤</a><br>';
marqueeContent[3]='<a style="color:#fff;text-decoration: none;font-size:12px;line-height:20px;height:20px" href="http://www.yzl.com.cn/product-list-11.html" target="_blank">俞兆林男士商务系列 成功男士的选择</a><br>';
marqueeContent[4]='<a style="color:#fff;text-decoration: none;font-size:12px;line-height:20px;height:20px" href="http://www.yzl.com.cn/product-list-14.html" target="_blank">俞兆林蚕丝棉护肤衬衫  男人要风度也要温度</a><br>';

var marqueeInterval=new Array();  //定义一些常用而且要经常用到的变量
var marqueeId=0;
var marqueeDelay=3000;  //更新时间,毫秒
var marqueeHeight=20;  //容器高度
//接下来的是定义一些要使用到的函数
function initMarquee() {
 var str=marqueeContent[0];
$("#foot_p2").html('<div id=marqueeBox style="overflow:hidden;height:'+marqueeHeight+'px" onmouseover="clearInterval(marqueeInterval[0])" onmouseout="marqueeInterval[0]=setInterval(\'startMarquee()\',marqueeDelay)"><div>'+str+'</div></div>');
 marqueeId++;
 marqueeInterval[0]=setInterval("startMarquee()",marqueeDelay);
 }
function startMarquee() {
 var str=marqueeContent[marqueeId];
  marqueeId++;
 if(marqueeId>=marqueeContent.length) marqueeId=0;
 if(document.getElementById("marqueeBox").childNodes.length==1) {
  var nextLine=document.createElement('DIV');
  nextLine.innerHTML=str;
  document.getElementById("marqueeBox").appendChild(nextLine);
  }
 else {
  document.getElementById("marqueeBox").childNodes[0].innerHTML=str;
  document.getElementById("marqueeBox").appendChild(document.getElementById("marqueeBox").childNodes[0]);
  document.getElementById("marqueeBox").scrollTop=0;
  }
 clearInterval(marqueeInterval[1]);
 marqueeInterval[1]=setInterval("scrollMarquee()",20);
 }
function scrollMarquee() {
 document.getElementById("marqueeBox").scrollTop++;
 if(document.getElementById("marqueeBox").scrollTop%marqueeHeight==(marqueeHeight-1)){
  clearInterval(marqueeInterval[1]);
  }
 }
