
var array=new Array();
array[0] = new Array('通用板材','根目录','通用板材');
array[1] = new Array('专业板材','根目录','专业板材');
array[2] = new Array('线螺及圆钢','根目录','线螺及圆钢');
array[3] = new Array('型材','根目录','型材');
array[4] = new Array('管材','根目录','管材');
array[5] = new Array('优钢特钢','根目录','优钢特钢');
array[6] = new Array('不锈钢','根目录','不锈钢');
array[7] = new Array('边角料及利用材','根目录','边角料及利用材');
array[8] = new Array('钢坯炉料','根目录','钢坯炉料');
array[9] = new Array('冷轧板卷','通用板材','冷轧板卷');
array[10] = new Array('热轧板卷','通用板材','热轧板卷');
array[11] = new Array('花纹板卷','通用板材','花纹板卷');
array[12] = new Array('带钢','通用板材','带钢');
array[13] = new Array('轧硬卷','通用板材','轧硬卷');
array[14] = new Array('中厚板','通用板材','中厚板');
array[15] = new Array('低合金板卷','通用板材','低合金板卷');
array[16] = new Array('镀锌板卷','通用板材','镀锌板卷');
array[17] = new Array('电镀锌板卷','通用板材','电镀锌板卷');
array[18] = new Array('镀铝锌板卷','通用板材','镀铝锌板卷');
array[19] = new Array('镀铝板卷','通用板材','镀铝板卷');
array[20] = new Array('彩涂板卷','通用板材','彩涂板卷');
array[21] = new Array('硅钢板卷','通用板材','硅钢板卷');
array[22] = new Array('酸洗板卷','通用板材','酸洗板卷');
array[23] = new Array('镀锡板卷','通用板材','镀锡板卷');
array[24] = new Array('碳结板','通用板材','碳结板');
array[25] = new Array('其它通用板材','通用板材','其它通用板材');
array[26] = new Array('容器板','专业板材','容器板');
array[27] = new Array('锅炉板','专业板材','锅炉板');
array[28] = new Array('船板','专业板材','船板');
array[29] = new Array('集装箱板','专业板材','集装箱板');
array[30] = new Array('大梁板','专业板材','大梁板');
array[31] = new Array('桥梁板','专业板材','桥梁板');
array[32] = new Array('耐候板','专业板材','耐候板');
array[33] = new Array('其它专用板材','专业板材','其它专用板材');
array[34] = new Array('螺纹钢','线螺及圆钢','螺纹钢');
array[35] = new Array('高线','线螺及圆钢','高线');
array[36] = new Array('普线','线螺及圆钢','普线');
array[37] = new Array('普园','线螺及圆钢','普园');
array[38] = new Array('硬线','线螺及圆钢','硬线');
array[39] = new Array('焊线','线螺及圆钢','焊线');
array[40] = new Array('拉丝线材','线螺及圆钢','拉丝线材');
array[41] = new Array('其它线螺及园钢','线螺及圆钢','其它线螺及园钢');
array[42] = new Array('工字钢','型材','工字钢');
array[43] = new Array('槽钢','型材','槽钢');
array[44] = new Array('角钢','型材','角钢');
array[45] = new Array('H型钢','型材','H型钢');
array[46] = new Array('翼缘板','型材','翼缘板');
array[47] = new Array('扁钢','型材','扁钢');
array[48] = new Array('方钢','型材','方钢');
array[49] = new Array('重轨','型材','重轨');
array[50] = new Array('轻轨','型材','轻轨');
array[51] = new Array('起重轨','型材','起重轨');
array[52] = new Array('C型钢','型材','C型钢');
array[53] = new Array('异型材','型材','异型材');
array[54] = new Array('其它型材','型材','其它型材');
array[55] = new Array('无缝管','管材','无缝管');
array[56] = new Array('焊管','管材','焊管');
array[57] = new Array('镀锌管','管材','镀锌管');
array[58] = new Array('脚手架管','管材','脚手架管');
array[59] = new Array('螺旋焊管','管材','螺旋焊管');
array[60] = new Array('锅炉管','管材','锅炉管');
array[61] = new Array('石油管','管材','石油管');
array[62] = new Array('化肥管','管材','化肥管');
array[63] = new Array('异形管','管材','异形管');
array[64] = new Array('方管','管材','方管');
array[65] = new Array('矩形管','管材','矩形管');
array[66] = new Array('铸铁管','管材','铸铁管');
array[67] = new Array('其它管材','管材','其它管材');
array[68] = new Array('碳结园钢','优钢特钢','碳结园钢');
array[69] = new Array('合结园钢','优钢特钢','合结园钢');
array[70] = new Array('模具钢','优钢特钢','模具钢');
array[71] = new Array('碳工钢','优钢特钢','碳工钢');
array[72] = new Array('合工钢','优钢特钢','合工钢');
array[73] = new Array('高工钢','优钢特钢','高工钢');
array[74] = new Array('弹簧钢','优钢特钢','弹簧钢');
array[75] = new Array('齿轮钢','优钢特钢','齿轮钢');
array[76] = new Array('轴承钢','优钢特钢','轴承钢');
array[77] = new Array('军工钢','优钢特钢','军工钢');
array[78] = new Array('其它优钢特钢','优钢特钢','其它优钢特钢');
array[79] = new Array('不锈钢板卷','不锈钢','不锈钢板卷');
array[80] = new Array('不锈钢型材','不锈钢','不锈钢型材');
array[81] = new Array('不锈钢带','不锈钢','不锈钢带');
array[82] = new Array('不锈钢管','不锈钢','不锈钢管');
array[83] = new Array('不锈钢元钢','不锈钢','不锈钢元钢');
array[84] = new Array('不锈坯锭','不锈钢','不锈坯锭');
array[85] = new Array('不锈钢丝','不锈钢','不锈钢丝');
array[86] = new Array('其它不锈钢','不锈钢','其它不锈钢');
array[87] = new Array('边角余料','边角料及利用材','边角余料');
array[88] = new Array('可利用钢材','边角料及利用材','可利用钢材');
array[89] = new Array('积压处理材','边角料及利用材','积压处理材');
array[90] = new Array('钢坯','钢坯炉料','钢坯');
array[91] = new Array('管坯','钢坯炉料','管坯');
array[92] = new Array('方坯','钢坯炉料','方坯');
array[93] = new Array('板坯','钢坯炉料','板坯');
array[94] = new Array('电磁纯铁','钢坯炉料','电磁纯铁');
array[95] = new Array('废钢','钢坯炉料','废钢');
array[96] = new Array('生铁','钢坯炉料','生铁');
array[97] = new Array('其它钢坯炉料','钢坯炉料','其它钢坯炉料');
array[98] = new Array('QualityName','螺纹钢','HRB335');
array[99] = new Array('QualityName','螺纹钢','HRB400');
array[100] = new Array('QualityName','高线','LQ235B');
array[101] = new Array('QualityName','高线','Q235A');
array[102] = new Array('QualityName','普线','Q235A');
array[103] = new Array('QualityName','中厚板','Q235A');
array[104] = new Array('QualityName','中厚板','Q235AB');
array[105] = new Array('QualityName','高线','Q235B');
array[106] = new Array('QualityName','普线','Q235B');
array[107] = new Array('QualityName','中厚板','Q235B');
array[108] = new Array('SpecName','高线','Φ10');
array[109] = new Array('SpecName','普线','Φ10');
array[110] = new Array('SpecName','高线','Φ10.5');
array[111] = new Array('SpecName','普线','Φ10.5');
array[112] = new Array('SpecName','螺纹钢','Φ12*9');
array[113] = new Array('SpecName','螺纹钢','Φ14*9');
array[114] = new Array('SpecName','螺纹钢','Φ16*9');
array[115] = new Array('SpecName','螺纹钢','Φ18*9');
array[116] = new Array('SpecName','螺纹钢','Φ20*9');
array[117] = new Array('SpecName','螺纹钢','Φ22*9');
array[118] = new Array('SpecName','高线','Φ6.5');
array[119] = new Array('SpecName','普线','Φ6.5');
array[120] = new Array('SpecName','高线','Φ8');
array[121] = new Array('SpecName','普线','Φ8');
array[122] = new Array('DepotName','螺纹钢','凇港库');
array[123] = new Array('DepotName','高线','凇港库');
array[124] = new Array('DepotName','普线','凇港库');
array[125] = new Array('DepotName','螺纹钢','杨浦站');
array[126] = new Array('DepotName','高线','杨浦站');
array[127] = new Array('DepotName','普线','杨浦站');

function selClass(selectitem)
{
	var tmp_str = "<div>";
	tmp_str += "<select name='supplyclass' style='width:90px;' onchange='chgtype()'>";
	tmp_str += "<option value=''>请选择类别</option>";
	for(var i=0;i<array.length;i++)
	{
		//alert(sel_class);
		if(array[i][1] == "根目录")
		{
			tmp_str += (array[i][2] == selectitem)?"<option value='"+array[i][2]+"' selected>"+array[i][0]+"</option>":"<option value='"+array[i][2]+"'>"+array[i][0]+"</option>"
			//tmp_str += "<option value='"+array[i][2]+"'>"+array[i][0]+"</option>";
		}
	}
	tmp_str += "</select>";
	tmp_str += "</div>";
	return tmp_str;
}
function selType(classitem, selectitem)
{
	var tmp_str = "<div>";
	tmp_str += "<select name='supplytype' style='width:90px;' onchange='setpname()'>";
	tmp_str += "<option value=''>请选择品种</option>";
	for(var i=0;i<array.length;i++)
	{
		//alert(sel_class);
		if(array[i][1] == classitem)
		{
			tmp_str += (array[i][2] == selectitem)?"<option value='"+array[i][2]+"' selected>"+array[i][0]+"</option>":"<option value='"+array[i][2]+"'>"+array[i][0]+"</option>"
			//tmp_str += "<option value='"+array[i][2]+"'>"+array[i][0]+"</option>";
		}
	}
	tmp_str += "</select>";
	tmp_str += "</div>";
	return tmp_str;
}

function chgtype()
{
	event.cancelBubble=true;
	var the_obj = event.srcElement;
	var sel_class = the_obj.value;
	var the_td = get_Element(the_obj, "td");if(the_td==null) return;
	var the_tr = the_td.parentElement;
	var the_table = the_tr.parentElement;
	the_table.rows[the_tr.rowIndex].cells[1].innerHTML = selType(sel_class, "");
	//alert( selType(sel_class, ""));
}

function setpname()
{
	event.cancelBubble=true;
	var the_obj = event.srcElement;
	var sel_type = the_obj.value;
	var the_td = get_Element(the_obj, "td");if(the_td==null) return;
	var the_tr = the_td.parentElement;
	var the_table = the_tr.parentElement;
	the_table.rows[the_tr.rowIndex].cells[2].innerHTML = "<div><input type='input' size='5' name='supplyproname' class='input' value='"+sel_type+"'></div>";

	var q_str_tmp = the_table.rows[the_tr.rowIndex].cells[3].innerHTML.toLowerCase();
	var s_str_tmp = the_table.rows[the_tr.rowIndex].cells[4].innerHTML.toLowerCase();
	var d_str_tmp = the_table.rows[the_tr.rowIndex].cells[9].innerHTML.toLowerCase();

	var q_str = q_str_tmp.substring(0,q_str_tmp.indexOf("<div",5));
	var s_str = s_str_tmp.substring(0,s_str_tmp.indexOf("<div",5));
	var d_str = d_str_tmp.substring(0,d_str_tmp.indexOf("<div",5));
	
	the_table.rows[the_tr.rowIndex].cells[3].innerHTML = q_str + "<div style='display:none'>"+sel_type+"</div>";
	the_table.rows[the_tr.rowIndex].cells[4].innerHTML = s_str + "<div style='display:none'>"+sel_type+"</div>";
	the_table.rows[the_tr.rowIndex].cells[9].innerHTML = d_str + "<div style='display:none'>"+sel_type+"</div>";
}

function showqdiv()
{
	event.cancelBubble=true;
	var the_obj = event.srcElement;
	var obj_name = the_obj.name;
	//alert(document.all[obj_name].index);
	var the_td = get_Element(the_obj, "td");if(the_td==null) return;
	var the_tr = the_td.parentElement;
	var cur_row = the_tr.rowIndex;
	var the_table = the_tr.parentElement;

	var sel_value = the_obj.parentElement.nextSibling.innerHTML;
	//alert(cur_row);

	var tmp_str = "<table border='1' bordercolorlight='#ffffff' bordercolordark='#ffffff' width='200' cellpadding='0' cellspacing='0'>"
	for(var i=0;i<array.length;i++)
	{
		if(array[i][1] == sel_value && array[i][0] == "QualityName")
		{
			tmp_str += "<tr align='center'>"
			tmp_str += "<td width='50%' height='20' bordercolorlight='#cccccc' bordercolordark='#cccccc' bgcolor='#ffffff'><span style='cursor:hand;' onMouseOver=\"document.getElementsByName('"+obj_name+"')["+(cur_row-1)+"].value=this.innerHTML\">"+array[i][2]+"</span></td>";
		}
		i++;
		if(array[i][1] == sel_value && array[i][0] == "QualityName")
		{
			tmp_str += "<td width='50%' height='20' bordercolorlight='#cccccc' bordercolordark='#cccccc' bgcolor='#ffffff'><span style='cursor:hand;' onMouseOver=\"document.getElementsByName('"+obj_name+"')["+(cur_row-1)+"].value=this.innerHTML\">"+array[i][2]+"</span></td>";
			tmp_str += "</tr>"
		}
	}
	tmp_str += "</table>"
	

	document.all["QualityList"].innerHTML = tmp_str;
	document.all["QualityList"].style.left = window.event.x+document.body.scrollLeft - 20;
	document.all["QualityList"].style.top = window.event.y+document.body.scrollTop + 10;
	document.all["QualityList"].style.display = '';
}

function hiddediv()
{
	document.all["QualityList"].style.display = 'none';
	document.all["QualityList"].innerHTML = '';
	document.all["SpecList"].style.display = 'none';
	document.all["SpecList"].innerHTML = '';
	document.all["DepotList"].style.display = 'none';
	document.all["DepotList"].innerHTML = '';
}

function hiddenqdiv()
{
	document.all["QualityList"].style.display = 'none';
	document.all["QualityList"].innerHTML = '';
}

function showsdiv()
{
	event.cancelBubble=true;
	var the_obj = event.srcElement;
	var obj_name = the_obj.name;
	var the_td = get_Element(the_obj, "td");if(the_td==null) return;
	var the_tr = the_td.parentElement;
	var cur_row = the_tr.rowIndex;
	var the_table = the_tr.parentElement;

	var sel_value = the_obj.parentElement.nextSibling.innerHTML;

	var tmp_str = "<table border='1' bordercolorlight='#ffffff' bordercolordark='#ffffff' width='200' cellpadding='0' cellspacing='0'>"
	
	for(var i=0;i<array.length;i++)
	{
		if(array[i][1] == sel_value && array[i][0] == "SpecName")
		{
			tmp_str += "<tr align='center'>"
			tmp_str += "<td width='50%' height='20' bordercolorlight='#cccccc' bordercolordark='#cccccc' bgcolor='#ffffff'><span style='cursor:hand;' onMouseOver=\"document.getElementsByName('"+obj_name+"')["+(cur_row-1)+"].value=this.innerHTML\">"+array[i][2]+"</span></td>";
		}
		i++;
		if(array[i][1] == sel_value && array[i][0] == "SpecName")
		{
			tmp_str += "<td width='50%' height='20' bordercolorlight='#cccccc' bordercolordark='#cccccc' bgcolor='#ffffff'><span style='cursor:hand;' onMouseOver=\"document.getElementsByName('"+obj_name+"')["+(cur_row-1)+"].value=this.innerHTML\">"+array[i][2]+"</span></td>";
			tmp_str += "</tr>"
		}
	}
	tmp_str += "</table>"
	//alert(tmp_str);

	document.all["SpecList"].innerHTML = tmp_str;
	document.all["SpecList"].style.left = window.event.x+document.body.scrollLeft - 20;
	document.all["SpecList"].style.top = window.event.y+document.body.scrollTop + 10;
	document.all["SpecList"].style.display = '';
}

function hiddensdiv()
{
	document.all["SpecList"].style.display = 'none';
	document.all["SpecList"].innerHTML = '';
}

function showddiv()
{
	event.cancelBubble=true;
	var the_obj = event.srcElement;
	var obj_name = the_obj.name;
	var the_td = get_Element(the_obj, "td");if(the_td==null) return;
	var the_tr = the_td.parentElement;
	var cur_row = the_tr.rowIndex;
	var the_table = the_tr.parentElement;

	var sel_value = the_obj.parentElement.nextSibling.innerHTML;

	var tmp_str = "<table border='1' bordercolorlight='#ffffff' bordercolordark='#ffffff' width='200' cellpadding='0' cellspacing='0'>"
	for(var i=0;i<array.length;i++)
	{
		if(array[i][1] == sel_value && array[i][0] == "DepotName")
		{
			tmp_str += "<tr align='center'>"
			tmp_str += "<td width='50%' height='20' bordercolorlight='#cccccc' bordercolordark='#cccccc' bgcolor='#ffffff'><span style='cursor:hand;' onMouseOver=\"document.getElementsByName('"+obj_name+"')["+(cur_row-1)+"].value=this.innerHTML\">"+array[i][2]+"</span></td>";
		}
		i++;
		if(array[i][1] == sel_value && array[i][0] == "DepotName")
		{
			tmp_str += "<td width='50%' height='20' bordercolorlight='#cccccc' bordercolordark='#cccccc' bgcolor='#ffffff'><span style='cursor:hand;' onMouseOver=\"document.getElementsByName('"+obj_name+"')["+(cur_row-1)+"].value=this.innerHTML\">"+array[i][2]+"</span></td>";
			tmp_str += "</tr>"
		}
	
	}
	tmp_str += "</table>"

	document.all["DepotList"].innerHTML = tmp_str;
	document.all["DepotList"].style.left = window.event.x+document.body.scrollLeft - 20;
	document.all["DepotList"].style.top = window.event.y+document.body.scrollTop + 10;
	document.all["DepotList"].style.display = '';
}

function hiddenddiv()
{
	document.all["DepotList"].style.display = 'none';
	document.all["DepotList"].innerHTML = '';
}

function get_Element(the_ele,the_tag)
{
	the_tag = the_tag.toLowerCase();
	if(the_ele.tagName.toLowerCase()==the_tag)return the_ele;
	while(the_ele=the_ele.offsetParent)
	{
		if(the_ele.tagName.toLowerCase()==the_tag)return the_ele;
	}
	return(null);
}

function del_row() 
{
	event.cancelBubble=true;
	var the_obj = event.srcElement;
	var the_td = get_Element(the_obj, "td");if(the_td==null) return;
	var the_tr = the_td.parentElement;
	var the_table = the_tr.parentElement;
	var cur_row = (the_tr.rowIndex==null || the_tr.rowIndex==0)?-1:the_tr.rowIndex;
	if(the_table.rows.length==1) return;
	the_table.deleteRow(cur_row);

	tmp_count = parseInt(document.all["SupplyList"].Count.value);
	if(tmp_count != "NaN" && tmp_count > 0)
		document.all["SupplyList"].Count.value = tmp_count - 1;
	read_def(the_table);
}

function add_row()
{
	event.cancelBubble=true;
	var the_obj = event.srcElement;

	var the_td = get_Element(the_obj, "td");if(the_td==null) return;
	var the_tr = the_td.parentElement;
	var the_table = the_tr.parentElement;
	var cur_row, add_row, the_cell;
	cur_row = the_tr.rowIndex;
	var data = new Array();
	if(cur_row > 0)
	{
		for(var i=0;i<the_table.rows[0].cells.length;i++)
		{
			data[i] = the_table.rows[cur_row].cells[i].innerHTML;
			//alert(data[i]);
			//LdCls;
		}
	}
	else
	{
		data[0] = selClass("");
		data[1] = selType("", "");
		data[2] = "<div><input type='input' size='2' name='supplyproname'></div>";
		data[3] = "<div><input type='input' size='2' name='supplyquality' onfocus='showqdiv()' onblur='hiddenqdiv()' value=''></div><div style='display:none'></div>";
		data[4] = "<div><input type='input' size='2' name='supplyspec' onfocus='showsdiv()' onblur='hiddensdiv()' value=''></div><div style='display:none'></div>";
		data[5] = "<div><input type='input' size='2' name='supplyprice'></div>";
		data[6] = "<div><input type='input' size='2' name='supplytnum'></div>";
		data[7] = "<div><input type='input' size='2' name='supplyfactory'></div>";
		data[8] = "<div><input type='input' size='2' name='supplytradeplace'></div>";
		data[9] = "<div><input type='input' size='2' name='supplydepot' onfocus='showddiv()' onblur='hiddenddiv()' value=''></div><div style='display:none'></div>";
		data[10] = "<div><input type='input' size='2' name='supplyordernum' value='0' style='ime-mode:disabled' onKeyUp=\"if((isNaN(this.value))||(this.value<0)) this.value='0';\"></div>";
		data[11] = "<div><input type='input' size='2' name='supplydemo'></div>";
		data[12] = "<div><input type='button' name='' value='删除' onclick='del_row()' style='width:35px'></div>";
		//<input type='button' name='' value='添加' onclick='add_row()' class='inputa' style='width:35px'>
	}

	add_row = cur_row + 1;
	var newrow = the_table.insertRow(add_row);
	newrow.style.backgroundColor = "#ffffff";
	newrow.style.height = "20px";
	
	for(var i=0;i<the_table.rows[0].cells.length;i++)
	{
		the_cell = newrow.insertCell(i);
		the_cell.innerHTML = data[i];
		the_cell.style.height = "25px";
		the_cell.style.textAlign = "center";
	}
	tmp_count = parseInt(document.all["SupplyList"].Count.value);
	if(tmp_count != "NaN")
		document.all["SupplyList"].Count.value = tmp_count + 1;
	read_def(the_table);
}

function read_def(the_table){
	for(var i=0;i<the_table.rows.length;i++){
		for(var j=0;j<the_table.rows[i].cells.length;j++){
			/*with(the_table.rows[i]){
				cells[j].oBgc = cells[j].currentStyle.backgroundColor;
				cells[j].oFc  = cells[j].currentStyle.color;
				if(i==0){
					cells[j].onmousedown	= drag_start;
					cells[j].onmouseup	= drag_end;
				}
			}*/
		}
	}
}