var con ={
	listAction : function(data) { resultListAction(data) ; }
}
	
function onInit()
{	
	listAction();
	setInterval("listAction()",5*60*1000);
}

//µ¥ÀÌÅ¸°Ë»ö ¿©±âºÎÅÍ Ajax
function listAction() 
{
	$("command").value = "_congestList_Ajax";
	$("form1").action = "main.do";
	$("form1").target = "";
	onSubmit(con.listAction, $("form1"));
	return;
		
}

function resultListAction(data)
{
	var list = data.conList;
	var txt1 = "";
	var roadNo = "";
	var roadBound = "";
	if(list.size() == 0){
		txt1 +="<table width='100%' border='0' cellspacing='0' cellpadding='2'>";
		txt1 +="<tr><td width='300' align='center' class='t2'>Á¤Ã¼Á¤º¸°¡ ¾ø½À´Ï´Ù.</td></tr>";
		txt1 +="</table>";
		$('mShortFrame04').innerHTML = txt1;
		return;
	}

	for( var i=0 ; i<list.size() ; i++ )
	{
		if( roadNo != list[i].roadNo||roadBound != list[i].roadBound )
		{
			new Insertion.Bottom("mShortFrame04", getTxt(list[i],i));
			$("td_route_"+list[i].roadNo+"_"+list[i].roadBound).update(getRouteTxt(list[i],i));
			$("td_contents_"+list[i].roadNo+"_"+list[i].roadBound).update(getContentsTxt(list[i],i));
			roadNo = list[i].roadNo;
			roadBound = list[i].roadBound;
		}
		else
		{
			new Insertion.Bottom("td_contents_"+list[i].roadNo+"_"+list[i].roadBound, getContentsTxt(list[i],i));
		}		
	}
	return;
}

function setRouteContents(list)
{
	var roadNo = "";
	var roadBound = "";
	for( var i=0 ; i<list.size() ; i++ )
	{
		if( roadNo != list[i].roadNo||roadBound != list[i].roadBound )
		{
			new Insertion.Bottom("mShortFrame04", getTxt(list[i],i));
			$("td_route_"+list[i].roadNo+"_"+list[i].roadBound).update(getRouteTxt(list[i],i));
			$("td_contents_"+list[i].roadNo+"_"+list[i].roadBound).update(getContentsTxt(list[i],i));
			roadNo = list[i].roadNo;
			roadBound = list[i].roadBound;
		}
		else
		{
			new Insertion.Bottom("td_contents_"+list[i].roadNo+"_"+list[i].roadBound, getContentsTxt(list[i],i));
		}		
	}
}
function getTxt(list, i)
{
	var txt = "";

	txt += "<table width='100%' border='0' cellspacing='0' cellpadding='1' bgcolor='#ffffff'>";
	txt += "  <tr>";
	txt += "    <td id='td_route_"+list.roadNo+"_"+list.roadBound+"'><!--³ë¼±³ÖÀ» À§Ä¡..--></td>";
	txt += "  </tr>";
	txt += "  <tr>";
	txt += "    <td id='td_contents_"+list.roadNo+"_"+list.roadBound+"'><!--³»¿ë³ÖÀ»À§Ä¡--></td>";
	txt += "  </tr>";
	txt += "</table>";

	return txt;
}
function getRouteTxt(list, i)
{
	var txt = "";
	txt += "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
	txt += "  <tr>";
	txt += "    <td width='180' class='head'><img src='images/icon_road1_"+list.roadNoImg+".png' width='27' height='27' align='absmiddle' /><strong>"+list.roadName+"</strong><br></td>";
	txt += "    <td width='128' class='head' align='right'>["+list.roadDname+"]</td><!--³ë¼±..--></td>";	
	txt += "  </tr>";
	txt += "</table>";
	return txt;
}
function getContentsTxt(list, i)
{
	var className = 't2';
	if(i%2==0) className = 't1';
	
	var imageArrow = "<img src='images/2009_main/traffic_list_icon_red.gif' width='30' height='19'>"
	var txt = "";
 	txt += "<table width='100%' border='0' cellspacing='0' cellpadding='2'>";
	txt += "<tr>";
	txt += "<td width='95' align='left' class='t1'>"+list.linkFname+"</td>";
	txt += "<td width='35' align='left' class='t1'>"+imageArrow+"</td>";
	txt += "<td width='106' align='left' class='t1'>"+list.linkTname+"</td>";
	txt += "<td width='33' align='right' class='t1'>"+list.speed+"</td>";
	txt += "<td width='41' align='right' class='t1'>"+list.travelTime+"</td>";
	txt += "</tr>";
	txt += "</table>";
	
	
	return txt;
}