/*	It's eShop4 Shopping Cart Routine Copy Right Infotechnica Ltd. 2000-2003	*/
cart_cookie_name = "es4cart=";
form_cookie_name = "es4order=";
baggage_div_count = parseInt("0");
if(baggage_div_count == 0)baggage_div_count = 1;
consumption_tax_rate = 0.05;
function get_pathname(pathname){
	var i = 0;	var ret = "";
	var cnt = 0;	var check_cnt = 1;	var dirname = "";	var dircount = 0;
	for(i = pathname.length - 1; i >= 0; i--){
		dirname = pathname.substr(i, 1) + dirname;
		if(dirname == "/item")check_cnt = 2;
		if(pathname.substr(i, 1) == "/"){dirname = "";	++dircount;}
		if(dircount >= 2)break;
	}
	for(i = pathname.length - 1; i > 0; i--){
		if(pathname.substr(i, 1) == "/"){
			++cnt;
			if(cnt >= check_cnt)break;
		}
	}
	if(i)	ret = pathname.substr(0, i);
	else ret = "/";
	return ret;
}
path_name = get_pathname(document.location.pathname);
function jump_url(url){document.location = url;}
function makeArray(maxIndex){
	this.length = maxIndex;
	for(i = 0; i < maxIndex; i++)this[i] = null;
	return this;
}
function getCookie(cookie_name){
	var cookie_value = document.cookie + ";";
	var start = cookie_value.indexOf(cookie_name);
	if(start != -1){
		var end = cookie_value.indexOf(";", start);
		return unescape(cookie_value.substring(start + cookie_name.length, end));
	}
	else
		return "";
}
function setCookie(cookie_name, cookie_value, expire){
	var str_cookie = cookie_name + escape(cookie_value) + "; path=" + path_name;
	if(expire != "")str_cookie += "; expires=" + expire;
	document.cookie = str_cookie;
}
function delCookie(cookie_name){document.cookie = cookie_name + "; path=" + path_name;}
function sliceCookie(cookie_value){return cookie_value.split("\r");}
function sliceItem(item_value){return item_value.split("\t");}
function ItemInBasket(item){
	this.id = item[0];	this.name = item[1];
	this.price = item[2];	this.amount = item[3];
	this.tax_div = item[4];	this.carry_div = item[5];
	this.color = item[6];	this.size = item[7];
	this.baggage_div = item[8];	this.include_div = item[9];
	this.carry_size = item[10];
	this.color_index = item[11];	this.size_index = item[12];
	this.tani = item[13];
	return this;
}
function delItem(Index){
	var arrItem = sliceCookie(getCookie(cart_cookie_name));
	var temp = "";
	for(i = 0; i < arrItem.length; i++){
		if(i != Index){
			if(temp == "")
				temp = arrItem[i];
			else
				temp += "\r" + arrItem[i];
		}
	}
	delCookie(cart_cookie_name);
	setCookie(cart_cookie_name, temp, "");
}
function format_number(value){
	var str_value = new String(value);
	var value_length = str_value.length;
	var ret = "";
	var i; var n = 1;
	for(i = value_length - 1; i >= 0; i--){
		ret = str_value.substr(i, 1) + ret;
		if((n == 3) && (i > 0)){ret = "," + ret; n = 0;}
		++n;
	}
	return ret;
}
function EraseMultiline(value){
	var str_value = new String(value);
	var end = str_value.indexOf("<BR>", 0);
	if(end >= 0)
		return str_value.substr(0, end);
	else
		return str_value;
}
function get_expire(){
	var now = new Date();
	var mseconds = now.getTime() + 15552000000;		// 180days later

	now.setTime(mseconds);
	
	var now_year = now.getUTCFullYear();
	var month_str = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
	var now_month = month_str[now.getUTCMonth()];
	var now_date = now.getUTCDate();
	var now_hours = now.getUTCHours();
	var now_minutes = now.getUTCMinutes();
	var now_seconds = now.getUTCSeconds();
	var now_day = now.getUTCDay();
	var day_str = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
	var now_day = day_str[now.getUTCDay()];

	now_year += "";
	if(now_date < 10)
		now_date = "0" + now_date;
	else
		now_date += "";
	if(now_hours < 10)
		now_hours = "0" + now_hours;
	else
		now_hours += "";
	if(now_minutes < 10)
		now_minutes = "0" + now_minutes;
	else
		now_minutes += "";
	if(now_seconds < 10)
		now_seconds = "0" + now_seconds;
	else
		now_seconds += "";

	return now_day + ", " + now_date + "-" + now_month + "-" + now_year + " "
		+ now_hours + ":" + now_minutes + ":" + now_seconds + " GMT";
}
function getFormCookie(form){
	var form_str = getCookie(form_cookie_name);
	if(form_str != ""){
		var arrForm = sliceCookie(form_str);
		var i = 0;
		var j = 0;
		var fieldName = "";
		var fieldValue = "";
		for(i = 0; i < arrForm.length; i++){
			var separate = arrForm[i].indexOf("=");
			if(separate != -1){
				fieldName = arrForm[i].substr(0, separate);
				fieldValue = arrForm[i].substr(separate + 1, arrForm[i].length - separate - 1);
				if(fieldValue.length > 0){
					for(j = 0; j < form.length; j++){
						if(form.elements[j].name == fieldName){
							if(form.elements[j].type.toLowerCase().indexOf("select") == -1){
								form.elements[j].value = fieldValue;
							}
							else{
								form.elements[j].options[parseInt(fieldValue)].selected = true;
								disp_shipping(arrItem);
							}
							break;
						}
					}
				}
			}
		}
	}
}
/*	End of Routine	*/



