function getArgs(){
var args = new Object();
var query = unescape(location.search.substring(1));  // Get query string.
var pairs = query.split('&');              // Break at comma.
for(var i = 0; i < pairs.length; i++)
{
var pos = pairs[i].indexOf('=');       // Look for 'name=value'.
if (pos == -1) continue;               // If not found, skip.
var argname = pairs[i].substring(0,pos);  // Extract the name.
var value = pairs[i].substring(pos+1); // Extract the value.
args[argname] = unescape(value);          // Store as a property.
}
return args;                               // Return the object.
}
var mode='';var stat='';var usesLeft='';var alluses='';var rest='';
function setDefaultValues()
{
mode = 'demo';
stat = 'enter';
usesLeft = '0';
alluses = '65';
rest = '1';
}
function setFromQueryString()
{
var queryArgs = getArgs();
mode = queryArgs['mode'];
stat = queryArgs['stat'];
usesLeft = queryArgs['usesLeft'];
alluses = queryArgs['allUses'];
rest = queryArgs['rest'];
}
try
{
var bHasWritePermission = window.external.HasWritePermission;
if(!bHasWritePermission)
{
setFromQueryString();
}
else
{
setDefaultValues();
}
}
catch(err)
{
setDefaultValues();
}
function getMode() { return mode;}
function getStat() { return stat;}
function getUsesLeft() { return usesLeft;}
function getMaxUsage() { return alluses;}
function getRest() { return rest;}
