var caution = false;
var daystore=365;

function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "")
	if (!caution || (name + "=" + escape(value)).length <= 4000)
		document.cookie = curCookie
	else
		if (confirm("Cookie exceeds 4KB and will be cut!"))
			document.cookie = curCookie
}

function getCookie(name) {
var prefix = name + "="
var cookieStartIndex = document.cookie.indexOf(prefix)
if (cookieStartIndex == -1) return null
var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length) 
if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length
return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}

function showCookie() {
	window.open();
}

function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" + ((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"
  }
}

function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)	 date.setTime(date.getTime() - skew);
}

/*function ProductBuy(Product_ID) {
  var now = new Date();
  var str1=getCookie("a_order");
  if (Product_ID!="") {
    if ((str1=="") || (str1=="0") || (str1==null) || (str1=="null")) {
      str1="["+Product_ID+"][000][1]";
    } else {
      str1=str1+"["+Product_ID+"][000][1]";
    }

    fixDate(now);
    now.setTime(now.getTime() + daystore * 24 * 60 * 60 * 1000);
    setCookie("a_order", str1, now,"/");
  }
 
}
*/
function ClearBag() {

  if (confirm("Clear All") != true){
 	window.location.href="../html/orderlist.html";
  	return false;
  }
  var str1="";
  var now = new Date();
  deleteCookie("a_order");
  fixDate(now);
  now.setTime(now.getTime() + daystore * 24 * 60 * 60 * 1000);
  str1="0";
  setCookie("a_order", str1, now,"/");

  window.location.href="../html/orderlist.html";
}

function new_item(cKno){
	var strFeatures = "dialogWidth=500px;dialogHeight=410px;scrollbars=no"+
	"center=yes;border=thick;help=no;status=no";
	window.showModalDialog("../html/newitem.html",cKno,strFeatures);
}
function showpict(cKno){
	var strFeatures = "dialogWidth=730px;dialogHeight=600px;scrollbars=no"+
	"center=yes;border=think;help=no;status=no;maximize=on";
	window.showModalDialog("../html/showpict.html",cKno,strFeatures);
}

function checkpict(cKno)
{
	var i = 0;
	var nret = 0;
	for (i=0;i<kingpict.length;i++){
		cPict = kingpict[i];
		if (cPict.substr(0,6) == cKno.substr(0,6)){
			nret = 1;
			break;
		}
	}
	return nret;
}

