﻿// ======================== common ================================!
function _(id)
{
	return document.getElementById(id);
}
function _x(root,tagName)
{
    var value = root.getElementsByTagName(tagName)[0].text;
    if (value == undefined) value = root.getElementsByTagName(tagName)[0].textContent;
    return value;
}
function _t(text)
{
	return document.createTextNode(text);
}
function _p(obj)
{
	return obj.parentElement || obj.parentNode;
}

//获取URL中的一个参数
function GetURLPamam(key)
{
	var URLSearch = window.location.search;
	if(URLSearch.indexOf(key) != -1)
	{
		var URLParam = URLSearch.substr(1).split("&");
		var keyName = "";
		var keyValue = "";
		for(var i=0; i<URLParam.length; i++ )
		{
			keyName = URLParam[i].split("=")[0];
			if(keyName == key)
				keyValue = URLParam[i].split("=")[1];
		}
		return keyValue;
	}
	else
	{
		return "";
	}
}
function URLRewriter(URL,key,value)
{
	var intIndex = URL.indexOf("?");
	if(intIndex == -1)
		return URL + "?" + key + "=" + value;
	var URLHost = URL.substring(0,intIndex);
	var URLSearch = URL.substring(intIndex+1,URL.length);
	var URLParam = URLSearch.split("&");
	URLSearch = "";
	var Param = "";
	var RewriteFlag = false;
	for(var i = 0; i < URLParam.length; i ++)
	{
		if(URLParam[i].split("=")[0] == key)
		{
			Param = key + "=" + value;
			RewriteFlag = true;
		}
		else
			Param = URLParam[i];
		URLSearch = URLSearch + Param + "&";
	}
	if(RewriteFlag == false)
		return URL + "&" + key + "=" + value;
	URLSearch = URLSearch.substring(0,URLSearch.length-1);
	return URLHost + "?" + URLSearch;
}
function MakePagerA(objPlace, intPageNum, intCurrentPage)
{
	var a = document.createElement("a");
	a.innerHTML = intPageNum;
	a.href = "javascript:void(0);";
	a.attachEvent("onclick",function(){RT('pn',intPageNum)});
	if(intPageNum == intCurrentPage) a.className = "thisPage";
	objPlace.appendChild(a);
}
//MakePager(页码放置位置, 总页数, 当前页, 要显示的页码个数--暂时只能为双数)
function MakePager(objPlace, intPageCount, intCurrentPage, intPageQuantity)
{
	objPlace.innerHTML = "";
	objPlace.style.visibility = "visible";
	var i = 0;
	if (intPageCount == 1)
	{
		objPlace.style.visibility = "hidden";
		return;
	}

	if (intPageCount <= intPageQuantity)
	{
		for (i = 1; i < intPageCount + 1; i++)
			MakePagerA(objPlace, i, intCurrentPage);
		return;
	}

	if (intCurrentPage <= intPageQuantity / 2)
	{
		for (i = 1; i <= intPageQuantity; i++)
			MakePagerA(objPlace, i, intCurrentPage);
		return;
	}

	if (intCurrentPage > intPageCount - intPageQuantity / 2)
	{
		for (i = intPageCount - intPageQuantity; i <= intPageCount; i++)
			MakePagerA(objPlace, i, intCurrentPage);
		return;
	}

	for (i = intCurrentPage - intPageQuantity / 2; i <= intCurrentPage + intPageQuantity / 2; i++)
		MakePagerA(objPlace, i, intCurrentPage);
}
function InfoBind(url,tableID)
{
    var xmlHttp = false;
    if (window.XMLHttpRequest)
        xmlHttp = new XMLHttpRequest();
    else if (window.ActiveXObject)
    {
        try
        {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {}
        }
    }
    if (!xmlHttp) {
        alert('由于浏览器不支持，您将无法正常使用此功能');
        return false;
    }

    xmlHttp.onreadystatechange = function() { addInfoListLi(xmlHttp,tableID); };
    xmlHttp.open('GET', url, true);
    xmlHttp.send(null);
}
function addInfoListLi(xmlHttp,tableID)
{
    if (xmlHttp.readyState == 4)
    {
        if (xmlHttp.status == 200)
        {
            var xmldoc = xmlHttp.responseXML;
            var root = xmldoc.documentElement;
			switch(root.getAttribute("id"))
			{
				case "CityBind":
					ajaxCityBind(root);
					break;
				case "GetWeather":
					ajaxGetWeather(root,tableID);
					break;
				case "InfoListBind":
					ajaxInfoListBind(root,tableID);
					break;
				case "MyTruckList":
					ajaxMyTruckList(root,tableID);
					break;
				case "CloseGoodsInfo":
				    ajaxCloseGoodsInfo(root);   //关闭一条货物信息
				    break;
				case "GetMyGoodsInfo":
				    ajaxGetMyGoodsInfo(root);   //取回一条货物信息
				    break;
				case "MyGoodsInfoList":
				    ajaxMyGoodsInfoList(root,tableID);  //获取我的货物信息列表
				    break;
				case "CloseTruckInfo":
				    ajaxCloseTruckInfo(root);   //关闭一条车辆信息
				    break;
				case "GetMyTruck":
				    ajaxGetMyTruck(root);   //取回一条车辆
				    break;
				case "GetMyTruckInfo":
				    ajaxGetMyTruckInfo(root);   //取回一条车辆信息
			        break;
		        case "MyTruckInfoList":
		            ajaxMyTruckInfoList(root,tableID);  //获取我的车辆信息列表
		            break;

		        case "GoodsSearch":
		            ajaxGoodsSearch(root,tableID);  //搜索货物信息
		            break;
		        case "TruckSearch":
		            ajaxTruckSearch(root,tableID);  //搜索车辆信息
		            break;
		            
		        case "GetContactInfo":
		            ajaxGetContactInfo(root,tableID);  //搜索车辆信息
		            break;
		            
		        case "TestUserName":
		            ajaxTestUserName(root,tableID);  //搜索车辆信息
		            break;
				
				case "GetDangousList":
					ajaxGetDangousList(root,tableID);	//搜索危险品名录
					break;
			}
        }
//        else
//            alert('服务器没有响应');
    }
}
// ========================================================

// ======================== default.ascx ================================!
function setHomepage(obj)
{
	obj.setHomePage("http://www.wxp168.com");
}
// ========================================================

// ======================== tools.ascx ================================!
function ajaxGetWeather(root,tableID)
{
	var table = _(tableID);
	for (var j=table.rows.length ; j>0 ; j--)
		 table.deleteRow(j-1);
	table.insertRow(-1);
	table.rows[0].insertCell(0);
	table.rows[0].cells[0].colSpan = 3;
	table.rows[0].cells[0].aligh = "left";
	table.rows[0].cells[0].innerHTML = _x(root,'city');
	for (var i=0 ; i<root.getElementsByTagName('day').length ; i++)
	{
		var day = root.getElementsByTagName('day')[i];
		var tr = table.insertRow(i+1);
		tr.insertCell(0).appendChild(_t(_x(day,'time')));
		tr.insertCell(1).appendChild(_t(_x(day,'weather')));
		tr.insertCell(2).appendChild(_t(_x(day,'temper')));
		tr.cells[0].className = "time";
		tr.cells[1].className = "weather";
		tr.cells[1].className = "temper";
	}
}
// ========================================================

// ======================== default.ascx ================================!
// Rmarquee(滚动对象id, 可见范围宽度, 可见范围高度, , , 滚动速度, 停留时间, 方向); 方向有left和up两种
function Rmarquee(id,mw,mh,mr,sr,ms,pause,dr){
	var obj= _(id);
	obj.ss=false; //stop tag
	obj.mr=mr; //marquee rows
	obj.sr=sr; //marquee display rows
	obj.mw=mw; //marquee width
	obj.mh=mh; //marquee height
	obj.ms=ms; //marquee speed
	obj.pause=pause; //pause time
	obj.pt=0; //pre top
	obj.st=0; //stop time
	obj.dr=dr; //direction

	with(obj){
		//style.width=mw+"px";
		//style.height=mh+"px";
		//style.height="80px";
		noWrap=false;
		onmouseover=stopm;
		onmouseout=startm;
		scrollTop=0+"px";
		scrollLeft=0+"px";
	}
	
	if(obj.mr!=1){
		switch(obj.dr){
			case("up"):
				obj.tt=mh*mr/sr;
				obj.ct=mh; //current top
				obj.innerHTML+=obj.innerHTML;
				setInterval(scrollUp,obj.ms); break;
			default://("left"):
				obj.tt=mw*mr/sr;
				obj.ct=mw;
				obj.innerHTML='<div style="width:'+(obj.tt*2)+'px;"><div style="float:left;">'+obj.innerHTML+'</div><div style="float:right;">'+obj.innerHTML+'</div></div>';
				document.write('<style type="text/css">#'+id+' table{width:'+mw*mr+'px;} #'+id+' td{width:'+mw+'px;}</style>');
				setInterval(scrollLeft,obj.ms); break;
		}
	}

	function scrollUp(){
		if(obj.ss==true) return;
		obj.ct+=1;
		if(obj.ct==obj.mh+1){
			obj.st+=1; obj.ct-=1;
			if(obj.st==obj.pause){obj.ct=0; obj.st=0;}
		}else {
			obj.pt=(++obj.scrollTop);
			if(obj.pt==obj.tt){obj.scrollTop=0;}
		}
	}

	function scrollLeft(){
		if(obj.ss==true) return;
		obj.ct+=1;
		if(obj.ct==obj.mw+1){
			obj.st+=1; obj.ct-=1;
			if(obj.st==obj.pause){obj.ct=0; obj.st=0;}
		}else {
			obj.pt=(++obj.scrollLeft);
			if(obj.pt==obj.tt){obj.scrollLeft=0;}
		}
	}

	function stopm(){obj.ss=true;}
	function startm(){obj.ss=false;}
}
// ========================================================

// ======================== flashMap.ascx ================================!
function ajaxCityBind(root)
{
	var ul = _("ulCityList");
	ul.innerHTML = "";
	for (var i=0 ; i<root.getElementsByTagName('city').length ; i++)
	{
		var text = root.getElementsByTagName('city')[i].text;
		if (text == undefined) text = root.getElementsByTagName('city')[i].textContent;
		var id = root.getElementsByTagName('city')[i].getAttribute("id");
		var li = document.createElement("li");
		li.innerHTML = '<a href="javascript:void(null)" onclick="Sentdata(\'' + id + '\',\'' + text + '\')">' + text + '</a>';
		ul.appendChild(li);
	}
	_('shi').style.visibility='visible';
}

var flashMapCityName;
var flashMapCityID;

function showsheng(cityName,cityID)
{
	flashMapCityName = _(cityName);
	flashMapCityID = _(cityID);
	showMap(_p(flashMapCityName));
}
function GetResult(main)
{
	InfoBind("ajax.aspx?oper=CityBind&fid="+main,'talbeID');
}
function ClearResult()
{
	var obj = _p(_('sheng'));
	obj.removeChild(_('shi'));
	obj.removeChild(_('sheng'));
	flashMapCityName.value = "";
	flashMapCityID.value = "";
}
function Sentdata(id,text)
{
	var obj = _p(_('sheng'));
	obj.removeChild(_('shi'));
	obj.removeChild(_('sheng'));
	flashMapCityName.value = text;
	flashMapCityID.value = id;
}
function showMap(obj) {
	if(_('sheng')!=null)
	{
		_('sheng').style.visibility = 'visible';
	}
	else
	{
		var HTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='380' height='300' id='map' align='middle'>";
		HTML += "<param name='movie' value='style/flash/map.swf'>";
		HTML += "<param name='quality' value='high'>";
		HTML += "<param name='bgcolor' value='#fffeef'>";
		HTML += "<param name='wmode' value='transparent'>";
		HTML += "<embed src='style/flash/map.swf' quality='high' bgcolor='#fffeef' width='380' height='300' name='map' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'>";
		HTML += "</object>";
		
		var div = document.createElement("div");
		div.id = "sheng";
		div.innerHTML = HTML;
		obj.appendChild(div);
		
		var HTMLShi = "<div class=\"close\"><a href=\"javascript:void(null)\" onClick=\"_p(_p(this)).style.visibility='hidden';\">[关闭]</a></div>";
		HTMLShi += "<ul id=\"ulCityList\"></ul>";
		var divShi = document.createElement("div");
		divShi.id = "shi";
		divShi.style.visibility = 'hidden';
		divShi.innerHTML = HTMLShi;
		obj.appendChild(divShi);
	}
}
// ========================================================

// ======================== infoRefreshList.ascx ================================!
function ajaxInfoListBind(root,tableID)
{
	var table = _(tableID);
	for (var j=table.rows.length ; j>0 ; j--)
		 table.deleteRow(j-1);
	for (var i=0 ; i<root.getElementsByTagName('info').length ; i++)
	{
		var info = root.getElementsByTagName('info')[i];
		table.insertRow(-1);
		if (_x(info,'type') == "车辆")
		{
			table.rows[i].insertCell(0);
			table.rows[i].cells[0].innerHTML = "<a target=\"_blank\" href=\"searchResultTruck.aspx?st=" + _x(info,'startingID') + "\">" + _x(info,'starting') + "</a> => ";
			if(_x(info,'endingID') != "")
			    table.rows[i].cells[0].innerHTML += "<a target=\"_blank\" href=\"searchResultTruck.aspx?en=" + _x(info,'endingID') + "\">" + _x(info,'ending') + "</a>";
			else
			    table.rows[i].cells[0].innerHTML += "全国";
			table.rows[i].insertCell(1);
			table.rows[i].cells[1].innerHTML = "<a target=\"_blank\" href=\"infoDetail.aspx?tp=t&id=" + _x(info,'ID') + "\">" + _x(info,'other') + '</a>';
		}
		else
		{
			table.rows[i].insertCell(0);
			table.rows[i].cells[0].innerHTML = "<a target=\"_blank\" href=\"searchResultGoods.aspx?st=" + _x(info,'startingID') + "\">" + _x(info,'starting') + "</a> => ";
			if(_x(info,'endingID') != "")
			    table.rows[i].cells[0].innerHTML += "<a target=\"_blank\" href=\"searchResultGoods.aspx?en=" + _x(info,'endingID') + "\">" + _x(info,'ending') + "</a>";
			else
			    table.rows[i].cells[0].innerHTML += "全国";
			table.rows[i].insertCell(1);
			table.rows[i].cells[1].innerHTML = "<a target=\"_blank\" href=\"infoDetail.aspx?tp=g&id=" + _x(info,'ID') + "\">" + _x(info,'other') + '</a>';
		}
		table.rows[i].insertCell(2);
/*		table.rows[i].cells[2].innerHTML = _x(info,'startTime');*/
		table.rows[i].cells[2].innerHTML = _x(info,'sTime');
	}
}
// ========================================================

// ======================== myTruck.aspx ================================!
function ajaxMyTruckList(root,tableID)
{
	var tag = _(tableID).tagName;
	if (tag == "TABLE")
	{
		var table = _(tableID);
		for (var j=table.rows.length ; j>0 ; j--)
			 table.deleteRow(j-1);
	    if (root.getElementsByTagName('info').length == 0)
	    {
	        table.insertRow(-1);
	        table.rows[0].insertCell(0);
	        table.rows[0].cells[0].className = "noResult";
	        table.rows[0].cells[0].innerHTML = "您还没有发布任何车辆";
	    }
		else
		{
			table.createTHead();
			var tr = table.tHead.insertRow(0);
			tr.insertCell(0).appendChild(_t("车牌号"));
			tr.insertCell(1).appendChild(_t("车型"));
			tr.insertCell(2).appendChild(_t("车长"));
			tr.insertCell(3).appendChild(_t("载重"));
			tr.insertCell(4).appendChild(_t("货物类型"));
			tr.insertCell(5).appendChild(_t(""));
		}
		for (var i=0 ; i<root.getElementsByTagName('info').length ; i++)
		{
			var info = root.getElementsByTagName('info')[i];
			var tr = table.insertRow(i+1);
			tr.insertCell(0).appendChild(_t(_x(info,'licenseTag')));
			tr.insertCell(1).appendChild(_t(_x(info,'truckType')));
			tr.insertCell(2).appendChild(_t(_x(info,'length') + "米"));
			tr.insertCell(3).appendChild(_t(_x(info,'tonnage') + "吨"));
			tr.insertCell(4).appendChild(_t(_x(info,'productType')));
			tr.insertCell(5);
			tr.cells[5].innerHTML = "<a href=\"javascript:void(null);\" onclick=\"getTruck(" + _x(info,'ID') + ");\"><img alt=\"引用\" src=\"../style/images/my_btn_02.gif\" width=\"60\" height=\"23\" /></a>";
		}
	}
	else
	{
		_(tableID).length = 0;
		var opt = document.createElement("option");
		opt.text = "在这里选择以前发布过的车辆，可以节省很多时间";
		_(tableID).options.add(opt);
	
		for (var i=0 ; i<root.getElementsByTagName('info').length ; i++)
		{
			var info = root.getElementsByTagName('info')[i];
			var opt = document.createElement("option");
			opt.value = _x(info,'ID');
			opt.text = _x(info,'licenseTag') + "   " + _x(info,'truckType') + "   " + _x(info,'length') + "米   " + _x(info,'tonnage') + "吨";
			_("sltTruckList").options.add(opt);
		}
	}
}
// ========================================================

// ======================== myGoodsInfo.aspx ================================!
function ajaxCloseGoodsInfo(root)
{
    var text = root.text;
    if (text == undefined) text = root.textContent;
    if (text == "Success")
        getMyGoodsInfoList();
    else
        alert("操作失败");
}
function ajaxGetMyGoodsInfo(root)
{
    _("txtName").value = _x(root,'name');

    _("DdlProductType1$ddlType").value = _x(root,'productType');

    var q = _x(root,'quantity').split(" ");
    _("txtQuantity").value = q[0];
    for (var i=0; i<document.getElementsByName("rblQuantityUnit").length; i++)
        if (document.form1.rblQuantityUnit.item(i).value == q[1])
            document.form1.rblQuantityUnit.item(i).checked = true;

    var p = _x(root,'price').split("/");
    _("txtPrice").value = p[0];
    for (i=0; i<document.getElementsByName("rblPriceUnit").length; i++)
        if (document.form1.rblPriceUnit.item(i).value == p[1])
            document.form1.rblPriceUnit.item(i).checked = true;

    for (i=0; i<document.getElementsByName("rblIndate").length; i++)
        if (document.form1.rblIndate.item(i).value == _x(root,'indate'))
            document.form1.rblIndate.item(i).checked = true;

    _("txtOther").value = _x(root,'other');

    _("hidID").value = _x(root,'ID');
    
    _("FlashMapS_txtCityName").value = _x(root,'startingN');
    _("FlashMapS_hidCityID").value = _x(root,'starting');
    _("FlashMapE_txtCityName").value = _x(root,'endingN');
    _("FlashMapE_hidCityID").value = _x(root,'ending');
    _("txtSDetail").value = _x(root,'startDetail');
    _("txtEDetail").value = _x(root,'endDetail');
}
function ajaxMyGoodsInfoList(root,tableID)
{
    var table = _(tableID);
    for (var j=table.rows.length ; j>0 ; j--)
	     table.deleteRow(j-1);
    if (root.getElementsByTagName('info').length == 0)
    {
        table.insertRow(-1);
        table.rows[0].insertCell(0);
        table.rows[0].cells[0].className = "noResult";
        table.rows[0].cells[0].innerHTML = "您还没有发布任何货物信息";
    }
	else
	{
		table.createTHead();
		var tr = table.tHead.insertRow(0);
		tr.insertCell(0).appendChild(_t("货物名称"));
		tr.insertCell(1).appendChild(_t("货物数量"));
		tr.insertCell(2).appendChild(_t("运输起止地"));
		tr.insertCell(3).appendChild(_t("详细内容"));
		tr.insertCell(4).appendChild(_t(""));
	}
    for (var i=0 ; i<root.getElementsByTagName('info').length ; i++)
    {
	    var info = root.getElementsByTagName('info')[i];
		var tr = table.insertRow(i+1);
		tr.insertCell(0).appendChild(_t(_x(info,'name')));
		tr.insertCell(1).appendChild(_t(_x(info,'quantity')));
		if(_x(info,'ending') != "")
		    tr.insertCell(2).appendChild(_t(_x(info,'starting') + " => " + _x(info,'ending')));
		else
		    tr.insertCell(2).appendChild(_t(_x(info,'starting') + " => 全国"));
		tr.insertCell(3);
		tr.cells[3].innerHTML = "<a target=\"_blank\" href=\"infoDetail.aspx?tp=g&id=" + _x(info,'ID') + "\">" + _x(info,'other') + "</a>";
		//tr.insertCell(3).appendChild(_t(_x(info,'other')));
	    tr.insertCell(4);
	    if (_x(info,'state') == "正常")
		    tr.cells[4].innerHTML = "<a href=\"javascript:void(null);\" onclick=\"closeGoodsInfo(" + _x(info,'ID') + ");\"><img alt=\"删除此信息\" src=\"../style/images/my_btn_03.gif\" width=\"60\" height=\"23\" /></a>";
	    else
		    tr.cells[4].innerHTML = "<a href=\"javascript:void(null);\" onclick=\"updateGoodsInfo(" + _x(info,'ID') + ");\"><img alt=\"重新发布此信息\" src=\"../style/images/my_btn_04.gif\" width=\"60\" height=\"23\" /></a>";
	    tr.cells[4].innerHTML += " <a href=\"javascript:void(null);\" onclick=\"newGoodsInfo(" + _x(info,'ID') + ");\"><img alt=\"发一条相似的新信息\" src=\"../style/images/my_btn_02.gif\" width=\"60\" height=\"23\" /></a>";
    }
}
// ========================================================

// ======================== myTruckInfo.aspx ================================!
function ajaxCloseTruckInfo(root)
{
    var text = root.text;
    if (text == undefined) text = root.textContent;
    if (text == "Success")
        InfoBind('ajax.aspx?oper=MyTruckInfoList&on=' + userID,'infoList');
    else
        alert("操作失败");
}
function ajaxGetMyTruck(root)
{
    _("txtLicenseTag").value = _x(root,'licenseTag');
    _("DdlTruckType1_ddlType").value = _x(root,'type');
    _("txtLength").value = _x(root,'length');
    _("txtTonnage").value = _x(root,'tonnage');
    _("DdlProductType1_ddlType").value = _x(root,'productType');
	
	if(_("hidTruckID") != null)
	{
		_("hidTruckID").value = _("sltTruckList").value;
		_("hidLicenseTag").value = _("txtLicenseTag").value;
		_("hidTruckType").value = _("DdlTruckType1_ddlType").value;
		_("hidLength").value = _("txtLength").value;
		_("hidTonnage").value = _("txtTonnage").value;
		_("hidProductType").value = _("DdlProductType1_ddlType").value;
	}
}
function ajaxGetMyTruckInfo(root)
{
    _("hidID").value = _x(root,'ID');

    _("hidTruckID").value = _x(root,'truckID');

    _("txtLicenseTag").value = _x(root,'licenseTag');
    _("hidLicenseTag").value = _x(root,'licenseTag');

    _("DdlTruckType1_ddlType").value = _x(root,'truckType');
    _("hidTruckType").value = _x(root,'truckType');

    _("txtLength").value = _x(root,'length');
    _("hidLength").value = _x(root,'length');

    _("txtTonnage").value = _x(root,'tonnage');
    _("hidTonnage").value = _x(root,'tonnage');

    _("DdlProductType1_ddlType").value = _x(root,'productType');
    _("hidProductType").value = _x(root,'productType');

    for (var i=0; i<document.getElementsByName("rblTransportType").length; i++)
        if (document.form1.rblTransportType.item(i).value == _x(root,'transportType'))
            document.form1.rblTransportType.item(i).checked = true;

    for (i=0; i<document.getElementsByName("rblIndate").length; i++)
        if (document.form1.rblIndate.item(i).value == _x(root,'indate'))
            document.form1.rblIndate.item(i).checked = true;

    _('txtReturn').value = _x(root,'returnTime');
    _("txtOther").value = _x(root,'other');
//=================================================================================
    _("FlashMapS_txtCityName").value = _x(root,'startingN');
    _("FlashMapS_hidCityID").value = _x(root,'starting');
    _("FlashMapE_txtCityName").value = _x(root,'endingN');
    _("FlashMapE_hidCityID").value = _x(root,'ending');
    _("txtSDetail").value = _x(root,'startDetail');
    _("txtEDetail").value = _x(root,'endDetail');
}
function ajaxMyTruckInfoList(root,tableID)
{
    var table = _(tableID);
    for (var j=table.rows.length ; j>0 ; j--)
	     table.deleteRow(j-1);
    if (root.getElementsByTagName('info').length == 0)
    {
        table.insertRow(-1);
        table.rows[0].insertCell(0);
        table.rows[0].cells[0].className = "noResult";
        table.rows[0].cells[0].innerHTML = "您还没有发布任何车辆信息";
    }
	else
	{
		table.createTHead();
		var tr = table.tHead.insertRow(0);
		tr.insertCell(0).appendChild(_t("车牌号"));
		tr.insertCell(1).appendChild(_t("运输类型"));
		tr.insertCell(2).appendChild(_t("运输起止地"));
		tr.insertCell(3).appendChild(_t("详细内容"));
		tr.insertCell(4).appendChild(_t(""));
	}
    for (var i=0 ; i<root.getElementsByTagName('info').length ; i++)
    {
	    var info = root.getElementsByTagName('info')[i];
		var tr = table.insertRow(i+1);
		tr.insertCell(0).appendChild(_t(_x(info,'licenseTag')));
		tr.insertCell(1).appendChild(_t(_x(info,'transportType')));
		if(_x(info,'ending') != "")
		    tr.insertCell(2).appendChild(_t(_x(info,'starting') + " => " + _x(info,'ending')));
		else
		    tr.insertCell(2).appendChild(_t(_x(info,'starting') + " => 全国"));
		//tr.insertCell(3).appendChild(_t(_x(info,'other')));
		tr.insertCell(3);
		tr.cells[3].innerHTML = "<a target=\"_blank\" href=\"infoDetail.aspx?tp=t&id=" + _x(info,'ID') + "\">" + _x(info,'other') + "</a>";
	    tr.insertCell(4);
	    if (_x(info,'state') == "正常")
	        tr.cells[4].innerHTML = "<a href=\"javascript:void(null);\" onclick=\"closeTruckInfo(" + _x(info,'ID') + ");\"><img alt=\"删除此信息\" src=\"../style/images/my_btn_03.gif\" width=\"60\" height=\"23\" /></a>";
	    else
	        tr.cells[4].innerHTML = "<a href=\"javascript:void(null);\" onclick=\"updateTruckInfo(" + _x(info,'ID') + ");\"><img alt=\"重新发布此信息\" src=\"../style/images/my_btn_04.gif\" width=\"60\" height=\"23\" /></a>";
	    tr.cells[4].innerHTML += " <a href=\"javascript:void(null);\" onclick=\"newTruckInfo(" + _x(info,'ID') + ");\"><img alt=\"发一条相似的信息\" src=\"../style/images/my_btn_02.gif\" width=\"60\" height=\"23\" /></a>";
    }
}
// ========================================================

// ======================== searchResultGoods.aspx ================================!
function ajaxGoodsSearch(root,tableID)
{
    var table = _(tableID);
    for (var j=table.rows.length ; j>0 ; j--)
	     table.deleteRow(j-1);
	if (root.getElementsByTagName('info').length == 0)
	{
		var tr = table.insertRow(0);
		tr.insertCell(0).appendChild(document.createTextNode("对不起，没有找到相关的信息"));
		tr.cells[0].className = "noResult";
		MakePager(_('palPageNum'), 1, 1, 10);
		return;
	}
    for (var i=0 ; i<root.getElementsByTagName('info').length ; i++)
    {
	    var info = root.getElementsByTagName('info')[i];
		var tr = table.insertRow(i);
		tr.insertCell(0).appendChild(_t(_x(info,'type')));
		tr.insertCell(1).appendChild(_t(_x(info,'name')));
		tr.insertCell(2).appendChild(_t(_x(info,'productType')));
        tr.insertCell(3);
        tr.cells[3].innerHTML = "<a target=\"_blank\" href=\"searchResultGoods.aspx?st=" + _x(info,'startingID') + "\">" + _x(info,'starting') + "</a> =&gt; ";
        if(_x(info,'endingID') != "")
            tr.cells[3].innerHTML += "<a target=\"_blank\" href=\"searchResultGoods.aspx?en=" + _x(info,'endingID') + "\">" + _x(info,'ending') + "</a>";
        else
            tr.cells[3].innerHTML += "全国";
        tr.insertCell(4);
        tr.cells[4].innerHTML = "<a target=\"_blank\" href=\"infoDetail.aspx?tp=g&id=" + _x(info,'ID') + "\">" + _x(info,'other') + '</a>';
		tr.insertCell(5).appendChild(_t(_x(info,'sTime')));
    }
	PageCount = Number(_x(root,'pageCount'));
	CurrentPage = Number(_x(root,'currentPage'));
	if(CurrentPage > PageCount) CurrentPage = PageCount;
	if(CurrentPage < 1) CurrentPage = 1;
	MakePager(_('palPageNum'), PageCount, CurrentPage, 10);
}
// ========================================================

// ======================== searchResultTruck.aspx ================================!
function ajaxTruckSearch(root,tableID)
{
    var table = _(tableID);
    for (var j=table.rows.length ; j>0 ; j--)
	     table.deleteRow(j-1);
	if (root.getElementsByTagName('info').length == 0)
	{
		var tr = table.insertRow(0);
		tr.insertCell(0).appendChild(document.createTextNode("对不起，没有找到相关的信息"));
		tr.cells[0].className = "noResult";
		MakePager(_('palPageNum'), 1, 1, 10);
		return;
	}
    for (var i=0 ; i<root.getElementsByTagName('info').length ; i++)
    {
	    var info = root.getElementsByTagName('info')[i];
		var tr = table.insertRow(i);
		tr.insertCell(0).appendChild(_t(_x(info,'type')));
		tr.insertCell(1).appendChild(_t(_x(info,'truckType')));
		tr.insertCell(2).appendChild(_t(_x(info,'length') + '米'));
		tr.insertCell(3).appendChild(_t(_x(info,'tonnage') + '吨'));
		tr.insertCell(4).appendChild(_t(_x(info,'productType')));
		tr.insertCell(5).appendChild(_t(_x(info,'transportType')));
        tr.insertCell(6);
        tr.cells[6].innerHTML = "<a target=\"_blank\" href=\"searchResultTruck.aspx?st=" + _x(info,'startingID') + "\">" + _x(info,'starting') + "</a> => ";
        if(_x(info,'endingID') != "")
            tr.cells[6].innerHTML += "<a target=\"_blank\" href=\"searchResultTruck.aspx?en=" + _x(info,'endingID') + "\">" + _x(info,'ending') + "</a>";
        else
            tr.cells[6].innerHTML += "全国";
        tr.insertCell(7);
        tr.cells[7].innerHTML = "<a target=\"_blank\" href=\"infoDetail.aspx?tp=t&id=" + _x(info,'ID') + "\">" + _x(info,'other') + '</a>';
		tr.insertCell(8).appendChild(_t(_x(info,'sTime')));
    }
	PageCount = Number(_x(root,'pageCount'));
	CurrentPage = Number(_x(root,'currentPage'));
	if(CurrentPage > PageCount) CurrentPage = PageCount;
	if(CurrentPage < 1) CurrentPage = 1;
	MakePager(_('palPageNum'), PageCount, CurrentPage, 10);
}
// ========================================================

// ======================== infoDetail.aspx ================================!
function ajaxGetContactInfo(root,tableID)
{

    var contact = _(tableID);
	contact.innerHTML = "";
    if (root.getElementsByTagName('contact').length == 0)
	{
	    //contact.innerHTML += "此信息发布者为免费会员<br />您不能查看他的联系方式";
	    contact.innerHTML += "您还不能查看货物信息的联系方式<br />请电话联系022-28041007";
		return;
	}
	contact.innerHTML += "联系人: " + _x(root,'contact') + "<br />";
	contact.innerHTML += "电  话: " + _x(root,'phone1') + "<br />";
	contact.innerHTML += "传  真: " + _x(root,'phone2') + "<br />";
	contact.innerHTML += "手  机: " + _x(root,'mobile') + "<br />";
	contact.innerHTML += "地  址: " + _x(root,'address') + "<br />";
	contact.innerHTML += "此联系方式已被浏览<span class=\"clickNum\">" + _x(root,'click') + "</span>次";
}
function countdown(auctionDate,result)
{
    var Temp;
    var ts=auctionDate;
    var dateLeft = 0;
    var hourLeft = 0;
    var minuteLeft = 0;
    var secondLeft = 0;
    if(ts < 0)
    {
        ts = 0;
        CurHour = 0;
        CurMinute = 0;
        CurSecond = 0;
    } else {
        dateLeft =parseInt(ts/86400);
        ts = ts - dateLeft * 86400;
        hourLeft = parseInt(ts/3600);
        ts = ts - hourLeft * 3600;
        minuteLeft = parseInt(ts/60);
        secondLeft = ts - minuteLeft * 60;
    }
    if(hourLeft < 10) hourLeft = '0' +hourLeft;
    if(minuteLeft < 10) minuteLeft = '0' +minuteLeft;
    if(secondLeft < 10) secondLeft='0'+secondLeft;
    if( dateLeft > 0 )
        dateLeft = dateLeft + '天' ;
    else
        dateLeft = "";
    if( hourLeft > 0 )
        hourLeft = hourLeft + '小时' ;
    else
    {
        if( dateLeft != "" )
            hourLeft = "00" + '小时';
        else
            hourLeft = "";
    }
    if( minuteLeft > 0 )
        minuteLeft = minuteLeft + '分钟' ;
    else
    {
        if( dateLeft !="" || hourLeft != "")
            minuteLeft = "00" + '分钟';
        else
            minuteLeft = "";
    }
    if( secondLeft > 0 )
        secondLeft = secondLeft + '秒' ;
    else
    {
        if( dateLeft !="" || hourLeft != "" || minuteLeft != "")
            secondLeft = "00" + '秒';
        else
            secondLeft = "";
    }
	if (dateLeft == '') {
   		Temp=dateLeft+hourLeft+minuteLeft+secondLeft ;
   	}else {
   		Temp=dateLeft+hourLeft;
   	}
    if(auctionDate <= 0 || dateLeft <=0 && hourLeft<=0 && minuteLeft<=0 && secondLeft <=0)
    {
        Temp = "<strong>"+'信息已过期'+"</strong>";
    }
	if (_(result)) _(result).innerHTML=Temp;
	auctionDate--;
}
// ========================================================

// ======================== register.aspx ================================!
function ajaxTestUserName(root,tableID)
{
    var text = root.text;
    if (text == undefined) text = root.textContent;
    if (text == "Success")
		_(tableID).innerHTML = "恭喜，这个用户名可以使用";
	else
		_(tableID).innerHTML = "这个用户名已经被别人注册，你必须换另外一个了";
	_(tableID).style.display = '';
}
// ========================================================

// ======================== waiter.ascx ================================!
var tips;
function initFloatTips() {
	tips = _("waiter");
	moveTips();
}
function moveTips() {
	var tt=50;
	if (window.innerHeight)
	{
		pos = window.pageYOffset + window.screen.availWidth;
	}
	else if (document.documentElement)
	{
		pos = document.documentElement.scrollTop + document.documentElement.clientHeight;
    }
	else if (document.body)
	{
		pos = document.body.scrollTop + document.body.clientHeight;
    }
    pos = pos - 102;
    if(Math.abs(pos-tips.offsetTop) >= 4 )
        pos = (pos + tips.offsetTop)/2;
    tips.style.top = pos+"px";
	setTimeout(moveTips,tt);
}
function gotoWaiter()
{
window.open("http://service.wxp168.com/ChatRoom.aspx?Server_id=1","","height=469,width=696,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no");
}
// ========================================================

// =========================ADList.ascx===============================
function ADGo(id,url) {
window.open(url,"");
InfoBind("ajax.aspx?oper=ADClick&id="+id,'');
}
// ========================================================


// =========================dangerdir.ascx===============================
function ajaxGetDangousList(root,tableID) {
    var table = _(tableID);
    for (var j=table.rows.length ; j>0 ; j--)
	     table.deleteRow(j-1);
	if (root.getElementsByTagName('info').length == 0)
	{
		var tr = table.insertRow(0);
		tr.insertCell(0).appendChild(document.createTextNode("对不起，没有找到相关的信息"));
		tr.cells[0].className = "noResult";
		MakePager(_('palPageNum'), 1, 1, 10);
		return;
	}
	else
	{
		var tr = table.insertRow(0);
		var th1 = document.createElement("th");
		th1.innerHTML = "编号";
		tr.appendChild(th1);
		var th2 = document.createElement("th");
		th2.innerHTML = "名称";
		tr.appendChild(th2);
		var th3 = document.createElement("th");
		th3.innerHTML = "别名";
		tr.appendChild(th3);
		var th4 = document.createElement("th");
		th4.innerHTML = "UN";
		tr.appendChild(th4);
	}
    for (var i=0 ; i<root.getElementsByTagName('info').length ; i++)
    {
	    var info = root.getElementsByTagName('info')[i];
		var tr = table.insertRow(i+1);
		tr.insertCell(0).appendChild(_t(_x(info,'SN')));
		tr.insertCell(1).appendChild(_t(_x(info,'name')));
		tr.insertCell(2).appendChild(_t(_x(info,'nickname')));
		tr.insertCell(3).appendChild(_t(_x(info,'un')));
    }
	PageCount = Number(_x(root,'pageCount'));
	CurrentPage = Number(_x(root,'currentPage'));
	if(CurrentPage > PageCount) CurrentPage = PageCount;
	if(CurrentPage < 1) CurrentPage = 1;
	MakePager(_("palPageNum"), PageCount, CurrentPage, 10);
}
// ========================================================
