function saveToConfigurationDate(newDate)
{ 
    GiantEagle.Applications.InternetSites.Web.Services.AdminService.SetCmsConfigurationDate(newDate,callbackSetCmsConfigurationDate, callbackAjaxError);    
}

function changeCacheSetting(isEnabled)
{
    GiantEagle.Applications.InternetSites.Web.Services.AdminService.ChangeCacheSetting(isEnabled, callbackEnableCache, callbackAjaxError);    
}

function clearCache()
{
    GiantEagle.Applications.InternetSites.Web.Services.AdminService.ClearCache(callbackEnableCache, callbackAjaxError);    
}

function callbackAjaxError(result)
{
    var message = "There was an error with the remote call : \n" + 
        result._exceptionType + 
        result._message +
        result._stackTrace +
        "\nTime Out: " + result._timedOut;
        alert(message);   
} 

function callbackSetCmsConfigurationDate(result)
{
    if (!result.OperationSucceeded)
    {
        alert("There was an error setting the Configuration Date.\n\n" + result.ClientErrorMessage);
        return;
    }
    else
    {
        document.location = document.location;
    }
}

function callbackEnableCache(result)
{
    if (!result.OperationSucceeded)
    {
        alert("There was an error changing your cache setting.\n\n" + result.ClientErrorMessage);
        return;
    }
    else
    {
        document.location = document.location;
    }
}


//In the dashboard New Member Registration
function EnterCheck(e, loginControl)
{
    var key;
    if(window.event)
    {
        key = e.keyCode;
    }
    else
    {
        key = e.which;
    }
       
    //keyCode for Enter key is 13    
    if(key == 13)
    {
       __doPostBack(loginControl,''); //'dashboard$MyAccountControl$Login'
    }
}


//In the dashboard MyAccout control, 'enter' key press in the password field should invoke Login button event
function EnterCheckLogin(e, loginControl)
{
    var key;
    if(window.event)
    {
        key = e.keyCode;
    }
    else
    {
        key = e.which;
    }
       
    //keyCode for Enter key is 13    
    if(key == 13)
    {
        // will this fix the login problem on dashboard?
        performSecureLogin();
    }
}


var _controlsToUpdate = new Array('MyPageManageList$updateLink', 'MyPageRecipes$LoadRecipeLink', 'MyPageFuelperks$LoadFuelperksLink', 'MyPageStores$LoadMyStore', 'MyPageShoppingHistory$LoadHistory');
var _controlsFieldToCheck = new Array('MyPageManageList_LoadingArrow', 'MyPageRecipes_LoadingArrow', 'MyPageFuelperks_LoadingArrow', 'MyPageStores_LoadingArrow', 'MyPageShoppingHistory_LoadingArrow');
var _controlsFieldToCheckAfter = new Array('loadedList', 'loadedRecipes', 'loadedFuelperks', 'loadedStores', 'loadedHistory');

var _currentControl = 0;

function updateMyPageNextControl()
{
    // wait until the last control loads before doing the next
    if (_currentControl > 0)
    {
        if (!document.getElementById(_controlsFieldToCheckAfter[_currentControl - 1]))
        {
            setTimeout("updateMyPageNextControl()", 500);
            return;
        }
    }
    
    if (_currentControl >= _controlsToUpdate.length)
	{
		return;
	}
	
	if (document.getElementById(_controlsFieldToCheck[_currentControl]))
    {        
        __doPostBack(_controlsToUpdate[_currentControl],'');
	}
	_currentControl++;
	setTimeout("updateMyPageNextControl()", 500);
}

