systemmessage='';
systemmessageconfirm='';
var count_refresh=0;

function call_footer_functions(){
  refresh_session();
  show_systemmessages();
  if (document.getElementById('hidden_windows') && !document.getElementById('hidden_windows2'))
    ShowNag();
  if (document.getElementById('hidden_windows2'))
    ShowNagStartUp();
}
function show_systemmessages(){
  if (systemmessage!='')
    alert(systemmessage);
  if (systemmessageconfirm==1)
    messageconfirm();
}

function addBookmark(title,url) {

  var msg_netscape = "NetScape message";
  var msg_opera    = "This function does not work with this version of Opera.  Please bookmark us manually.";
  var msg_other    = "Your browser does not support automatic bookmarks.  Please bookmark us manually.";
  var agt          = navigator.userAgent.toLowerCase();


  if (agt.indexOf("opera") != -1) 
  {
    if (window.opera && window.print)
    {
      return true;
    } else 
    {
      alert(msg_other);
    }
  }    
  else if (agt.indexOf("firefox") != -1) window.sidebar.addPanel(title,url,"");
  else if ((agt.indexOf("msie") != -1) && (parseInt(navigator.appVersion) >=4)) window.external.AddFavorite(url,title); 
  else if (agt.indexOf("netscape") != -1) window.sidebar.addPanel(title,url,"")         
  else if (window.sidebar && window.sidebar.addPanel) window.sidebar.addPanel(title,url,""); 
  else alert(msg_other);
  
}
function formDefault(obj){
  return true;
}
  
function BuyCredits(url) {
	var winParam = 'screenX=10,screenY=10,left=10,top=10,toolbar=no,height=600,width=620,directories=no,status=yes,scrollbars=yes,resize=no,menubar=no';
	goBuyCredits = window.open(url, 'goBuyCredits', winParam);
	//goBuyCredits.opener = window.opener;
	goBuyCredits.focus();
	//setTimeout("checkChild()",4000);
	setTimeout("checkOpenChild()",4000);
}

function checkOpenChild() {
	if (document.form1.opened.value=="1") {
	  if (goBuyCredits.closed){
	    LoadURL(urlsite+'/index2.php?no_html=1&option=com_smallfunctionality&task=show_tokens','ChangeHeader()');
	  }else
	    setTimeout("checkOpenChild()",4000);
  }else
   	setTimeout("checkOpenChild()",4000);
}
function ChangeHeader(){
  tmp=ajax_result.split(',');
  if (isFinite(tmp[0]) && isFinite(tmp[1])){
    //document.getElementById('header_irewards').innerHTML=tmp[0];
    document.getElementById('header_points').innerHTML=tmp[1];
  }
}
function checkChild() {
	if (document.form1.opened.value=="0") {
		alert("It appears that the Cashier window failed to open.\r\nIf you have a popup blocker, please set it to allow popup windows for this page and try again.");
	} else {
		//alert("Window Opened!");
	}
}

function popUp(url, width, height){
 	var winParam = 'screenX=10,screenY=10,left=10,top=10,toolbar=no,height='+height+',width='+width+',directories=no,status=yes,scrollbars=yes,resize=no,menubar=no';
	mypopup = window.open(url, 'popup', winParam);
}

function refresh_session(){
	var iframe = document.getElementById('session_iframe');
	if (iframe){
	  var tmp = iframe.contentWindow.document.body;
	  var content = '';
	  if (tmp!=null)
	    content=tmp.innerHTML;
	  if (count_refresh>0 && (content=='0' || count_refresh<24))
  	  iframe.src = urlsite+'/index2.php?no_html=1&option=com_smallfunctionality&task=refresh_session&count_refresh='+count_refresh;
  	count_refresh++;
	  setTimeout('refresh_session()',1000*60*5); //5 minutos
	}
}
function redirect(url){
  document.location=url;
}
function changegraph(num){
  document.getElementById('canvasline1').style.display='none';
  document.getElementById('canvasline2').style.display='none';
  document.getElementById('canvasline3').style.display='none';
  document.getElementById('canvasline'+num).style.display='block';
}
function TryGame(objname, delaytime){
  if (initgame==1){
    initgame=0;
    setTimeout('TryGame(\''+objname+'\', '+delaytime+')',1000*delaytime);
  }else{
    obj=document.getElementById(objname);
    obj.style.display = 'none';
    document.getElementById(objname+'_alert').style.display='block';
    //document.location='index.php?option=com_puarcade';
  }
}
function PreloadGame(objname, maxtime, delaytime){
  if (delaytime>=0){
    MM_showHideLayers(objname+'_preloaded','','show',objname,'','hide')
    obj=document.getElementById(objname+'_statusbar_in');
    var width=getStyle(document.getElementById(objname+'_statusbar'), 'width');
    width=width.substr(0, width.length-2)*1;
    var barwidth=width/maxtime*(maxtime-delaytime);
    document.getElementById(objname+'_statusbar_in').style.width=barwidth+'px';
    
    var delaytime=delaytime-1;
    setTimeout('PreloadGame(\''+objname+'\', '+maxtime+', '+delaytime+')',1000);
  }else{
    MM_showHideLayers(objname+'_preloaded','','hide',objname,'','show')
    document.getElementById(objname+'_preloaded').style.display='none';
  }
}
function ChangeGame(id){
  document.getElementById('games_b1').className='slots_bingo_txt_2';
  document.getElementById('games_b2').className='slots_bingo_txt_2';
  document.getElementById('games_b3').className='slots_bingo_txt_2';
  document.getElementById('games_b'+id).className='slots_bingo_txt_1';
  
  document.getElementById('game_content1').style.display='none';
  document.getElementById('game_content2').style.display='none';
  document.getElementById('game_content3').style.display='none';
  document.getElementById('game_content'+id).style.display='block';
  
}

function windowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  var tmp=new Array();
  tmp[0]=myWidth;
  tmp[1]=myHeight;
  return tmp;
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
}
function getStyle(el,styleProp){
	//var x = document.getElementById(el);
	var x = el;
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}

function closeNag(id, opc, url){
  /*if (url=='')
    LoadURL(urlsite+'/index2.php?no_html=1&option=smallfunctionality', '');
  else
    LoadURL(urlsite+'/index2.php?no_html=1&option=smallfunctionality&task=closenag&nag='+opc, 'closeNagRedirect("'+url+'")');*/
  
  document.cookie = "nag" + "=" + escape (opc) + ';path=/';

  obj=document.getElementById(id);
  obj.style.display='none';
  if (document.getElementById('hidden_windows') && !document.getElementById('hidden_windows2'))
    document.getElementById('hidden_windows').style.display='none';
  if (document.getElementById('hidden_windows2')) 
    document.getElementById('hidden_windows2').style.display='none';
  if (url!='')
    document.location=url;
}
function closeNagRedirect(url){
  document.location=url;
}

function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}
	else {
		elm['on' + evType] = fn;
	}
}
  
function setDate(objname, d_year, d_month, d_day){
  document.getElementById('year'+objname).value=d_year;
  document.getElementById('month'+objname).value=d_month;
  document.getElementById('day'+objname).value=d_day;
}





function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v;}
}
     
//Credit Card Validation Javascript

//copyright 12th May 2003, by Stephen Chapman, Felgall Pty Ltd


//You have permission to copy and use this javascript provided that

//the content of the script is not changed in any way.


function validateCreditCard(s) {
  //function cardval(s) {
  //remove non-numerics
  var v = "0123456789";
  var w = "";
  for (i=0; i < s.length; i++) {
    x = s.charAt(i);
    if (v.indexOf(x,0) != -1)
      w += x;
  }

  //validate number
  j = w.length / 2;
  if (j < 6.5 || j > 8 || j == 7) return false;
  k = Math.floor(j);
  m = Math.ceil(j) - k;
  c = 0;
  for (i=0; i<k; i++) {
    a = w.charAt(i*2+m) * 2;
    c += a > 9 ? Math.floor(a/10 + a%10) : a;
  }

  for (i=0; i<k+m; i++) c += w.charAt(i*2+1-m) * 1;

  return (c%10 == 0);
}
function strrpos (haystack, needle, offset) {
    // Finds position of last occurrence of a string within another string  
    // 
    // version: 1006.1915
    // discuss at: http://phpjs.org/functions/strrpos    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +   input by: saulius
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: strrpos('Kevin van Zonneveld', 'e');    // *     returns 1: 16
    // *     example 2: strrpos('somepage.com', '.', false);
    // *     returns 2: 8
    // *     example 3: strrpos('baa', 'a', 3);
    // *     returns 3: false    // *     example 4: strrpos('baa', 'a', 2);
    // *     returns 4: 2
    var i = -1;
    if (offset) {
        i = (haystack+'').slice(offset).lastIndexOf(needle); // strrpos' offset indicates starting point of range till end,        // while lastIndexOf's optional 2nd argument indicates ending point of range from the beginning
        if (i !== -1) {
            i += offset;
        }
    }    else {
        i = (haystack+'').lastIndexOf(needle);
    }
    return i >= 0 ? i : false;
}
function IsNumeric(input){ 
   return (input - 0) == input && input.length > 0; 
}