﻿// ***********************************************************************************
// Script Name: global.js
// Desc      : This javascript consists with functions use through out this application.
//             See each function comments for more info. on each usages.
// Author    : Peter Puth
// Date      : 3/2/2011
// ***********************************************************************************
// ISSR         Date      Staff   Desc
// ***********************************************************************************
// IS1110034    3/2/2011  PPP     Created
// ***********************************************************************************
//Notify user of timeout and return to index.cfm by calling eqLogoff.cfm
function redirect()
{
	parent.location.href="https://www.bloodsource.org/donorportal/logoff.aspx";
}
//Notify user of timeout and return to index.cfm by calling eqLogoff.cfm
function redirectErrorPage()
{
	parent.location.href="http://www.bloodsource.org/donorportal/OAS/unavailable.aspx";
}

function restart()
{
	alert("BloodSource Online Appointment Scheduling Timeout: Your session has expired!");
	parent.location.href="https://www.bloodsource.org/donorportal/logoff.aspx";
}
//Set to expire in 20 minute (1200000) (time in milisecond).
var timerID = 0;

function startTimer()
{
	if(timerID)
    	clearTimeout(timerID);
      	timerID = setTimeout("restart()", 1200000);
}
function showRetrieveDonorID()
{
    var WinSettings = "center:yes;resizable:no;dialogHeight:640px;dialogWidth:780px;"   
    var MyArgs = window.showModalDialog('https://www.bloodsource.org/onlineappointmentscheduling/RetrieveDonorID.aspx', '', WinSettings);                             
}        
function popupWindow(pageName)
{
    var WinSettings = "center:yes;resizable:no;dialogHeight:620px;dialogWidth:720px;"   
    var MyArgs = window.showModalDialog(pageName, '', WinSettings);                             
}     
function verifyConfirmEmail()
{

    if (document.getElementById("txtEmail").value.toLowerCase() != document.getElementById("txtConfirmEmail").value.toLowerCase())
    {
        document.getElementById("lblMessage").innerHTML = "Email doesn't match.<br/><br/>" ;
        document.getElementById("lblMessage").className = "ErrorMsg";
        /*document.getElementById("txtConfirmEmail").className = "highlight";*/
        return false;
    }
   return true;
 }
 
function goNextField(thisObject, nextField)
{
    var formName = thisObject.form.id;
    if (thisObject.value.length==thisObject.maxLength)
      {
        var next=thisObject.tabIndex;

         for (var i=0; i < thisObject.form.elements.length; ++i) 
         {
            //alert(document.getElementById(formName).elements[i].name);
            var nextFieldName = document.getElementById(formName).elements[i].name;
            if (typeof(nextFieldName) != "undefined")
            {
               if (nextFieldName.indexOf(nextField) >= 0)
                {
                   
                    window.setTimeout(function(){
                        document.getElementById(nextFieldName).focus();
                        document.getElementById(nextFieldName).select();
                    }, 0);
                    return true;
                }  
            }
             
         }

      }
}


//Display date mask pattern base on the event
function DateMask(thisObject)
{   
    //If the current text is MM/DD/YYYY and user focus on the field,
    //make value empty for user to enter date.
    if(thisObject.value == "MM/DD/YYYY" & event.type == 'focus') 
    { 
        thisObject.value = ""; 
        thisObject.select();
    } 
    //If the current text is empty and user goes to another field,
    //display the mask pattern.
    if (thisObject.value.replace(/^\s+|\s+$/g,"") == "" & event.type == 'blur') {
        thisObject.value = "MM/DD/YYYY"; 
    }
}
//redirect to maintenace page if OAS application open during the below time.
function Maintenance()
{
    //uncomment every 3rd Sat of the month between 11pm-12am
    //parent.location.href="http://www.bloodsource.org/donorportal/OAS/Maintenance.aspx";
}

