function getQueryString(queryStringName) {
    var returnValue = "";
    var URLString = new String(document.location);
    var serachLocation = -1;
    var queryStringLength = queryStringName.length;
    do {
        serachLocation = URLString.indexOf(queryStringName + "\=");
        if (serachLocation != -1) {
            if ((URLString.charAt(serachLocation - 1) == '?') || (URLString.charAt(serachLocation - 1) == '&')) {
                URLString = URLString.substr(serachLocation);
                break;
            }
            URLString = URLString.substr(serachLocation + queryStringLength + 1);
        }
    }
    while (serachLocation != -1)
    if (serachLocation != -1) {
        var seperatorLocation = URLString.indexOf("&");
        if (seperatorLocation == -1) {
            returnValue = URLString.substr(queryStringLength + 1);
        }
        else {
            returnValue = URLString.substring(queryStringLength + 1, seperatorLocation);
        }
    }
    returnValue = returnValue.replace(/#/g, '');
    return returnValue;
}
//---------------------------获取cookie----------------------------------------------------------------
function getCookie(cName) { var search = cName + "="; var returnvalue = ""; if (document.cookie.length > 0) { offset = document.cookie.indexOf(search); if (offset != -1) { offset += search.length; end = document.cookie.indexOf(";", offset); if (end == -1) { end = document.cookie.length; } returnvalue = unescape(document.cookie.substring(offset, end)); } } return returnvalue; }
//------------------------------设置cookie值------------------------------------------------------------
function setCookie(cName, value, cookie_time, domain) { var then = new Date(); then.setTime(then.getTime() + cookie_time * 1000); document.cookie = cName + '=' + value + ';expires=' + then.toGMTString() + ';path=/' + ((domain) ? ';domain=' + domain : ''); }

var agent_id = getQueryString("agent_id"); //agent_id
var placeid = getQueryString("placeid");
var adid = getQueryString("aid"); //adid
var referer = getQueryString("referer"); //referer
var tid = getQueryString("tid"); //tid
var sid = getQueryString("sid"); //sid
var adtype = getQueryString("type"); //adtype
var rand = getQueryString("rand"); //rand
var game_id = getQueryString("game_id"); //game_id
if (game_id <= 0) { game_id = 132; } //13.04.22 - tiger
var cplaceid = getQueryString("cplaceid");
var turn = getQueryString("turn");

var ref = getQueryString("ref");
if (ref == "") {
    try {
        ref = escape(document.referrer);
    }
    catch (e) {
    }
}
if (ref == "") {
    try {
        ref = getCookie("91wan_ref");
    }
    catch (e) {
    }
}
setCookie('91wan_ref', ref, 86400);
//-----------enterSite,addBookmark,qq,sinaWeibo-------------
function enterSite(url) {
    window.location = url + '?agent_id=' + agent_id + '&placeid=' + placeid + '&adid=' + adid + '&cplaceid=' + cplaceid;
}
function addBookmark(url, title) {
    var uri = url + '?agent_id=' + agent_id + '&placeid=' + placeid + '&adid=' + adid + '&cplaceid=' + cplaceid;
    if (window.sidebar) {
        window.sidebar.addPanel(title, uri, "");
    } else if (document.all) {
        window.external.AddFavorite(uri, title);
    } else if (window.opera && window.print) {
        return true;
    }
}
function qqLogin() {
    //window.location=''+game_id+'&agent_id='+agent_id+'&placeid='+placeid+'&adid='+adid+'&cplaceid='+cplaceid;
    //window.location=''+game_id+'&agent_id='+agent_id+'&placeid='+placeid+'&adid='+adid+'&cplaceid='+cplaceid;
    //return true;
}
function sinaWeiboLogin() { }

document.writeln('<scr' + 'ipt language="javascript" src="/ajax/jquery.js"></scr' + 'ipt>');


if (navigator.appVersion.indexOf('MSIE 6.0') > 0) {
    document.writeln('<scr' + 'ipt src="/iepng.js" type="text/javascript"></scr' + 'ipt>');
} else {
    var EvPNG = { fix: function () { } }
}

