// printf(format, ...);
function printf() {
  document.write(va_sprintf(printf.arguments));
}

// str = sprintf(format, ...);
function sprintf() {
  return va_sprintf(sprintf.arguments);
}

function va_sprintf(args) {
  var ch;
  var value;
  var longflag;
  var ljust;
  var len, llen;
  var zpad;
  var p;
  var output;
  var format_index, arg_index;
  var argc, argv;
  var specin;
  var format;

  output = '';
  format_index = 0;
  arg_index = 1;
  argv = args;
  argc = args.length;
  format = args[0];

  while (format_index < format.length) {
    ch = format.substr(format_index++, 1);
    if (ch != '%' || format_index == format.length) {
      output += ch;
    } else {
      // ch == '%'
      ljust = len = zpad = longflag = 0;
      llen = -1;
      p = format_index;
      specin = true;

      while (specin) {
	ch = format.substr(format_index++, 1);
	switch(ch) {
	case '-':
	  ljust = 1;
          continue;

	case '0':         // set zero padding if len not set
	  if(len == 0)
	    zpad = 1;
	  // FALLTHROUGH
	case '1': case '2': case '3':
	case '4': case '5': case '6':
	case '7': case '8': case '9':
	  len = len * 10 + parseInt(ch);
	  continue;

	case '.':
	  llen = len;
	  len = 0;
	  continue;

	case '*':
	  if (arg_index < argc)
	    len = parseInt(argv[arg_index++]);
	  else
	    len = 0;
	  if (len < 0) {
	    ljust = 1;
	    len = -len;
	  }
	  continue;

	case 'l':
	  longflag = 1;
	  continue;

	case 'u': case 'U':
	  if (arg_index < argc) {
	    if (longflag) {
	      value = parseInt(argv[arg_index++]);
	    } else {
	      value = parseInt(argv[arg_index++]);
	      value %= 4294967296;
	    }
	  } else {
	    value = 0;
	  }
	  output += _dopr_fmtnum(value, 10,0, ljust, len, zpad);
	  break;

	case 'o': case 'O':
	  if (arg_index < argc) {
	    if (longflag) {
	      value = parseInt(argv[arg_index++]);
	    } else {
	      value = parseInt(argv[arg_index++]);
	      value %= 4294967296;
	    }
	  } else {
	    value = 0;
	  }
	  output += _dopr_fmtnum(value, 8,0, ljust, len, zpad);
	  break;

	case 'd': case 'D':
	  if (arg_index < argc) {
	    if (longflag) {
	      value = parseInt(argv[arg_index++]);
	    } else {
	      value = parseInt(argv[arg_index++]);
	      value %= 4294967296;
	    }
	  } else {
	    value = 0;
	  }
	  output += _dopr_fmtnum(value, 10,1, ljust, len, zpad);
	  break;

	case 'x':
	  if (arg_index < argc) {
	    if (longflag) {
	      value = parseInt(argv[arg_index++]);
	    } else {
	      value = parseInt(argv[arg_index++]);
	      value %= 4294967296;
	    }
	  } else {
	    value = 0;
	  }
	  output += _dopr_fmtnum(value, 16,0, ljust, len, zpad);
	  break;

	case 'X':
	  if (arg_index < argc) {
	    if (longflag) {
	      value = parseInt(argv[arg_index++]);
	    } else {
	      value = parseInt(argv[arg_index++]);
	      value %= 4294967296;
	    }
	  } else {
	    value = 0;
	  }
	  output += _dopr_fmtnum(value, -16,0, ljust, len, zpad);
	  break;

	case 's':
	  if (arg_index < argc) {
	    value = argv[arg_index++];
	    if(value == null)
	      value = "(null)";
	    else
	      value = value + "";	// toString
	  } else {
	    value = '';
	  }
	  output += _dopr_fmtstr(value, ljust, len, llen);
	  break;

	case 'c':
	  if (arg_index < argc) {
	    value = parseInt(argv[arg_index++]);
	  } else {
	    value = 0;
	  }
	  output += _dopr_fromCharCode(value);
	  break;

	case '%':
	  output += '%';
	  break;

/* Not supported
	case 'f': case 'e': case 'E': case 'g': case 'G':
	  if (arg_index < argc) {
	    value = argv[arg_index++];
	  } else {
	    value = 0.0;
	  }
	  output += _dopr_fmtdouble(format.substr(p, format_index - p), value);
	  break;
*/

	default:
	  if(p + 1 == format_index) {
	    output += '%';
	    output += ch;
	  }
	  else {
	    // alert("format error: " + format);
	  }
	  break;
	}
	specin = false;
      }
    }
  }
  return output;
}

// Private function
function _dopr_fmtnum(value, base, dosign, ljust, len, zpad)
{
  var signvalue = '';
  var uvalue;
  var place = 0;
  var padlen;		// amount to pad
  var caps = 0;
  var convert;
  var output;

  convert = '';
  output = '';

  if(value >= 0)
    uvalue = value;
  else
    uvalue = (value % 4294967296) + 4294967296;

  if (dosign) {
    if (value < 0) {
      signvalue = '-';
      uvalue = -value;
    }
  }

  if (base < 0) {
    caps = 1;
    base = -base;
  }

  if(uvalue == 0) {
    convert = '0';
    place = 1;
  } else {
    while (uvalue) {
      if(caps)
	convert = '0123456789ABCDEF'.substr(uvalue % base, 1) + convert;
      else
	convert = '0123456789abcdef'.substr(uvalue % base, 1) + convert;
      uvalue = parseInt(uvalue / base);
      place++;
    }
  }

  padlen = len - place;
  if (padlen < 0) padlen = 0;
  if (ljust) padlen = -padlen;

  if (zpad && padlen > 0) {
    if(signvalue) {
      output += signvalue;
      --padlen;
      signvalue = 0;
    }

    while (padlen > 0) {
      output += '0';
      --padlen;
    }
  }

  while (padlen > 0) {
    output += ' ';
    --padlen;
  }
  if (signvalue) {
    output += signvalue;
  }

  output += convert;
        
  while(padlen < 0) {
    output += ' ';
    ++padlen;
  }
  return output;
}

// Private function
function _dopr_fmtstr(value, ljust, field_len, llen)
{
  var padlen;			// amount to pad
  var slen, truncstr = 0;
  var output = '';

  slen = value.length;

  if (llen != -1) {
    var rlen;

    rlen = field_len;
    if (slen > rlen) {
      truncstr = 1;
      slen = rlen;
    }
    field_len = llen;
  }
  padlen = field_len - slen;
        
  if (padlen < 0)
    padlen = 0;
  if (ljust)
    padlen = -padlen;
  while (padlen > 0) {
    output += ' ';
    --padlen;
  }
  if (truncstr) {
    output += value.substr(0, slen);
  } else {
    output += value;
  }

  while (padlen < 0) {
    output += ' ';
    ++padlen;
  }
  return output;
}

// Private function
var _dopr_fromCharCode_chars = null;
function _dopr_fromCharCode(code)
{
  if(String.fromCharCode)
    return String.fromCharCode(code);
  if(!_dopr_fromCharCode_chars)
    _dopr_fromCharCode_chars =
      "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020" +
      "\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !\"#$%&" +
      "'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghi" +
      "jklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211" +
      "\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232" +
      "\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253" +
      "\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274" +
      "\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315" +
      "\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336" +
      "\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357" +
      "\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377";
  if(code < 0)
    return "";
  if(code <= 255)
    return _dopr_fromCharCode_chars.substr(code, 1);
  return eval(sprintf("\"\\u%04x\"", code));
}

function MakeCloud(centerX,centerY)
{
	var maxWidth = 18;
	var w = audience.length;
	if( w > maxWidth )
	{
		w = maxWidth;
	}
	var h = Math.floor((audience.length-1)/maxWidth)+1;
	

	var fileName = '';
	var randX = 0;
	var randY = 0;
	var posX = 0;
	var posY = 0;
	var offsetX = 0;
	var imageWidth = 32;
	var imageHeight = 64;
	var cloudHTML = '';
	var cloudCount = 0;
	var altName = '';

	document.getElementById('cloudArea').style.height = (imageHeight+((h-1)*(imageHeight/4))+8)+'px';

	for(var y=0; y < h; y++ )
	{
		for( var x=0; x < w; x++ )
		{
			var nickname = audience[cloudCount][1];
			if( nickname == '' )
			{
				nickname = 'ゲスト';
			}
			nickname += 'さん';

			randX = (imageWidth/6) - Math.floor( Math.random() * (imageWidth/3) );
			randY = (imageHeight/16) - Math.floor( Math.random() * (imageHeight/8) );
			if( y%2 == 0 )
			{
				offsetX = -(imageWidth/4);
			}
			else
			{
				offsetX = (imageWidth/4);
			}

			if( audience[cloudCount][2] == '' )
			{
				if( myID == audience[cloudCount][0] )
				{
					fileName = 'man-mine';
					altName = '自分ですｗ';
				}
				else if( createrID == audience[cloudCount][0] )
				{
					fileName = 'man-comment';
					altName = '私がこの場所の名付け親の';
					altName += nickname;
					altName += 'です。';
				}
				else
				{
					fileName = 'man';
					altName = nickname;
				}
				posX = centerX-(w*imageWidth/2)+(imageWidth*x)+randX+offsetX;
				posY = centerY+(y*(imageHeight/4))+randY;
			}
			else
			{
				if( myID == audience[cloudCount][0] )
				{
  				fileName = 'man-talk-mine';
					altName = '自分ですｗ';
				}
				else if( createrID == audience[cloudCount][0] )
				{
  				fileName = 'man-talk-comment';
					altName = '私がこの場所の名付け親の';
					altName += nickname;
					altName += 'です。';
				}
				else
				{
					fileName = 'man-talk';
					altName = nickname;
				}

				posX = centerX-(w*imageWidth/2)+(imageWidth*x)+randX+offsetX-4;
				posY = centerY+(y*(imageHeight/4))+randY;
				var tmp2HTML = '';
				tmpHTML = sprintf('<a href="member%d.html">',audience[cloudCount][0]);
				cloudHTML += tmpHTML;
				tmp2HTML = sprintf('<img id="cloudFace%08d" ',audience[cloudCount][0]);
				cloudHTML += tmp2HTML;
				tmp2HTML = sprintf('src="/img/face/%08d/%08d/face%08d.jpg" alt="%s" style="position: absolute;',(Math.floor(audience[cloudCount][0]/10000)+1)*10000,(Math.floor((audience[cloudCount][0]%10000)/100)+1)*100,audience[cloudCount][0],altName);
				cloudHTML += tmp2HTML;
				tmp2HTML = sprintf('left: %dpx; top: %dpx; width:30px; height:30px; z-index: %d;" /></a>',posX+5,posY+6,cloudCount*2+1);
				cloudHTML += tmp2HTML;
			}
			var tmpHTML = '';
			tmpHTML = sprintf('<a href="member%d.html">',audience[cloudCount][0]);
			cloudHTML += tmpHTML;
			tmpHTML = sprintf('<img id="cloud%08d" ',audience[cloudCount][0]);
			cloudHTML += tmpHTML;
			tmpHTML = sprintf('src="/img/%s.gif" alt="%s" style="position: absolute;',fileName,altName);
			cloudHTML += tmpHTML;
			tmpHTML = sprintf('left: %dpx; top: %dpx; z-index: %d;" /></a>',posX,posY,cloudCount*2);
			cloudHTML += tmpHTML;
			cloudCount++;
			if( audience.length == cloudCount )
			{
			  document.getElementById('cloudArea').innerHTML = cloudHTML;
			  return;
			}
		}
  }
  document.getElementById('cloudArea').innerHTML = cloudHTML;
}

function checkFormData(data,data2)
{
	if(data.value != data2.value)
	{
		alert('確認用のデータが異なります！');
		return false;
	}
	return true;
}

function ckFormData2(formObject)
{
	if( (formObject.tit.value == '') && (formObject.come.value == '') )
	{
		alert("名前とコメントを記入してください");
		return false;
	}
	if( formObject.come.value == '' )
	{
		alert("コメントを記入してください");
		return false;
	}
	if( formObject.tit.value == '' )
	{
		alert("名前を記入してください");
		return false;
	}
}

function ckFormData(formObject)
{
	if( 1 == formObject.cnt.value )
	{
		if( (formObject.tit00.value == '') && (formObject.locid00.value == '-1')  )
		{
			alert("スポット01にタイトルを設定してください");
			return false;
		}
	}
	else
	{
		for( i = 0; i < formObject.cnt.value; i++ )
		{
			if( (document.getElementById(sprintf("tit%02d",i)).value == '') && (document.getElementById(sprintf("locid%02d",i)).value == '-1') )
			{
				alert(sprintf("スポット%02dにタイトルを設定してください",(i+1)));
				return false;
			}
		}
		if( formObject.title.value == '' )
		{
			alert("ルートにタイトルを設定してください");
			return false;
		}
	}
}
function setFormData(formObject)
{
	formObject.max.value = currentX;
	formObject.may.value = currentY;
	formObject.yaw.value = currentYaw;
	formObject.pit.value = currentPit;
	formObject.zom.value = currentZom;
}

function setFormData2(formObject)
{
	formObject.max.value = currentX;
	formObject.may.value = currentY;
	formObject.yaw.value = currentYaw;
	formObject.pit.value = currentPit;
	formObject.zom.value = currentZom;

	if( InfoList[0]['drawCnt'] )
	{
		formObject.drawcnt00.value = InfoList[0]['drawCnt'];
		var tmpDrawData = '';
		for( var k = 0; k < InfoList[0]['drawCnt']; k++ )
		{
			tmpDrawData += sprintf("%s:%d:%d,",InfoList[0]['drawList'][k]['mode'],
																				InfoList[0]['drawList'][k]['x'],
																				InfoList[0]['drawList'][k]['y']);
		}
		formObject.drawlist00.value = tmpDrawData;
	}
	else
	{
		formObject.drawcnt00.value = 0;
		formObject.drawlist00.value = "";
	}
}
var gKey = '';
var polylinecount = 0;
var previewcount = 0;
var panoClient;
var polyline = new Array();
var myPano;
var map;
var marker;
var iniX;
var iniY;
var iniPlace = '';

var nextTitle = '';
var moveMode = 0;
var recMode = 0;
var POVList = new Array();
var InfoList = new Array();
var PreviewList = new Array();
var IniVertex = new Array();
var timerID = -1;
var arroundURL;
var elem = new Array();
var iniData = new Array();
var iniDataCounter=0;

var drawEvent = new Array();
var drawEventSw = 0;
var drawEventIndex = 0;

var iniZoom = 17;
var currentX;
var currentY;
var nextX;
var nextY;
var currentYaw;
var currentPit;
var currentZom;
var alreadyPOV = 0;

var panoW = 0;
var panoH = 0;
var panoUrl = '';

var myID;
var createrID;

var funcSearch;

var animtimerID = -1;
var animPOVList = new Array(3);
var animCounter = 0;

var animtimerID2 = -1;
var animCounter2 = 0;

var dummyID = -1;

var isIE = false;
var isLDown = false;

var spoticon;

var MarkerList = new Array();

var loopSw = 0;

function ClearMarkers()
{
	for(var i = 0; i < MarkerList.length; i++)
	{
		if( MarkerList[i] )
		{
			if( $('map') ){map.removeOverlay(MarkerList[i]);}
			MarkerList[i] = null;
		}
	}
}
function createMarker(point,uid,title,id,yaw,pitch,zoom)
{
	var marker = new GMarker(point,spoticon);
	GEvent.addListener(marker, "click", function()
	{
		currentYaw = yaw;
		currentPit = pitch;
		currentZom = zoom;
		alreadyPOV = 1;
		ClearPanoDrawing();
		moveMode = 0;
		MovePointWithCheck(marker.getLatLng());
		nextTitle = title;
  });
	GEvent.addListener(marker, "mouseover", function()
	{
	});

  return marker;
}
function AddMarker(x,y,uid,title,id,yaw,pitch,zoom)
{
	var marker = createMarker(new GLatLng(x,y),uid,title,id,yaw,pitch,zoom);
	if( $('map') ){map.addOverlay(marker);}
	MarkerList.push(marker);
}

function createMarker2(point,uid,title,id,photo,nickname)
{
	var marker2 = new GMarker(point,spoticon);
	GEvent.addListener(marker2, "click", function mkcl2()
	{
		if( panoW == 440 )
		{
			var tmpSrc = '';
			tmpSrc += '<table>';
			tmpSrc += '<tr>';
			tmpSrc += '<td>';
			tmpSrc += '<a href="'+sprintf('http://navitte.jp/location%d.html',id)+'">';
			tmpSrc += '「'+title+'」の掲示板';
			tmpSrc += '</a>';
			tmpSrc += '</td>';
			tmpSrc += '</tr>';
			tmpSrc += '</table>';
			marker2.openInfoWindowHtml(tmpSrc);
		}
		else
		{
			document.location=sprintf('http://navitte.jp/location%d.html',id);
		}
  });

  return marker2;
}
function AddMarker2(x,y,uid,title,id,photo,nickname)
{
	var mk2 = createMarker2(new GLatLng(x,y),uid,title,id,photo,nickname);
	if( $('map') ){map.addOverlay(mk2);}
	MarkerList.push(mk2);
}

function createMarker3(point,title,id,photo)
{
	if( id == '-1' )
	{
		var marker3 = new GMarker(point,spoticon2);
	}
	else if( id == '-2' )
	{
		var marker3 = new GMarker(point,spoticon3);
	}
	else
	{
		var marker3 = new GMarker(point,spoticon4);
	}

	GEvent.addListener(marker3, "click", function mkcl3()
	{
		if( panoW == 440 )
		{
			var tmpSrc = '';
			tmpSrc += '<table>';
			tmpSrc += '<tr>';
			tmpSrc += '<td>';
			tmpSrc += '<a href="'+sprintf('http://navitte.jp/location.php?max=%s&may=%s&yaw=%s&pit=%s&zom=%s&tit=%s',marker3.getLatLng().lat(),marker3.getLatLng().lng(),currentYaw,currentPit,currentZom,title)+'">';
			tmpSrc += title;
			tmpSrc += '</a>';
			tmpSrc += '</td>';
			tmpSrc += '</tr>';
			if( photo )
			{
				tmpSrc += '<tr>';
				tmpSrc += '<td>';
				tmpSrc += '<a href="'+sprintf('http://navitte.jp/location.php?max=%s&may=%s&yaw=%s&pit=%s&zom=%s&tit=%s',marker3.getLatLng().lat(),marker3.getLatLng().lng(),currentYaw,currentPit,currentZom,title)+'">';
				tmpSrc += '<img src="'+photo+'" onload="if(this.width>this.height){this.width=120;}else{this.height=120;}" />';
				tmpSrc += '</a>';
				tmpSrc += '</td>';
				tmpSrc += '</tr>';
			}
			tmpSrc += '</table>';
			marker3.openInfoWindowHtml(tmpSrc);
		}
		else
		{
			document.location=sprintf('http://navitte.jp/location.php?max=%s&may=%s&yaw=%s&pit=%s&zom=%s&tit=%s',marker3.getLatLng().lat(),marker3.getLatLng().lng(),currentYaw,currentPit,currentZom,title);
		}
  });
	GEvent.addListener(marker3, "mouseover", function()
	{
	});

  return marker3;
}
function AddMarker3(x,y,title,id,photo)
{
	var mk3 = createMarker3(new GLatLng(x,y),title,id,photo);
	if( $('map') ){map.addOverlay(mk3);}
	MarkerList.push(mk3);
}


function UploadCurrentData()
{
	var tmpSrc = '';
	
	if( 1 == polylinecount )
	{
		POVList[0] = {yaw:currentYaw,pitch:currentPit,zoom:currentZom};
	}

	polylineDistance = 0;
	for( i = 0; i < polylinecount; i++ )
	{
		tmpSrc += sprintf('<input type="hidden" name="max%02d" value="%s" />',i,polyline[i].getVertex(1).lat());
		tmpSrc += sprintf('<input type="hidden" name="may%02d" value="%s" />',i,polyline[i].getVertex(1).lng());
		tmpSrc += sprintf('<input type="hidden" name="yaw%02d" value="%s" />',i,POVList[i]['yaw']);
		tmpSrc += sprintf('<input type="hidden" name="pit%02d" value="%s" />',i,POVList[i]['pitch']);
		tmpSrc += sprintf('<input type="hidden" name="zom%02d" value="%s" />',i,POVList[i]['zoom']);
		tmpSrc += sprintf('<input type="hidden" name="tit%02d" value="%s" />',i,((InfoList[i])?InfoList[i]['title']:''));
		tmpSrc += sprintf('<input type="hidden" name="comment%02d" value="%s" />',i,((InfoList[i])?InfoList[i]['comment']:''));
		if( InfoList[i]['drawCnt'] )
		{
			tmpSrc += sprintf('<input type="hidden" name="drawcnt%02d" value="%d" />',i,InfoList[i]['drawCnt']);
			var tmpDrawData = '';
			for( var k = 0; k < InfoList[i]['drawCnt']; k++ )
			{
				tmpDrawData += sprintf("%s:%d:%d,",InfoList[i]['drawList'][k]['mode'],
																					InfoList[i]['drawList'][k]['x'],
																					InfoList[i]['drawList'][k]['y']);
			}
			tmpSrc += sprintf('<input type="hidden" name="drawlist%02d" value="%s" />',i,tmpDrawData);
		}
		else
		{
			tmpSrc += sprintf('<input type="hidden" name="drawcnt%02d" value="%d" />',i,'0');
			tmpSrc += sprintf('<input type="hidden" name="drawlist%02d" value="" />',i);
		}
		polylineDistance += polyline[i].getLength();
	}
	tmpSrc += sprintf('<input type="hidden" name="distance" value="%d" />',polylineDistance);
	tmpSrc += sprintf('<input type="hidden" name="user" value="%s" />',myID);
	tmpSrc += sprintf('<input type="hidden" name="cnt" value="%s" />',polylinecount);
	tmpSrc += '<input id="uploadRouteButton" type="submit" style="visibility:hidden;" />';
	if(document.getElementById('uploadRouteFormDiv')){document.getElementById('uploadRouteFormDiv').innerHTML = tmpSrc;}
	if(document.getElementById('uploadRouteForm')){document.getElementById('uploadRouteForm').onSubmit = "";}
	if(document.getElementById('uploadRouteForm')){document.getElementById('uploadRouteForm').submit();}
}


function insertNewSpot(latlngData)
{
	if( recMode == 1 )
	{
		DisplayArroundData(latlngData.lat(),latlngData.lng(),'add','addPointArea3');		
	}
	else
	{
		DisplayArroundData(latlngData.lat(),latlngData.lng(),'link','addPointArea3');
	}
}

var last_x = 0;
var last_y = 0;

function DisplayArroundData(x,y,type,id)
{
	if( loopSw == 1 )
	{
		return;
	}
	if( ((last_x == 0) && (last_y == 0)) || ((last_x != x) && (last_y != y)) || (type == 'user') )
	{
//		if( (((((last_x-x)*256)*((last_x-x)*256))+(((last_y-y)*256)*((last_y-y)*256))) > 0.559943778) || (type == 'user') )
		if( 
				(type == 'user')
				||
				(
					(last_x-0.002923 > x) ||
					(last_x+0.002923 < x) ||
					(last_y-0.002923 > y) ||
					(last_y+0.002923 < y) 
				)
		)
		{//近場のリロードを禁止
			last_x = x;
			last_y = y;
			if( $(id) )
			{
				var of = new Ajax.Updater(
					id,
					sprintf("%s/arround.php",arroundURL),
					{
						method:'get',
						parameters:sprintf("&max=%s&may=%s&type=%s&uid=%s&rnd=%d",x,y,type,myID,Math.floor(Math.random()*1024*1024)),
						insertion:Insertion.Top,
						evalScripts:true,
						onSuccess: function(request){
							$(id).innerHTML = '';
//						alert('DisplayArroundData:'+id+' x:'+x+' y:'+y+' last_x:'+last_x+' last_y:'+last_y);
							ClearMarkers();
						}
					}
				);
			}
		}
		else
		{
//			alert(((((last_x-x)*256)*((last_x-x)*256))+(((last_y-y)*256)*((last_y-y)*256))));
		}
	}
}

function DeleteSpotCore()
{
	if( 2 > polylinecount )
	{
		return;
	}

	if( $('map') ){map.removeOverlay(polyline[previewcount-1]);}

	for( var i = previewcount-1; i < polylinecount-1; i++ )
	{
		POVList[i]  = POVList[i+1];
		InfoList[i] = InfoList[i+1];
		if( i == previewcount-1 )
		{
			var points = [];
			if( i == 0 )
			{
				points[0] = polyline[i+1].getVertex(1);
			}
			else
			{
				points[0] = polyline[i].getVertex(0);
			}
			points[1] = polyline[i+1].getVertex(1);
			if( $('map') ){map.removeOverlay(polyline[i+1]);}
			polyline[i] = new GPolyline(points,'#0000FF',5,0.7);
			if( $('map') ){map.addOverlay(polyline[i]);}
		}
		else
		{
			polyline[i] = polyline[i+1];
		}
	}

	polylinecount--;
	if( previewcount == 1 )
	{
		previewcount = 1;
	}
	else
	{
		previewcount--;
	}

	MovePointWithCheck(polyline[previewcount-1].getVertex(1));

	SetProp();

/*
	if( window['externalInterface2'] && isIE )
	{
		window['externalInterface2'].setMessage(InfoList[previewcount-1]['comment'],sprintf('「%s」',InfoList[previewcount-1]['title']),sprintf('http://navitte.jp/location%d.html',InfoList[previewcount-1]['id']));
	}
	else if( document['externalInterface2'] )
	{
		document['externalInterface2'].setMessage(InfoList[previewcount-1]['comment'],sprintf('「%s」',InfoList[previewcount-1]['title']),sprintf('http://navitte.jp/location%d.html',InfoList[previewcount-1]['id']));
	}

	if( recMode == 1 )
	{
		LoadDrawCommands();
	}
	else
	{
		LoadDrawCommands2();
	}
*/
}

function SetProp()
{
	if( $('routeList') )
	{
		var tmpSrc1 = '<div class="routeHead">ルート通過スポット</div>';
		for( var i = 0; i < polylinecount; i++ )
		{
			if( i == (previewcount-1) )
			{
				tmpSrc1 += '<div class="routeItem spot_active">';
			}
			else
			{
				tmpSrc1 += '<div class="routeItem">';
			}
			tmpSrc1 += sprintf('<a id="spot%s" onclick="spotClick(this);return false" href="/#spot%s">%s</a>',i+1,i+1,GetPropTitle(InfoList[i]['title']));
			tmpSrc1 += '</div>';
		}
		document.getElementById('routeList').innerHTML = tmpSrc1;
	}
}

function AddSpotCore(title,x,y,yaw,pitch,zoom)
{
	if( polylinecount >= 19 )
	{
		alert("ルート保存のスポットは19ヵ所までです");
		return;
	}

	if( title == '' )
	{
		title = sprintf("通過点%d",polylinecount+1);
	}

	var addPoint = new GLatLng(x,y);

	moveMode = 0;

	var points = [];
	points[0] = polyline[polylinecount-1].getVertex(1);
	points[1] = addPoint;
	polyline[polylinecount] = new GPolyline(points,'#0000FF',5,0.7);
	if( $('map') ){map.addOverlay(polyline[polylinecount]);}

	polylinecount++;
	previewcount = polylinecount;

	currentYaw = yaw;
	currentPit = pitch;
	currentZom = zoom;

	POVList[polylinecount-1] = {yaw:currentYaw,pitch:currentPit,zoom:currentZom};
	InfoList[previewcount-1] = {title:title,comment:sprintf('コメント%02d',previewcount),drawCnt:0}
	LoadDrawCommands();

	if(elem['tcTitle']){elem['tcTitle'].value = title;}
	if(elem['tcComment']){elem['tcComment'].value =  sprintf('コメント%02d',previewcount);}

	SetProp();

	currentX = x;
	currentY = y;
	if( $('map') ){map.panTo(addPoint);marker.setLatLng(addPoint);}
	myPano.setLocationAndPOV(addPoint, POVList[polylinecount-1]);

	var distance = GetCurrentDistance();
	if(elem['tcDistance']){elem['tcDistance'].value = sprintf("歩いた距離：%dm",distance);}
	if(elem['tcSpotNum']){elem['tcSpotNum'].value = sprintf("通過点：%dヵ所",polylinecount);}
	if(elem['tcAverage']){elem['tcAverage'].value = sprintf("平均移動距離：%dm",distance/(polylinecount-1));}

	DisplayArroundData(addPoint.lat(),addPoint.lng(),'add','addPointArea3');
}

function AddSpot(id,x,y,yaw,pitch,zoom)
{
	currentYaw = yaw;
	currentPit = pitch;
	currentZom = zoom;
	alreadyPOV = 1;
	ClearPanoDrawing();
	moveMode = 0;
	MovePointWithCheck(new GLatLng(x,y));

	nextTitle = $('addspotText'+id).innerHTML;
}

function spotClick(obj)
{
	var tmpStr = String(obj.id);
	tmpStr = tmpStr.replace("spot","");
	moveMode = 1;
	previewcount = parseInt(tmpStr);
	MovePointWithCheck(polyline[previewcount-1].getVertex(1));
	if( window['externalInterface2'] && isIE )
	{
		window['externalInterface2'].setMessage(InfoList[previewcount-1]['comment'],sprintf('「%s」',InfoList[previewcount-1]['title']),sprintf('http://navitte.jp/location%d.html',InfoList[previewcount-1]['id']));
	}
	else if( document['externalInterface2'] )
	{
		document['externalInterface2'].setMessage(InfoList[previewcount-1]['comment'],sprintf('「%s」',InfoList[previewcount-1]['title']),sprintf('http://navitte.jp/location%d.html',InfoList[previewcount-1]['id']));
	}
	if(recMode==1)
	{
		LoadDrawCommands();
		if( !isIE )
		{
			$('topconsole2').style.visibility='visible';
			$('topconsole3').style.visibility='visible';
		}
		if(document.getElementById('tcViewStart'))
		{
			document.getElementById('tcViewStart').src="/img/view-start.gif";
		}
		OptionPanelOpen();
	}
	else
	{
		LoadDrawCommands2();
	}

	SetProp();
}

function resetListData()
{
//	moveMode = 1;
}

function startListData(latlngData)
{
	moveMode = 0;

	var points = [];
	points[0] = latlngData;
	points[1] = latlngData;
	polyline[0] = new GPolyline(points,'#0000FF',5,0.7);
	if( $('map') ){map.addOverlay(polyline[0]);}

	polylinecount = 1;
	previewcount = 1;

	if( InfoList[previewcount-1] )
	{
		if( InfoList[previewcount-1]['title'] == '' )
		{
			if(elem['tcTitle']){elem['tcTitle'].value = '出発地点';}
			InfoList[previewcount-1]['title'] = '出発地点';
			InfoList[previewcount-1]['comment'] = '出発地点です';
		}
		else
		{
			if(elem['tcTitle']){elem['tcTitle'].value = InfoList[previewcount-1]['title'];}
			InfoList[previewcount-1]['comment'] = '出発地点です';
		}
	}
	else
	{
		InfoList[previewcount-1] = new Array();
		InfoList[previewcount-1]['title'] = '出発地点';
		InfoList[previewcount-1]['comment'] = '出発地点です';
//		if(elem['tcTitle']){elem['tcTitle'].value = sprintf('タイトル%02d',previewcount);}
		if(elem['tcTitle']){elem['tcTitle'].value = '出発地点';}
	}
	if(elem['tcComment']){elem['tcComment'].value = '出発地点です';}
	InfoList[previewcount-1]['drawCnt'] = 0;

	SetProp();
}

function GetPropTitle(title)
{
/*
	if( title.length > 5)
	{
		title = title.substr(0, 4) + '…' ;
	}
*/
	return(title);
}

function GetCurrentDistance()
{
	var distance = 0;
	for( var i = 0; i < polylinecount; i++ )
	{
		distance += polyline[i].getLength();
	}
	return distance;
}

function OptionPanelClose()
{
	if( $('drawconsole2').style.visibility == 'hidden' )
	{
		return;
	}

	if( !InfoList[previewcount-1] ){InfoList[previewcount-1]=new Array();}
	InfoList[previewcount-1]['title'] = elem['tcTitle'].value;
	InfoList[previewcount-1]['comment']=elem['tcComment'].value;

	if(document.getElementById('tcSaveTip')){document.getElementById('tcSaveTip').src="/img/draw-end_a.gif";}

	SetProp();

	POVList[previewcount-1] = {yaw:currentYaw,pitch:currentPit,zoom:currentZom};

	if( !isIE )
	{
//		$('topconsole2').style.visibility='visible';
//		$('topconsole3').style.visibility='visible';
	}
	if(document.getElementById('tcViewStart')){document.getElementById('tcViewStart').src="/img/view-start.gif";}
	if(document.getElementById('tcViewEnd')){document.getElementById('tcViewEnd').src="/img/draw-end_a.gif";}

	EndDrawing();

	if(document.getElementById('tcDrawStart')){document.getElementById('tcDrawStart').src="/img/draw-start.gif";}
	if(document.getElementById('tcDrawEnd')){document.getElementById('tcDrawEnd').src="/img/draw-end_a.gif";}
	if(document.getElementById('tcDrawClear')){document.getElementById('tcDrawClear').src="/img/draw-clear_a.gif";}
	if(document.getElementById('tcDrawCol00')){document.getElementById('tcDrawCol00').src="/img/draw-c_a.gif";}
	if(document.getElementById('tcDrawCol01')){document.getElementById('tcDrawCol01').src="/img/draw-c_a.gif";}
	if(document.getElementById('tcDrawCol02')){document.getElementById('tcDrawCol02').src="/img/draw-c_a.gif";}
	if(document.getElementById('tcDrawCol03')){document.getElementById('tcDrawCol03').src="/img/draw-c_a.gif";}
	if(document.getElementById('tcDrawCol04')){document.getElementById('tcDrawCol04').src="/img/draw-c_a.gif";}
	if(document.getElementById('tcDrawCol05')){document.getElementById('tcDrawCol05').src="/img/draw-c_a.gif";}
	if(document.getElementById('tcDrawCol06')){document.getElementById('tcDrawCol06').src="/img/draw-c_a.gif";}
	if(document.getElementById('tcDrawCol07')){document.getElementById('tcDrawCol07').src="/img/draw-c_a.gif";}

	$('tcTitle').style.visibility  ='hidden';
	$('tcComment').style.visibility='hidden';
	$('tcSaveTip').style.visibility='hidden';
	$('option1').style.visibility  ='hidden';
	$('option2').style.visibility  ='hidden';
	$('option3').style.visibility  ='hidden';
	$('drawconsole2').style.visibility  ='hidden';

}
function OptionPanelOpen()
{
	$('tcTitle').style.visibility  ='visible';
	$('tcComment').style.visibility='visible';
	$('tcSaveTip').style.visibility='visible';
	$('option1').style.visibility  ='visible';
	$('option2').style.visibility  ='visible';
	$('option3').style.visibility  ='visible';
	$('drawconsole2').style.visibility  ='visible';
}

function CheckPanel(latlng)
{
	if( 1 == recMode )
	{
		var ontheline = 0;
		for( var i = 0; i < polylinecount; i++ )
		{
			if( (polyline[i].getVertex(1).lat() == latlng.lat()) && (polyline[i].getVertex(1).lng() == latlng.lng()) )
			{
				ontheline = 1;
			}
		}
		if( ontheline == 0 )
		{
			OptionPanelClose();
		}
	}
}

function movePoint(latlng,svFlag)
{
	CheckPanel(latlng);
	
	if( (iniX != latlng.lat()) || (iniY != latlng.lng()) )
	{
		insertNewSpot(latlng);

		if( alreadyPOV == 0 )
		{
			currentYaw = GetYawFrom2PT(latlng,new GLatLng(currentX,currentY));
			currentPit = 0;
			currentZom = 0;
		}
		else
		{
			alreadyPOV = 0;
		}


		if( iniPlace != '' )
		{
			if( $('map') ){map.setZoom(17);}
			iniPlace = '';
			if( $('map') ){map.panTo(latlng);}
		}
		else
		{
			if( $('map') ){map.panTo(latlng);}
		}
		if( $('map') ){marker.setLatLng(latlng);}

		if( moveMode == 0 )
		{
			if( svFlag == 1 )
			{
				POV = {yaw:currentYaw,pitch:currentPit,zoom:currentZom};
				myPano.setLocationAndPOV(latlng, POV);
			}
		}
		else
		{
			if( svFlag == 1 )
			{
				if( (1 < previewcount) && (previewcount <polylinecount) )
				{
					StartAnimation(polyline[previewcount-2].getVertex(1),latlng,POVList[previewcount-1],polyline[previewcount].getVertex(1));
				}
				else if( (previewcount == 1) && (previewcount <polylinecount) )
				{
					StartAnimation(0,latlng,POVList[previewcount-1],polyline[previewcount].getVertex(1));
				}
				else if( (1 < previewcount) && (previewcount == polylinecount) )
				{
					StartAnimation(polyline[previewcount-2].getVertex(1),latlng,POVList[previewcount-1],0);
				}
				else
				{
					myPano.setLocationAndPOV(latlng, POVList[previewcount-1]);//ムーブモードの開始
				}
			}

			if(elem['tcTitle']){elem['tcTitle'].value = ((InfoList[previewcount-1]['title']!='')?InfoList[previewcount-1]['title']:sprintf('タイトル%02d',previewcount));}
			if(elem['tcComment']){elem['tcComment'].value =  ((InfoList[previewcount-1]['comment']!='')?InfoList[previewcount-1]['comment']:sprintf('コメント%02d',previewcount));}
			if( recMode == 1 )
			{
				if(document.getElementById('tcSaveTip')){document.getElementById('tcSaveTip').src="/img/draw-end_a.gif";}
			}
		}
		currentX = latlng.lat();
		currentY = latlng.lng();

		if( 1 < polylinecount )
		{
			var distance = GetCurrentDistance();
			if(elem['tcDistance']){elem['tcDistance'].value = sprintf("歩いた距離：%dm",distance);}
			if(elem['tcSpotNum']){elem['tcSpotNum'].value = sprintf("通過点：%dヵ所",polylinecount);}
			if(elem['tcAverage']){elem['tcAverage'].value = sprintf("平均移動距離：%dm",distance/(polylinecount-1));}
		}
		else
		{
			if(elem['tcDistance']){elem['tcDistance'].value = sprintf("歩いた距離：%dm",0);}
			if(elem['tcSpotNum']){elem['tcSpotNum'].value = sprintf("通過点：%dヵ所",1);}
			if(elem['tcAverage']){elem['tcAverage'].value = sprintf("平均移動距離：%dm",0);}
		}
	}
	else
	{
		if( 1 < polylinecount )
		{
			var distance = GetCurrentDistance();
			if(elem['tcDistance']){elem['tcDistance'].value = sprintf("歩いた距離：%dm",distance);}
			if(elem['tcSpotNum']){elem['tcSpotNum'].value = sprintf("通過点：%dヵ所",polylinecount);}
			if(elem['tcAverage']){elem['tcAverage'].value = sprintf("平均移動距離：%dm",distance/(polylinecount-1));}
		}
		else
		{
			if(elem['tcDistance']){elem['tcDistance'].value = sprintf("歩いた距離：%dm",0);}
			if(elem['tcSpotNum']){elem['tcSpotNum'].value = sprintf("通過点：%dヵ所",1);}
			if(elem['tcAverage']){elem['tcAverage'].value = sprintf("平均移動距離：%dm",0);}
		}

		if( $('map') ){map.panTo(latlng);marker.setLatLng(latlng);}

		if( moveMode == 0 )
		{
			if( svFlag == 1 )
			{
				POV = {yaw:currentYaw,pitch:currentPit,zoom:currentZom};
				myPano.setLocationAndPOV(latlng, POV);
			}
		}
		else
		{
			if( svFlag == 1 )
			{
				if( (1 < previewcount) && (previewcount <polylinecount) )
				{
					StartAnimation(polyline[previewcount-2].getVertex(1),latlng,POVList[previewcount-1],polyline[previewcount].getVertex(1));
				}
				else if( (previewcount == 1) && (previewcount <polylinecount) )
				{
					StartAnimation(0,latlng,POVList[previewcount-1],polyline[previewcount].getVertex(1));
				}
				else if( (1 < previewcount) && (previewcount == polylinecount) )
				{
					StartAnimation(polyline[previewcount-2].getVertex(1),latlng,POVList[previewcount-1],0);
				}
				else
				{
					myPano.setLocationAndPOV(latlng, POVList[previewcount-1]);//ムーブモードの開始
				}
			}
			if(elem['tcTitle']){elem['tcTitle'].value = ((InfoList[previewcount-1]['title']!='')?InfoList[previewcount-1]['title']:sprintf('タイトル%02d',previewcount));}
			if(elem['tcComment']){elem['tcComment'].value =  ((InfoList[previewcount-1]['comment']!='')?InfoList[previewcount-1]['comment']:sprintf('コメント%02d',previewcount));}
			if( recMode == 1 )
			{
				if(document.getElementById('tcSaveTip')){document.getElementById('tcSaveTip').src="/img/draw-end_a.gif";}
			}
		}
		currentX = latlng.lat();
		currentY = latlng.lng();
	}
}

function showPanoData(panoData)
{
	if (panoData.code != 200)
	{
		if (panoData.code == 600) {// 未対応エリアのエラー処理
			strTmp = '<div id="errorDiv" style="width:100%;text-align:center;">';
			if( panoUrl != '' )
			{
				strTmp += sprintf('<img src="%s" height="%s" border="0">',panoUrl,panoH-16);
				strTmp += '<br />※Googleマップ・ストリートビュー未対応地域のため投稿画像を表示しています';
			}
			else
			{
				strTmp += sprintf('<img src="http://maps.google.com/staticmap?center=%s,%s&size=%sx%s&zoom=19&markers=%s,%s,blue&key=%s" border="0">',nextX,nextY,panoW,panoH-16,nextX,nextY,gKey);
				strTmp += '<br />※Googleマップ・ストリートビュー未対応地域のため詳細地図を表示しています';
			}
			strTmp += '</div>';
			document.getElementById('pano').innerHTML = strTmp;
			movePoint(new GLatLng(nextX,nextY),0);
		}
	}
	else
	{
		if(document.getElementById('errorDiv')){document.getElementById('errorDiv').style.visibility='hidden';document.getElementById('errorDiv').style.height=0;document.getElementById('errorDiv').outerHTML = '';}
		movePoint(panoData.location.latlng,1);
	}
}

function showPanoDataSimple(panoData)
{
	if (panoData.code != 200)
	{
		if (panoData.code == 600) {// 未対応エリアのエラー処理
			strTmp = '<div id="errorDiv" style="width:100%;text-align:center;">';
			if( panoUrl != '' )
			{
				strTmp += sprintf('<img src="%s" height="%s" border="0">',panoUrl,panoH-16);
				strTmp += '<br />※Googleマップ・ストリートビュー未対応地域のため投稿画像を表示しています';
			}
			else
			{
				strTmp += sprintf('<img src="http://maps.google.com/staticmap?center=%s,%s&size=%sx%s&zoom=19&markers=%s,%s,blue&key=%s" border="0">',nextX,nextY,panoW,panoH-16,nextX,nextY,gKey);
				strTmp += '<br />※Googleマップ・ストリートビュー未対応地域のため詳細地図を表示しています';
			}
			strTmp += '</div>';
			document.getElementById('pano').innerHTML = strTmp;
		}
	}
	else
	{
		if(document.getElementById('errorDiv')){document.getElementById('errorDiv').style.visibility='hidden';document.getElementById('errorDiv').style.height=0;document.getElementById('errorDiv').outerHTML = '';}
		POV = {yaw:currentYaw,pitch:currentPit,zoom:currentZom};
		myPano.setLocationAndPOV(panoData.location.latlng, POV);
	}
}

function MovePointWithCheck(point)
{
	if( point )
	{
		nextX = point.lat();
		nextY = point.lng();
	}
	panoClient.getNearestPanorama(point, showPanoData);
}

function CleanMap()
{
	if( $('map') )
	{
		var base = document.getElementById("map"); 
		var objs = base.getElementsByTagName("span"); 
		for(var i=0;i<objs.length;i++) 
		{ 
			if(objs[i].innerHTML.match("ZENRIN"))
			{
				var strTmp = objs[i].innerHTML;
				strTmp += '<br />';
				objs[i].innerHTML = strTmp;
//			objs[i].style.overflow='hidden'; 
			}
		}
	}
}


function mapload(x,y)
{

	if ( !window.opera && navigator.userAgent.indexOf('MSIE') != -1 ) {
	    isIE = true;
	}

	iniX = x;
	iniY = y;
	if (GBrowserIsCompatible())
	{
		elem['tcDistance'] = document.getElementById('tcDistance');
		elem['tcSpotNum']  = document.getElementById('tcSpotNum');
		elem['tcAverage']  = document.getElementById('tcAverage');
		elem['tcTitle']    = document.getElementById('tcTitle');
		elem['tcComment']  = document.getElementById('tcComment');
		elem['tcSaveTip']  = document.getElementById('tcSaveTip');

		var POV = {yaw:currentYaw,pitch:currentPit,zoom:currentZom};

		var point = new GLatLng(x,y);
		if( $('map') )
		{
			map = new GMap2(document.getElementById("map"));
			map.setCenter(new GLatLng(x,y), iniZoom);
			map.addControl(new GSmallMapControl());
			if( panoW == 440 )
			{
				map.addControl( new GMapTypeControl() );
			}
			map.setMapType(G_NORMAL_MAP);
//		map.setMapType(G_HYBRID_TYPE);

			GMap2.prototype.wheelZoom = function(event) {
				if (event.cancelable) event.preventDefault();
				if ((event.detail || -event.wheelDelta) < 0) {
					map.zoomIn();
				}else{
					map.zoomOut();
				}
				return false;
			}

			GEvent.addDomListener(document.getElementById("map"), "DOMMouseScroll", map.wheelZoom);
			GEvent.addDomListener(document.getElementById("map"), "mousewheel", map.wheelZoom);

			var myicon = new GIcon();
			myicon.image=sprintf('/img/face/%08d/%08d/face%08d.jpg',(Math.floor(myID/10000)+1)*10000,(Math.floor((myID%10000)/100)+1)*100,myID);
			myicon.shadow="/img/man-mine.gif";
			myicon.iconSize = new GSize(30,30);
			myicon.shadowSize = new GSize(30,64);
			myicon.iconAnchor = new GPoint(15,64);
			myicon.infoWindowAnchor = new GPoint(15,4);
//		myicon.transparent = "";

			spoticon = new GIcon();
			spoticon.image="";
			spoticon.shadow="/img/map-spot.gif";
			spoticon.iconSize = new GSize(28,28);
			spoticon.shadowSize = new GSize(30,44);
			spoticon.iconAnchor = new GPoint(9,43);
			spoticon.infoWindowAnchor = new GPoint(15,15);

			spoticon2 = new GIcon();
			spoticon2.image="";
			spoticon2.shadow="/img/map-spot2.gif";
			spoticon2.iconSize = new GSize(18,18);
			spoticon2.shadowSize = new GSize(20,28);
			spoticon2.iconAnchor = new GPoint(6,28);
			spoticon2.infoWindowAnchor = new GPoint(10,10);

			spoticon3 = new GIcon();
			spoticon3.image="";
			spoticon3.shadow="/img/map-spot3.gif";
			spoticon3.iconSize = new GSize(18,18);
			spoticon3.shadowSize = new GSize(20,28);
			spoticon3.iconAnchor = new GPoint(6,28);
			spoticon3.infoWindowAnchor = new GPoint(10,10);

			spoticon4 = new GIcon();
			spoticon4.image="";
			spoticon4.shadow="/img/map-spot4.gif";
			spoticon4.iconSize = new GSize(18,18);
			spoticon4.shadowSize = new GSize(20,28);
			spoticon4.iconAnchor = new GPoint(6,28);
			spoticon4.infoWindowAnchor = new GPoint(10,10);


			marker = new GMarker(point,myicon);
			map.addOverlay(marker);
		}

		moveMode = 0;
		if( recMode == 1 )
		{
			startListData(point);
			if(elem['tcDistance']){elem['tcDistance'].value = sprintf("歩いた距離：%dm",0);}
			if(elem['tcSpotNum']){elem['tcSpotNum'].value = sprintf("通過点：%dヵ所",1);}
			if(elem['tcAverage']){elem['tcAverage'].value = sprintf("平均移動距離：%dm",0);}

			if(elem['tcDistance']){elem['tcDistance'].style.visibility = 'visible';}
			if(elem['tcSpotNum']) {elem['tcSpotNum'].style.visibility = 'visible';}
			if(elem['tcAverage']) {elem['tcAverage'].style.visibility = 'visible';}
			if(elem['tcTitle'])	 {elem['tcTitle'].style.visibility = 'visible';}
			if(elem['tcComment']) {elem['tcComment'].style.visibility = 'visible';}
			if(elem['tcSaveTip']) {elem['tcSaveTip'].style.visibility = 'visible';}
			DisplayArroundData(point.lat(),point.lng(),'add','addPointArea3');
			DisplayArroundData(point.lat(),point.lng(),'user','addPointArea4');
			if( !isIE )
			{
				$('topconsole2').style.visibility='hidden';
				$('topconsole3').style.visibility='hidden';
			}
		}
		else
		{
			if( 0 != polylinecount )
			{
				moveMode = 1;
				previewcount = 1;

				tmpSrc1 = '';
				tmpSrc2 = '';
				for( i = 0; i < polylinecount; i++ )
				{
					if( i == 0 )
					{
						var points = [];
						points[0] = point;
						points[1] = point;
						polyline[0] = new GPolyline(points,'#0000FF',5,0.7);
					}
					else
					{
						var points = [];
						points[0] = polyline[i-1].getVertex(1);
						points[1] = new GLatLng(IniVertex[i]['x'],IniVertex[i]['y']);
						polyline[i] = new GPolyline(points,'#0000FF',5,0.7);
					}
					if( $('map') ){map.addOverlay(polyline[i]);}
				}
				SetProp();

				if(elem['tcTitle']){elem['tcTitle'].value = InfoList[0]['title'];}
				if(elem['tcComment']){elem['tcComment'].value =  InfoList[0]['comment'];}

				var distance = GetCurrentDistance();
				if(elem['tcDistance']){elem['tcDistance'].value = sprintf("歩いた距離：%dm",distance);}
				if(elem['tcSpotNum']){elem['tcSpotNum'].value = sprintf("通過点：%dヵ所",polylinecount);}
				if(elem['tcAverage']){elem['tcAverage'].value = sprintf("平均移動距離：%dm",distance/(polylinecount-1));}
				
				if( loopSw == 0 )
				{
					if( $('tcPlay') )
					{
						document.getElementById('tcPlay').src="/img/tc_pause.gif";
					}
					previewcount = 0;
					timerID = setInterval('myTimerFunc()', 2000);
				}
			}
			else
			{
				if( iniData.length != 0 )
				{
					if( window['externalInterface2'] && isIE )
					{
						window['externalInterface2'].setMessage(sprintf('「%s」',iniData[0]['comment']),iniData[0]['nickname'],iniData[0]['id']);
					}
					else if( document['externalInterface2'] )
					{
						document['externalInterface2'].setMessage(sprintf('「%s」',iniData[0]['comment']),iniData[0]['nickname'],iniData[0]['id']);
					}
					if( 1 != iniData.length )
					{
						iniDataCounter = 1;
						timerID = setInterval('myTimerFunc2()', 8000);
					}
				}
				if( PreviewList[0] )
				{
					previewcount=1;
					LoadDrawCommands2();
				}
				else if( (InfoList[0]) && (InfoList[0]['drawCnt']) && (InfoList[0]['drawCnt'] != 0) )
				{
					previewcount=1;
					LoadDrawCommands();
					if( !isIE )
					{
						$('topconsole2').style.visibility='hidden';
						$('topconsole3').style.visibility='hidden';
					}
				}
			}
//			DisplayArroundData(point.lat(),point.lng(),'link','addPointArea3');
		}

		panoClient = new GStreetviewClient();  

		var geocoder = new GClientGeocoder();

		function moveAddress(address){
			iniPlace=address;
			nextTitle = address;
  		geocoder.getLatLng(address, showMap);
		}
		
		funcSearch = moveAddress;

		function showMap(latlng){

			if (latlng)
			{
				moveMode = 0;
				ClearPanoDrawing();
				moveMode = 0;
				MovePointWithCheck(latlng);
  		}
  		else
  		{
    		alert("住所から緯度経度に変換できませんでした");
				iniPlace='';
  		}
		}

		if( $('map') )
		{
			GEvent.addListener(map, "click", function(overlay,point)
			{
				ClearPanoDrawing();
				moveMode = 0;
				MovePointWithCheck(point);
			});
			GEvent.addListener(marker, "click", function()
			{
			});
			GEvent.addListener(marker, "mouseover", function ()
			{
			});
		}
		

		var streetViewId = "pano";// ストリートビューを表示するHTMLのid名
		myPano = new GStreetviewPanorama(document.getElementById(streetViewId));
		
		GEvent.addListener(myPano, "error",function (errorCode)
		{
			if (errorCode == 600) {// 未対応エリアのエラー処理
				strTmp = '<div id="errorDiv" style="width:100%;text-align:center;">';
				if( panoUrl != '' )
				{
					strTmp += sprintf('<img src="%s" height="%s" border="0">',panoUrl,panoH-16);
					strTmp += '<br />※Googleマップ・ストリートビュー未対応地域のため投稿画像を表示しています';
				}
				else
				{
					strTmp += sprintf('<img src="http://maps.google.com/staticmap?center=%s,%s&size=%sx%s&zoom=19&markers=%s,%s,blue&key=%s" border="0">',currentX,currentY,panoW,panoH-16,currentX,currentY,gKey);
					strTmp += '<br />※Googleマップ・ストリートビュー未対応地域のため詳細地図を表示しています';
				}
				strTmp += '</div>';
				document.getElementById('pano').innerHTML = strTmp;
				return;
			}
			if (errorCode == FLASH_UNAVAILABLE)
			{
				document.getElementById(streetViewId).innerHTML = '<p style="color:red;">お使いのブラウザがFlashに対応していないためGoogleマップ・ストリートビューを表示できません。</p>';
				return;
			}
		});

		GEvent.addListener(myPano, "initialized", function(loc)
		{
			CheckPanel(loc.latlng);

			ClearPanoDrawing();

			if( $('map') ){map.panTo(loc.latlng);marker.setLatLng(loc.latlng);}

  		currentX = loc.latlng.lat();
			currentY = loc.latlng.lng();
			insertNewSpot(loc.latlng)


/*
  		if( (x != loc.latlng.lat()) || (y != loc.latlng.lng()) )
  		{
				moveMode = 0;
				insertNewSpot(loc.latlng)
				var distance = GetCurrentDistance();
				if(elem['tcDistance']){elem['tcDistance'].value = sprintf("歩いた距離：%dm",distance);}
				if(elem['tcSpotNum']){elem['tcSpotNum'].value = sprintf("通過点：%dヵ所",polylinecount);}
				if( 1 < polylinecount )
				{
					if(elem['tcAverage']){elem['tcAverage'].value = sprintf("平均移動距離：%dm",distance/(polylinecount-1));}
				}
			}
*/			
		});

		if( iniPlace == '' )
		{
			nextX = point.lat();
			nextY = point.lng();
			panoClient.getNearestPanorama(point, showPanoDataSimple);
		}

		GEvent.addListener(myPano, "yawchanged", function(yaw)
		{
			currentYaw=yaw;
			if( recMode == 1 )
			{
				if( (POVList[previewcount-1]['yaw'] != currentYaw) && 
						(polyline[previewcount-1].getVertex(1).lat()==currentX) && 
						(polyline[previewcount-1].getVertex(1).lng()==currentY)  )
				{
					if(document.getElementById('tcViewEnd'))
					{
						document.getElementById('tcViewEnd').src="/img/draw-end.gif";
					}
				}
				else if( (POVList[previewcount-1]['yaw'] == currentYaw) && 
						(polyline[previewcount-1].getVertex(1).lat()==currentX) && 
						(polyline[previewcount-1].getVertex(1).lng()==currentY)  )
				{
					if(document.getElementById('tcViewEnd'))
					{
						document.getElementById('tcViewEnd').src="/img/draw-end_a.gif";
					}
				}
			}
		});
		GEvent.addListener(myPano, "pitchchanged", function(pitch)
		{
			currentPit=pitch;
			if( recMode == 1 )
			{
				if( (POVList[previewcount-1]['pitch'] != currentPit) &&
						(polyline[previewcount-1].getVertex(1).lat()==currentX) && 
						(polyline[previewcount-1].getVertex(1).lng()==currentY)  )
				{
					if(document.getElementById('tcViewEnd'))
					{
						document.getElementById('tcViewEnd').src="/img/draw-end.gif";
					}
				}
				else if( (POVList[previewcount-1]['pitch'] == currentPit) &&
						(polyline[previewcount-1].getVertex(1).lat()==currentX) && 
						(polyline[previewcount-1].getVertex(1).lng()==currentY)  )
				{
					if(document.getElementById('tcViewEnd'))
					{
						document.getElementById('tcViewEnd').src="/img/draw-end_a.gif";
					}
				}
			}
		});
		GEvent.addListener(myPano, "zoomchanged", function(zoom)
		{
			currentZom=zoom;
			if( recMode == 1 )
			{
				if( (POVList[previewcount-1]['zoom'] != currentZom) &&
						(polyline[previewcount-1].getVertex(1).lat()==currentX) && 
						(polyline[previewcount-1].getVertex(1).lng()==currentY)  )
				{
					if(document.getElementById('tcViewEnd'))
					{
						document.getElementById('tcViewEnd').src="/img/draw-end.gif";
					}
				}
				else if( (POVList[previewcount-1]['zoom'] == currentZom) &&
						(polyline[previewcount-1].getVertex(1).lat()==currentX) && 
						(polyline[previewcount-1].getVertex(1).lng()==currentY)  )
				{
					if(document.getElementById('tcViewEnd'))
					{
						document.getElementById('tcViewEnd').src="/img/draw-end.gif";
					}
				}
			}
		});

		dummyID = setInterval('myTimerFunc4()', 2000);
	}
}


function tcMouseover(imgObj)
{
	if( imgObj.id.substring(0,10) == 'tcNewRoute' )
	{
		if(document.getElementById(imgObj.id)){document.getElementById(imgObj.id).src="/img/newroute_a.png";}
		return;
	}
	if( imgObj.id.substring(0,9) == 'tcNewDraw' )
	{
		if(document.getElementById(imgObj.id)){document.getElementById(imgObj.id).src="/img/newdraw_a.gif";}
		return;
	}
	switch(imgObj.id)
	{
		case 'tcRec'  :
										document.getElementById(imgObj.id).src="/img/tc_rec_a.gif";break;
		case 'tcDel'  :
										document.getElementById(imgObj.id).src="/img/tc_del_a.gif";break;
		case 'tcPrev' :document.getElementById(imgObj.id).src="/img/tc_prev_a.gif";break;
		case 'tcPlay' :
										if( -1 != timerID )
										{
											document.getElementById(imgObj.id).src="/img/tc_pause_a.gif";
										}
										else
										{
											document.getElementById(imgObj.id).src="/img/tc_play_a.gif";
										}
										break;
		case 'tcStop' :document.getElementById(imgObj.id).src="/img/tc_stop_a.gif";break;
		case 'tcNext' :document.getElementById(imgObj.id).src="/img/tc_next_a.gif";break;
		case 'tcSaveTip' :document.getElementById(imgObj.id).src="/img/tc_save_a.gif";break;
		case 'tcCS' :document.getElementById(imgObj.id).src="/img/createspot_a.gif";break;
		case 'tcCR' :document.getElementById(imgObj.id).src="/img/createroute_a.gif";break;
		case 'tcSearch' :document.getElementById(imgObj.id).src="/img/search_a.gif";break;
		case 'tcBack' :document.getElementById(imgObj.id).src="/img/backhome2_a.gif";break;
		case 'tcBack2' :document.getElementById(imgObj.id).src="/img/backhome2_a.gif";break;
		case 'tcMapSearch' :document.getElementById(imgObj.id).src="/img/mapsearch_a.gif";break;
		case 'tcHeadTop' :document.getElementById(imgObj.id).src="/img/head-top_a.gif";break;
		case 'tcHeadMy' :document.getElementById(imgObj.id).src="/img/head-my_a.gif";break;
		case 'tcHeadRank' :document.getElementById(imgObj.id).src="/img/head-rank_a.gif";break;
		case 'tcHeadNew' :document.getElementById(imgObj.id).src="/img/head-new_a.gif";break;
		case 'tcHeadLogin' :document.getElementById(imgObj.id).src="/img/head-login_a.gif";break;
		case 'tcHeadHelp' :document.getElementById(imgObj.id).src="/img/head-help_a.gif";break;
		case 'tcHeadAbout' :document.getElementById(imgObj.id).src="/img/head-about_a.gif";break;
		case 'tcHeadReg' :document.getElementById(imgObj.id).src="/img/head-reg_a.gif";break;
		case 'tcHeadLogout' :document.getElementById(imgObj.id).src="/img/head-logout_a.gif";break;
		default:break;
	}
//	document.body.style.cursor = "hand";
}
function tcMouseout(imgObj)
{
	if( imgObj.id.substring(0,10) == 'tcNewRoute' )
	{
		document.getElementById(imgObj.id).src="/img/newroute.png";
		return;
	}
	if( imgObj.id.substring(0,9) == 'tcNewDraw' )
	{
		document.getElementById(imgObj.id).src="/img/newdraw.gif";
		return;
	}
	switch(imgObj.id)
	{
		case 'tcRec'  :
										document.getElementById(imgObj.id).src="/img/tc_rec.gif";
										break;
		case 'tcDel'  :
										document.getElementById(imgObj.id).src="/img/tc_del.gif";
										break;
		case 'tcPrev' :document.getElementById(imgObj.id).src="/img/tc_prev.gif";break;
		case 'tcPlay' :
										if( -1 != timerID )
										{
											document.getElementById(imgObj.id).src="/img/tc_pause.gif";
										}
										else
										{
											document.getElementById(imgObj.id).src="/img/tc_play.gif";
										}
										break;
		case 'tcStop' :document.getElementById(imgObj.id).src="/img/tc_stop.gif";break;
		case 'tcNext' :document.getElementById(imgObj.id).src="/img/tc_next.gif";break;
		case 'tcSaveTip' :document.getElementById(imgObj.id).src="/img/tc_save.gif";break;
		case 'tcCS' :document.getElementById(imgObj.id).src="/img/createspot.gif";break;
		case 'tcCR' :document.getElementById(imgObj.id).src="/img/createroute.gif";break;
		case 'tcBack' :document.getElementById(imgObj.id).src="/img/backhome2.gif";break;
		case 'tcBack2' :document.getElementById(imgObj.id).src="/img/backhome2.gif";break;
		case 'tcSearch' :document.getElementById(imgObj.id).src="/img/search.gif";break;
		case 'tcMapSearch' :document.getElementById(imgObj.id).src="/img/mapsearch.gif";break;
		case 'tcHeadTop' :document.getElementById(imgObj.id).src="/img/head-top.gif";break;
		case 'tcHeadMy' :document.getElementById(imgObj.id).src="/img/head-my.gif";break;
		case 'tcHeadRank' :document.getElementById(imgObj.id).src="/img/head-rank.gif";break;
		case 'tcHeadNew' :document.getElementById(imgObj.id).src="/img/head-new.gif";break;
		case 'tcHeadLogin' :document.getElementById(imgObj.id).src="/img/head-login.gif";break;
		case 'tcHeadHelp' :document.getElementById(imgObj.id).src="/img/head-help.gif";break;
		case 'tcHeadAbout' :document.getElementById(imgObj.id).src="/img/head-about.gif";break;
		case 'tcHeadReg' :document.getElementById(imgObj.id).src="/img/head-reg.gif";break;
		case 'tcHeadLogout' :document.getElementById(imgObj.id).src="/img/head-logout.gif";break;
		default:break;
	}
//	document.body.style.cursor = "default";
}
function tcMousedown(imgObj)
{
	if( imgObj.id.substring(0,9) == 'tcNewDraw' )
	{
		if(document.getElementById(imgObj.id)){document.getElementById(imgObj.id).src="/img/newdraw_p.gif";}
		return;
	}
	switch(imgObj.id)
	{
		case 'tcRec'  :document.getElementById(imgObj.id).src="/img/tc_rec_p.gif";break;
		case 'tcDel'  :document.getElementById(imgObj.id).src="/img/tc_del_p.gif";break;
		case 'tcPrev' :document.getElementById(imgObj.id).src="/img/tc_prev_p.gif";break;
		case 'tcPlay' :
										if( -1 != timerID )
										{
											document.getElementById(imgObj.id).src="/img/tc_pause_p.gif";
										}
										else
										{
											document.getElementById(imgObj.id).src="/img/tc_play_p.gif";
										}
										break;
		case 'tcStop' :document.getElementById(imgObj.id).src="/img/tc_stop_p.gif";break;
		case 'tcNext' :document.getElementById(imgObj.id).src="/img/tc_next_p.gif";break;
		case 'tcSaveTip' :document.getElementById(imgObj.id).src="/img/tc_save_p.gif";break;
		case 'tcCS' :document.getElementById(imgObj.id).src="/img/createspot_p.gif";break;
		case 'tcCR' :document.getElementById(imgObj.id).src="/img/createroute_p.gif";break;
		case 'tcSearch' :document.getElementById(imgObj.id).src="/img/search_p.gif";break;
		case 'tcMapSearch' :document.getElementById(imgObj.id).src="/img/mapsearch_p.gif";break;
		case 'tcBack' :document.getElementById(imgObj.id).src="/img/backhome2_p.gif";break;
		case 'tcBack2' :document.getElementById(imgObj.id).src="/img/backhome2_p.gif";break;
		default:break;
	}
//	document.body.style.cursor = "default";
}
function tcMouseup(imgObj)
{
	if( imgObj.id.substring(0,9) == 'tcNewDraw' )
	{
		if(document.getElementById(imgObj.id)){document.getElementById(imgObj.id).src="/img/newdraw_a.gif";}
		return;
	}
	switch(imgObj.id)
	{
		case 'tcRec'  :document.getElementById(imgObj.id).src="/img/tc_rec_a.gif";break;
		case 'tcDel'  :document.getElementById(imgObj.id).src="/img/tc_del_a.gif";break;
		case 'tcPrev' :document.getElementById(imgObj.id).src="/img/tc_prev_a.gif";break;
		case 'tcPlay' :
										if( -1 != timerID )
										{
											document.getElementById(imgObj.id).src="/img/tc_pause.gif";
										}
										else
										{
											document.getElementById(imgObj.id).src="/img/tc_play.gif";
										}
										break;
		case 'tcStop' :document.getElementById(imgObj.id).src="/img/tc_stop_a.gif";break;
		case 'tcNext' :document.getElementById(imgObj.id).src="/img/tc_next_a.gif";break;
		case 'tcSaveTip' :document.getElementById(imgObj.id).src="/img/tc_save_a.gif";break;
		case 'tcCS' :document.getElementById(imgObj.id).src="/img/createspot_a.gif";break;
		case 'tcCR' :document.getElementById(imgObj.id).src="/img/createroute_a.gif";break;
		case 'tcSearch' :document.getElementById(imgObj.id).src="/img/search_a.gif";break;
		case 'tcMapSearch' :document.getElementById(imgObj.id).src="/img/mapsearch_a.gif";break;
		case 'tcBack' :document.getElementById(imgObj.id).src="/img/backhome2_a.gif";break;
		case 'tcBack2' :document.getElementById(imgObj.id).src="/img/backhome2_a.gif";break;
		default:break;
	}
}

function myTimerFunc()
{
	if( previewcount < polylinecount )
	{
		if( 0 == previewcount )
		{
			clearInterval(timerID);
			timerID = setInterval('myTimerFunc()', 8500);
		}
		previewcount++;
	}
	else
	{
		if( loopSw == 0 )
		{
			if(-1 != timerID)
			{
				clearInterval(timerID);
				timerID = -1;
				if( $('tcPlay') )
				{
					document.getElementById('tcPlay').src="/img/tc_play.gif";
				}
			}
			return;
		}
		else
		{
			if(-1 != timerID)
			{
				clearInterval(timerID);
				timerID = -1;
				if( $('tcPlay') )
				{
					document.getElementById('tcPlay').src="/img/tc_play.gif";
					document.getElementById('tcPlay').style.visibility="visible";
				}
			}
			return;
		}
	}

	moveMode = 1;
	MovePointWithCheck(polyline[previewcount-1].getVertex(1));
	if( window['externalInterface2'] && isIE )
	{
		window['externalInterface2'].setMessage(InfoList[previewcount-1]['comment'],sprintf('「%s」',InfoList[previewcount-1]['title']),sprintf('http://navitte.jp/location%d.html',InfoList[previewcount-1]['id']));
	}
	else if( document['externalInterface2'] )
	{
		document['externalInterface2'].setMessage(InfoList[previewcount-1]['comment'],sprintf('「%s」',InfoList[previewcount-1]['title']),sprintf('http://navitte.jp/location%d.html',InfoList[previewcount-1]['id']));
	}
	if( recMode == 1 )
	{
		LoadDrawCommands();
	}
	else
	{
		LoadDrawCommands2();
	}
	SetProp();
}

function myTimerFunc2()
{
	if( window['externalInterface2'] && isIE )
	{
		window['externalInterface2'].setMessage(sprintf('「%s」',iniData[iniDataCounter]['comment']),iniData[iniDataCounter]['nickname'],iniData[iniDataCounter]['id']);
	}
	else if( document['externalInterface2'] )
	{
		document['externalInterface2'].setMessage(sprintf('「%s」',iniData[iniDataCounter]['comment']),iniData[iniDataCounter]['nickname'],iniData[iniDataCounter]['id']);
	}
	iniDataCounter = Math.floor( Math.random() * (iniData.length) )
	if( iniDataCounter == iniData.length )
	{
		iniDataCounter = 0;
	}

//	iniDataCounter++;
//	if( iniData.length == iniDataCounter )
//	{
//		iniDataCounter = 0;
//		clearInterval(timerID);
//		timerID = -1;
//	}
}

function GetYawFrom2PT(toPT,fromPT)
{
	var width = toPT.lat() - fromPT.lat();
	var height = toPT.lng() - fromPT.lng();
	var rad;
	var deg;
	rad = Math.atan2(height, width);
	if (rad > 0 && height < 0)
	{
		rad += -Math.PI;
	}
	else if (rad < 0 && height > 0)
	{
		rad += Math.PI;
	}
	deg = (rad * 180) / Math.PI;
	if( deg < 0 )
	{
		deg += 360;
	}
	return(deg);
}

function loadDrawXml(fileName)
{
	if( window['externalInterface3'] && isIE )
	{
		window['externalInterface3'].loadDrawXml(fileName);
	}
	else if( document['externalInterface3'] )
	{
		document['externalInterface3'].loadDrawXml(fileName);
	}
}

function DrawPanoLine(tx,ty)
{
	if( window['externalInterface3'] && isIE )
	{
		window['externalInterface3'].drawLine(tx,ty);
	}
	else if( document['externalInterface3'] )
	{
		document['externalInterface3'].drawLine(tx,ty);
	}
}
function SetPanoStartPoint(sx,sy)
{
	if( window['externalInterface3'] && isIE )
	{
		window['externalInterface3'].setStartPoint(sx,sy);
	}
	else if( document['externalInterface3'] )
	{
		document['externalInterface3'].setStartPoint(sx,sy);
	}
}
function ClearPanoDrawing()
{
	if( window['externalInterface3'] && isIE )
	{
		window['externalInterface3'].clearView();
	}
	else if( document['externalInterface3'] )
	{
		document['externalInterface3'].clearView();
	}
}

var pencolortbl=new Array(0xFF0000,0x0000FF,0x00FF00,0xFFFF00,0x00FFFF,0xFF00FF,0xFFFFFF,0x000000);

function ChangePanoPenColor(color)
{
	if( window['externalInterface3'] && isIE )
	{
		window['externalInterface3'].setPenColor(pencolortbl[color]);
	}
	else if( document['externalInterface3'] )
	{
		document['externalInterface3'].setPenColor(pencolortbl[color]);
	}
}

function AddDrawCommand(mode,x,y)
{
	drawEvent[drawEventIndex] = new Array();
	drawEvent[drawEventIndex]['mode'] = mode;
	drawEvent[drawEventIndex]['x'] = x;
	drawEvent[drawEventIndex]['y'] = y;
	drawEventIndex++;
}

function SaveDrawCommands()
{
	InfoList[previewcount-1]['drawCnt'] = drawEventIndex;
	InfoList[previewcount-1]['drawList'] = new Array();
	for( i = 0; i < drawEventIndex; i++ )
	{
		InfoList[previewcount-1]['drawList'][i] = new Array();
		InfoList[previewcount-1]['drawList'][i]['mode'] = drawEvent[i]['mode'];
		InfoList[previewcount-1]['drawList'][i]['x'] = drawEvent[i]['x'];
		InfoList[previewcount-1]['drawList'][i]['y'] = drawEvent[i]['y'];
	}
}

function LoadDrawCommands()
{
	if( -1 != animtimerID2 )
	{
		clearInterval(animtimerID2);
		animtimerID2 = -1;
	}
	if( InfoList[previewcount-1]['drawCnt'] )
	{
		if( 0 > InfoList[previewcount-1]['drawCnt'] )
		{
			InfoList[previewcount-1]['drawCnt'] = 0;
			drawEventIndex = 0;
		}
		else
		{
			drawEventIndex = InfoList[previewcount-1]['drawCnt'];
			for( i = 0; i < drawEventIndex; i++ )
			{
				drawEvent[i] = {mode:InfoList[previewcount-1]['drawList'][i]['mode'],x:InfoList[previewcount-1]['drawList'][i]['x'],y:InfoList[previewcount-1]['drawList'][i]['y']};
			}
		}
	}
	else
	{
		InfoList[previewcount-1]['drawCnt'] = 0;
		drawEventIndex = 0;
	}
	UpdateDrawView();
}

function LoadDrawCommands2()
{
	if( -1 != animtimerID2 )
	{
		clearInterval(animtimerID2);
		animtimerID2 = -1;
	}
	ClearPanoDrawing();

	if( PreviewList[previewcount-1] )
	{
		animCounter2 = 0;
		animtimerID2 = setInterval('myTimerFunc6()', 2000);
	}

}

function myTimerFunc6()
{
	if( -1 != animtimerID2 )
	{
		clearInterval(animtimerID2);
		animtimerID2 = -1;
	}
	if( (PreviewList[previewcount-1]) && (PreviewList[previewcount-1] != '') )
	{
		loadDrawXml(PreviewList[previewcount-1]);
	}
}

function myTimerFunc5()
{
	if( -1 != animtimerID2 )
	{
		clearInterval(animtimerID2);
		animtimerID2 = -1;
	}
	if( drawEventIndex <= animCounter2 )
	{
		return;
	}

	for( i = animCounter2; i < drawEventIndex; i++ )
	{
		if( drawEvent[i]['mode'] == 'm' )
		{
			SetPanoStartPoint(drawEvent[i]['x'],drawEvent[i]['y']);
		}
		if( drawEvent[i]['mode'] == 'l' )
		{
			DrawPanoLine(drawEvent[i]['x'],drawEvent[i]['y']);
		}
		if( drawEvent[i]['mode'] == 'p' )
		{
			ChangePanoPenColor(drawEvent[i]['x']);
		}
	}

//	animCounter2++;
//	animtimerID2 = setInterval('myTimerFunc5()',100);
}

function UpdateDrawView()
{
	ClearPanoDrawing();

	if( -1 != animtimerID2 )
	{
		clearInterval(animtimerID2);
		animtimerID2 = -1;
	}
	if( 0 < drawEventIndex )
	{
		animCounter2 = 0;
		animtimerID2 = setInterval('myTimerFunc5()', 2000);
	}

}

function addEvent(element, eventType, fn, useCapture) 
{

	if (element.addEventListener) { // W3C DOM 系 - FireFox ...
	    element.addEventListener(eventType, fn, useCapture);
	    return true;
	}
	else if (element.attachEvent) { // Internet Explorer 系
  	  var r = element.attachEvent('on' + eventType, fn);
    	return r;    
	}
	else {

 	   element['on'+eventType] = fn;

	}    

}

function StartDrawing()
{
	var element = isIE ? $('pano') : $('topconsole3');
	var element2 = isIE ? $('pano') : $('topconsole2');
	
	if( !isIE )
	{
		$('topconsole2').style.visibility='visible';
		$('topconsole3').style.visibility='visible';
	}

	drawEventSw = 1;
	addEvent(element,'mousedown',
	function(ev)
	{
		var t = ev.target ? ev.target : ev.srcElement;
		var e = window.event ? window.event : ev;
		var x0 = e.offsetX ? e.offsetX : e.layerX;
		var y0 = e.offsetY ? e.offsetY : e.layerY;
		if( drawEventSw == 1 )
		{
			isLDown=true;
			SetPanoStartPoint(x0,y0);
			AddDrawCommand('m',x0,y0);
			return false;
		}
	},true);

	addEvent(element,'mousemove',
	function(ev)
	{
		var t = ev.target ? ev.target : ev.srcElement;
		var e = window.event ? window.event : ev;
		var x0 = e.offsetX ? e.offsetX : e.layerX;
		var y0 = e.offsetY ? e.offsetY : e.layerY;
		if( drawEventSw == 1 )
		{
			if( isIE )
			{
				if( isLDown && (e.button == 1) )
				{
//					document.title = sprintf("%s,x:%d,y:%d",t.id,x0,y0);;
					if( (t.id=='externalInterface3') || (t.id=='panoflash1') )
					{
						DrawPanoLine(x0,y0);
						AddDrawCommand('l',x0,y0);
					}
					return false;
				}
			}
			else
			{
				if( isLDown )
				{
					DrawPanoLine(x0,y0);
					AddDrawCommand('l',x0,y0);
					return false;
				}
			}
		}
	},true);
	if( !isIE )
	{
		addEvent(element2,'mousedown',
		function(ev)
		{
			var t = ev.target ? ev.target : ev.srcElement;
			var e = window.event ? window.event : ev;
			var x0 = e.offsetX ? e.offsetX : e.layerX;
			var y0 = e.offsetY ? e.offsetY : e.layerY;
			if( drawEventSw == 1 )
			{
				isLDown=true;
				SetPanoStartPoint(x0,y0);
				AddDrawCommand('m',x0,y0);
				return false;
			}
		},true);

		addEvent(element2,'mousemove',
		function(ev)
		{
			var t = ev.target ? ev.target : ev.srcElement;
			var e = window.event ? window.event : ev;
			var x0 = e.offsetX ? e.offsetX : e.layerX;
			var y0 = e.offsetY ? e.offsetY : e.layerY;
			if( drawEventSw == 1 )
			{
				if( isLDown )
				{
					DrawPanoLine(x0,y0);
					AddDrawCommand('l',x0,y0);
					return false;
				}
			}
		},true);
	}
	addEvent(document,'mouseup',
	function(ev)
	{
		var t = ev.target ? ev.target : ev.srcElement;
		var e = window.event ? window.event : ev;
		if( isIE )
		{
			if( e.button == 1 )
			{
				isLDown=false;
			}
		}
		else
		{
			if( e.button == 0 )
			{
				isLDown=false;
			}
		}
	},true);
}

function EndDrawing()
{
	if( isIE )
	{
		var element = $('pano');
		element.onmousedown='';
		element.onmousemove='';
		document.onmouseup='';
	}
	else
	{
		var element = $('topconsole3');
		var element2 = $('topconsole2');
		element.onmousedown='';
		element.onmousemove='';
		element2.onmousedown='';
		element2.onmousemove='';
		document.onmouseup='';
	}
	drawEventSw = 0;
	SaveDrawCommands();
}

function myTimerFunc4()
{
	CleanMap();
	clearInterval(dummyID);
	if( iniPlace != '' )
	{
		funcSearch(iniPlace);
	}
}

function myTimerFunc3()
{
	if( animCounter == 0 )
	{
		clearInterval(animtimerID);
		animtimerID = -1;
		animtimerID = setInterval('myTimerFunc3()', 5000);
		animCounter = 1;
		myPano.panTo(animPOVList[1]);
	}
	else if( 1 == animCounter )
	{
		clearInterval(animtimerID);
		animtimerID = -1;
		if( -1 != timerID )
		{
			animtimerID = setInterval('myTimerFunc3()', 1500);
			animCounter = 3;
			ClearPanoDrawing();
			myPano.panTo(animPOVList[2]);
		}
	}
	else if( 2 == animCounter )
	{
		clearInterval(animtimerID);
		animtimerID = -1;
		myPano.panTo(animPOVList[1]);
	}
	else if( 3 == animCounter )
	{
		clearInterval(animtimerID);
		animtimerID = -1;
		myPano.followLink(animPOVList[2].yaw);
	}
	else
	{
		if( -1 != animtimerID )
		{
			clearInterval(animtimerID);
			animtimerID = -1;
		}
	}
}

function StartAnimation(prevPT,curPT,curPOV,nextPT)
{
	if( -1 != animtimerID )
	{
		clearInterval(animtimerID);
		animtimerID = -1;
	}

	animCounter = 0;
	if( 0 != prevPT )
	{
		animPOVList[0] = {yaw:GetYawFrom2PT(curPT,prevPT),pitch:0,zoom:0};
	}
	animPOVList[1] = curPOV;
	if( 0 != nextPT )
	{
		animPOVList[2] = {yaw:GetYawFrom2PT(nextPT,curPT),pitch:0,zoom:0};
	}

	if( (0 != prevPT) && (0 != nextPT) )
	{
		myPano.setLocationAndPOV(curPT, animPOVList[0]);
		animCounter = 0;
		animtimerID = setInterval('myTimerFunc3()', 1000);
	}
	else if( (0 == prevPT) && (0 != nextPT) )
	{
		myPano.setLocationAndPOV(curPT, animPOVList[1]);
		animCounter = 1;
		animtimerID = setInterval('myTimerFunc3()', 5000);
	}
	else if( (0 != prevPT) && (0 == nextPT) )
	{
		myPano.setLocationAndPOV(curPT, animPOVList[0]);
		animCounter = 2;
		animtimerID = setInterval('myTimerFunc3()', 1000);
	}
}

function tcChange(imgObj)
{
	switch(imgObj.id)
	{
		case 'tcComment' :
											if(document.getElementById('tcSaveTip')){document.getElementById('tcSaveTip').src="/img/draw-end.gif";}
											break;
		case 'tcTitle'   :
											if(document.getElementById('tcSaveTip')){document.getElementById('tcSaveTip').src="/img/draw-end.gif";}
											break;
	}
}

function tcClick(imgObj)
{
	switch(imgObj.id)
	{
		case 'tcRec'  :
										if(-1 != timerID)
										{
											clearInterval(timerID);
											timerID = -1;
											if(document.getElementById('tcPlay')){document.getElementById('tcPlay').src="/img/tc_play.gif";}
										}
										if( recMode == 1 )
										{
											if( (polyline[previewcount-1].getVertex(1).lat() == currentX) && (polyline[previewcount-1].getVertex(1).lng() == currentY) )
											{
												if( true != confirm(sprintf("このスポット「%s」はすでに通過スポットとして設定されていますが、ビューを変えた通過スポットのために、新たに通過スポット設定しますか？",InfoList[previewcount-1]['title'])) )
												{
													return;
												}
											}
											AddSpotCore(nextTitle,currentX,currentY,currentYaw,currentPit,currentZom);
											nextTitle = '';
											OptionPanelOpen();
										}
										break;
		case 'tcDel'  :
										if(-1 != timerID)
										{
											clearInterval(timerID);
											timerID = -1;
											if(document.getElementById('tcPlay')){document.getElementById('tcPlay').src="/img/tc_play.gif";}
										}
										if( recMode == 1 )
										{
											if( polylinecount == 1 )
											{
												alert("すべてのスポットを削除することはできません。このスポットを削除したい場合は、他の通過スポットを設定してから削除を行ってください");
											}
											else
											{
												if( true == confirm(sprintf("本当にこのスポット「%s」を削除しますか？",InfoList[previewcount-1]['title'])) )
												{
													DeleteSpotCore();
												}
											}
										}
										break;
		case 'tcPrev' :
										if(-1 != timerID)
										{
											clearInterval(timerID);
											timerID = -1;
											document.getElementById('tcPlay').src="/img/tc_play.gif";
										}

										moveMode = 1;

										if( (1 < polylinecount) && (1 < previewcount) )
										{
											previewcount--;
										}
										else
										{
											previewcount = polylinecount;
										}

										MovePointWithCheck(polyline[previewcount-1].getVertex(1));

										if( window['externalInterface2'] && isIE )
										{
											window['externalInterface2'].setMessage(InfoList[previewcount-1]['comment'],sprintf('「%s」',InfoList[previewcount-1]['title']),sprintf('http://navitte.jp/location%d.html',InfoList[previewcount-1]['id']));
										}
										else if( document['externalInterface2'] )
										{
											document['externalInterface2'].setMessage(InfoList[previewcount-1]['comment'],sprintf('「%s」',InfoList[previewcount-1]['title']),sprintf('http://navitte.jp/location%d.html',InfoList[previewcount-1]['id']));
										}

										if( recMode == 1 )
										{
											LoadDrawCommands();
										}
										else
										{
											LoadDrawCommands2();
										}
										SetProp();
										break;
		case 'tcPlay' :
										if( -1 == timerID )
										{
											if( 1 < polylinecount )
											{
												moveMode = 1;
												previewcount = 1;
												MovePointWithCheck(polyline[previewcount-1].getVertex(1));
												if( window['externalInterface2'] && isIE )
												{
													window['externalInterface2'].setMessage(InfoList[previewcount-1]['comment'],sprintf('「%s」',InfoList[previewcount-1]['title']),sprintf('http://navitte.jp/location%d.html',InfoList[previewcount-1]['id']));
												}
												else if( document['externalInterface2'] )
												{
													document['externalInterface2'].setMessage(InfoList[previewcount-1]['comment'],sprintf('「%s」',InfoList[previewcount-1]['title']),sprintf('http://navitte.jp/location%d.html',InfoList[previewcount-1]['id']));
												}
												timerID = setInterval('myTimerFunc()', 8500);
												document.getElementById(imgObj.id).src="/img/tc_pause.gif";
												if( recMode == 1 )
												{
													LoadDrawCommands();
												}
												else
												{
													LoadDrawCommands2();
												}
												SetProp();
												if( !isIE )
												{
													$('topconsole2').style.visibility='visible';
													$('topconsole3').style.visibility='visible';
												}
												if(document.getElementById('tcViewStart')){document.getElementById('tcViewStart').src="/img/view-start.gif";}
												if(document.getElementById('tcViewEnd')){document.getElementById('tcViewEnd').src="/img/draw-end_a.gif";}
												if( loopSw == 1 ){document.getElementById(imgObj.id).style.visibility="hidden";}
											}
										}
										else
										{
											clearInterval(timerID);
											timerID = -1;
											document.getElementById(imgObj.id).src="/img/tc_play.gif";
										}
										break;
		case 'tcStop' :	
										if(-1 != timerID)
										{
											clearInterval(timerID);
											timerID = -1;
											document.getElementById('tcPlay').src="/img/tc_play.gif";
										}
										if( polylinecount == 0 )
										{
											alert("アップロードするデータがありません");
										}
										else
										{
											if( true == confirm("現在のルートを保存して確認画面に移ります。確認画面に進むとタイトルとコメント以外は編集ができません。本当にルート登録を完了しますか？") )
											{
												UploadCurrentData();
											}
										}
										break;
		case 'tcNext' :
										if(-1 != timerID)
										{
											clearInterval(timerID);
											timerID = -1;
											document.getElementById('tcPlay').src="/img/tc_play.gif";
										}
										moveMode = 1;
										if( previewcount < polylinecount )
										{
											previewcount++;
										}
										else
										{
											previewcount = 1;
										}
										MovePointWithCheck(polyline[previewcount-1].getVertex(1));

										if( window['externalInterface2'] && isIE )
										{
											window['externalInterface2'].setMessage(InfoList[previewcount-1]['comment'],sprintf('「%s」',InfoList[previewcount-1]['title']),sprintf('http://navitte.jp/location%d.html',InfoList[previewcount-1]['id']));
										}
										else if( document['externalInterface2'] )
										{
											document['externalInterface2'].setMessage(InfoList[previewcount-1]['comment'],sprintf('「%s」',InfoList[previewcount-1]['title']),sprintf('http://navitte.jp/location%d.html',InfoList[previewcount-1]['id']));
										}
										if( recMode == 1 )
										{
											LoadDrawCommands();
										}
										else
										{
											LoadDrawCommands2();
										}
										SetProp();
									break;
		case 'tcSaveTip' :
											if(-1 != timerID)
											{
												clearInterval(timerID);
												timerID = -1;
												document.getElementById('tcPlay').src="/img/tc_play.gif";
											}
											if( (polyline[previewcount-1].getVertex(1).lat() == currentX) && (polyline[previewcount-1].getVertex(1).lng() == currentY) )
											{
												if( !InfoList[previewcount-1] ){InfoList[previewcount-1]=new Array();}
												InfoList[previewcount-1]['title'] = elem['tcTitle'].value;
												InfoList[previewcount-1]['comment']=elem['tcComment'].value;
												if(document.getElementById('tcSaveTip')){document.getElementById('tcSaveTip').src="/img/draw-end_a.gif";}
												SetProp();
											}
											else
											{
												alert("現在地は通過スポットに設定されていません。通過スポットに設定する場合は、「通過スポット設定」ボタンを押してください");
											}
										break;
		case 'tcViewStart' :
										if( !isIE )
										{
											$('topconsole2').style.visibility='hidden';
											$('topconsole3').style.visibility='hidden';
											if( recMode != 1 )
											{
												if(document.getElementById('tcViewEnd')){document.getElementById('tcViewEnd').src="/img/draw-end.gif";}
											}
										}
										if(document.getElementById('tcViewStart')){document.getElementById('tcViewStart').src="/img/view-start_a.gif";}
										break;
		case 'tcViewEnd' :
										POVList[previewcount-1] = {yaw:currentYaw,pitch:currentPit,zoom:currentZom};
										if( !isIE )
										{
											$('topconsole2').style.visibility='visible';
											$('topconsole3').style.visibility='visible';
										}
										if(document.getElementById('tcViewStart')){document.getElementById('tcViewStart').src="/img/view-start.gif";}
										if(document.getElementById('tcViewEnd')){document.getElementById('tcViewEnd').src="/img/draw-end_a.gif";}
										break;
		case 'tcDrawStart' :
											POVList[previewcount-1] = {yaw:currentYaw,pitch:currentPit,zoom:currentZom};
											if(document.getElementById('tcViewStart')){document.getElementById('tcViewStart').src="/img/view-start.gif";}
											if(document.getElementById('tcViewEnd')){document.getElementById('tcViewEnd').src="/img/draw-end_a.gif";}
											StartDrawing();
											ChangePanoPenColor(0);
											AddDrawCommand('p',0,0);
											if(document.getElementById('tcDrawStart')){document.getElementById('tcDrawStart').src="/img/draw-start_a.gif";}
											if(document.getElementById('tcDrawEnd')){document.getElementById('tcDrawEnd').src="/img/draw-end.gif";}
											if(document.getElementById('tcDrawClear')){document.getElementById('tcDrawClear').src="/img/draw-clear.gif";}
											if(document.getElementById('tcDrawCol00')){document.getElementById('tcDrawCol00').src="/img/draw-c00_a.gif";}
											if(document.getElementById('tcDrawCol01')){document.getElementById('tcDrawCol01').src="/img/draw-c01.gif";}
											if(document.getElementById('tcDrawCol02')){document.getElementById('tcDrawCol02').src="/img/draw-c02.gif";}
											if(document.getElementById('tcDrawCol03')){document.getElementById('tcDrawCol03').src="/img/draw-c03.gif";}
											if(document.getElementById('tcDrawCol04')){document.getElementById('tcDrawCol04').src="/img/draw-c04.gif";}
											if(document.getElementById('tcDrawCol05')){document.getElementById('tcDrawCol05').src="/img/draw-c05.gif";}
											if(document.getElementById('tcDrawCol06')){document.getElementById('tcDrawCol06').src="/img/draw-c06.gif";}
											if(document.getElementById('tcDrawCol07')){document.getElementById('tcDrawCol07').src="/img/draw-c07.gif";}
											if(document.getElementById('tcViewStart')){document.getElementById('tcViewStart').src="/img/view-start.gif";}
											break;
		case 'tcDrawClear' :
											drawEventIndex = 0;
											ClearPanoDrawing();
											break;
		case 'tcDrawEnd' :
											EndDrawing();
											if(document.getElementById('tcDrawStart')){document.getElementById('tcDrawStart').src="/img/draw-start.gif";}
											if(document.getElementById('tcDrawEnd')){document.getElementById('tcDrawEnd').src="/img/draw-end_a.gif";}
											if(document.getElementById('tcDrawClear')){document.getElementById('tcDrawClear').src="/img/draw-clear_a.gif";}
											if(document.getElementById('tcDrawCol00')){document.getElementById('tcDrawCol00').src="/img/draw-c_a.gif";}
											if(document.getElementById('tcDrawCol01')){document.getElementById('tcDrawCol01').src="/img/draw-c_a.gif";}
											if(document.getElementById('tcDrawCol02')){document.getElementById('tcDrawCol02').src="/img/draw-c_a.gif";}
											if(document.getElementById('tcDrawCol03')){document.getElementById('tcDrawCol03').src="/img/draw-c_a.gif";}
											if(document.getElementById('tcDrawCol04')){document.getElementById('tcDrawCol04').src="/img/draw-c_a.gif";}
											if(document.getElementById('tcDrawCol05')){document.getElementById('tcDrawCol05').src="/img/draw-c_a.gif";}
											if(document.getElementById('tcDrawCol06')){document.getElementById('tcDrawCol06').src="/img/draw-c_a.gif";}
											if(document.getElementById('tcDrawCol07')){document.getElementById('tcDrawCol07').src="/img/draw-c_a.gif";}
											break;
		case 'tcDrawCol00' :
											ChangePanoPenColor(0);
											AddDrawCommand('p',0,0);
											if(document.getElementById('tcDrawCol00')){document.getElementById('tcDrawCol00').src="/img/draw-c00_a.gif";}
											if(document.getElementById('tcDrawCol01')){document.getElementById('tcDrawCol01').src="/img/draw-c01.gif";}
											if(document.getElementById('tcDrawCol02')){document.getElementById('tcDrawCol02').src="/img/draw-c02.gif";}
											if(document.getElementById('tcDrawCol03')){document.getElementById('tcDrawCol03').src="/img/draw-c03.gif";}
											if(document.getElementById('tcDrawCol04')){document.getElementById('tcDrawCol04').src="/img/draw-c04.gif";}
											if(document.getElementById('tcDrawCol05')){document.getElementById('tcDrawCol05').src="/img/draw-c05.gif";}
											if(document.getElementById('tcDrawCol06')){document.getElementById('tcDrawCol06').src="/img/draw-c06.gif";}
											if(document.getElementById('tcDrawCol07')){document.getElementById('tcDrawCol07').src="/img/draw-c07.gif";}
											break;
		case 'tcDrawCol01' :
											ChangePanoPenColor(1);
											AddDrawCommand('p',1,1);
											if(document.getElementById('tcDrawCol00')){document.getElementById('tcDrawCol00').src="/img/draw-c00.gif";}
											if(document.getElementById('tcDrawCol01')){document.getElementById('tcDrawCol01').src="/img/draw-c01_a.gif";}
											if(document.getElementById('tcDrawCol02')){document.getElementById('tcDrawCol02').src="/img/draw-c02.gif";}
											if(document.getElementById('tcDrawCol03')){document.getElementById('tcDrawCol03').src="/img/draw-c03.gif";}
											if(document.getElementById('tcDrawCol04')){document.getElementById('tcDrawCol04').src="/img/draw-c04.gif";}
											if(document.getElementById('tcDrawCol05')){document.getElementById('tcDrawCol05').src="/img/draw-c05.gif";}
											if(document.getElementById('tcDrawCol06')){document.getElementById('tcDrawCol06').src="/img/draw-c06.gif";}
											if(document.getElementById('tcDrawCol07')){document.getElementById('tcDrawCol07').src="/img/draw-c07.gif";}
											break;
		case 'tcDrawCol02' :
											ChangePanoPenColor(2);
											AddDrawCommand('p',2,2);
											if(document.getElementById('tcDrawCol00')){document.getElementById('tcDrawCol00').src="/img/draw-c00.gif";}
											if(document.getElementById('tcDrawCol01')){document.getElementById('tcDrawCol01').src="/img/draw-c01.gif";}
											if(document.getElementById('tcDrawCol02')){document.getElementById('tcDrawCol02').src="/img/draw-c02_a.gif";}
											if(document.getElementById('tcDrawCol03')){document.getElementById('tcDrawCol03').src="/img/draw-c03.gif";}
											if(document.getElementById('tcDrawCol04')){document.getElementById('tcDrawCol04').src="/img/draw-c04.gif";}
											if(document.getElementById('tcDrawCol05')){document.getElementById('tcDrawCol05').src="/img/draw-c05.gif";}
											if(document.getElementById('tcDrawCol06')){document.getElementById('tcDrawCol06').src="/img/draw-c06.gif";}
											if(document.getElementById('tcDrawCol07')){document.getElementById('tcDrawCol07').src="/img/draw-c07.gif";}
											break;
		case 'tcDrawCol03' :
											ChangePanoPenColor(3);
											AddDrawCommand('p',3,3);
											if(document.getElementById('tcDrawCol00')){document.getElementById('tcDrawCol00').src="/img/draw-c00.gif";}
											if(document.getElementById('tcDrawCol01')){document.getElementById('tcDrawCol01').src="/img/draw-c01.gif";}
											if(document.getElementById('tcDrawCol02')){document.getElementById('tcDrawCol02').src="/img/draw-c02.gif";}
											if(document.getElementById('tcDrawCol03')){document.getElementById('tcDrawCol03').src="/img/draw-c03_a.gif";}
											if(document.getElementById('tcDrawCol04')){document.getElementById('tcDrawCol04').src="/img/draw-c04.gif";}
											if(document.getElementById('tcDrawCol05')){document.getElementById('tcDrawCol05').src="/img/draw-c05.gif";}
											if(document.getElementById('tcDrawCol06')){document.getElementById('tcDrawCol06').src="/img/draw-c06.gif";}
											if(document.getElementById('tcDrawCol07')){document.getElementById('tcDrawCol07').src="/img/draw-c07.gif";}
											break;
		case 'tcDrawCol04' :
											ChangePanoPenColor(4);
											AddDrawCommand('p',4,4);
											if(document.getElementById('tcDrawCol00')){document.getElementById('tcDrawCol00').src="/img/draw-c00.gif";}
											if(document.getElementById('tcDrawCol01')){document.getElementById('tcDrawCol01').src="/img/draw-c01.gif";}
											if(document.getElementById('tcDrawCol02')){document.getElementById('tcDrawCol02').src="/img/draw-c02.gif";}
											if(document.getElementById('tcDrawCol03')){document.getElementById('tcDrawCol03').src="/img/draw-c03.gif";}
											if(document.getElementById('tcDrawCol04')){document.getElementById('tcDrawCol04').src="/img/draw-c04_a.gif";}
											if(document.getElementById('tcDrawCol05')){document.getElementById('tcDrawCol05').src="/img/draw-c05.gif";}
											if(document.getElementById('tcDrawCol06')){document.getElementById('tcDrawCol06').src="/img/draw-c06.gif";}
											if(document.getElementById('tcDrawCol07')){document.getElementById('tcDrawCol07').src="/img/draw-c07.gif";}
											break;
		case 'tcDrawCol05' :
											ChangePanoPenColor(5);
											AddDrawCommand('p',5,5);
											if(document.getElementById('tcDrawCol00')){document.getElementById('tcDrawCol00').src="/img/draw-c00.gif";}
											if(document.getElementById('tcDrawCol01')){document.getElementById('tcDrawCol01').src="/img/draw-c01.gif";}
											if(document.getElementById('tcDrawCol02')){document.getElementById('tcDrawCol02').src="/img/draw-c02.gif";}
											if(document.getElementById('tcDrawCol03')){document.getElementById('tcDrawCol03').src="/img/draw-c03.gif";}
											if(document.getElementById('tcDrawCol04')){document.getElementById('tcDrawCol04').src="/img/draw-c04.gif";}
											if(document.getElementById('tcDrawCol05')){document.getElementById('tcDrawCol05').src="/img/draw-c05_a.gif";}
											if(document.getElementById('tcDrawCol06')){document.getElementById('tcDrawCol06').src="/img/draw-c06.gif";}
											if(document.getElementById('tcDrawCol07')){document.getElementById('tcDrawCol07').src="/img/draw-c07.gif";}
											break;
		case 'tcDrawCol06' :
											ChangePanoPenColor(6);
											AddDrawCommand('p',6,6);
											if(document.getElementById('tcDrawCol00')){document.getElementById('tcDrawCol00').src="/img/draw-c00.gif";}
											if(document.getElementById('tcDrawCol01')){document.getElementById('tcDrawCol01').src="/img/draw-c01.gif";}
											if(document.getElementById('tcDrawCol02')){document.getElementById('tcDrawCol02').src="/img/draw-c02.gif";}
											if(document.getElementById('tcDrawCol03')){document.getElementById('tcDrawCol03').src="/img/draw-c03.gif";}
											if(document.getElementById('tcDrawCol04')){document.getElementById('tcDrawCol04').src="/img/draw-c04.gif";}
											if(document.getElementById('tcDrawCol05')){document.getElementById('tcDrawCol05').src="/img/draw-c05.gif";}
											if(document.getElementById('tcDrawCol06')){document.getElementById('tcDrawCol06').src="/img/draw-c06_a.gif";}
											if(document.getElementById('tcDrawCol07')){document.getElementById('tcDrawCol07').src="/img/draw-c07.gif";}
											break;
		case 'tcDrawCol07' :
											ChangePanoPenColor(7);
											AddDrawCommand('p',7,7);
											if(document.getElementById('tcDrawCol00')){document.getElementById('tcDrawCol00').src="/img/draw-c00.gif";}
											if(document.getElementById('tcDrawCol01')){document.getElementById('tcDrawCol01').src="/img/draw-c01.gif";}
											if(document.getElementById('tcDrawCol02')){document.getElementById('tcDrawCol02').src="/img/draw-c02.gif";}
											if(document.getElementById('tcDrawCol03')){document.getElementById('tcDrawCol03').src="/img/draw-c03.gif";}
											if(document.getElementById('tcDrawCol04')){document.getElementById('tcDrawCol04').src="/img/draw-c04.gif";}
											if(document.getElementById('tcDrawCol05')){document.getElementById('tcDrawCol05').src="/img/draw-c05.gif";}
											if(document.getElementById('tcDrawCol06')){document.getElementById('tcDrawCol06').src="/img/draw-c06.gif";}
											if(document.getElementById('tcDrawCol07')){document.getElementById('tcDrawCol07').src="/img/draw-c07_a.gif";}
											break;
		default:break;
	}
}







