//───────────────────────────────────────────
//
//(C) Nihon Computer Graphic Co.,Ltd.
//
//───────────────────────────────────────────

var PlotIcon = {
	Version: '1.1.0',
	
	begin: function(x, y, scl, wid, hei, grp, grpOffset){
		this.cx = x;
		this.cy = y;
		this.scl = scl;
		this.wid = wid;
		this.hei = hei;
		this.grp = "1";
		this.grpOffset = 10;
		if(null != grp) this.grp = grp;
		if(null != grpOffset) this.grpOffset = grpOffset;
		this.x = new Array();
		this.y = new Array();
		this.iconName = new Array();
		this.iconLink = new Array();
		this.jsDelDiv = "";
		this.jsInsDiv = "";
	},

	append: function(x, y, iconName, iconLink){
		var recX = new refvar();
		var recY = new refvar();
		CMBLPixel.bltoPixel(this.cx, this.cy, this.scl, 3, this.wid, this.hei, x, y, recX, recY);
		if("" == recX.value) return false;
		if("1" == this.grp){
			for(var i = 0; i < this.x.length; i++){
				if(this.grpOffset >= Math.abs(recX.value - this.x[i]) && this.grpOffset >= Math.abs(recY.value - this.y[i])){
					this.iconName[i].push(iconName);
					this.iconLink[i].push(iconLink);
					return true;
				}
			}
		}
		this.x.push(recX.value);
		this.y.push(recY.value);
		this.iconName.push([]);
		this.iconLink.push([]);
		this.iconName[this.x.length-1].push(iconName);
		this.iconLink[this.x.length-1].push(iconLink);
		return true;
	},
	
	end: function(mapLeft, mapTop, iconWid, iconHei){
		var jsAllDiv = "";
		var jsIconLink = "";
		for(var i = 0; i < this.x.length; i++){
			var tip = "<div onMouseOver=czMov('dummydiv'," + 
					String(this.x[i] + mapLeft - iconWid / 2) + "," + 
					String(this.y[i] + mapTop - iconHei / 2) + 
					",PlotIcon.listLink" + i + ",835);><img src='images/chizumaru/apple_frm.gif' border='0'></div>";
	 		if("undefined" == typeof eval("this.icon" + i)){
				jsAllDiv += "this.icon" + i + " = createLayer( 0, 0, " + iconWid + ", " + iconHei + 
					", null, \"" + tip + "\" );";
			}
			else{
				jsAllDiv += "writeDivHTML( PlotIcon.icon" + i + ", true, true, \"" + tip + "\" );";
			}
			jsAllDiv += "czMov_obj( PlotIcon.icon" + i + ", " + 
				String(this.x[i] + mapLeft - iconWid / 2) + ", " + 
				String(this.y[i] + mapTop - iconHei / 2) + ", null, 830 );";

			jsIconLink += "this.listLink" + i + " = \"<TABLE class='nom' id='dummylink' bgcolor='#ffffff' border='1' " + 
				"bordercolor='#C6C6C6' cellspacing='0' cellpadding='1' style='filter:alpha(opacity=85);' " + 
				"onMouseOver=czVisibility('dummylink',true);setDivZIndex(PlotIcon.icon" + i + ",832); " + 
				"onMouseOut=setDivZIndex(PlotIcon.icon" + i + ",830);czVisibility('dummylink',false);>";
			for(var n = 0; n < this.iconName[i].length; n++){
// @osj
				//jsIconLink += "<TR><TD nowrap>" + (n + 1) + ".<a target='_blank' href='" + this.iconLink[i][n] + "'>" + 
				jsIconLink += "<TR><TD nowrap><a target='_blank' href='" + this.iconLink[i][n] + "'>" + 
					this.iconName[i][n] + "</a></TD></TR>";
			}
			jsIconLink += "</TABLE>\";";

			this.jsDelDiv += "parent.setDivVisibility( parent.PlotIcon.icon" + i + ", false );"
			this.jsInsDiv += "parent.setDivVisibility( parent.PlotIcon.icon" + i + ", true );"
		}

// @osj
		//if("" != jsIconLink) eval( jsIconLink );
		if("" != jsAllDiv) eval( jsAllDiv );
		return;
	},

	getJSInsDiv: function(){
		return this.jsInsDiv;
	},

	getJSDelDiv: function(){
		return this.jsDelDiv;
	}
}
//───────────────────────────────────────────
//
//	ver 1.00
//	ver 1.10
//		iframe利用時の不具合を修正
//
//───────────────────────────────────────────
