//汎用ウインドウオープン
function newwindow(URL,WSIZE,HSIZE,SCROLL,RESIZE){
	if(URL==""){return;}
	if(WSIZE==""){WSIZE='320';}
	if(HSIZE==""){HSIZE='300';}
	if(SCROLL==""){SCROLL='yes';}else{SCROLL='no';}
	if(RESIZE==""){RESIZE='yes';}else{RESIZE='no';}
	window.open(URL,'window','width=' + WSIZE + ',height=' + HSIZE + ', toolbar=no, directories=no, scrollbars=' + SCROLL + ', resizable=' + RESIZE + '');
}

//クッキー取得
function getCookie(key,  tmp1, tmp2, xx1, xx2, xx3) {
	tmp1 = " " + document.cookie + ";";
	xx1 = xx2 = 0;
	len = tmp1.length;
	while (xx1 < len) {
		xx2 = tmp1.indexOf(";", xx1);
		tmp2 = tmp1.substring(xx1 + 1, xx2);
		xx3 = tmp2.indexOf("=");
		if (tmp2.substring(0, xx3) == key) {
			return(unescape(tmp2.substring(xx3 + 1, xx2 - xx1 - 1)));
		}
		xx1 = xx2 + 1;
	}
	return("");
}

//クッキーセット
function setCookie(key, val, time) {
	tmp = key + "=" + escape(val) + "; ";
	tmp += "path=/; ";
	if(time == ""){
		tmp += "expires=Fri, 31-Dec-2030 23:59:59; ";
	}else{
		tmp += "expires=" + time + "; ";
	}
	document.cookie = tmp;
}

//クッキークリア
function clearCookie(key) {
	setCookie(key, 'XXX', '1-Jan-1997 00:00:00');
}

//税込み価格算出
function get_amt_intax (amt){
	ret = Math.ceil(amt * ((100 + 5) / 100));
	return ret;
}

//税抜き価格算出
function get_amt_notax (amt){
	ret = Math.floor(amt / (100 + 5) * 100);
	return ret;
}

//URLエンコード
function encodeURL(str){
	var s0, i, s, u;
	s0 = "";								// encoded str
	for (i = 0; i < str.length; i++){ 	// scan the source
		s = str.charAt(i);
		u = str.charCodeAt(i);					// get unicode of the char
		if (s == " "){s0 += "+";} 			// SP should be converted to "+"
		else {
			if ( u == 0x2a || u == 0x2d || u == 0x2e || u == 0x5f || ((u >= 0x30) && (u <= 0x39)) || ((u >= 0x41) && (u <= 0x5a)) || ((u >= 0x61) && (u <= 0x7a))){ 			// check for escape
					s0 = s0 + s;						// don't escape
			}
			else {									// escape
				if ((u >= 0x0) && (u <= 0x7f)){ 		// single byte format
						s = "0"+u.toString(16);
						s0 += "%"+ s.substr(s.length-2);
				}
				else if (u > 0x1fffff){ 		// quaternary byte format (extended)
						s0 += "%" + (oxf0 + ((u & 0x1c0000) >> 18)).toString(16);
						s0 += "%" + (0x80 + ((u & 0x3f000) >> 12)).toString(16);
						s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
						s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
				}
				else if (u > 0x7ff){				// triple byte format
						s0 += "%" + (0xe0 + ((u & 0xf000) >> 12)).toString(16);
						s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
						s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
				}
				else {											// double byte format
						s0 += "%" + (0xc0 + ((u & 0x7c0) >> 6)).toString(16);
						s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
				}
			}
		}
	}
	return s0;
}

//レコメンドクリックログ
function recommend_click(itemcode,recommendkbn){
	$.ajaxSetup({ timeout : 0, dataType : 'text' });
	$.get('/5shopping/recommend_log.php?ic=' + itemcode + '&re=' + recommendkbn);
}

