﻿/* --------- 代码生成器 更新时间 2010-3-9 14:01:18-------- */
//数据
var adsData = {
    "id": "1",
    "width": "950",
    "height": "35",
    "radom": "0",
    "isCount": "True",
    "data": [

    {
        "id": "1",
        "url": "http://www.qs168.net/wangzhan/wangye/ss.html",
        "src": "/Upload/AdsData/2009/12/12/f6d13fc25f5e44ad8bb7d91f50e57895.gif",
        "code": "<div title=\"企业篮球邀请赛\" style=\"width: WIDTH_VARpx; height: HEIGHT_VARpx;\" ><a href=\"http://www.rkanr.com/Stat/Click.rails?id=1&rUrl=http://www.qs168.net/wangzhan/wangye/ss.html\" target=_blank><img style=\"width: WIDTH_VARpx; height: HEIGHT_VARpx;\" src=\"/Upload/AdsData/2009/12/12/f6d13fc25f5e44ad8bb7d91f50e57895.gif\" border=0></a></div>"
    }

 ]
}
//共用方法
//读取cookie
function getCookie(name){
    var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
    if (arr != null) 
        return unescape(arr[2]);
    return "";
};
//设cookie
function setCookie(name, value){
    var exp = new Date();
    exp.setUTCDate((exp.getUTCDate() + 1));
    exp.setUTCHours(0);
    exp.setUTCMinutes(0);
    document.cookie = name + "=" + escape(value) + "; domain=rkanr.com; path=/; expires=" + exp.toGMTString();
};
//加载广告
try {
    var htmlcode = "";
    var dataId = "";
    if (adsData.radom == "0") {
        //取所有广告
        for (var i = 0, x = adsData.data.length; i < x; i++) {
            htmlcode = htmlcode + adsData.data[i].code;
            dataId = dataId + "d" + adsData.data[i].id;
        };
            }
    else {
        //随机给出一条广告
        var randomNumber = Math.floor(Math.random() * adsData.data.length);
        var tmp = adsData.data[randomNumber];
        htmlcode = tmp.code;
        dataId = "d" + tmp.id;
    }
    //配置输出
    htmlcode = htmlcode.replace(/WIDTH_VAR/g, adsData.width);
    htmlcode = htmlcode.replace(/HEIGHT_VAR/g, adsData.height);
    document.write(htmlcode);
    //记录Cookie
	if(adsData.isCount == "True")
	{
		var cook = getCookie("ads");
	    cook = cook + "b"+adsData.id+dataId;
	    setCookie("ads", cook);
	}	
} 
catch (e) {
}
/* --------- end -------- */