﻿/**
 * SUBMODAL v1.4
 * Used for displaying DHTML only popups instead of using buggy modal windows.
 *
 * By Seth Banks (webmaster at subimage dot com)
 * http://www.subimage.com/
 *
 * Contributions by:
 * 	Eric Angel - tab index code
 * 	Scott - hiding/showing selects for IE users
 *	Todd Huss - inserting modal dynamically and anchor classes
 *
 * Up to date code can be found at http://www.subimage.com/dhtml/subModal
 * 
 *
 * This code is free for you to use anywhere, just keep this comment block.
 */

Type.registerNamespace('CommonLibrary');

// Popup code
var gPopupMask = null;
var gPopFrame = null;
var gSubModal = null;
var gPopupCounter = 0;
var gSubModalStack = new Array(); 
var gTabIndexes = new Array();
// Pre-defined list of tags we want to disable/enable tabbing into
var gTabbableTags = new Array("A","BUTTON","TEXTAREA","INPUT","IFRAME");	

var gHideSelects = false;

CommonLibrary.SubModalDialog = function CommonLibrary$SubModalDialog(element) {
    this.isShown = false;

    var theBody = document.getElementsByTagName('BODY')[0];
    this.popupContainer = document.createElement('DIV');
    this.popupContainer.className = 'popupContainer';
    this.popupContainer.id = "dlgModalContainer_div" + gPopupCounter;
    this.notHideDuringDragging = false;
    theBody.appendChild(this.popupContainer);

    CommonLibrary.SubModalDialog.initializeBase(this, [this.popupContainer]);

    this.popupInner = document.createElement('DIV');
    this.popupInner.className = 'popupInner';
    this.popupContainer.appendChild(this.popupInner);

    // Creating popup titlebar
    this.popupTitleBar = document.createElement('DIV');
    this.popupTitleBar.className = 'popupTitleBar';
    this.popupTitleBar.style.cursor = 'move';
    this.popupInner.appendChild(this.popupTitleBar);
    this._clickTBHandler = Function.createDelegate(this, this.dragStart);
    $addHandler(this.popupTitleBar, 'mousedown', this._clickTBHandler);


    this.popupTitle = document.createElement('DIV');
    this.popupTitle.className = 'popupTitle';
    this.popupTitleBar.appendChild(this.popupTitle);

    this.popupControls = document.createElement('DIV');
    this.popupControls.className = 'popupControls';
    this.popupTitleBar.appendChild(this.popupControls);

    this.popupCloseButton = document.createElement('IMG');
    this.popupCloseButton.src = web_root + '/WebResource.axd?d=IcCCv1a5TkWenkBOVEeonTL4oVMiyci2awarirOC70_iAURz_ee3TOrw503uN4umJWhuWzmex29Ws2r08n_mpaYAEd6DqRKzfTS3Rh3DyjU1&t=634152946980189020';
    this.popupControls.appendChild(this.popupCloseButton);

    this._clickHandler = Function.createDelegate(this, this.close);
    $addHandler(this.popupCloseButton, 'click', this._clickHandler);


    // creating popup frame
    gPopupCounter++;
    this.frameName = 'subModal' + gPopupCounter;

    //Ego: walkaround of IE bug - border of IFRAME is shown if it is created dynamically in DOM, frameborder doesn't work as expected
    var divWrapper = document.createElement("DIV");
    divWrapper.innerHTML = '<iframe border="0" frameborder="0"></iframe>';
    var iframe = divWrapper.childNodes[0];

    //this.popupFrameObj = document.createElement("IFRAME");
    //this.popupFrame = this.popupFrameObj;

    this.popupFrame = this.popupFrameObj = iframe;

    this.popupFrame.id = this.frameName;
    this.popupFrame.name = this.frameName;
    this.popupFrame.className = "popupFrame";
    this.popupFrame.src = web_root + '/WebResource.axd?d=IcCCv1a5TkWenkBOVEeonTL4oVMiyci2awarirOC70_iAURz_ee3TOrw503uN4umJWhuWzmex29Ws2r08n_mpQZo-EPg2CKaw5CsNe45qiY1&t=634152946980189020';
    this.popupFrame.style.width = '100%';
    this.popupFrame.style.height = '100%';
    this.popupFrame.style.backgroundColor = 'transparent';
    this.popupFrame.style.display = 'none';
    this.popupFrame.scrolling = 'auto';
    this.popupFrame.frameborder = 0;
    this.popupFrame.allowtransparency = 'true';
    this.popupFrame.width = '100%';
    this.popupFrame.height = '100%';
    //this.popupInner.appendChild(this.popupFrame);

    this.popupInner.appendChild(divWrapper);

    this.popupLoader = document.createElement("DIV");
    this.popupLoader.style.width = '100%';
    this.popupLoader.style.height = '100%';
    this.popupInner.appendChild(this.popupLoader);

    var html = "<div class='popupLoader'><img align='absmiddle' src='";
    html += web_root + '/WebResource.axd?d=IcCCv1a5TkWenkBOVEeonTL4oVMiyci2awarirOC70_iAURz_ee3TOrw503uN4umJWhuWzmex29Ws2r08n_mpcNt7qfz1NGeCBCakVno3KY1&t=634152946980189020\' width=16 height=16 /> Loading...</div>';

    this.popupLoader.innerHTML = html;



    this._loadTHandler = Function.createDelegate(this, this.setTitle);
    $addHandler(this.popupFrame, 'load', this._loadTHandler);

    this._resizeHandler = Function.createDelegate(this, this.center);
    $addHandler(window, 'resize', this._resizeHandler);
    this._scrollHandler = Function.createDelegate(this, this.center);
    $addHandler(window, 'scroll', this._scrollHandler);

    this._mousemoveHandler = Function.createDelegate(this, this.dragGo);
    this._mouseupHandler = Function.createDelegate(this, this.dragStop);


    this.dragObj = new Object();
    this.dragObj.zIndex = 0;

}

function CommonLibrary$SubModalDialog$restore() 
{
	this.popupContainer.style.display = "block";
}

function CommonLibrary$SubModalDialog$minimize() 
{
	this.popupContainer.style.display = "none";
}

function CommonLibrary$SubModalDialog$show(url, width, height, returnFunc, cancelFunc, showCloseBox) 
{
    this.popupContainer.style.display = 'block';
    this.reset();    
    
    if (gPopupMask)
	    gPopupMask.style.display = "block";

// show or hide the window close widget
//	if (showCloseBox == null || showCloseBox == true) {
//		this.popCloseBox.style.display = "block";
//	} else {
//		this.popCloseBox.style.display = "none";
//	}
	
	this.isShown = true;
	
	// calculate where to place the window on screen
	this.center(width, height);
	
	var titleBarHeight = parseInt(this.popupTitleBar.offsetHeight, 10);

	this.popupContainer.style.width = width + "px";
	this.popupContainer.style.height = (height+titleBarHeight) + "px";
	
	setMaskSize();

	// need to set the width of the iframe to the title bar width because of the dropshadow
	// some oddness was occuring and causing the frame to poke outside the border in IE6 & FF
    var t = document.all ? 0 : 4;
    //t was replaced by 0, because of not valid background color
    if (this.popupFrame.style)
    {
	    this.popupFrame.style.width = (parseInt(this.popupTitleBar.offsetWidth, 10) - 0) + "px";
	    this.popupFrame.style.height = (height) + "px";
	    this.popupLoader.style.width = this.popupFrame.style.width;
	    this.popupLoader.style.height = this.popupFrame.style.height;
	}
	
	this.popupFrame.src = url;

	this.returnFunc = returnFunc;
    this.cancelFunc = cancelFunc;

	//window.setTimeout(Function.createDelegate(this, this.setTitle), 10);
}

/**
 * Sets the popup title based on the title of the html document it contains.
 * Uses a timeout to keep checking until the title is valid.
 */
 
function CommonLibrary$SubModalDialog$setTitle(e)
{
    // FF
    if (window.frames) 
        this.popupFrame = window.frames[this.frameName];
    else
        this.popupFrame = document.frames[this.frameName];
        
    if (this.popupFrame && this.isShown)
    {
  
        var oDoc = this.popupFrame; //(this.popupFrame.contentWindow || this.popupFrame.contentDocument);
        if (oDoc) 
        {
            if (oDoc.document) {
                oDoc = oDoc.document;
            }
            
            if (oDoc && oDoc.body) 
            {
        	    this.popupTitle.innerHTML = oDoc.title;
        	    this.registerEscHandler();
        	    this.popupLoader.style.display = 'none';
        	    this.popupFrameObj.style.display = 'block';
       	        
       	        if (document.all) 
       	            this.popupFrame.document.body.focus(); 
       	        else 
       	        {
       	            // Workaround since FF doesn't correctly set focus
       	            var t = new CommonLibrary$SubModalDialog$_setTimeout(this.popupFrameObj);
       	            t.focusTimeout(100);
       	        }
       	        
        	    return;
            }
        }
    }
    
  // if(this.isShown)
  //  window.setTimeout(Function.createDelegate(this, this.setTitle), 100);
}

function CommonLibrary$SubModalDialog$_setTimeout(obj)
{
    this.obj = obj;
    this.focus = function () { this.obj.contentWindow.focus(); };
    
    this.focusTimeout = function (ms)
    {
        var _self = this;
        setTimeout(
            function(ms)
            {
                _self.focus();
            }, ms);
    };
}

function CommonLibrary$SubModalDialog$reset()
{
    try
    {
        this.popupFrame.open();
        this.popupFrame.write("<html><title></title><body>Please wait while page is loading...</body></html>");
	    this.popupFrame.close();
    } 
    catch(e)
    {
//        alert(e);
    }
}

function CommonLibrary$SubModalDialog$resize(width, height)
{

}

function CommonLibrary$SubModalDialog$center(width, height)
{
	if (this.isShown) {
		if (width == null || isNaN(width)) {
			width = this.popupContainer.offsetWidth;
		}
		if (height == null) {
			height = this.popupContainer.offsetHeight;
		}
		


	    var theBody;
        // IE6 +4.01 but no scrolling going on
    	if (document.documentElement) 
    	    theBody = document.documentElement;
    	else
    	{
    	    theBody = document.getElementsByTagName("BODY")[0];
		    theBody.style.overflow = "hidden";
		}
		
		
		var scTop = parseInt(theBody.scrollTop,10);
		var scLeft = parseInt(theBody.scrollLeft,10);
		
		if (gPopupMask)
		{
		    gPopupMask.style.top = scTop + "px";
		    gPopupMask.style.left = scLeft + "px";
	    }

		setMaskSize();
		
		var titleBarHeight = parseInt(this.popupTitleBar.offsetHeight, 10);
		
		var fullHeight = getViewportHeight();
		var fullWidth = getViewportWidth();
		
		this.popupContainer.style.top = (scTop + ((fullHeight - (height+titleBarHeight)) / 2)) + "px";
		this.popupContainer.style.left =  (scLeft + ((fullWidth - width) / 2)) + "px";
//		alert(fullWidth + " " + width + " " + gPopupContainer.style.left);
	}
}


function CommonLibrary$SubModalDialog$dragStart(event) 
{
  var el;
  var x, y;
  var hideFrame = true;  


    this.dragObj.elNode = this.popupContainer;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  this.dragObj.cursorStartX = x;
  this.dragObj.cursorStartY = y;
  this.dragObj.elStartLeft  = parseInt(this.dragObj.elNode.style.left, 10);
  this.dragObj.elStartTop   = parseInt(this.dragObj.elNode.style.top,  10);

  if (isNaN(this.dragObj.elStartLeft)) this.dragObj.elStartLeft = 0;
  if (isNaN(this.dragObj.elStartTop))  this.dragObj.elStartTop  = 0;

  // Update element's z-index.

  //dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.
  
  $addHandler(document, 'mousemove', this._mousemoveHandler);
  $addHandler(document, 'mouseup', this._mouseupHandler);

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
    if (window.event.srcElement == this.popupCloseButton) hideFrame = false;
  }
  if (browser.isNS) {
    event.preventDefault();
    var target = event.target; 
    while(target.nodeType != target.ELEMENT_NODE) target = target.parentNode;
    if (target == this.popupCloseButton) hideFrame = false;
  }

  if (hideFrame && !this.notHideDuringDragging) this.popupFrameObj.style.display = 'none';
}

function CommonLibrary$SubModalDialog$dragGo(event) {

  var x, y;
    

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  this.dragObj.elNode.style.left = (this.dragObj.elStartLeft + x - this.dragObj.cursorStartX) + "px";
  this.dragObj.elNode.style.top  = (this.dragObj.elStartTop  + y - this.dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }

  if (browser.isNS) 
    event.preventDefault();
}

function CommonLibrary$SubModalDialog$dragStop(event) 
{
    this.popupFrameObj.style.display = 'block';

    if (this._mousemoveHandler) 
    {
        $removeHandler(document, "mousemove", this._mousemoveHandler);
//        this._mousemoveHandler = null;
    }
    
    if (this._mousemoveHandler) 
    {
        $removeHandler(document, "mouseup", this._mouseupHandler);
//        this._mousemoveHandler = null;
    }
    
    this.popupFrame.focus();
}

/**
 * @argument callReturnFunc - bool - determines if return function should be called
 * @argument returnVal - anything - return value 
 */
function CommonLibrary$SubModalDialog$close(callReturnFunc, frame) {
	this.isShown = false;

    if (typeof(this.popupFrame.document) != 'undefined')
    {
        if (typeof this.popupFrame.document.removeEventListener != 'undefined')
            this.popupFrame.document.removeEventListener('keydown', this._escHandlerDelegate, false);
        else
            this.popupFrame.document.detachEvent('onkeydown', this._escHandlerDelegate);
    }
    
	this.popupContainer.style.display = "none";

	if (callReturnFunc == true && this.returnFunc != null && frame != null) {
		this.returnFunc(frame.returnVal);
    }
    else if (this.cancelFunc != null) {
        this.cancelFunc();        
    }

	this.popupTitle.innerHTML = "";

    SubModal_Hide();
  	window.focus();    	
}

function CommonLibrary$SubModalDialog$registerEscHandler() 
{
    this._escHandlerDelegate = Function.createDelegate(this, this._escHandler);
    if(this.popupFrame.document.addEventListener)
            this.popupFrame.document.addEventListener('keydown', this._escHandlerDelegate, false);
        else
            this.popupFrame.document.attachEvent('onkeydown', this._escHandlerDelegate);
    //$addHandler(this.popupFrame.document, 'keydown',  this._escHandlerDelegate);
}

function CommonLibrary$SubModalDialog$unregisterEscHandler() 
{
    if(!this._escHandlerDelegate)
        return;
   
    if(this.popupFrame.document.addEventListener)
            this.popupFrame.document.removeEventListener('keydown', this._escHandlerDelegate, false);
        else
            this.popupFrame.document.detachEvent('onkeydown', this._escHandlerDelegate);
    //$addHandler(this.popupFrame.document, 'keydown',  this._escHandlerDelegate);
}

function CommonLibrary$SubModalDialog$_escHandler(e) 
{
	if(e.keyCode == 27)
	{
	    var ev = new Sys.UI.DomEvent(e);
	    ev.stopPropagation();
        ev.preventDefault();       
	    this.close();
	}
}

CommonLibrary.SubModalDialog.prototype =
{
    show : CommonLibrary$SubModalDialog$show,
    close : CommonLibrary$SubModalDialog$close,
    reset : CommonLibrary$SubModalDialog$reset,
    resize : CommonLibrary$SubModalDialog$resize,
    center : CommonLibrary$SubModalDialog$center,
    setTitle : CommonLibrary$SubModalDialog$setTitle,
    dragGo : CommonLibrary$SubModalDialog$dragGo,
    dragStart : CommonLibrary$SubModalDialog$dragStart,
    dragStop : CommonLibrary$SubModalDialog$dragStop,
    minimize : CommonLibrary$SubModalDialog$minimize,
    restore : CommonLibrary$SubModalDialog$restore,
    registerEscHandler : CommonLibrary$SubModalDialog$registerEscHandler,
    unregisterEscHandler : CommonLibrary$SubModalDialog$unregisterEscHandler,
    _escHandler :   CommonLibrary$SubModalDialog$_escHandler,
    initialize: function()
    {
        CommonLibrary.SubModalDialog.callBaseMethod(this, 'initialize');
        this.initialized = true;
    },
    
    dispose: function()
    {
        CommonLibrary.SubModalDialog.callBaseMethod(this, 'dispose');
    }
}

CommonLibrary.SubModalDialog.registerClass('CommonLibrary.SubModalDialog', Sys.UI.Control);


function getViewportHeight() {
	if (window.innerHeight!=window.undefined) return window.innerHeight;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight; 
	return window.undefined; 
}
function getViewportWidth() {
	if (window.innerWidth!=window.undefined) return window.innerWidth; 
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
	if (document.body) return document.body.clientWidth; 
	return window.undefined; 
}

/**
 * Initializes popup code on load.	
 */
function SubModal_Init(showMask) {
    gHideSelects  = false;
    
    if (gPopFrame == null && showMask == "true") 
    {
	    theBody = document.getElementsByTagName('BODY')[0];
	    popmask = document.createElement('div');
	    popmask.id = 'popupMask';
            
	    theBody.appendChild(popmask);
    }
    
	disableTabIndexes();
    // for IE
	if (gHideSelects == true) {
		hideSelectBoxes();
	}
    

	gSubModal = new CommonLibrary.SubModalDialog();
	
	gPopupMask = document.getElementById("popupMask");

	
	// check to see if this is IE version 6 or lower. hide select boxes if so
	// maybe they'll fix this in version 7?
	var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
	if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) {
		gHideSelects = true;
	}
	
	// Add onclick handlers to 'a' elements of class submodal or submodal-width-height
	var elms = document.getElementsByTagName('a');
	for (i = 0; i < elms.length; i++) {
		if (elms[i].className.indexOf("submodal") == 0) { 
			// var onclick = 'function (){showPopWin(\''+elms[i].href+'\','+width+', '+height+', null);return false;};';
			// elms[i].onclick = eval(onclick);
			elms[i].onclick = function(){
				// default width and height
				var width = 400;
				var height = 200;
				// Parse out optional width and height from className
				params = this.className.split('-');
				if (params.length == 3) {
					width = parseInt(params[1]);
					height = parseInt(params[2]);
				}
				//showPopWin(this.href,width,height,null); return false;
			}
		}
	}
	

    // If using Mozilla or Firefox, use Tab-key trap.
//    if (!document.all) {
//	    document.onkeypress = keyDownHandler;
//    }

}

function SubModal_Show(url, width, height, returnFunc, cancelFunc, showCloseBox) 
{
    if (!gSubModal.isShown) 
    {
        gSubModal.show(url, width, height, returnFunc, cancelFunc, showCloseBox);
        return;
    }
    
    gSubModalStack.push(gSubModal);
    gSubModal.minimize();
    
    gSubModal = new CommonLibrary.SubModalDialog();
    gSubModal.show(url, width, height, returnFunc, cancelFunc, showCloseBox);
}

function SubModal_Hide()
{
    if (gSubModalStack.length == 0)
    {
	    var theBody = document.getElementsByTagName("BODY")[0];

	    theBody.style.overflow = "auto";
	    restoreTabIndexes();
	    if (gPopupMask == null) return;
    	
	    gPopupMask.style.display = "none";
	    
	    // display all select boxes
	    if (gHideSelects == true) {
		    displaySelectBoxes();
	    }	 
	    
	    return;   
    }

    if (gSubModalStack.length > 0) 
    {
        gSubModal = gSubModalStack.pop();
        gSubModal.restore();
    }
   
}

var gi = 0;

/**
 * Sets the size of the popup mask.
 *
 */
function setMaskSize() {
	var theBody = document.getElementsByTagName("BODY")[0];
			
	var fullHeight = getViewportHeight();
	var fullWidth = getViewportWidth();
	
	// Determine what's bigger, scrollHeight or fullHeight / width
	if (fullHeight > theBody.scrollHeight) {
		popHeight = fullHeight;
	} else {
		popHeight = theBody.scrollHeight;
	}
	
	if (fullWidth > theBody.scrollWidth) {
		popWidth = fullWidth;
	} else {
		popWidth = theBody.scrollWidth;
	}
	
	if (gPopupMask)
	{
	    gPopupMask.style.height = popHeight + "px";
	    gPopupMask.style.width = popWidth + "px";
    }
}





// Tab key trap. iff popup is shown and key was [TAB], suppress it.
// @argument e - event - keyboard event that caused this function to be called.
function keyDownHandler(e) {
    if (gPopupIsShown && e.keyCode == 9)  return false;
}

// For IE.  Go through predefined tags and disable tabbing into them.
function disableTabIndexes() {
    gTabIndexes = new Array();

	if (document.all) {
		var i = 0;
		for (var j = 0; j < gTabbableTags.length; j++) {
			var tagElements = document.getElementsByTagName(gTabbableTags[j]);
			for (var k = 0 ; k < tagElements.length; k++) {
				gTabIndexes[i] = tagElements[k].tabIndex;
				tagElements[k].tabIndex="-1";
				i++;
			}
		}
	}
}

// For IE. Restore tab-indexes.
function restoreTabIndexes() {
	if (document.all) {
		var i = 0;
		for (var j = 0; j < gTabbableTags.length; j++) {
			var tagElements = document.getElementsByTagName(gTabbableTags[j]);
			for (var k = 0 ; k < tagElements.length; k++) {
				tagElements[k].tabIndex = gTabIndexes[i];
				tagElements[k].tabEnabled = true;
				i++;
			}
		}
	}
}


/**
* Hides all drop down form select boxes on the screen so they do not appear above the mask layer.
* IE has a problem with wanted select form tags to always be the topmost z-index or layer
*
* Thanks for the code Scott!
*/
function hideSelectBoxes() {
	for(var i = 0; i < document.forms.length; i++) {
		for(var e = 0; e < document.forms[i].length; e++){
			if(document.forms[i].elements[e].tagName == "SELECT") {
				document.forms[i].elements[e].style.visibility="hidden";
			}
		}
	}
}

/**
* Makes all drop down form select boxes on the screen visible so they do not reappear after the dialog is closed.
* IE has a problem with wanted select form tags to always be the topmost z-index or layer
*/
function displaySelectBoxes() {
	for(var i = 0; i < document.forms.length; i++) {
		for(var e = 0; e < document.forms[i].length; e++){
			if(document.forms[i].elements[e].tagName == "SELECT") {
			document.forms[i].elements[e].style.visibility="visible";
			}
		}
	}
}

function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}


var browser = new Browser();

// Global object to hold drag information.
//if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();

if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();