
function LiteViewUpdatePanel(element)
{LiteViewUpdatePanel.initializeBase(this,[element]);this._events=new Sys.EventHandlerList();this._currentCmd=null;this._httpMethod="GET";LiteViewUpdatePanel.registry.push(this);}
LiteViewUpdatePanel.registry=[];LiteViewUpdatePanel.getInstance=function(containerId)
{for(var i=0;i<LiteViewUpdatePanel.registry.length;i++)
{var instance=LiteViewUpdatePanel.registry[i];if(instance.get_id()==containerId)
return instance;};return null;};LiteViewUpdatePanel.prototype.get_serviceUrl=function()
{return this._serviceUrl;};LiteViewUpdatePanel.prototype.set_serviceUrl=function(value)
{this._serviceUrl=value;};LiteViewUpdatePanel.prototype.get_id=function()
{return this._id;};LiteViewUpdatePanel.prototype.set_id=function(value)
{this._id=value;};LiteViewUpdatePanel.prototype.get_httpMethod=function()
{return this._httpMethod;};LiteViewUpdatePanel.prototype.set_httpMethod=function(value)
{this._httpMethod=value;};LiteViewUpdatePanel.prototype.add_updating=function(handler)
{this._events.addHandler("updating",handler);};LiteViewUpdatePanel.prototype.remove_updating=function(handler)
{this._events.removeHandler("updating",handler);};LiteViewUpdatePanel.prototype.raise_updating=function(handler)
{var handler=this._events.getHandler("updating");if(handler)
handler();};LiteViewUpdatePanel.prototype.add_htmlUpdated=function(handler)
{this._events.addHandler("htmlUpdated",handler);};LiteViewUpdatePanel.prototype.remove_htmlUpdated=function(handler)
{this._events.removeHandler("htmlUpdated",handler);};LiteViewUpdatePanel.prototype.raise_htmlUpdated=function(args)
{var handler=this._events.getHandler("htmlUpdated");if(handler)
handler(args);};LiteViewUpdatePanel.prototype.add_updated=function(handler)
{this._events.addHandler("updated",handler);};LiteViewUpdatePanel.prototype.remove_updated=function(handler)
{this._events.removeHandler("updated",handler);};LiteViewUpdatePanel.prototype.raise_updated=function(args)
{var handler=this._events.getHandler("updated");if(handler)
handler(args);};LiteViewUpdatePanel.prototype.update=function(serviceMethod,serviceParams,state)
{this.raise_updating();this._currentCmd=ClientCommandFactory.createCommand(this._serviceUrl,serviceMethod);this._currentCmd.setHttpMethod(this._httpMethod);this._currentCmd.parameters=serviceParams;this._currentCmd.state.clientState=state;this._currentCmd.state.cmdId=this._getUniqueCmdId();this._currentCmd.execute(Function.createDelegate(this,this._endUpdate));};LiteViewUpdatePanel.prototype._endUpdate=function(response)
{if(this._currentCmd==null||this._currentCmd.state.cmdId!=response.state.cmdId)
{return;}
this._currentCmd=null;if(response.success)
{var jsonValue=response.value;if(!jsonValue||!jsonValue.html)
{response.state=response.state.clientState;this.raise_updated(response);return;}
try
{this._disposeTree(this.get_element());this.get_element().innerHTML=jsonValue.html;this.raise_htmlUpdated();jsonValue.scriptBlocks.each(function(scriptBlock)
{LiteViewUpdatePanel._evalScript(scriptBlock);});jsonValue.startupScripts.each(function(startupScript)
{LiteViewUpdatePanel._evalScript(startupScript);});}
catch(ex)
{this.raise_updated({'success':false,'state':response.state.clientState,'error':response.error});throw ex;}
this.raise_updated({'success':true,'state':response.state.clientState});}
else
{this.raise_updated({'success':false,'state':response.state.clientState,'error':response.error});}};LiteViewUpdatePanel.prototype._disposeTree=function(element)
{var childNodes=element.childNodes;for(var i=childNodes.length-1;i>=0;i--)
{var node=childNodes[i];if(node.nodeType===1)
{if(node.dispose&&typeof(node.dispose)==="function")
{node.dispose();}
this._disposeTree(node);}}};LiteViewUpdatePanel._evalScript=function(script)
{if(window.execScript)
{window.execScript(script);}
else if(Sys.Browser.agent==Sys.Browser.Safari)
{window.setTimeout(script,0);}
else
{window.eval(script);}};LiteViewUpdatePanel.prototype._getUniqueCmdId=function()
{if(!this._uniqueCmdId)
this._uniqueCmdId=0;this._uniqueCmdId+=1;return this._uniqueCmdId;}
if(LiteViewUpdatePanel.registerClass)
LiteViewUpdatePanel.registerClass("LiteViewUpdatePanel",Sys.UI.Control);

function ClientCommandFactory(){}
ClientCommandFactory.createCommand=function(baseUrl,action)
{return new ClientCommand(baseUrl,action);};function ClientCommand(baseUrl,action)
{this.baseUrl=baseUrl;this.action=action;this._httpMethod="GET";this.parameters=new Object();this.state=new Object();}
ClientCommand.prototype.setHttpMethod=function(method)
{method=method.toUpperCase();if(method!="GET"&&method!="POST")
{throw"Invalid HttpMethod.  It must be either 'GET' or 'POST'.";}
this._httpMethod=method;};ClientCommand.prototype.execute=function(callback)
{var requestUrl=this._constructUrl();var request=AsyncRequestFactory.createRequest(requestUrl,this.parameters);request.setHttpMethod(this._httpMethod);request.execute(callback,this.state);};ClientCommand.prototype._constructUrl=function()
{var url=this.baseUrl;var paramSeparator="?";if(this.baseUrl.endsWith(".aspx")||this.baseUrl.endsWith(".ashx"))
{url+='?__action='+this.action;paramSeparator="&";}
else
{if(!url.endsWith("/"))
url+="/";url+=this.action;}
if(this._httpMethod=="GET")
{var paramString=ClientCommandUtil.encodeParametersToURI(this.parameters);if(paramString!="")
url+=paramSeparator+paramString;}
return url;};function ClientCommandUtil(){}
ClientCommandUtil.encodeParametersToURI=function(parameters)
{var value="";var first=true;for(name in parameters)
{if(!first)
value+="&";value+=name;value+="=";value+=encodeURIComponent(parameters[name]);first=false;}
return value;};function AsyncRequestFactory(){}
AsyncRequestFactory.createRequest=function(requestUrl,parameters)
{var request;if(XmlHttpRequest.isXmlHttpSupported())
request=new XmlHttpRequest();else
request=new IFrameRequest();request.requestUrl=requestUrl;request.parameters=parameters;request.handleResponse=AsyncRequest_handleResponse;request.handleError=AsyncRequest_handleError;return request;};function AsyncRequest_handleResponse(callback,responseText,state)
{var response=eval('('+responseText+')');response.state=state;if(callback)
callback(response);}
function AsyncRequest_handleError(callback,errorMessage,state)
{var response=new Object();response.success=false;response.value='';response.error=errorMessage;response.state=state;if(callback)
callback(response);}
function IFrameRequest()
{}
IFrameRequest._createIFrame=function()
{var hiddenFrameId='hiddenFrame';var frameElement=document.createElement('iframe');frameElement.width=0;frameElement.height=0;frameElement.frameBorder=0;frameElement.name=hiddenFrameId;frameElement.id=hiddenFrameId;document.body.appendChild(frameElement);return frames[hiddenFrameId];};IFrameRequest.hiddenFrame=null;IFrameRequest.callback=null;IFrameRequest.prototype.setHttpMethod=function(method)
{if(method!="GET")
throw"Invalid Http Method.  Right now, only GET is supported by the IFrameRequest.";}
IFrameRequest.prototype.execute=function(callback,state)
{if(IFrameRequest.hiddenFrame==null)
{IFrameRequest.hiddenFrame=IFrameRequest._createIFrame();}
IFrameRequest.callback=callback;IFrameRequest.cmd=this;IFrameRequest.state=state;IFrameRequest._request(this.requestUrl);};IFrameRequest._request=function(url)
{url+="&__strategy=iframe";IFrameRequest.hiddenFrame.location.replace(url);};IFrameRequest._IFrameReady=function(responseText)
{var cmd=IFrameRequest.cmd;if(cmd)
{cmd.handleResponse(IFrameRequest.callback,responseText,IFrameRequest.state);}
IFrameRequest.callback=null;IFrameRequest.cmd=null;IFrameRequest.state=null;};function XmlHttpRequest()
{}
XmlHttpRequest.prototype.setHttpMethod=function(method)
{this._httpMethod=method;};XmlHttpRequest.prototype.execute=function(callback,state)
{var oThis=this;var xmlHttp=XmlHttpRequest._createXmlHttp();xmlHttp.open(this._httpMethod,this.requestUrl,true);if(this._httpMethod=="POST")
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlHttp.onreadystatechange=function()
{if(xmlHttp.readyState==4)
{if(xmlHttp.status==200)
{oThis.handleResponse(callback,xmlHttp.responseText,state);}
else
{oThis.handleError(callback,'Http Error: '+xmlHttp.status,state);}}};xmlHttp.send(this._getDataToSend());};XmlHttpRequest.prototype._getDataToSend=function()
{if(this._httpMethod=="POST")
return ClientCommandUtil.encodeParametersToURI(this.parameters);else
return null;};XmlHttpRequest._isXmlHttpSupported=null;XmlHttpRequest.isXmlHttpSupported=function()
{if(XmlHttpRequest._isXmlHttpSupported==null)
{try
{XmlHttpRequest._createXmlHttp();XmlHttpRequest._isXmlHttpSupported=true;}
catch(ex)
{XmlHttpRequest._isXmlHttpSupported=false;}}
return XmlHttpRequest._isXmlHttpSupported;};XmlHttpRequest._createXmlHttp=function()
{if(typeof XMLHttpRequest!='undefined')
{return new XMLHttpRequest();}
else if(window.ActiveXObject)
{var versions=["MSXML2.XMLHttp.5.0","MSXML2.XmlHttp.4.0","MSXML2.XmlHttp.3.0","MSXML2.XMLHttp","Microsoft.XMLHttp"];for(var i=0;i<versions.length;i++)
{try
{var xmlHttp=new ActiveXObject(versions[i]);return xmlHttp;}
catch(ex)
{}}}
throw"XMLHttp object could not be created.";};if(!String.prototype.endsWith)
{String.prototype.endsWith=function(value)
{var L1=this.length;var L2=value.length;if(L2>L1)
return false;return(L2==0||this.substr(L1-L2,L2)==value);};}