//───────────────────────────────────────────
//
//(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++){
			
			if(arrRec[i][6] == 2){
				var tip = "<a href=javascript:setCenter(" + arrRec[i][0] + "," + arrRec[i][1] + ");selectArticle(" + arrRec[i][0] + "," + arrRec[i][1] + ");><div onMouseOut=czVisibility('article_balloon',false); onMouseOver=showArticleBalloon(" + arrRec[i][0] + "," + arrRec[i][1] + "," + arrRec[i][2] + ");><img src='img/icon1.gif' border='0'></div></a>";
	 		}else if(arrRec[i][6] == 1){
	 			var tip = "<a href=javascript:setCenter(" + arrRec[i][0] + "," + arrRec[i][1] + "); onMouseOut=czVisibility('shop_balloon',false); onMouseOver=showShopBalloon(" + arrRec[i][0] + "," + arrRec[i][1] + ",'" + arrRec[i][4] + "','" + arrRec[i][5] + "');><div><img src='img/icon2.gif' border='0'></div></a>";
	 		}
	 		if("undefined" == typeof eval("this.icon" + i)){
				jsAllDiv += "this.icon" + i + " = parent.createLayer( 0, 0, " + iconWid + ", " + iconHei + 
					", null, \"" + tip + "\" );";
			}
			else{
				jsAllDiv += "parent.writeDivHTML( PlotIcon.icon" + i + ", true, true, \"" + tip + "\" );";
			}
			jsAllDiv += "parent.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++){
				jsIconLink += "<TR><TD nowrap>" + (n + 1) + ".<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 );"
		}

		if("" != jsIconLink) eval( jsIconLink );
		if("" != jsAllDiv) eval( jsAllDiv );
		return;
	},

	getJSInsDiv: function(){
		return this.jsInsDiv;
	},

	getJSDelDiv: function(){
		return this.jsDelDiv;
	}
}
