﻿// JScript File

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function game_show(title, text)
{
	if (text != '' && title != '')
	{
	    window.document.getElementById('gameboxtitle').innerHTML=title;
		window.document.getElementById('gameboxcontent').innerHTML=text;
		window.document.getElementById('gamebox').style.display='';
	}
}

function game_hide()
{
	window.document.getElementById('gamebox').style.display='none';	
	window.document.getElementById('gameboxtitle').innerHTML='';
	window.document.getElementById('gameboxcontent').innerHTML='';
}

function game_position (Ereignis) {
	
	if (!Ereignis)
   		Ereignis = window.event;
   		
	if (document.all) {
	    if (document.body && document.body.scrollTop)
	    {
	        tempX = event.clientX + document.body.scrollLeft;
	        tempY = event.clientY + document.body.scrollTop;
	    }
	    else
	    {
	        tempX = event.clientX + document.documentElement.scrollLeft;
	        tempY = event.clientY + document.documentElement.scrollTop;	    
	    }
	  } else {
	    tempX = Ereignis.pageX;
	    tempY = Ereignis.pageY;
	} 
	
	
	
	
	document.getElementById("gamebox").style.left  = (tempX + 15) + "px";
	document.getElementById("gamebox").style.top = (tempY - 50) + "px";
}

function game_position_left(Ereignis) {

    if (!Ereignis)
        Ereignis = window.event;

    if (document.all) {
        if (document.body && document.body.scrollTop) {
            tempX = event.clientX + document.body.scrollLeft;
            tempY = event.clientY + document.body.scrollTop;
        }
        else {
            tempX = event.clientX + document.documentElement.scrollLeft;
            tempY = event.clientY + document.documentElement.scrollTop;
        }
    } else {
        tempX = Ereignis.pageX;
        tempY = Ereignis.pageY;
    }

    document.getElementById("gamebox").style.left = (tempX - 150) + "px";
    document.getElementById("gamebox").style.top = (tempY + 10) + "px";
}


function OpenWindowEX(url, w, h, resizable)
{
	if (resizable == undefined || resizable == false)
		resizable = "no";
	else
		resizable = "yes";

    //var basestring="window"+new Date().getTime();
	var s = new String("width=" + w + ",height=" + h + ",resizable=" + resizable + ",scrollbars=yes");
	if(url.indexOf("?") == -1)
	    url = url + "?" + new Date().getTime();
	else
	    url = url + "&" + new Date().getTime();
	
	window.open(url, "popup", s);
}

function NewWindow(url) 
{
    window.open(url, "_NEW", "", "");
}


function OpenExternalWindow(url, width, height, windowname, scrollbar)
{
    if(typeof width == 'undefined')
        width=800;
    if(typeof height == 'undefined')
        height=600;
    //if(typeof windowname == 'undefined')
        windowname = "window"+new Date().getTime();
    if(typeof scrollbar == 'undefined')
        scrollbar = "yes";
        
	if(url.indexOf("?") == -1)
	    url = url + "?" + new Date().getTime();
	else
	    url = url + "&" + new Date().getTime();
	
    exWin = open(url,windowname,"width="+width+",height="+height+",resizable=yes,scrollbars="+scrollbar);
	exWin.focus();
	checkBlocker(exWin);
}

function OpenExternalWindowCost(url,text)
{
/*
    if(!confirm(text))
        return false;
        */
    var basestring= "exWin"+new Date().getTime();//"exWin";

    exWin = open(url,basestring,"width=800,height=600,resizable=yes,scrollbars=no");
	exWin.focus();
	checkBlocker(exWin);
	return true;
}

function checkBlocker(exWin)
{
  window.setTimeout(function(exWin)
    {
        return function()
        {
                if(exWin.closed == true){ alert ("It looks like you may have a Pop-Up Blocker installed.");  }
        }
    } (exWin), 500);
}

function startcounter(totalseconds, element, prefix)
{
    totalseconds--;
    
    minutesLeft = Math.floor(totalseconds/60);
    secondsLeft = Math.floor(totalseconds-(minutesLeft*60));
    
    if(secondsLeft < 10)
        secondsLeft = "0" + secondsLeft;
    
    var html = minutesLeft + ":" + secondsLeft;
    
    if(typeof prefix != 'undefined')
        html = prefix + html;
   
    if(totalseconds >= 0)
    {
        document.getElementById(element).innerHTML = html;
        setTimeout("startcounter("+totalseconds+", '"+element+"', '"+prefix+"')", 1000);
    }
}

function InsufficientFundsConfirm(text)
{
    var window = confirm(text);    
    if(window)
    {
        document.location.href = "Account/Deposit.aspx";
    }
    return window;
}

function InsufficientFundsConfirmNotAuthorized(text)
{
    var window = confirm(text);    
    if(window)
    {
        document.location.href = "Authorized/Account/Deposit.aspx";
    }
    return window;
}

var postBackElement;
function InitializeRequest(sender, args) {
    postBackElement = args.get_postBackElement();
    if (postBackElement.id == buttonLeftId || postBackElement.id == buttonRightId)
    {  
          fadeOut(upGamesId);
    }
}

function fadeOut(element)
{
    var obj = document.getElementById(element);  
    
    var animation = new AjaxControlToolkit.Animation.FadeOutAnimation(obj, .2, 20, 0.0, 0.9, true);         //Instantiate
    animation.play();                                   //Once everything is setup, it can be executed.
}

function Redirect(url)
{
    window.location = url;
}

function checkMaxLen(txt,maxLen)
{
    try{
        if(txt.value.length > (maxLen-1))
        {
            var cont = txt.value;
            txt.value = cont.substring(0,(maxLen -1));
            return false;
        }
    }
    catch(e){}

}

function ConfirmGoBack(txt) 
{
    var confirmBack = confirm(txt);

    if (confirmBack)
        history.go(-1);
    else
        return false;
}

function ClientValidation(source, args)
{
    args.IsValid = document.getElementById(cbxTerms).checked;
}

function ValidateThisPage(errorelement, message)
{    
    if(!Page_IsValid)
        document.getElementById(errorelement).innerHTML = message;
        
    return;
}

function doPostBackAsync(eventName, eventArgs)
{
    var prm = Sys.WebForms.PageRequestManager.getInstance();
 
    if( !Array.contains( prm._asyncPostBackControlIDs, eventName ) )
    {
        prm._asyncPostBackControlIDs.push(eventName);
    }
 
    if( !Array.contains( prm._asyncPostBackControlClientIDs, eventName ) )
    {
        prm._asyncPostBackControlClientIDs.push(eventName);
    }
 
    __doPostBack( eventName, eventArgs );
}

function AppLoad()
{
  Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);
} 
function EndRequest(sender, args)
 {
  // Check to see if there's an error on this request.
  // and don't throw the JavaScript alert.
  if (args.get_error() != undefined && true) // change to false for debug
  {
    args.set_errorHandled(true);
  }
}
// ajax error handler
/*
Sys.Application.add_load(AppLoad); 
function AppLoad()
{
  Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);
  //Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequest);
}
 
function EndRequest(sender, args) {
  // Check to see if there's an error on this request.
  if (args.get_error() != undefined)
  {
    // If there is, show the custom error.
    //$get('Error').style.visibility = "visible";
 
    // Let the framework know that the error is handled, 
    //  so it doesn't throw the JavaScript alert.
    args.set_errorHandled(true);
  }
}
 
function BeginRequest(sender, args) {
  // Clear the error if it's visible from a previous request.
  if ($get('Error').style.visibility == "visible")
    CloseError();
}
 
function CloseError() {
  // Hide the error div.
  $get('Error').style.visibility = "hidden";
}


function Sys$WebForms$PageRequestManager$_endPostBack(error, response)
{
    this._processingRequest = false;

    this._request = null;
    this._additionalInput = null;

    var handler = this._get_eventHandlerList().getHandler("endRequest");
    var errorHandled = false;
    if (handler)
    {
        var eventArgs = new Sys.WebForms.EndRequestEventArgs(error, this._dataItems, response);
        handler(this, eventArgs);
        errorHandled = eventArgs.get_errorHandled();
    }
    this._dataItems = null;
    
    if (error && !errorHandled)
    {
        alert(error.message);
    }
}
*/