var qstr=location.search;
qstr = qstr.replace(/^\?/,'');
var query = new Array();
var arr = qstr.split("&");
for(var i = 0; i < arr.length; i++){
	var str = arr[i].split('=');
	var key = str[0];
	var val = str[1];
	if(key != ''){
		query[key] = val;
	}
}
var id1="";
var id2="";
if(typeof(query['id'])!='undefined'){
	var id_arr=query['id'].split('/');
	id1=id_arr[0];
	if(typeof(id_arr[1])!='undefined') id2=id_arr[1];
	genCookieValue(query['id']);
	location.replace(location.pathname);
}
if(checkTCVCookie('tcv_temp')){
	var c_array=getTCVCookie('tcv_temp').split('/');
	id1=c_array[0];
	if(typeof(c_array[1])!='undefined') id2=c_array[1];
}
// Embed TCV SWF-----------------------------------
function embedTCVSwf(swf_path,width,height,wmode,xml_path){
	var wmode_at="";
	var minfo=moonPhase(shougo)+","+getSunInfo('rise')+","+getSunInfo('set');
	var fv_id="";
	if(id1!="") fv_id+="&id1="+id1;
	if(id2!=""||id2!="null") fv_id+="&id2="+id2;
	if(typeof(wmode)!='undefined'&&wmode!='') wmode_at=' wmode=\"'+wmode+'\"';
	document.write('<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"'+width+'\" height=\"'+height+'\" align=\"middle\" />');
	document.write('<param name=\"allowScriptAccess\" value=\"sameDomain\" />');
	document.write('<param name=\"movie\" value=\"'+swf_path+'\" />');
	document.write('<param name=\"quality\" value=\"high\" />');
	document.write('<param name=\"bgcolor\" value=\"#ffffff\" />');
	if(typeof(wmode)!='undefined'&&wmode!='') document.write('<param name=\"wmode" value=\"'+wmode+'\" />');
	document.write('<param name=\"FlashVars" value=\"xmlurl='+xml_path+'&minfo='+minfo+fv_id+'\" />');
	document.write('<embed src=\"'+swf_path+'\" quality=\"high\" bgcolor=\"#ffffff\"'+wmode_at+' width=\"'+width+'\" height=\"'+height+'\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" FlashVars=\"xmlurl='+xml_path+'&minfo='+minfo+fv_id+'" />');
	document.write('</object>');
}
function genCookieValue(id){
	setTCVCookie('tcv_temp',id);
}

function checkTCVCookie(val){
	var check = getTCVCookie(val);
	return (check != '' ? true : false);
}
function setTCVCookie(name, str){
		var expires="";
		window.document.cookie = name + "=" + str +expires+ ";domain="+location.hostname+";path=/";
	return;
}
function getTCVCookie(name){
	var cookieStr = document.cookie;
	var existNum = cookieStr.indexOf(name);
	if(existNum != -1){
		start = existNum + name.length + 1;
		end = cookieStr.indexOf(";" , start);
		if(end == -1){
			end = cookieStr.length;
		}
		var cookieValue = cookieStr.substring(start,end);
		return cookieValue;
	}else{
		return "";
	}
}
