if(!document.getElementById){
  if(document.all)
  document.getElementById=function(){
    if(typeof document.all[arguments[0]]!="undefined")
    return document.all[arguments[0]]
    else
    return null
  }
  else if(document.layers)
  document.getElementById=function(){
    if(typeof document[arguments[0]]!="undefined")
    return document[arguments[0]]
    else
    return null
  }
}

function setBalances(sBalance,cBalance,lBalance,pBalance,lLevel,vtBalance,pBBBalance)
{
    var topprot;
    var docname;
    try {
        topprot = top.frames['topframe'].document.location.protocol;
    }
    catch (ex) {
        topprot = 'error';
    }
    if (topprot != 'error' && top.frames['topframe']) {
	    if (sBalance!=''&&top.frames['topframe'].document.getElementById('accountbalance')) top.frames['topframe'].document.getElementById('accountbalance').innerHTML = sBalance;
	    if (pBalance!=''&&top.frames['topframe'].document.getElementById('primabalance')) top.frames['topframe'].document.getElementById('primabalance').innerHTML = pBalance;
	    if (pBalance != '' && top.frames['topframe'].document.getElementById('pokerbalance')) top.frames['topframe'].document.getElementById('pokerbalance').innerHTML = pBalance;
	    if (pBBBalance != '' && top.frames['topframe'].document.getElementById('pokerpoints')) top.frames['topframe'].document.getElementById('pokerpoints').innerHTML = pBBBalance;
	    if (lBalance != '' && top.frames['topframe'].document.getElementById('loyaltybalance')) top.frames['topframe'].document.getElementById('loyaltybalance').innerHTML = lBalance;
	    if (lLevel!=''&&top.frames['topframe'].document.getElementById('loyaltylevel')) top.frames['topframe'].document.getElementById('loyaltylevel').innerHTML = lLevel + ' member';
	    if (cBalance!=''&&top.frames['topframe'].document.getElementById('rtgbalance')) top.frames['topframe'].document.getElementById('rtgbalance').innerHTML = cBalance;
	    if (vtBalance!=''&&top.frames['topframe'].document.getElementById('vtbalance')) top.frames['topframe'].document.getElementById('vtbalance').innerHTML = vtBalance;
	}
    try {
        topprot = top.frames['main'].document.location.protocol;
    }
    catch (ex) {
        topprot = 'error';
    }
    if (topprot != 'error' && top.frames['main']) {
        docname = top.frames['main'].location.toString();
        if (docname.indexOf('cashier.asp')>0){
            if (sBalance != '' && top.frames['main'].document.getElementById('accountbalance')) top.frames['main'].document.getElementById('accountbalance').innerHTML = sBalance;
            if (pBalance != '' && top.frames['main'].document.getElementById('primabalance')) top.frames['main'].document.getElementById('primabalance').innerHTML = pBalance;
            if (pBalance != '' && top.frames['topframe'].document.getElementById('pokerbalance')) top.frames['topframe'].document.getElementById('pokerbalance').innerHTML = pBalance;
            if (pBBBalance != '' && top.frames['topframe'].document.getElementById('pokerpoints')) top.frames['topframe'].document.getElementById('pokerpoints').innerHTML = pBBBalance;            
            if (lBalance != '' && top.frames['main'].document.getElementById('loyaltybalance')) top.frames['main'].document.getElementById('loyaltybalance').innerHTML = lBalance;
            if (lLevel != '' && top.frames['main'].document.getElementById('loyaltylevel')) top.frames['main'].document.getElementById('loyaltylevel').innerHTML = lLevel + ' member';
            if (cBalance != '' && top.frames['main'].document.getElementById('rtgbalance')) top.frames['main'].document.getElementById('rtgbalance').innerHTML = cBalance;
            if (vtBalance != '' && top.frames['main'].document.getElementById('vtbalance')) top.frames['main'].document.getElementById('vtbalance').innerHTML = vtBalance;
        }
    }
}

function winopen(url,width,height)
{
	var w=640,h=480;
	if(isNaN(width))
		w=640
	else
		w=width;
	if(isNaN(height))
		h=480
	else
		h=height;
	if (url.indexOf('?') < 0)
	{
		url=url+'?popup=yes'
	}
	else
	{
		url=url+'&popup=yes'
	};
	bWinOpen = true;
	window.open(url,'', 'resizable=yes,left='+(800-w)/2+',top=150,width='+w+',height='+h+',scrollbars=yes')
}
	
var bContinue = true;
function IsNumber(elem,count)
{
	var value = elem.value;
	if (count == 0) 
	{ 
		var matchArray = value.match(/^(\d+$)/);
	} else if (count == 4) 
	{ 
		var matchArray = value.match(/^\d{4}/); 
	} else if (count == 8)
	{ 
		var matchArray = value.match(/^\d{8}/); 
	} else if (count == 9) 
	{ 
		var matchArray = value.match(/^\d{9}/); 
	}
	
	if (matchArray == null) 
	{  
		if (count == 0) 
		{ 
			alert('Enter digits only.'); 
		}else 
		{ 
			if (bContinue == true)
			{ 
				elem.select(); 
			} 
			alert('Enter '+ count +' digits only.'); 
		} 
		bContinue = false;
	} 
	else 
	{
			bContinue = true;
	}
}

function postBack(sURL, sData) {
    try {
        var browse = new ActiveXObject('Microsoft.XMLHTTP');
        var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        var response;

        browse.Open('POST', sURL, false);
        browse.SetRequestHeader('Content-type', 'application/x-www-form-urlencoded');
        browse.Send(sData);
        response = browse.ResponseText;
        if (response != '') {
            xmlDoc.loadXML(response);
        }
        else {
            response = '<?xml version=""1.0"" encoding=""utf-8""?><error>No data available</error>'
            xmlDoc.loadXML(response);
        }
    }
    catch (ex) {
        response = '<?xml version=""1.0"" encoding=""utf-8""?><error>Error: ' + ex.description + '</error>'
        xmlDoc.loadXML(response);
    }
    finally {
        delete browse;
        return xmlDoc
    }

}