﻿// JavaScript Document
function getCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  {
    offsetNum = document.cookie.indexOf(search);
    if (offsetNum != -1)
    {	
      offsetNum += search.length;
      end = document.cookie.indexOf(";", offsetNum);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offsetNum, end))
    }
  }
  return cookieValue;
}

function setCookie(cookieName,cookieValue,DayValue)
{
	var expire = "";
	var day_value=1;
	if(DayValue!=null)
	{
		day_value=DayValue;
	}
    expire = new Date((new Date()).getTime() + day_value);
    expire = "; expires=" + expire.toGMTString();
	document.cookie = cookieName + "=" + escape(cookieValue) +";path=/"+ expire;
}

function delCookie(cookieName)
{
	var expire = "";
    expire = new Date((new Date()).getTime() - 1 );
    expire = "; expires=" + expire.toGMTString();
	document.cookie = cookieName + "=" + escape("") +";path=/"+ expire;
	//path=/
}

function setShoppingUrl(){
    setCookie("ShoppingBackUrl",location.href,30*86400000);//设置返回页面
}

function backShoppingUrl()
{
    var Url=getCookie("ShoppingBackUrl");
    if(Url=="")Url="/";
    location.href=Url;
}
function goTop(){
	document.body.scrollTop = 0;
	document.documentElement.scrollTop = 0;
}
function setCloseLive800()
{
    setCookie("HasCloseLive800",1,180000);//豪秒
}
function getCloseLive800(){
    return getCookie("HasCloseLive800");
}
function closeLive800(){
    setCloseLive800();
    document.getElementById("live800msg").style.display = "none";
}
 function openwindow(url, winName, width, height, r, s) 
{
    var xposition=0;
    var yposition=0;
    if ((parseInt(navigator.appVersion) >= 4 )){
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;
    }
    var theproperty = "width=" + width + ","+ "height=" + height + "," + "resizable=" + r + "," + "scrollbars=" + s + "," 
    + "location=0,"
    + "menubar=0,"
    + "status=0," 
    + "titlebar=0,"
    + "toolbar=0,"
    + "hotkeys=0,"
    + "screenx=" + xposition + "," //仅适用于Netscape
    + "screeny=" + yposition + "," //仅适用于Netscape
    + "left=" + xposition + "," //IE
    + "top=" + yposition; //IE 
    window.open(url,winName,theproperty);
}
