///////////////////////////////////////////////////////////
// Func：disp PrevItems
// Trig：page open
// Arg：path
// Ret：none(innerHTML)
///////////////////////////////////////////////////////////
function walk(path){

	var strPrevItems = loadCookie();
	if(strPrevItems.length > 0){
		var obj = create_obj();
		obj.onreadystatechange = function(){
			if( (obj.readyState == 4) && (obj.status == 200) ){
				document.getElementById('walkInfo').innerHTML = obj.responseText;
			}
		}
		if(obj){
			if(path){
				obj.open('GET', '../walk/?ps=' + escape(strPrevItems), true);
			}else{
				obj.open('GET', './walk/?ps=' + escape(strPrevItems), true);
			}
			obj.send(null);
		}
	}
}

///////////////////////////////////////////////////////////
// Func：disp PrevItems, columCols, otokuData and ruijiData for datail's page
// Trig：datail's page open
// Arg：i_pk, cp_pk, cate_search_words, maker
// Ret：none(innerHTML)
///////////////////////////////////////////////////////////
function dispData(i_pk, cp_pk, cate_search_words, maker){

	var strPrevItems = loadCookie();
	if(i_pk.length > 0){
		var arrayNextItems = [];
		if(strPrevItems.length > 0){
			var arrayPrevItems = strPrevItems.split('_s_');
			for(var i = 0; i < arrayPrevItems.length; i++){
				if(i_pk == arrayPrevItems[i]){
					continue;
				}
				arrayNextItems.push(arrayPrevItems[i]);
			}
		}

		arrayNextItems.push(i_pk);
		if(arrayNextItems.length > 5){
			arrayNextItems.shift();
		}
		saveCookie(arrayNextItems.join('_s_'));
	}

	var obj = create_obj();
	obj.onreadystatechange = function(){
		if( (obj.readyState == 4) && (obj.status == 200) ){
			var tex = obj.responseText;
			var tex_ary = tex.split("<!-- SEP -->");
			for(var i = 0; i < tex_ary.length; i++){
				if(tex_ary[i].indexOf("ruijidata") > 0){
					document.getElementById('ruiji').innerHTML = tex_ary[i];
				}
				if(tex_ary[i].indexOf("kanrencolumn") > 0){
					document.getElementById('column').innerHTML = tex_ary[i];
				}
				if(tex_ary[i].indexOf("otokudata") > 0){
					document.getElementById('otoku').innerHTML = tex_ary[i];
				}
				if(tex_ary[i].indexOf("walkdata") > 0){
					document.getElementById('walkInfo').innerHTML = tex_ary[i];
				}
			}
		}
	}
//alert('../dispdata/?ps=' + escape(strPrevItems) + '&i_pk=' + escape(i_pk) + '&cp_pk=' + escape(cp_pk) + '&cs=' + escape(cate_search_words) + '&mk=' + escape(maker));
	if(obj){
		obj.open('GET', '../dispdata/?ps=' + escape(strPrevItems) + '&i_pk=' + escape(i_pk) + '&cp_pk=' + escape(cp_pk) + '&cs=' + escape(cate_search_words) + '&mk=' + escape(maker), true);
		obj.send(null);
	}
}

///////////////////////////////////////////////////////////
// Func：disp file change
// Trig：onClick
// Arg：file_fullpath, disp_width, disp_height
// Ret：none(innerHTML)
///////////////////////////////////////////////////////////
function ImageChange(file, w, h){

	arrayFileTails = file.split('.');
	strFileTail = arrayFileTails.slice(-1);

	strHtml = "";
	if(strFileTail == "mp3"){
		strHtml = '<script type="text/javascript"><!-- act_x(\'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="320" height="70" title="MP3">\');// --></script><param name="movie" value="../share/js/files/mp3player.swf" /><param name="quality" value="high" /><param name="salign" value="TL" /><param name="scale" value="noScale" /><param name="FlashVars" value="path=' + file + '" /><embed src="../share/js/files/mp3player.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="320" height="70" salign="TL" scale="noScale" FlashVars="path=' +file + '"></embed></object>';
	}else if(strFileTail == "flv"){
		strHtml = '<script type="text/javascript"><!--act_x(\'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="540" height="380" title="FLASH MOVIE">\');// --></script><param name="movie" value="../share/js/files/flvplayer.swf" /><param name="quality" value="high" /><param name="salign" value="TL" /><param name="scale" value="noScale" /><param name="FlashVars" value="path=' + file + '" /><embed src="../share/js/files/flvplayer.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="540" height="380" salign="TL" scale="noScale" FlashVars="path=' + file + '"></embed></object>';
	}else if(strFileTail == "mov"){
		strHtml = '<script type="text/javascript"><!--act_x(\'<object type="video/quicktime" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="540" height="420">\');// --></script><param name="src" value="' + file + '" /><param name="autoplay" value="true" /><param name="controller" value="true" /><param name="enablejavascript" value="true" /><embed src="' + file + '" autoplay="true" pluginspage="http://www.apple.com/quicktime/download/" width="540" height="420"></embed></object>';
	}else{
		strHtml = '<img src="' + file + '" alt="photo" width="' + w + '" height="' + h + '" />';
	}

	if(strHtml){
		document.getElementById('MainImage').innerHTML = strHtml;
	}

}

///////////////////////////////////////////////////////////
// Func：load tcgakki_items cookie from client
// Trig：function
// Arg：
// Ret：str
///////////////////////////////////////////////////////////
function loadCookie(){
	var strPrevItems = "";
	var arrayCookies = document.cookie.split('; ');
	for(var i = 0; i < arrayCookies.length; i++){
		var arrayCookie = arrayCookies[i].split('=');
		if(arrayCookie[0] == "_tcitem"){
			strPrevItems = unescape(arrayCookie[1]);
		}
	}
	return strPrevItems;
}


///////////////////////////////////////////////////////////
// Func：save tcgakki_items cookie(30days) on client
// Trig：function
// Arg：str
// Ret：
///////////////////////////////////////////////////////////
function saveCookie(strNextItems){

	var cName = "_tcitem";
	var dateExp = new Date();
	dateExp.setDate(dateExp.getDate() + 30); // 30days+;
	strCookie = cName + "=" + escape(strNextItems) + "; path=/; expires=" + dateExp.toGMTString();
	document.cookie = strCookie;

}


///////////////////////////////////////////////////////////
// Func：create reqObj for ajax
// Trig：function
// Arg：
// Ret：RequestObj
///////////////////////////////////////////////////////////
function create_obj(){
	if(window.ActiveXObject){// for win.ie
		try{
			return new ActiveXObject("Msxml2.XMLHTTP");// for msxls2 or more
		}catch(e){
			try{
				return new ActiveXObject("Microsoft.XMLHTTP");// for msxls
			}catch(e2){
				return null;
			}
		}
	}else if(window.XMLHttpRequest){// for other browser that mounts XMLHttpRequest object
		return new XMLHttpRequest();
	}else{
		return null;
	}
}


function naviTest(file){
	var obj = create_obj();
	obj.onreadystatechange = function(){
		if( (obj.readyState == 4) && (obj.status == 200) ){
			document.getElementById('naviTest').innerHTML = obj.responseText;
		}else{
			document.getElementById('naviTest').innerHTML = "wait...";
		}
	}
	if(obj){
		obj.open('GET', '../navigation/' + escape(file) + '.html', true);
		obj.send(null);
	}
}

function columnRowTest(file){
	var obj = create_obj();
	obj.onreadystatechange = function(){
		if( (obj.readyState == 4) && (obj.status == 200) ){
			document.getElementById('columnRowTest').innerHTML = obj.responseText;
		}else{
			document.getElementById('columnRowTest').innerHTML = "wait...";
		}
	}
	if(obj){
		obj.open('GET', '../column_banner_row/' + escape(file) + '.html', true);
		obj.send(null);
	}
}

function columnColTest(file){
	var obj = create_obj();
	obj.onreadystatechange = function(){
		if( (obj.readyState == 4) && (obj.status == 200) ){
			document.getElementById('columnColTest').innerHTML = obj.responseText;
		}else{
			document.getElementById('columnColTest').innerHTML = "wait...";
		}
	}
	if(obj){
		obj.open('GET', '/column_banner_col/' + escape(file) + '.html', true);
		obj.send(null);
	}
}


function sendcp(url){
	var cp = document.getElementById('cp').value;
	var obj = create_obj();
	obj.onreadystatechange = function(){
		if( (obj.readyState == 4) && (obj.status == 200) ){
			document.getElementById('ccco').innerHTML = obj.responseText;
		}else{
			document.getElementById('ccco').innerHTML = "wait...";
		}
	}
	if(obj){
		obj.open('GET', url + '?md=ajaxcp&cp=' + escape(cp), true);
		obj.send(null);
	}
}


