﻿
function addEvent(obj,evType,fn){if(obj.addEventListener){obj.addEventListener(evType,fn,false);return true;}else if(obj.attachEvent){var r=obj.attachEvent("on"+evType,fn);return r;}else{return false;}}
function removeEvent(obj,evType,fn,useCapture){if(obj.removeEventListener){obj.removeEventListener(evType,fn,useCapture);return true;}else if(obj.detachEvent){var r=obj.detachEvent("on"+evType,fn);return r;}else{alert("Handler could not be removed");}}
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(){var offset=17;var width=null;if(window.innerWidth!=window.undefined)return window.innerWidth;if(document.compatMode=='CSS1Compat')return document.documentElement.clientWidth;if(document.body)return document.body.clientWidth;}
function getScrollTop(){if(self.pageYOffset)
{return self.pageYOffset;}
else if(document.documentElement&&document.documentElement.scrollTop)
{return document.documentElement.scrollTop;}
else if(document.body)
{return document.body.scrollTop;}}
function getScrollLeft(){if(self.pageXOffset)
{return self.pageXOffset;}
else if(document.documentElement&&document.documentElement.scrollLeft)
{return document.documentElement.scrollLeft;}
else if(document.body)
{return document.body.scrollLeft;}}
function getSrcElement(evt)
{if(Sys.Browser.agent==Sys.Browser.InternetExplorer)
{return evt.srcElement;}
else
{return evt.currentTarget;}}
function concatQueryString(url,qName,value)
{if(value!=null&&qName!=null&&qName!="")
{var matchRegex=new RegExp("[?|&]"+qName+"=");if(url.match(matchRegex)!=null)
{var replaceRegex=new RegExp(qName+'=.+&');url=url.replace(replaceRegex,'');replaceRegex=new RegExp('&'+qName+'=[^&]+');url=url.replace(replaceRegex,'');replaceRegex=new RegExp('\\?'+qName+'=[^&]+');url=url.replace(replaceRegex,'');}
var q=qName+"="+encodeURIComponent(value);if(url.indexOf("?")==-1)
{return url+"?"+q;}
else
{return url+"&"+q;}}
return url;}
window.history.back=function()
{PageMethods.GetHistory(onBackSuccessful,onBackFailed);}
function onBackSuccessful(history)
{if(history!="")
{window.location.href=history;}
else
{window.history.go(-1);}}
function onBackFailed()
{window.history.go(-1);}
function getElementById(elements,id)
{for(var i=0;i<elements.length;i++)
{if(elements[i].id.indexOf(id)>-1)
{return elements[i];}}
return null;}
function setDefaultWithQuery(elementId,qName,propertyName)
{if(window.location.queryString[qName]!=undefined)
{var txtId=document.getElementById(elementId);if(propertyName==undefined)
txtId.value=window.location.queryString[qName];else
txtId[propertyName]=window.location.queryString[qName];}}
function appendQueryString(url,qName,elementId,propertyName)
{var txtId=document.getElementById(elementId);if(txtId!=null&&txtId.value!="")
{if(propertyName==undefined)
{return concatQueryString(url,qName,txtId.value);}
else{return concatQueryString(url,qName,txtId[propertyName]);}}
return url;}
function unascii(str){try
{return decodeURIComponent(str);}
catch(e)
{return unescape(str.replace(/\\u/g,"%u"));}}
function SplitQueryString(queryString)
{window.location.queryString=new Array();var splitedQuery=queryString.split('&');if(splitedQuery!="")
{for(i=0;i<splitedQuery.length;i++)
{var nameValue=splitedQuery[i].split('=');window.location.queryString[nameValue[0]]=unascii(nameValue[1]);}}}
function DisableButton(buttonElem,text,validationGroup){if(typeof(Page_ClientValidate)!='undefined')
{if(!Page_ClientValidate(validationGroup))
return false;}
buttonElem.value=text;buttonElem.disabled=true;}
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();