 	 var datauser = 'FX168'
	 ddd=new Date();
     var datarow='';
	 var currdate=ddd.getFullYear()+'-'+(ddd.getMonth()+1)+'-'+((ddd.getDate()<10)?'0'+ddd.getDate():ddd.getDate());
	 var dataurl = 'http://service.fx168.com'
	 function ShowDetail(obj, CountryCode, columnCode, table, objrowindex) { 
		if($("#d1"+objrowindex).length>0){
			if($("#d1"+objrowindex).is(":hidden")){
			$("#d1"+objrowindex).show();
			}else $("#d1"+objrowindex).hide();
			return ;
		}
	    datarow=objrowindex;
        strDetail = "<tr id='d1"+objrowindex+"' class='xtrcon'>";
        strDetail += "<td colspan=\"6\" class=\"yjl_caijingyueli_detelBox_td\" width=\"100%\">";
        strDetail += "<div class=\"yjl_caijingyueli_detelBox\">";
        strDetail += "<div class=\"yjl_caijingyueli_detelBox_head\">";
        strDetail += "<div class=\"head_l\">";
        strDetail += "<div>";
        strDetail += "<p><span>公布值：</span><span>" + obj.cells[5].innerHTML + "</span></p>";
        strDetail += "<p><span>预测值：</span><span>" + obj.cells[4].innerHTML + "</span></p>";
        strDetail += "<p><span>前&nbsp;&nbsp;值：</span><span>" + obj.cells[3].innerHTML.split('<')[0] + "</span></p>";
        strDetail += "<p><span>重要性：</span><span>" + obj.cells[1].innerHTML + "</span></p>";
        strDetail += "</div></div>";
        strDetail += "<div class=\"head_t\">" + obj.cells[2].innerHTML + "</div>";
        strDetail += "<div class=\"head_r\"></div>";
        //strDetail += "<h3 id=newh3tr><a href=\"replaceurl\" target=\"_blank\" title=\"" + titltxt + "\">" + titltxt + "</a></h3>";
        //strDetail += "<h3 id=newh3tr>" + titltxt + "</h3>";
        strDetail += "</td></tr>";
        $(obj).after(strDetail);
        SetContentDetail(obj, columnCode, strDetail,objrowindex);
}
function SetContentDetail(obj, columnCode, strDetail,objrowindex) {
    $.ajax({
        type: "get",
        async: false,
        url: dataurl + "/IDataPlatform/FinancialCalendarNew/IFinancialCalendarDetial.ashx",
        data: "user=" + datauser + "&columnCode=" + columnCode + "&dataCount=10&succ_callback=CallbackContentDetail&rd=" + (new Date()).valueOf(),
        dataType: "jsonp",
        jsonp: "callbackfun",
        jsonpCallback: CallbackContentDetail,
        error: function (XMLHttpRequest, textStatus, errorThrown) {
        }
    });
}

//财经详细内容
function CallbackContentDetail(jsonObj) {
	SetDetailHtml(jsonObj);
}
function SetDetailHtml(jsonObj) {  
	if(jsonObj!=null&&jsonObj["List"].length>0){  
		$("#d1"+datarow+" td:eq(0)").find(".head_r").html(jsonObj["List"][0].Define);
	}
}
function SetContent(beginDate) { 
	currdate=beginDate;
	if($("[ty="+currdate+"]").length>0){
		$("[ty]").removeClass("tt");
		$("[ty="+currdate+"]").addClass("tt");
	}
    $.ajax({
        type: "get",
        async: true,
        url: dataurl + "/IDataPlatform/FinancialCalendarNew/IFinancialCalendarData.ashx",
        data: "user=" + datauser + "&beginDate=" + beginDate + "&rd=" + (new Date()).valueOf(),
        dataType: "jsonp",
        jsonp: "succ_callback",
        jsonpCallback: "CallbackContent",
        error: function (XMLHttpRequest, textStatus, errorThrown) {
        }
    });
}
function CallbackContent(jsonObj) {
    SetHtml(jsonObj);
}
//拼html 
function SetHtml(jsonObj) {
    if (jsonObj == null) {
        return;
    } 
    var ftable = "";
    var FinancialCalendarData = jsonObj["List"][0]["FinancialCalendarData"];
    var x_str = "";
    if (FinancialCalendarData != null) {
        if (FinancialCalendarData.length > 0) {
            for (var i = 0; i < FinancialCalendarData.length; i++) {
                var x_connt = FinancialCalendarData[i]["Weightiness"];
                if(x_connt != "3")continue;
                if (x_connt == "0")
                    x_str = "<b class=\"td_star2\"></b><b class=\"td_star2\"></b><b class=\"td_star2\"></b>";
                if (x_connt == "1")
                    x_str = "<b class=\"td_star\"></b><b class=\"td_star2\"></b><b class=\"td_star2\"></b>";
                if (x_connt == "2")
                    x_str = "<b class=\"td_star\"></b><b class=\"td_star\"></b><b class=\"td_star2\"></b>";
                if (x_connt == "3")
                    x_str = "<b class=\"td_star\"></b><b class=\"td_star\"></b><b class=\"td_star\"></b>";

                ftable += "<tr>";
                if (x_connt == "3") {
                    ftable += "<td class=\"td1\">" + FinancialCalendarData[i]["Time"] + "</td>";
                    ftable += "<td class=\"td2\">";
                    ftable += "" + x_str + "";
                    ftable += "</td>";
                    ftable += "<td class=\"td3\">";
                }
                else {
                    ftable += "<td class='td1'>" + FinancialCalendarData[i]["Time"] + "</td>";
                    ftable += "<td class='td2'>";
                    ftable += "" + x_str + "";
                    ftable += "</td>";
                    ftable += "<td class='td3'>";
                }

                ftable += "<span>" + FinancialCalendarData[i]["CountryName"] + "</span>" + FinancialCalendarData[i]["Content"] + "";

                var Previous = FinancialCalendarData[i]["Previous"] == "" ? "&nbsp;" : FinancialCalendarData[i]["Previous"];
                var Predict = FinancialCalendarData[i]["Predict"] == "" ? "&nbsp;" : FinancialCalendarData[i]["Predict"];
                var CurrentValue = FinancialCalendarData[i]["CurrentValue"] == "" ? "&nbsp;" : FinancialCalendarData[i]["CurrentValue"];
                if (FinancialCalendarData[i]["Revised"] != "") {
                    ftable += "</td><td class='td4'>" + Previous + "";
                    ftable += "<a style=\"display: none;width:10px\" class=yjl_caijingyueli_xiugai title=" + FinancialCalendarData[i]["Revised"] + " /></td>";
                } else
                    ftable += "</td><td class='td4'>" + Previous + "</td>";
                ftable += "<td class='td5'>" + Predict + "</td>";
                ftable += "<td class='td6'>" + CurrentValue + "</td></tr>";
            }
            $("#d1").find("tbody").html(ftable);
        }else
        	{
        	$("#d1").find("tbody").html("<tr><td colspan=3>今日无重要预告公布！<td></tr>");
        	} 
        
    }
}
$(function(){
	
	var ttttt=function(){
		SetContent(currdate);
		setTimeout(function(){ttttt();},60000); 
	}
	ttttt();
	
});