﻿function addLoadEvent(loadFunc)
{if(loadFunc)
{var oldonload=window.onload;if(typeof window.onload!='function')
{window.onload=loadFunc;}
else
{window.onload=function()
{if(typeof oldonload=='function')oldonload();loadFunc();}}}}
function addAjaxLoadEvent(loadFunc)
{function f(){loadFunc();Sys.Application.remove_load(f);};Sys.Application.add_load(f);}
function addResizeEvent(resizeFunc,resizeControl)
{if(resizeControl==null)
resizeControl=window;$addHandler(resizeControl,'resize',resizeFunc)}
var resizeFunctionNames=new Array();function addContentResizeEvent(resizeFunctionName)
{resizeFunctionNames.push(resizeFunctionName);}
function contentResized(contentWidth,contentHeight)
{for(var i=0;i<resizeFunctionNames.length;i++)
{var evalText=resizeFunctionNames[i]+'('+contentWidth+','+contentHeight+')';eval(evalText);}}
function getNextObject(n)
{do n=n.nextSibling;while(n&&n.nodeType!=1);return n;}
function getPreviousObject(p)
{do p=p.previousSibling;while(p&&p.nodeType!=1);return p;}
function cancelSubmit()
{return CancelEvent();}
function CancelEvent(e)
{if(!e)
{e=window.event;}
if(e!=null)
e.returnValue=false;return false;}
function cancelEvent()
{return CancelEvent();}
function CancelEventPropagation(e)
{if(!e)
{e=window.event;}
e.cancelBubble=true;if(e.stopPropagation)
e.stopPropagation();}
function eventSource(e)
{if(window.event)
return window.event.srcElement;return e.target;}
function KeyStroke(e)
{if(window.event)
{return e.keyCode;}
else
{return e.which;}}
function ExtractNumber(value)
{var n=parseInt(value);return n==null||isNaN(n)?0:n;}
function $(id)
{return document.getElementById(id);}
function submitForm(object)
{if(object&&object!=null)
form=findAncestor(object,"FORM");else
form=window.template;if(form!=null)
form.submit();}
function getParent(element)
{return element.parentNode||element.parentElement;}
if(!window.Node)var Node={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12}
function findAncestor(object,type)
{oParent=getParent(object);while(oParent!=null)
{if(oParent.tagName.toLowerCase()==type.toLowerCase())
return oParent;oParent=getParent(oParent);}
return null;}
function trim(str,chars)
{return ltrim(rtrim(str,chars),chars);}
function ltrim(str,chars)
{chars=chars||"\\s";return str.replace(new RegExp("^["+chars+"]+","g"),"");}
function rtrim(str,chars)
{chars=chars||"\\s";return str.replace(new RegExp("["+chars+"]+$","g"),"");}
function livePageHeight()
{if(window.innerHeight&&window.scrollMaxY&&BrowserDetect.version<3)
{return window.innerHeight+window.scrollMaxY;}
else
{return document.body.offsetHeight+document.body.offsetTop;}
return null;}
function livePageWidth()
{if(window.innerHeight&&window.scrollMaxY)
{return window.innerWidth+window.scrollMaxX;}
else
{return document.body.offsetWidth+document.body.offsetLeft;}
return null;}
function findAbsoluteCoords(obj)
{var shape=new Object();shape.left=obj.offsetLeft;shape.top=obj.offsetTop;shape.width=obj.clientWidth;shape.height=obj.clientHeight;shape.absoluteLeft=0;shape.absoluteTop=0;var temp=obj;while(temp!=null)
{var tagName=temp.tagName.toUpperCase();if(tagName=='BODY'||tagName=='FORM'||tagName=='HTML')
break;shape.absoluteLeft=shape.absoluteLeft+temp.offsetLeft;shape.absoluteTop=shape.absoluteTop+temp.offsetTop;temp=temp.offsetParent;if(temp!=null&&(temp.style.position=='absolute'||temp.style.position=='relative'))
break;}
if(shape.width==0)
shape.width=livePageWidth()-shape.absoluteLeft;if(shape.height==0)
shape.height=livePageHeight()-shape.absoluteTop;return shape;}
function GetURLParameters()
{var url=window.document.URL.toString();if(url.indexOf("?")>0)
{var parts=url.split("?");var paramsArray=parts[1].split("&");return paramsArray;}
return null;}
function FindURLParameter(paramName)
{paramName=paramName.toUpperCase();var paramsArray=GetURLParameters();if(paramsArray!=null)
return FindParameterInArray(paramName,paramsArray);return null;}
function FindParameterInArray(paramName,paramsArray)
{paramName=paramName.toUpperCase();for(i=0;i<paramsArray.length;i++)
{var sParam=paramsArray[i].split("=");if(sParam[0].toUpperCase()==paramName)
return sParam[1];}
return null;}
function findPos(obj)
{var curleft=curtop=0;if(obj.offsetParent){do{curleft+=obj.offsetLeft;curtop+=obj.offsetTop;}while(obj=obj.offsetParent);}
return[curleft,curtop];}
function Cover(bottomElement,topElement,ignoreSize,offsetX,offsetY){var location=findPos(bottomElement);topElement.style.position='absolute';var positionY=location[1];if(offsetY!=null&&!isNaN(offsetY))
positionY=positionY+offsetY;var positionX=location[0];if(offsetX!=null&&!isNaN(offsetX))
positionX=positionX+offsetX;var bottomheight=0;var bottomwidth=0;bottomheight=bottomElement.offsetHeight;if(screen.height<bottomheight)
bottomheight=screen.height;bottomwidth=bottomElement.offsetWidth;if(screen.width<bottomwidth)
bottomwidth=screen.width;if(!ignoreSize){topElement.style.height=bottomheight+'px';topElement.style.width=bottomwidth+'px';}
var pageLeft=GetViewportScrollPos().x;var pageRight=pageLeft+document.body.offsetWidth-1;var pageTop=GetViewportScrollPos().y;var pageBottom=pageTop+document.body.offsetHeight-1;var elementHeight=topElement.offsetHeight>0?topElement.offsetHeight:bottomheight;var elementWidth=topElement.offsetWidth>0?topElement.offsetWidth:bottomwidth;if((positionY+elementHeight)>pageBottom)
positionY=pageBottom-elementHeight;if((positionX+elementWidth)>pageRight)
positionX=pageRight-elementWidth;if(positionX<pageLeft)
positionX=pageLeft;if(positionY<pageTop)
positionY=pageTop;topElement.style.top=positionY+'px';topElement.style.left=positionX+'px';topElement.style.zIndex=1001;}
function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=name+"="+value+expires+"; path=/";}
function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}
function eraseCookie(name){createCookie(name,"",-1);}
function IsUrl(s,optionalSchema){var regexp=new RegExp('^(([a-z]+)://)'+(optionalSchema?'?':'')+'([a-z0-9\-]+|[a-z0-9][a-z0-9\-\.\_]*\.[a-z]+)(:[0-9]+)?(/.*)?$','i');return regexp.test(s);}
var BrowserDetect={init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.OS=this.searchString(this.dataOS)||"an unknown OS";},searchString:function(data){for(var i=0;i<data.length;i++){var dataString=data[i].string;var dataProp=data[i].prop;this.versionSearchString=data[i].versionSearch||data[i].identity;if(dataString){if(dataString.indexOf(data[i].subString)!=-1)
return data[i].identity;}
else if(dataProp)
return data[i].identity;}},searchVersion:function(dataString){var index=dataString.indexOf(this.versionSearchString);if(index==-1)return;return parseFloat(dataString.substring(index+this.versionSearchString.length+1));},dataBrowser:[{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari"},{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};BrowserDetect.init();function GetElementViewportOffset(forElement){var valueY=0,valueX=0,docBody=document.body;var element=forElement;do{valueY+=element.offsetTop||0;valueX+=element.offsetLeft||0;if(element.offsetParent==docBody&&element.style.position&&element.style.position=='absolute')break;}while(element=element.offsetParent);element=forElement;do{if(element!=docBody){valueY-=element.scrollTop||0;valueX-=element.scrollLeft||0;}}while(element=element.parentNode);var coords=new Object();coords.x=valueX;coords.y=valueY;return coords;}
function GetViewportScrollPos(){var scrollPos=new Object();scrollPos.x=scrollPos.y=0;if(typeof window.pageYOffset!='undefined'){scrollPos.y=window.pageYOffset;scrollPos.x=window.pageXOffset;}
else
if(document.documentElement){scrollPos.y=document.documentElement.scrollTop;scrollPos.x=document.documentElement.scrollLeft;}
else
if(document.body&&typeof document.body.scrollTop!='undefined'){scrollPos.y=document.body.scrollTop;scrollPos.x=document.body.scrollLeft;}
return scrollPos;}
function SizeImageWithinBounds(imageElement,maxWidth,maxHeight,allowUpsize){maxWidth=parseInt(maxWidth);if(isNaN(maxWidth))maxWidth=0;maxHeight=parseInt(maxHeight);if(isNaN(maxHeight))maxHeight=0;if(maxWidth<=0&&maxHeight<=0)return;if(imageElement==null)return;if(!imageElement.tagName)return;if(imageElement.tagName.toUpperCase()!="IMG")return;var width=imageElement.width;var height=imageElement.height;if(width==0||height==0)return;var aspectRatio=imageElement.width/imageElement.height;var sizeMode=0;if(maxWidth>0&&maxHeight>0){sizeMode=(Math.floor(maxWidth/aspectRatio)<=maxHeight)?1:2;}
else{if(maxWidth>0){if(width>maxWidth||(width<maxWidth&&allowUpsize))sizeMode=1;}
else{if(height>maxHeight||(height<maxHeight&&allowUpsize))sizeMode=2;}}
if(sizeMode==0)return;if(sizeMode==1){width=maxWidth;height=Math.max(Math.floor(width/aspectRatio),1);}
else{height=maxHeight;width=Math.max(Math.floor(height*aspectRatio),1);}
imageElement.width=width;imageElement.height=height;}
