function formatResult(lotshortname, result) {
	if(lotshortname=='sd'&&result=='')result='&nbsp;,&nbsp;,&nbsp;';
	var html = '',
	left = result,
	right = '';
	if (/\|/.test(result)) {
		var tmp = result.split('|');
		left = tmp[0];
		right = tmp[1];
	};
	left = left.split(/,/.test(left) ? ',': '');
	if (right != undefined && right != '') {
		right = right.split(',');
		if (right.length == 1) right = '<li class="ball_blue">' + right + '</li>';
		else right = '<li class="ball_blue">' + right.join('</li><li class="ball_blue">') + '</li>';
	};
	var red = /dlt|ssq/.test(lotshortname) ? 'ball_red': 'ball_orange';

	if (/sfc|jq4|zc6|dc/.test(lotshortname)) {
		html = left.join(' ');
	} else {
		html = '<div class="ball_box01"><ul><li class="' + red + '">' + left.join('</li><li class="' + red + '">') + '</li>' + right + '</ul></div>';
	}
	return document.write(html);
};

function formatCCMoney(lotshortname, ccmoney) {
	var m=ccmoney.replace(/,/g, "").replace(/(\d)(?=(\d{3})+$)/g,'$1,');
	var CCMoney = m + "元";
	document.write(CCMoney);
};
function main() {
	var serverTimeURL= location.protocol+'//'+location.host+'/115/getServerTime.php';
	var today=new Date;
	var todayShow = fm.get('#gonggo_today', 0);
	var todayOpen = function() {
		var xml = location.protocol+'//'+location.host+'/static/info/kaijiang/xml/index.xml';
		var opts = {
			from: xml,
			load: function(h, x) {
				var openLot = [],
				html = [];
				var day=today.get('W');
				var date=today.get();
				fm.xml(x).get('//lottery[isdf="false"]',
				function() {
					var kjDay=this.get("openday/text()",0).nodeValue;
					var kjDate=this.get("resulttime/text()",0).nodeValue;
					if(kjDay=='不定期'){
						if(kjDate!=date)return;
					}else{
						if(kjDay!='每日'&&kjDay.indexOf(day)==-1)return;
					};
					var tmp={};
					tmp.name=this.get("lotchinesename/text()",0).nodeValue;
					tmp.id=this.get("lotshortname/text()",0).nodeValue;
					openLot.push(tmp);
				});
				openLot.each(function(i, o) {
					//html.push('<a href="kj_' + this.id + '.shtml" target="_blank">' + this.name + '</a>')
					html.push('<a href = /'+this.id+'.shtml target="_blank">'+ this.name +'</a>');
					//html.push('<a href="http://kaijiang.500wan.com/' + this.id + '.shtml" target="_blank">' + this.name + '</a>')
				});
				todayShow.innerHTML = '<span class="title">今日开奖：</span><div class="scrollShell" style="width:839px;"><div id="todayContent" style="float:left;white-space:noWrap;display:inline">' + html.join(' &nbsp; ') + '</div></div>';
				todayScroll();
			}
		};
		fm.Ajax(opts);
	};
	var todayScroll = function() {
		var todayContent = fm.get('#todayContent', 0);
		var i = 0,
		max = todayContent.offsetWidth,
		reset= todayContent.parentNode.offsetWidth,
		stop = false;
		setInterval(function() {
			todayContent.style.marginLeft = i + 'px';
			if (!stop) i--;
			if (i < - max) i = reset;
		},
		24);
		todayContent.onmouseover = function() {
			stop = true;
		};
		todayContent.onmouseout = function() {
			stop = false;
		};
	};
	fm.Ajax(serverTimeURL,function(h){
		today=new Date(parseInt(h));
		todayOpen();
	});


	var table = document.getElementsByTagName("table");
	var trbe = document.getElementById('row_fc');

	var tr = document.getElementById('bjdc');

	table[0].getElementsByTagName("tbody")[0].insertBefore(tr,trbe);
};
/*
began to run from here
*/
fm.domInit(main);