var arr_icon=new Array();
var select_icon=new Array();
var action_icon=new Array();

function place_icon(sens) {
	arr_icon = new Array();
	select_icon = new Array();
	var currIcoWidth = 10;
	var currIcoHeight = 10;
	for(i=0; i<60; i++) {
		if(document.getElementById('icon_'+i)) {
			arr_icon.push('icon_'+i);
			select_icon.push(0);
			
			if(sens == 0 || sens == undefined) {
				if (currIcoHeight >= (document.body.clientHeight-100)) {
					currIcoWidth = currIcoWidth + 95
					currIcoHeight = 10
					document.getElementById('icon_'+i).style.left = currIcoWidth
					document.getElementById('icon_'+i).style.top = currIcoHeight
					currIcoHeight = currIcoHeight + 95
				} else {
					document.getElementById('icon_'+i).style.left = currIcoWidth
					document.getElementById('icon_'+i).style.top = currIcoHeight
					currIcoHeight = currIcoHeight + 95
				}
			} else if(sens == 1) {
				if (currIcoWidth >= (document.body.clientWidth-100)) {
					currIcoHeight = currIcoHeight + 95
					currIcoWidth = 10
					document.getElementById('icon_'+i).style.left = currIcoWidth
					document.getElementById('icon_'+i).style.top = currIcoHeight
					currIcoWidth = currIcoWidth + 95
				} else {
					document.getElementById('icon_'+i).style.left = currIcoWidth
					document.getElementById('icon_'+i).style.top = currIcoHeight
					currIcoWidth = currIcoWidth + 95
				}
			}	
			if(document.getElementById('icon_'+i).getAttribute("action") != undefined) {
				action_icon.push(new Array('icon_'+i, document.getElementById('icon_'+i).getAttribute("action"), parseInt(document.getElementById('icon_'+i).style.top,10), parseInt(document.getElementById('icon_'+i).style.left,10), parseInt(document.getElementById('icon_'+i).style.width,10) ,parseInt(document.getElementById('icon_'+i).style.height),10));
			}
		}
	}
}

function icon_add(color, rep, name, type, ac, ico, isParent) {
	var html = new Array()
	var dblclick = (ac!=''?"creatWindow('"+name+"', '600', '500', '"+rep+"gif/"+ico+"', '"+ac+"', '"+isParent+"')":"");
	html.push("<table ondblclick=\""+dblclick+"\" cellpadding=0 cellspacing=0 id=\"icon_"+select_icon.length+"\" type=\"icon\" onmousedown='selectDrag(this, 5, 5, event);' style=\"color:'"+color+"';z-index:1;position: absolute; left: 20; top:200;font-family: Arial; font-size: 14px;height:40;width:80;table-layout:fixed;\">");
	html.push("<tr>");
	html.push("<td style=\"background: url("+rep+"gif/"+ico+") no-repeat;z-index:1;background-position: center center;width:64; height:64;\">&nbsp;</td>");
	html.push("</tr>");
	html.push("<tr align=center>");
	html.push("<td valign=top style=\"word-wrap: normal;vertical-align:top;overflow: hidden; text-overflow: ellipsis\">"+name+"</td>");
	html.push("</tr>");
	html.push("</table>");
	arr_icon.push("icon_"+select_icon.length);
	select_icon.push(0);
	document.body.innerHTML += html.join('');
}

function color_icon(get, color) {
	get.getElementsByTagName('tr')[1].style.backgroundColor=color;
}