﻿// JScript File

var requestManager = null;
if (typeof Sys != 'undefined')

    requestManager = Sys.WebForms.PageRequestManager.getInstance();

if (requestManager)
{
    requestManager.add_beginRequest(BeginRequestHandler);
    requestManager.add_endRequest(EndRequestHandler);

}
function BeginRequestHandler(sender, args)
{
     var elem = args.get_postBackElement();
     ActivateAlertDiv(true, 'visible', 'AlertDiv', elem.value + ' processing...');
}
function EndRequestHandler(sender, args)
{
     ActivateAlertDiv(false, 'hidden', 'AlertDiv', '');
}
function ActivateAlertDiv(visible, visstring, elem, msg)
{
     //var adiv = $get(elem);
     //adiv.style.visibility = visstring;
     //adiv.innerHTML = msg;                     
    //ev.preventDefault();
    var modalPopupBehavior = $find('mpeBehaviorPopup');
    if (!modalPopupBehavior)
        return;
    if (visible)
        modalPopupBehavior.show();
    else
        modalPopupBehavior.hide();
}

function toggleFeedback(visible)
{
    var modalPopupBehavior = $find('mpeFeedbackBehavior');
    if (!modalPopupBehavior)
        return;
    if (visible)
        modalPopupBehavior.show();
    else
        modalPopupBehavior.hide();
}

function toggleForgotPassword(visible)
{
    var modalPopupBehavior = $find('mpeForgotPasswordBehavior');
    if (!modalPopupBehavior)
        return;
    if (visible)
        modalPopupBehavior.show();
    else
        modalPopupBehavior.hide();
}

function setToShim(divMenu)
{
    var IfrRef = getShim();
	if (IfrRef) {
		IfrRef.style.width = divMenu.offsetWidth;
		IfrRef.style.height = divMenu.offsetHeight;
		IfrRef.style.top = divMenu.style.top;
		IfrRef.style.left = divMenu.style.left;
		IfrRef.style.zIndex = divMenu.style.zIndex - 1;
		IfrRef.style.display = divMenu.style.display;
	}
}

function getShim()
{
    return document.getElementById('ContextShim');
}

var clientid;
function fnSetFocus(txtClientId)
{
	clientid=txtClientId;
	setTimeout("fnFocus()",10);
    
}

function fnFocus()
{
    //eval("document.getElementById('"+clientid+"').focus()");
    var objFocus = document.getElementById(clientid)
    if (objFocus && !isHidden(objFocus))
        objFocus.focus();
    else
        setTimeout("fnFocus()",100);
}

function isHidden(control)
{
	if(control==null)
		return true;
	if (control.style.display=="none")
		return true;
	var c = control;
	while (c.parentElement)
	{
		c = c.parentElement;
		if (c.style.display=="none")
			return true;
	}
	return false;	
}

function DateStatusFunc(date, y, m, d) {
    var Today = new Date(); 
    // 1 day = 1 * 24 hours = 24 hours // 24 hours = 24 * 60 min = 1440 min // 1440 min = 1440 * 60 sec = 86400 sec // 86400 sec = 86400 * 1000 ms = 86400000 ms 
    var Yesterday = new Date( Today.getTime() - 86400000 ); 
    if (date<Yesterday)
        return true; //disabled
    else
        return false; // other dates are enabled
}

/*
function performPostBack(aTargetElement, aArg)
{
    var postBack = new Sys.WebForms.PostBackAction();
    postBack.set_target(aTargetElement);
    postBack.set_eventArgument(aArg);
    postBack.performAction();
}
*/
