﻿var curgameid=2;//当前游戏ID,2是远征,3是九州
function Request(sName) {
    //本javascript函数 实现重任意的IE地址栏取出参数 
    var sURL = new String(window.location).toLowerCase(); //不区分大小写
    sName = new String(sName).toLowerCase();
    sURL = sURL.replace(/'/g, "");
    var iQMark = sURL.lastIndexOf('?');
    var iLensName = sName.length;
    //retrieve loc. of sName
    var iStart = sURL.indexOf('?' + sName + '=') //limitation 1
    if (iStart == -1) {//not found at start
        iStart = sURL.indexOf('&' + sName + '=')//limitation 1
        if (iStart == -1) {//not found at end
            return 0; //not found
        }
    }
    iStart = iStart + +iLensName + 2;
    var iTemp = sURL.indexOf('&', iStart); //next pair start
    if (iTemp == -1) {//EOF
        iTemp = sURL.length;
    }
    return sURL.slice(iStart, iTemp);
    sURL = null; //destroy String
}

function GetCookie(name) {
    var cookies = document.cookie;
    var index = cookies.indexOf(name);
    if (index != -1) {
        index += name.length + 1;
        lastchar = cookies.indexOf(";", index);
        if (lastchar == -1) {
            lastchar = cookies.length;
        };
        return unescape(cookies.substring(index, lastchar));
    };
    return "";
}

var wl = window.location;
var dr = document.referrer;
var pto = new Date();
var fid = dr.match(new RegExp(".*fad=([^&]*)(&|$)", "i"));
if (!fid) fid = wl.href.match(new RegExp(".*radid=([^&]*)(&|$)", "i"));
if (fid) {
    if (GetCookie("radid").toLowerCase() != "client") {
        pto.setTime((new Date()).getTime() + 60 * 60 * 1000);
        document.cookie = "radid=" + fid[1] + ";path=/;domain=szgla.com;expires=" + pto.toGMTString();
    }
};

var pto2 = new Date();
var fid2 = wl.href.match(new RegExp(".*rsid=([^&]*)(&|$)", "i"));
if (fid2) {
    pto2.setTime((new Date()).getTime() + 60 * 60 * 1000);
    document.cookie = "rsid=" + fid2[1] + ";path=/;domain=szgla.com;expires=" + pto2.toGMTString();
};


var pto3 = new Date();
var fid3 = wl.href.match(new RegExp(".*gameid=([^&]*)(&|$)", "i"));
if (fid3) {
    curgameid=fid3[1];
}
pto3.setTime((new Date()).getTime() + 60 * 60 * 1000);
document.cookie = "gameid=" +curgameid + ";path=/;domain=szgla.com;expires=" + pto3.toGMTString();

