﻿// JavaScript Document
function getCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  {
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    {	
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, 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,120000);//ms
}
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 + ",screeny=" + yposition + ",left=" + xposition + ",top=" + yposition;  
	window.open(url,winName,theproperty);
} 