﻿// JScript File

function clearStatus() {
	window.status = 'Done';	
	return true;
}		

function popupWin(hwndPopup, windowName, closeFirst, sURL, Height, Width, toolbar, status, loc, menu, resize, scroll) {
	var	opts = "toolbar=" + (toolbar == false ? 0 : 1) + ",status=" + (status == false ? 0 : 1) + ",location=" + (loc == false ? 0 : 1) + ",menubar=" + (menu == false ? 0 : 1) + ",resizable=" + (resize == false ? 0 : 1) + ",";
	opts = opts + "height=" + Height + ",width=" + Width + ",scrollbars=" + (scroll == false ? 0 : 1);

	if (hwndPopup == null || hwndPopup.closed) {
		newPopup = window.open(sURL, windowName, opts);
		newPopup.focus();
		return newPopup;
	}

	if (closeFirst) {
		if (hwndPopup != null) { hwndPopup.close(); }
		newPopup = window.open(sURL, windowName, opts);
		newPopup.focus();
		return newPopup;
	}

	hwndPopup.location.href = sURL;
	hwndPopup.focus();
	return hwndPopup;			
}

function popupWin2(hwndPopup, windowName, closeFirst, sURL, Height, Width, toolbar, status, loc, menu, resize, scroll) {
	var	opts = "toolbar=" + (toolbar == false ? 0 : 1) + ",status=" + (status == false ? 0 : 1) + ",location=" + (loc == false ? 0 : 1) + ",menubar=" + (menu == false ? 0 : 1) + ",resizable=" + (resize == false ? 0 : 1) + ",";
	opts = opts + "height=" + Height + ",width=" + Width + ",scrollbars=" + (scroll == false ? 0 : 1);

	if (hwndPopup == null || hwndPopup.closed) {
		newPopup = window.open(sURL, windowName, opts);
		//newPopup.focus();
		return newPopup;
	}

	if (closeFirst) {
		if (hwndPopup != null) { hwndPopup.close(); }
		newPopup = window.open(sURL, windowName, opts);
		//newPopup.focus();
		return newPopup;
	}

	hwndPopup.location.href = sURL;
	hwndPopup.focus();
	return hwndPopup;			
}

var ajaxProgressElementIds = null;
function RegisterAjaxProgressHandlers() {
    ajaxProgressElementIds = arguments;
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(CommonBeginRequestHandler);
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(CommonEndRequestHandler);
}

function CommonBeginRequestHandler(sender, args)
{
    progressHideShow("block");
}

function CommonEndRequestHandler(sender, args) {
    progressHideShow("none");
}

function progressHideShow(displayValue) {
    
    if(ajaxProgressElementIds == null) {
        return;
    }

    for(var i = 0, j = ajaxProgressElementIds.length; i < j; i++) {
        var element = $find(ajaxProgressElementIds[i]).get_element();
        if(element != null)
        {
            element.style.display = displayValue;                
        }
    }
}
