﻿/*
Description:  This script file contains functions that will redirect a website using the location property.  
*/
//check return from callback for a session timeout or an error and handle accordingly.
function handleError(arg, context)
{
    if(arg.indexOf('ADNSessionTimeout')!=-1)
	 {
        alert('We\'re sorry, but for security purposes your session automatically ended after a period of inactivity.\nYou will now be redirect to the login page.')
        redirectSessionTimeout();
    }
	
    else
    {
        //set the returnstr (which is the returned error message) and the 'error' string which will tell the raisecallbackevent that this is an error.
        var errObj = new Array();
        errObj[0] = 'error';
        errObj[1] = arg;
        errObj[2] = context;
        setError(JSON.stringify(errObj),'');
    }
}

//Redirects the page based on the provided URL.
function redirectPage(url)
{
    window.location.href = url;
}

//Redirects the page to the default ADN session timeout page.
function redirectError()
{
    window.location = window.location.protocol + "//" + window.location.host + "/error.aspx";
}

//Redirects the page to the default ADN error page.
function redirectSessionTimeout()
{
    window.location = window.location.protocol + "//" + window.location.host + "/SessionTimeOut.aspx";
}