/**
 *	Copyright (c) HenuSoft, All Rights Reserved.
 *	http://www.HenuSoft.se
 */

{HsBrowser=function(){try{this.isDOM=((typeof document.getElementById)!='undefined');this.isIE=((typeof document.all)!='undefined');this.isIE4=(!this.isDOM&&this.isIE);this.isNN4=((typeof document.layers)!='undefined');this.isSafari=(navigator.userAgent.indexOf('Safari')!=-1);this.isMozilla=(this.isDOM&&!this.isIE&&!this.isNN4&&!this.isSafari);this.isMac=(navigator.userAgent.indexOf('Mac')!=-1);this.isWin=(navigator.userAgent.indexOf('Win')!=-1);this.screenWidth=((typeof screen.width)=='undefined'?'na':screen.width);this.screenHeight=((typeof screen.height)=='undefined'?'na':screen.height);this.colors=((typeof screen.pixelDepth)=='undefined'?((typeof screen.colorDepth)=='undefined'?'na':screen.colorDepth):screen.pixelDepth);this.isJava=navigator.javaEnabled();this.referrer=(''+escape(document.referrer));}catch(ex){throw new Error(createErrorMessage('HsScript.js','HsBrowser',ex));}
}
HsBrowser.newInstance=function(){try{window.hsBrowser=((typeof top.hsBrowser)=='object'?top.hsBrowser:new HsBrowser());if(window.hsBrowser==null){throw new Error('top.hsBrowser is null!');}
}catch(ex){throw new Error(createErrorMessage('HsScript.js','HsBrowser.newInstance',ex));}
}
HsBrowser.newInstance();HsDebug=function(){try{this.debugElement=null;this.messageStack=new Array();this.isInitialized=false;this.isInitializing=false;this.isDebugging=false;}catch(ex){throw new Error(createErrorMessage('HsScript.js','HsDebug',ex));}
}
HsDebug.newInstance=function(){try{window.top.hsDebug.isDebugging=true;window.top.hsDebug.isInitializing=true;if((window.top.frames.length==0&&window.top.document.body!=null)||((typeof window.top.MainFrame)!='undefined'&&window.top.MainFrame.document.body!=null)){window.top.hsDebug.create();}else{setTimeout(HsDebug.newInstance,200);}
window.top.hsDebug.isDebugging=false;}catch(ex){throw new Error(createErrorMessage('HsScript.js','HsDebug.newInstance',ex));}
}
HsDebug.prototype.create=function(){try{this.isDebugging=true;var spanElement=newElement('span',(window.top.frames.length==0?window.top:window.top.MainFrame).document.body,null,'id=HsDebugElement','zIndex=999999998','style-position=absolute','style-width=100%','style-height=100px','left=0px','bottom=2px');this.debugElement=newElement('textarea',spanElement,null,'id=HsDebugTextArea','zIndex=999999999','style-width=100%','style-height=100%');this.debugElement.value='### HsDebug ###\n';show.call(spanElement);HsDebug.onMoveEvent();attachEvent.call((window.top.frames.length==0?window.top:window.top.MainFrame).document,'scroll',HsDebug.onMoveEvent);attachEvent.call(window,'resize',HsDebug.onMoveEvent);this.isInitializing=false;this.isInitialized=true;this.isDebugging=false;}catch(ex){throw new Error(createErrorMessage('HsScript.js','HsDebug.prototype.create',ex));}
}
HsDebug.isInitialized=function(){try{window.top.hsDebug.isDebugging=true;var rIsInitialized=false;if(window.top.hsDebug.isInitialized&&!window.top.hsDebug.isInitializing){if((window.top.frames.length==0&&window.top.document.body!=null)||((typeof window.top.MainFrame)!='undefined'&&window.top.MainFrame.document.body!=null)){if(findElementById('HsDebugTextArea',(window.top.frames.length==0?window.top:window.top.MainFrame).document)==null){HsDebug.newInstance();}else{rIsInitialized=true;}
}else{HsDebug.newInstance();}
}
window.top.hsDebug.isDebugging=false;return rIsInitialized;}catch(ex){throw new Error(createErrorMessage('HsScript.js','HsDebug.prototype.create',ex));}
}
HsDebug.print=function(){try{window.top.hsDebug.isDebugging=true;if(HsDebug.isInitialized()){var message=window.top.hsDebug.messageStack.pop();findElementById('HsDebugTextArea',(window.top.frames.length==0?window.top.document:window.top.MainFrame.document)).value+=(message+'\n');if((typeof console)!='undefined'){console.debug(message);}
}else{setTimeout(HsDebug.print,200);}
window.top.hsDebug.isDebugging=false;}catch(ex){throw new Error(createErrorMessage('HsScript.js','HsDebug.print',ex));}
}
HsDebug.onMoveEvent=function(aEvent){try{window.top.hsDebug.isDebugging=true;var documentElement=((typeof this.body)=='undefined'?(window.top.frames.length==0?window.top.document:window.top.MainFrame.document):this);debugElement=findElementById('HsDebugElement',documentElement);if(debugElement!=null){calculateGraphics.call(debugElement,documentElement);moveTo.call(debugElement,debugElement.graphics.left,(documentElement.body.scrollTop+documentElement.body.clientHeight-debugElement.graphics.height-2),this);}
window.top.hsDebug.isDebugging=false;}catch(ex){throw new Error(createErrorMessage('HsScript.js','HsDebug.onMoveEvent',ex));}
}
HsDebug.debug=function(aMessage){try{if((typeof aMessage)=='undefined'){throw new Error('\'aMessage\' is a undefined parameter!');}
if((typeof window.top.hsDebug)=='undefined'){window.top.hsDebug=new HsDebug();}
if(!window.top.hsDebug.isDebugging){if(!window.top.hsDebug.isInitialized&&!window.top.hsDebug.isInitializing){HsDebug.newInstance();}
window.top.hsDebug.messageStack.push(aMessage);HsDebug.print();}
}catch(ex){throw new Error(createErrorMessage('HsScript.js','HsDebug.debug',ex));}
}
Array.prototype.indexOf=function(aObject){try{if((typeof aObject)=='undefined'){throw new Error('\'aObject\' is a undefined parameter!');}
var rIndex=-1;if(this.length>0){for(var index=0;index<this.length;index++){if((typeof this[index])!='undefined'){var isArray=(this[index].constructor.toString().indexOf('Array')!=-1);if((isArray&&this[index][0]==aObject)||(!isArray&&this[index]==aObject)){rIndex=index;break;}
}
}
}
return rIndex;}catch(ex){throw new Error(createErrorMessage('HsScript.js','Array.prototype.contains',ex));}
}
Array.prototype.contains=function(aObject){try{if((typeof aObject)=='undefined'){throw new Error('\'aObject\' is a undefined parameter!');}
return(this.indexOf(aObject)!=-1);}catch(ex){throw new Error(createErrorMessage('HsScript.js','Array.prototype.contains',ex));}
}
String.prototype.startsWith=function(aString){try{if((typeof aString)=='undefined'){throw new Error('\'aString\' is a undefined parameter!');}
var filter=new RegExp(('^'+aString+'+'));return filter.test(this);}catch(ex){throw new Error(createErrorMessage('HsScript.js','String.prototype.startsWith',ex));}
}
String.prototype.endsWith=function(aString){try{if((typeof aString)=='undefined'){throw new Error('\'aString\' is a undefined parameter!');}
var filter=new RegExp((aString+'+$'));return filter.test(this);}catch(ex){throw new Error(createErrorMessage('HsScript.js','String.prototype.endsWith',ex));}
}
String.prototype.isEmpty=function(){try{return(this.length==0);}catch(ex){throw new Error(createErrorMessage('HsScript.js','String.prototype.isEmpty',ex));}
}
String.transformXmlCode=function(aXmlCode){try{if((typeof aXmlCode)=='undefined'){throw new Error('\'aXmlCode\' is a undefined parameter!');}
return String.fromCharCode(aXmlCode.substring(2,(aXmlCode.length-1)).toInt());}catch(ex){throw new Error(createErrorMessage('HsScript.js','String.transformXmlCode',ex));}
}
String.prototype.transformXml=function(){try{return this.replace(/(&#\d+;)/g,String.transformXmlCode);}catch(ex){throw new Error(createErrorMessage('HsScript.js','String.prototype.transformXml',ex));}
}
String.prototype.trim=function(){try{return this.replace(/^\s+|\s+$/g,'');}catch(ex){throw new Error(createErrorMessage('HsScript.js','String.prototype.trim',ex));}
}
String.prototype.leftTrim=function(){try{return this.replace(/^\s+/,'');}catch(ex){throw new Error(createErrorMessage('HsScript.js','String.prototype.leftTrim',ex));}
}
String.prototype.rightTrim=function(){try{return this.replace(/\s+$/,'');}catch(ex){throw new Error(createErrorMessage('HsScript.js','String.prototype.rightTrim',ex));}
}
String.prototype.toInt=function(){try{var rInt=parseInt(this.trim().replace(/^0+/,''));return(isNaN(rInt)?0:rInt);}catch(ex){throw new Error(createErrorMessage('HsScript.js','String.prototype.toInt',ex));}
}
String.prototype.toLower=function(){try{return this.toLowerCase();}catch(ex){throw new Error(createErrorMessage('HsScript.js','String.prototype.toLower',ex));}
}
String.prototype.toUpper=function(){try{return this.toUpperCase();}catch(ex){throw new Error(createErrorMessage('HsScript.js','String.prototype.toUpper',ex));}
}
String.prototype.padLeft=function(aLength,aCharacter){try{if((typeof aLength)=='undefined'){throw new Error('\'aLength\' is a undefined parameter!');}else if((typeof aCharacter)=='undefined'){throw new Error('\'aCharacter\' is a undefined parameter!');}
var rString=this;if(this.length>aLength){rString=rString.substring((this.length-aLength),this.length);}else if(this.length<aLength){for(var i=0;i<(aLength-this.length);i++){rString=(aCharacter+rString);}
}
return rString;}catch(ex){throw new Error(createErrorMessage('HsScript.js','String.prototype.padLeft',ex));}
}
String.prototype.padRight=function(aLength,aCharacter){try{if((typeof aLength)=='undefined'){throw new Error('\'aLength\' is a undefined parameter!');}else if((typeof aCharacter)=='undefined'){throw new Error('\'aCharacter\' is a undefined parameter!');}
var rString=this;if(this.length>aLength){rString=rString.substring(0,aLength);}else if(this.length<aLength){for(var i=0;i<(aLength-this.length);i++){rString+=aCharacter;}
}
return rString;}catch(ex){throw new Error(createErrorMessage('HsScript.js','String.prototype.padRight',ex));}
}
String.prototype.left=function(aLength){try{if((typeof aLength)=='undefined'){throw new Error('\'aLength\' is a undefined parameter!');}
var rString=this;if(aLength>0&&this.length>aLength){rString=rString.substring(0,aLength);}else if(aLength<0){rString=rString.substring((aLength*-1),rString.length);}
return rString;}catch(ex){throw new Error(createErrorMessage('HsScript.js','String.prototype.left',ex));}
}
String.prototype.right=function(aLength){try{if((typeof aLength)=='undefined'){throw new Error('\'aLength\' is a undefined parameter!');}
var rString=this;if(aLength>0&&this.length>aLength){rString=rString.substring((rString.length-aLength),rString.length);}else if(aLength<0){rString=rString.substring(0,(rString.length+aLength));}
return rString;}catch(ex){throw new Error(createErrorMessage('HsScript.js','String.prototype.right',ex));}
}
Date.newDate=function(aYear,aMonth,aDay){try{if((typeof aYear)=='undefined'){throw new Error('\'aYear\' is a undefined parameter!');}else if((typeof aMonth)=='undefined'){throw new Error('\'aMonth\' is a undefined parameter!');}else if((typeof aDay)=='undefined'){throw new Error('\'aDay\' is a undefined parameter!');}
return new Date(Date.UTC(aYear,(aMonth-1),aDay,0,0,0));}catch(ex){throw new Error(createErrorMessage('HsScript.js','Date.newDate',ex));}
}
Date.prototype.addDays=function(aCount){try{if((typeof aCount)=='undefined'){throw new Error('\'aCount\' is a undefined parameter!');}
this.setDate((this.getDate()+aCount));}catch(ex){throw new Error(createErrorMessage('HsScript.js','Date.prototype.addDays',ex));}
}
Date.prototype.addWeeks=function(aCount){try{if((typeof aCount)=='undefined'){throw new Error('\'aCount\' is a undefined parameter!');}
this.setDate((this.getDate()+(7*aCount)));}catch(ex){throw new Error(createErrorMessage('HsScript.js','Date.prototype.addWeeks',ex));}
}
Date.prototype.addMonths=function(aCount){try{if((typeof aCount)=='undefined'){throw new Error('\'aCount\' is a undefined parameter!');}
this.setMonth((this.getMonth()+aCount));}catch(ex){throw new Error(createErrorMessage('HsScript.js','Date.prototype.addMonths',ex));}
}
Date.prototype.addYears=function(aCount){try{if((typeof aCount)=='undefined'){throw new Error('\'aCount\' is a undefined parameter!');}
this.setFullYear((this.getFullYear()+aCount));}catch(ex){throw new Error(createErrorMessage('HsScript.js','Date.prototype.addYears',ex));}
}
Date.prototype.getWeekDay=function(){try{return((this.getDay()==0?7:this.getDay())-1);}catch(ex){throw new Error(createErrorMessage('HsScript.js','Date.prototype.getWeekDay',ex));}
}
Date.prototype.getWeekNumber=function(){try{var thisDate=Date.newDate(this.getFullYear(),(this.getMonth()+1),this.getDate());thisDate.setDate((thisDate.getDate()-thisDate.getWeekDay()+3));var thisMilliseconds=thisDate.valueOf();thisDate.setMonth(0);thisDate.setDate(4);return(Math.round(((thisMilliseconds-thisDate.valueOf())/(7*864e5)))+1);}catch(ex){throw new Error(createErrorMessage('HsScript.js','Date.prototype.getWeekNumber',ex));}
}
Date.prototype.formatDate=function(aDateFormat){try{if((typeof aDateFormat)=='undefined'){throw new Error('\'aDateFormat\' is a undefined parameter!');}
var rDateString=null;if(aDateFormat!=null&&(typeof aDateFormat)=='string'){rDateString=aDateFormat.replace('yyyy',this.getFullYear());rDateString=rDateString.replace('MM',(''+(this.getMonth()+1)).padLeft(2,'0'));rDateString=rDateString.replace('dd',(''+this.getDate()).padLeft(2,'0'));}
return rDateString;}catch(ex){throw new Error(createErrorMessage('HsScript.js','Date.prototype.formatDate',ex));}
}
Date.parseDate=function(aDateString,aDateFormat){try{if((typeof aDateString)=='undefined'){throw new Error('\'aDateString\' is a undefined parameter!');}else if((typeof aDateFormat)=='undefined'){throw new Error('\'aDateFormat\' is a undefined parameter!');}
var rDate=null;var yearPosition=aDateFormat.indexOf('yyyy');var monthPosition=aDateFormat.indexOf('MM');var dayPosition=aDateFormat.indexOf('dd');if(yearPosition==-1||monthPosition==-1||dayPosition==-1){throw new Error('\'aDateFormat\' is in invalid format!');}else{rDate=Date.newDate(aDateString.substring(yearPosition,(yearPosition+4)),aDateString.substring(monthPosition,(monthPosition+2)),aDateString.substring(dayPosition,(dayPosition+2)));}
return rDate;}catch(ex){throw new Error(createErrorMessage('HsScript.js','Date.prototype.parseDate',ex));}
}
function calculateGraphics(aDocument){try{var currentElement=((typeof this.id)=='string'?this:findElementById(this,aDocument));if(currentElement!=null&&(typeof currentElement.offsetParent)!='unknown'){var oldDisplay=currentElement.style.display;var positionX=null;var positionY=null;if(hsBrowser.isDOM||hsBrowser.isIE4){var tempElement=currentElement;positionX=0;positionY=0;while(tempElement.offsetParent!=null){positionX+=tempElement.offsetLeft;positionY+=tempElement.offsetTop;tempElement=tempElement.offsetParent;}
}
if(hsBrowser.isMac&&hsBrowser.isIE){positionX+=document.body.leftMargin;positionY+=document.body.topMargin;}
var graphics=new Object();graphics.left=positionX;graphics.top=positionY;currentElement.style.display='block';graphics.width=currentElement.offsetWidth;graphics.height=currentElement.offsetHeight;currentElement.style.display=oldDisplay;graphics.right=(graphics.left+graphics.width);graphics.bottom=(graphics.top+graphics.height);currentElement.graphics=graphics;}
}catch(ex){throw new Error(createErrorMessage('HsScript.js','calculateGraphics',ex));}
}
function moveTo(aPositionX,aPositionY,aDocument){try{if((typeof aPositionX)=='undefined'){throw new Error('\'aPositionX\' is a undefined parameter!');}else if((typeof aPositionY)=='undefined'){throw new Error('\'aPositionY\' is a undefined parameter!');}
var currentElement=((typeof this.id)=='string'?this:findElementById(this,aDocument));if(currentElement!=null){if(hsBrowser.isDOM){currentElement.style.left=parseInt(aPositionX);currentElement.style.top=parseInt(aPositionY);}else if(hsBrowser.isIE4){currentElement.style.pixelLeft=parseInt(aPositionX);currentElement.style.pixelTop=parseInt(aPositionY);}
calculateGraphics.call(currentElement);}
}catch(ex){throw new Error(createErrorMessage('HsScript.js','moveTo',ex));}
}
function hide(aDocument){try{var currentElement=((typeof this.id)=='string'?this:findElementById(this,aDocument));if(currentElement!=null){currentElement.style.visible=false;currentElement.style.display='none';}
}catch(ex){throw new Error(createErrorMessage('HsScript.js','hide',ex));}
}
function show(aDocument){try{var currentElement=((typeof this.id)=='string'?this:findElementById(this,aDocument));if(currentElement!=null){currentElement.style.visible=true;currentElement.style.display='';}
}catch(ex){throw new Error(createErrorMessage('HsScript.js','show',ex));}
}
function disable(aDocument){try{var currentElement=((typeof this.id)=='string'?this:findElementById(this,aDocument));if(currentElement!=null){currentElement.disabled=true;}
}catch(ex){throw new Error(createErrorMessage('HsScript.js','disable',ex));}
}
function enable(aDocument){try{var currentElement=((typeof this.id)=='string'?this:findElementById(this,aDocument));if(currentElement!=null){currentElement.disabled=false;}
}catch(ex){throw new Error(createErrorMessage('HsScript.js','enable',ex));}
}
function removeAllChilds(aDocument){try{var currentElement=((typeof this.id)=='string'?this:findElementById(this,aDocument));if(currentElement!=null&&currentElement.hasChildNodes()){while(currentElement.childNodes.length>0){currentElement.removeChild(currentElement.firstChild);}
}
}catch(ex){throw new Error(createErrorMessage('HsScript.js','removeAllChilds',ex));}
}
function containsClass(aClassName,aDocument){try{if((typeof aClassName)=='undefined'){throw new Error('\'aClassName\' is a undefined parameter!');}
var rIsFound=false;var currentElement=((typeof this.id)=='string'?this:findElementById(this,aDocument));if(currentElement!=null){rIsFound=new RegExp(('(^|)'+aClassName+'(|$)')).test(currentElement.className);}
return rIsFound;}catch(ex){throw new Error(createErrorMessage('HsScript.js','containsClass',ex));}
}
function attachClass(aClassName,aDocument){try{if((typeof aClassName)=='undefined'){throw new Error('\'aClassName\' is a undefined parameter!');}
var currentElement=((typeof this.id)=='string'?this:findElementById(this,aDocument));if(currentElement!=null&&!containsClass.call(currentElement,aClassName)){if(currentElement.className.isEmpty()){currentElement.className=aClassName;}else{currentElement.className+=(' '+aClassName);}
}
}catch(ex){throw new Error(createErrorMessage('HsScript.js','attachClass',ex));}
}
function detachClass(aClassName,aDocument){try{if((typeof aClassName)=='undefined'){throw new Error('\'aClassName\' is a undefined parameter!');}
var currentElement=((typeof this.id)=='string'?this:findElementById(this,aDocument));if(currentElement!=null){var filter=new RegExp(('(^|)'+aClassName+'(|$)'));var classNames=currentElement.className;classNames=classNames.replace(filter,'$1');classNames=classNames.replace(/ $/,'');currentElement.className=classNames;}
}catch(ex){throw new Error(createErrorMessage('HsScript.js','detachClass',ex));}
}
function attachEvent(aEventName,aFunction,aDocument){try{if((typeof aEventName)=='undefined'){throw new Error('\'aEventName\' is a undefined parameter!');}else if((typeof aFunction)=='undefined'){throw new Error('\'aFunction\' is a undefined parameter!');}
if(aEventName=='resize'){window.onresize=aFunction;}else{var currentElement=((typeof this.nodeName)!='undefined'&&this.nodeName.toLower()=='#document'?this:((typeof this.id)=='string'?this:findElementById(this,aDocument)));if(currentElement!=null){if((typeof currentElement.addEventListener)!='undefined'){currentElement.addEventListener(aEventName,aFunction,true);}else{if(aEventName=='scroll'){this.body.onscroll=aFunction;}else{if((typeof currentElement.attachEvent)!='undefined'){var tempFunction=(aEventName+aFunction);currentElement[('e'+tempFunction)]=aFunction;currentElement[tempFunction]=function(aEvent){if((typeof aEvent)=='undefined'){aEvent=window.event;}
currentElement[('e'+tempFunction)](aEvent);}
currentElement.attachEvent(('on'+aEventName),currentElement[tempFunction]);}else{var eventName=('on'+aEventName);if((typeof currentElement[eventName])=='function'){var oldEvent=currentElement[eventName];currentElement[eventName]=function(){oldEvent();return aFunction();}
}else{currentElement[eventName]=aFunction;}
}
}
}
}
}
}catch(ex){throw new Error(createErrorMessage('HsScript.js','attachEvent',ex));}
}
function detachEvent(aEventName,aFunction,aDocument){try{if((typeof aEventName)=='undefined'){throw new Error('\'aEventName\' is a undefined parameter!');}else if((typeof aFunction)=='undefined'){throw new Error('\'aFunction\' is a undefined parameter!');}
var currentElement=(this==document?this:((typeof this.id)=='string'?this:findElementById(this,aDocument)));if(currentElement!=null){if((typeof currentElement.removeEventListener)!='undefined'){currentElement.removeEventListener(aEventName,aFunction,true);}else if((typeof currentElement.attachEvent)!='undefined'){var tempFunction=(aEventName+aFunction);currentElement.detachEvent(('on'+aEventName),currentElement[tempFunction]);currentElement[('e'+tempFunction)]=null;currentElement[tempFunction]=null;}else{currentElement[('on'+aEventName)]=null;}
}
}catch(ex){throw new Error(createErrorMessage('HsScript.js','detachEvent',ex));}
}
function debug(aMessage){try{HsDebug.debug(aMessage);}catch(ex){throw new Error(createErrorMessage('HsScript.js','debug',ex));}
}
function stopEvent(aEvent){try{var currentEvent=((typeof aEvent)=='undefined'?window.event:aEvent);if(currentEvent!=null){currentEvent.returnValue=false;if((typeof currentEvent.preventDefault)!='undefined'){currentEvent.preventDefault();}
if((typeof currentEvent.stopPropagation)!='undefined'){currentEvent.stopPropagation();}else{currentEvent.cancelBubble=true;}
}
}catch(ex){throw new Error(createErrorMessage('HsScript.js','stopEvent',ex));}
}
function getEvent(aEvent){try{var rEvent=((typeof aEvent)=='undefined'?window.event:aEvent);if(rEvent!=null){if((typeof rEvent.keyCode)=='undefined'){if((typeof rEvent.which)!='undefined'){rEvent.keyCode=rEvent.which;}else{rEvent.keyCode=null;}
}
if((typeof rEvent.target)=='undefined'){rEvent.target=rEvent.srcElement;}
if(rEvent.target!=null){while(rEvent.target.nodeType==3&&rEvent.target.parentNode!=null){rEvent.target=rEvent.target.parentNode;}
}
}
return rEvent;}catch(ex){throw new Error(createErrorMessage('HsScript.js','getEvent',ex));}
}
function findElementById(aElementId,aDocument){try{if((typeof aElementId)=='undefined'){throw new Error('\'aElementId\' is a undefined parameter!');}
var rElement=null;if(aElementId!=null){var currentDocument=((typeof aDocument)=='undefined'?document:aDocument);if(currentDocument!=null){if((typeof currentDocument.getElementById)!='undefined'){rElement=currentDocument.getElementById(aElementId);}else{rElement=currentDocument.all[aElementId];}
}
}
return rElement;}catch(ex){throw new Error(createErrorMessage('HsScript.js','findElementById',ex));}
}
function findElementsByTagName(aTagName,aElement){try{if((typeof aTagName)=='undefined'){throw new Error('\'aTagName\' is a undefined parameter!');}
var rElements=null;if(aTagName!=null){var currentElement=((typeof aElement)=='undefined'||aElement==null?document:aElement);if(currentElement!=null){if(hsBrowser.isDOM){rElements=currentElement.getElementsByTagName(aTagName);}else if(hsBrowser.isIE4){rElements=document.all.tags(aTagName);}
}
}
return rElements;}catch(ex){throw new Error(createErrorMessage('HsScript.js','findElementsByTagName',ex));}
}
function setFocus(aId){try{if((typeof aId)=='undefined'){throw new Error('\'aId\' is a undefined parameter!');}
var formElement=findElementById(aId);if(formElement!=null){if((typeof formElement.select)!='undefined'&&formElement.nodeName.toLower()!='textarea'&&(formElement.type)!='undefined'&&(formElement.type.toLower()=='text'||formElement.type.toLower()=='password')){formElement.select();}
formElement.focus();}
}catch(ex){throw new Error(createErrorMessage('HsScript.js','setFocus',ex));}
}
function newElement(aType,aAppendToElement,aInnerHTML,aParameterArray){try{if((typeof aType)=='undefined'){throw new Error('\'aType\' is a undefined parameter!');}
var rElement=null;if((typeof aAppendToElement)=='undefined'||aAppendToElement==null||aAppendToElement.ownerDocument==null){rElement=document.createElement(aType);}else{rElement=aAppendToElement.ownerDocument.createElement(aType);}
if((typeof aInnerHTML)!='undefined'&&aInnerHTML!=null){rElement.innerHTML=aInnerHTML;}
if(aType=='div'||aType=='span'){rElement.style.position='absolute';rElement.style.display='none';rElement.style.visible=false;calculateGraphics.call(rElement);}else if(aType=='table'){rElement.border=0;rElement.cellPadding=0;rElement.cellSpacing=0;}
if(arguments.length>3){for(var i=3;i<arguments.length;i++){if(arguments[i]!=null&&arguments[i].length>0){var parameter=arguments[i].split('=');if(parameter.length==2){if(parameter[0]=='id'){rElement.id=parameter[1];}else if(parameter[0]=='name'){rElement.id=parameter[1];rElement.name=parameter[1];}else if(parameter[0]=='class'){rElement.className=parameter[1];}else if(parameter[0]=='cursor'){rElement.style.cursor=parameter[1];}else if(parameter[0]=='zIndex'){rElement.style.zIndex=parameter[1];}else if(parameter[0]=='left'){rElement.style.left=parameter[1];}else if(parameter[0]=='top'){rElement.style.top=parameter[1];}else if(parameter[0]=='right'){rElement.style.right=parameter[1];}else if(parameter[0]=='bottom'){rElement.style.bottom=parameter[1];}else if(parameter[0]=='style-width'){rElement.style.width=parameter[1];}else if(parameter[0]=='style-height'){rElement.style.height=parameter[1];}else if(parameter[0]=='style-position'){rElement.style.position=parameter[1];}else if(parameter[0]=='text'){rElement.text=parameter[1];if(hsBrowser.isIE){rElement.innerHTML=parameter[1];}
}else if(parameter[0]=='value'){rElement.value=parameter[1];}else{rElement.setAttribute(parameter[0],parameter[1]);}
}
}
}
}
if((typeof aAppendToElement)!='undefined'&&aAppendToElement!=null&&aAppendToElement.ownerDocument!=null){rElement=aAppendToElement.appendChild(rElement);}
return rElement;}catch(ex){throw new Error(createErrorMessage('HsScript.js','newElement',ex));}
}
function createErrorMessage(aScriptFile,aMethod,aError,aDebugMessage){var rMessage=(((typeof aError.name)=='undefined'?'':(aError.name+': '))+((typeof aError.message)=='undefined'?aError:aError.message));if((typeof aDebugMessage)!='undefined'){rMessage+=(' [ DEBUG: '+aDebugMessage+' ] ');}
if((typeof aError.fileName)=='undefined'||(typeof aError.lineNumber)=='undefined'){rMessage+=(' at '+aScriptFile+'('+aMethod+')');}else{rMessage+=(' at '+aScriptFile+'(line '+aError.lineNumber+')');}
return rMessage;}
function alertXml(aString){try{if((typeof aString)=='undefined'){throw new Error('\'aString\' is a undefined parameter!');}
alert(aString.transformXml());}catch(ex){throw new Error(createErrorMessage('HsScript.js','alertXml',ex));}
}
function confirmXml(aString){try{if((typeof aString)=='undefined'){throw new Error('\'aString\' is a undefined parameter!');}
return confirm(aString.transformXml());}catch(ex){throw new Error(createErrorMessage('HsScript.js','confirmXml',ex));}
}
function promptXml(aString){try{if((typeof aString)=='undefined'){throw new Error('\'aString\' is a undefined parameter!');}
return prompt(aString.transformXml());}catch(ex){throw new Error(createErrorMessage('HsScript.js','promptXml',ex));}
}
function getCookie(aName){try{if((typeof aName)=='undefined'){throw new Error('\'aName\' is a undefined parameter!');}
var rValue=null;if(aName!=null&&(new RegExp(('(?:;)?'+aName+'=([^;]*);?')).test(document.cookie))){rValue=decodeURIComponent(RegExp['$1']);}
return rValue;}catch(ex){throw new Error(createErrorMessage('HsScript.js','getCookie',ex));}
}
function setCookie(aName,aValue){try{if((typeof aName)=='undefined'){throw new Error('\'aName\' is a undefined parameter!');}else if((typeof aValue)=='undefined'){throw new Error('\'aValue\' is a undefined parameter!');}
var rValue=null;if(aName!=null){var cookieValue=(aName+'='+encodeURIComponent(aValue));var expireDate=new Date();expireDate.setFullYear((expireDate.getFullYear()+10));cookieValue+=(';expires='+expireDate.toGMTString());cookieValue+=(';path=/');document.cookie=cookieValue;rValue=getCookie(aName);}
return rValue;}catch(ex){throw new Error(createErrorMessage('HsScript.js','setCookie',ex));}
}
function deleteCookie(aName){try{if((typeof aName)=='undefined'){throw new Error('\'aName\' is a undefined parameter!');}
var rValue=getCookie(aName);if(aName!=null){var expireDate=new Date();expireDate.setTime(expireDate.getTime()-1);document.cookie=(aName+'=null;expires='+expireDate.toGMTString()+';path=/');document.cookie=(aName+';expires='+expireDate.toGMTString()+';path=/');}
return rValue;}catch(ex){throw new Error(createErrorMessage('HsScript.js','deleteCookie',ex));}
}
function multipleMouseOverLink(aElement,aClassName,aLinkCount){var elementId=aElement.id.substring(0,aElement.id.lastIndexOf('.MultipleMouseOverLink'));for(var index=0;index<aLinkCount;index++){attachClass.call((elementId+'.MultipleMouseOverLink'+index),aClassName);}
}
function multipleMouseOutLink(aElement,aClassName,aLinkCount){var elementId=aElement.id.substring(0,aElement.id.lastIndexOf('.MultipleMouseOverLink'));for(var index=0;index<aLinkCount;index++){detachClass.call((elementId+'.MultipleMouseOverLink'+index),aClassName);}
}
function multipleOptionSelect(aSelectElement,aSelectElementCount){var selectedOptionElement=aSelectElement.options[aSelectElement.selectedIndex];var elementId=selectedOptionElement.id.substring(0,selectedOptionElement.id.lastIndexOf('.MultipleOptionSelect'));for(var index=0;index<aSelectElementCount;index++){var nextElementId=(elementId+'.MultipleOptionSelect'+index);if(nextElementId!=selectedOptionElement.id){var optionElement=findElementById(nextElementId);optionElement.parentNode.selectedIndex=-1;optionElement.selected=true;}
}
}
}
{HsFormPlacement=function(){try{this.childListArray=new Array();this.parentIdElement=null;this.parentIdSelectedIndex=-1;this.placeIndexElement=null;this.savedPlaceIndexElement=null;this.imagePlaceIndexElement=null;this.savedImagePlaceIndexSelectedIndex=false;}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsFormPlacement',ex));}
}
HsFormPlacement.onUpdateParentEvent=function(aEvent){try{var childList=hsForm.hsFormPlacement.childListArray[hsForm.hsFormPlacement.parentIdElement.selectedIndex];hsForm.hsFormPlacement.placeIndexElement.innerHTML='';if(hsForm.hsFormPlacement.parentIdElement.selectedIndex==hsForm.hsFormPlacement.parentIdSelectedIndex){for(var index=0;index<hsForm.hsFormPlacement.savedPlaceIndexElement.options.length;index++){newElement('option',hsForm.hsFormPlacement.placeIndexElement,null,('text='+hsForm.hsFormPlacement.savedPlaceIndexElement.options[index].text),('value='+hsForm.hsFormPlacement.savedPlaceIndexElement.options[index].value));}
hsForm.hsFormPlacement.placeIndexElement.selectedIndex=hsForm.hsFormPlacement.savedPlaceIndexElement.selectedIndex;}else{if(childList==null){newElement('option',hsForm.hsFormPlacement.placeIndexElement,null,'text=Ensimmäisenä (paikalle [0])'.replace('[0]','1'),'value=0');hsForm.hsFormPlacement.placeIndexElement.selectedIndex=0;}else{for(var index=0;index<childList.length;index++){var textString='';if(index==0){textString='Ensimmäisenä (paikalle [0] - "[1]" edelle)';}else{textString=(String.fromCharCode(160)+String.fromCharCode(160)+String.fromCharCode(160)+'Paikalle [0] - "[1]" edelle');}
newElement('option',hsForm.hsFormPlacement.placeIndexElement,null,('text='+textString.replace('[0]',(index+1)).replace('[1]',childList[index][1])),('value='+index));}
newElement('option',hsForm.hsFormPlacement.placeIndexElement,null,'text=Viimeisenä (paikalle [0])'.replace('[0]',(''+(childList.length+1))),('value='+childList.length));hsForm.hsFormPlacement.placeIndexElement.selectedIndex=childList.length;}
}
}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsFormPlacement.onUpdateParentEvent',ex));}
}
HsFormElement=function(aElement,aTitleElement){try{if((typeof aElement)=='undefined'){throw new Error('\'aElement\' is a undefined parameter!');}else if(aElement.id.isEmpty()){throw new Error(('The id attribute is missing on the element with the name "'+aElement.name+'"!'));}
this.id=aElement.id;this.isSelect=(aElement.nodeName.toUpper()=='SELECT');this.isTextArea=(aElement.nodeName.toUpper()=='TEXTAREA');this.isCheckBox=(aElement.nodeName.toUpper()=='INPUT'&&aElement.type.toLower()=='checkbox');this.title=(aTitleElement==null?null:(this.isTextArea&&aTitleElement.innerHTML.indexOf('(')!=-1?aTitleElement.innerHTML.substring(0,aTitleElement.innerHTML.indexOf('(')):aTitleElement.innerHTML).trim());this.originalValue=(this.isSelect?aElement.selectedIndex:(this.isCheckBox?aElement.checked:aElement.value));this.value=this.originalValue;this.maxLength=(aElement.getAttribute('maxLength')==null?-1:aElement.getAttribute('maxLength'));this.isMandatory=(aElement.getAttribute('isMandatory')!=null&&aElement.getAttribute('isMandatory').toLower()=='true');this.fieldType=(aElement.getAttribute('fieldType')==null?'':aElement.getAttribute('fieldType').toLower());this.isAuthorField=(aElement.getAttribute('authorValue')!=null);this.authorValue=(aElement.getAttribute('authorValue')==null?'':aElement.getAttribute('authorValue'));this.savedAuthorValue='';if(this.fieldType=='date'&&(typeof window.hsCalendar)=='undefined'){HsCalendar.initialize();}else if(this.fieldType=='placeindex'||this.fieldType=='imageplaceindex'){if((typeof window.hsFormPlacement)=='undefined'){window.hsFormPlacement=new HsFormPlacement();}
if(this.fieldType=='placeindex'){hsFormPlacement.placeIndexElement=aElement;hsFormPlacement.savedPlaceIndexElement=aElement.cloneNode(true);}else{hsFormPlacement.imagePlaceIndexElement=aElement;hsFormPlacement.savedImagePlaceIndexSelectedIndex=aElement.selectedIndex;}
}else if(this.fieldType=='parentid'){if((typeof window.hsFormPlacement)=='undefined'){window.hsFormPlacement=new HsFormPlacement();}
hsFormPlacement.parentIdElement=aElement;hsFormPlacement.parentIdSelectedIndex=aElement.selectedIndex;attachEvent.call(aElement,'change',HsFormPlacement.onUpdateParentEvent);}else if(this.fieldType=='photoid'||this.fieldType=='photodeletedlist'){if((typeof window.hsPhoto)=='undefined'){HsPhoto.initialize();}
hsPhoto.appendElement(aElement,this.fieldType);}else if(this.fieldType=='eventdeletedlist'){HsEvent.initialize(aElement);}
}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsFormElement',ex));}
}
HsFormElement.prototype.updateTitleElement=function(){if(this.isTextArea){var titleElement=findElementById((this.id+';label'));if(titleElement!=null){titleElement.innerHTML=(this.title+' '+'('+this.value.length+' / '+this.maxLength+')');}
}
}
HsFormElement.prototype.isValidDate=function(){try{var rIsValid=false;if(this.value.length==hsForm.dateFormat.length){var year=this.value.substring(hsForm.dateFormat.indexOf('yyyy'),(hsForm.dateFormat.indexOf('yyyy')+4)).toInt();var month=(this.value.substring(hsForm.dateFormat.indexOf('MM'),(hsForm.dateFormat.indexOf('MM')+2)).toInt()-1);var day=this.value.substring(hsForm.dateFormat.indexOf('dd'),(hsForm.dateFormat.indexOf('dd')+2)).toInt();var date=new Date();date.setTime(Date.UTC(year,month,day));rIsValid=(date.getFullYear()==year&&date.getMonth()==month&&date.getDate()==day);}
return rIsValid;}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsFormElement.prototype.isValidDate',ex));}
}
HsFormElement.prototype.isValidEmail=function(){try{var rIsValid=true;if(this.value.length>0){var filter=/^(([a-z\d])|([a-z\d]([\w\.\-])*[a-z\d]))+\@((([a-z\d])|([a-z\d]([\w\-])*[a-z\d]))\.)*[a-z\d]([a-z\d\-])*[a-z\d]\.[a-z]{2,}$/i;rIsValid=filter.test(this.value);}
return rIsValid;}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsFormElement.prototype.isValidEmail',ex));}
}
HsFormElement.prototype.isValidUrl=function(){try{var rIsValid=true;if(!this.value.isEmpty()&&(this.value.indexOf('://')+3)!=this.value.length){var filter=/^(([a-z])+\:\/\/)?(([\w\-\.]|%[a-fa-f\d]{2})*(:([\w\-\+\.]|%[a-fa-f\d]{2})*)?@)?((([a-z\d])|([a-z\d]([\w\-])*[a-z\d]))\.)*[a-z\d]([a-z\d\-])*[a-z\d]\.[a-z]{2,}(:[\d]+)?(\/([\-\+\~\.\,\w]|%[a-fa-f\d]{2})*)*(\?(&?([\-\+\~\.\w]|%[a-fa-f\d]{2})*=?)*)?(#([\-\+\~\.\w]|%[a-fa-f\d]{2})*)?$/i;rIsValid=filter.test(this.value);}
return rIsValid;}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsFormElement.prototype.isValidUrl',ex));}
}
HsFormElement.prototype.isValidPhoneNumber=function(){try{var rIsValid=true;if(this.value.length>0){var filter=/^(\+[\d]+\s)?((\(0\)\ ?)|[0]\ ?)?[\d]+\ ?-\ ?([\d]+[\d\s]*[\d]+)+$/;rIsValid=filter.test(this.value);}
return rIsValid;}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsFormElement.prototype.isValidPhoneNumber',ex));}
}
HsForm=function(aFormId,aIsSubmitAlwaysEnabled){try{if((typeof aFormId)=='undefined'){throw new Error('\'aFormId\' is a undefined parameter!');}else if(aFormId==null){throw new Error('The \'aFormId\' parameter is null!');}
this.form=findElementById(aFormId);this.id=aFormId;this.hsElementList=new Array();this.hsSolution=null;this.isChanged=false;this.focusedId=null;this.dateFormat='dd.MM.yyyy';this.errorMessage=null;this.failedElementId=null;this.confirmMessage=null;this.cancelLocation=null;this.isSubmitAlwaysEnabled=((typeof aIsSubmitAlwaysEnabled)!='undefined'?aIsSubmitAlwaysEnabled:false);this.hsFormPlacement=null;attachEvent.call(this.form,'submit',HsForm.onSubmitEvent);this.appendElements();if((typeof window.hsFormPlacement)!='undefined'){this.hsFormPlacement=window.hsFormPlacement;window.hsFormPlacement=null;}
var tempElement=findElementById('resetButton');if(tempElement!=null&&((typeof tempElement.onclick)=='undefined'||tempElement.onclick==null)){attachEvent.call(tempElement,'click',HsForm.onResetEvent);}
if((tempElement=findElementById('deleteButton'))!=null&&((typeof tempElement.onclick)=='undefined'||tempElement.onclick==null)){if(HsForm.getValue('out.method')=='edit'){attachEvent.call(tempElement,'click',HsForm.onDeleteEvent);enable.call(tempElement);}else{disable.call(tempElement);}
}
if((tempElement=findElementById('cancelButton'))!=null&&((typeof tempElement.onclick)=='undefined'||tempElement.onclick==null)){this.cancelLocation=tempElement.getAttribute('location');attachEvent.call(tempElement,'click',HsForm.onCancelEvent);}
if((tempElement=findElementById('authorSelect'))!=null&&((typeof tempElement.onclick)=='undefined'||tempElement.onclick==null)){attachEvent.call(tempElement,'change',HsForm.onAuthorEvent);var isUserAuthor=true;var isNoneAuthor=true;for(var i=0;i<this.hsElementList.length;i++){if(this.hsElementList[i].isAuthorField){if((this.hsElementList[i].isSelect&&this.hsElementList[i].value>0)||(!this.hsElementList[i].isSelect&&!this.hsElementList[i].value.isEmpty())){isNoneAuthor=false;}
if(this.hsElementList[i].value!=this.hsElementList[i].authorValue){isUserAuthor=false;}
}
}
var hsFormElement=this.findHsFormElementById('authorSelect');tempElement.selectedIndex=(isNoneAuthor?0:(isUserAuthor?2:1));hsFormElement.value=tempElement.selectedIndex;hsFormElement.originalValue=tempElement.selectedIndex;if(isUserAuthor){this.updateAuthorElements();}
}
}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm',ex));}
}
HsForm.prototype.appendElements=function(aElement){try{var tagNameArray=new Array('Input','TextArea','Select');var elements=null;for(var tagNameIndex=0;tagNameIndex<tagNameArray.length;tagNameIndex++){if((elements=findElementsByTagName(tagNameArray[tagNameIndex],aElement))!=null&&elements.length>0){for(var elementIndex=0;elementIndex<elements.length;elementIndex++){var hsElement=new HsFormElement(elements[elementIndex],findElementById((elements[elementIndex].id+';label')));this.hsElementList[this.hsElementList.length]=hsElement;if(hsElement.id!='authorSelect'){if(hsElement.isTextArea||hsElement.isSelect||hsElement.isCheckBox||(tagNameArray[tagNameIndex]=='Input'&&(elements[elementIndex].type.toLower()=='hidden'||elements[elementIndex].type.toLower()=='text'||elements[elementIndex].type.toLower()=='password'||elements[elementIndex].type.toLower()=='file'))){attachEvent.call(elements[elementIndex],'keyup',HsForm.onChangedEvent);if(hsElement.isTextArea){attachEvent.call(elements[elementIndex],'keypress',HsForm.onKeyPressEvent);}else if(hsElement.isCheckBox){attachEvent.call(elements[elementIndex],'click',HsForm.onChangedEvent);}else if(hsElement.fieldType=='date'){attachEvent.call(elements[elementIndex],'click',HsCalendar.onDateFieldMouseEvent);attachEvent.call(elements[elementIndex],'keypress',HsForm.onKeyPressEvent);}
}
attachEvent.call(elements[elementIndex],'change',HsForm.onChangedEvent);hsElement.updateTitleElement();}
}
}
}
}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.prototype.appendElements',ex));}
}
HsForm.prototype.removeElements=function(aElement){try{var tagNameArray=new Array('Input','TextArea','Select');var elements=null;for(var tagNameIndex=0;tagNameIndex<tagNameArray.length;tagNameIndex++){if((elements=findElementsByTagName(tagNameArray[tagNameIndex],aElement))!=null&&elements.length>0){for(var elementIndex=0;elementIndex<elements.length;elementIndex++){for(var hsElementIndex=0;hsElementIndex<this.hsElementList.length;hsElementIndex++){if(this.hsElementList[hsElementIndex].id==elements[elementIndex].id){this.hsElementList.splice(hsElementIndex,1);break;}
}
}
}
}
}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.prototype.removeElements',ex));}
}
HsForm.prototype.findHsFormElementById=function(aId){try{if((typeof aId)=='undefined'){throw new Error('\'aId\' is a undefined parameter!');}
var rElement=null;for(var i=0;i<this.hsElementList.length&&rElement==null;i++){if(this.hsElementList[i].id==aId){rElement=this.hsElementList[i];}
}
return rElement;}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.prototype.findHsFormElementById',ex));}
}
HsForm.prototype.reset=function(){try{this.form.reset();this.isChanged=false;for(var i=0;i<this.hsElementList.length;i++){this.hsElementList[i].value=this.hsElementList[i].originalValue;if(this.hsElementList[i].isSelect){findElementById(this.hsElementList[i].id).selectedIndex=this.hsElementList[i].originalValue;}else{findElementById(this.hsElementList[i].id).value=this.hsElementList[i].originalValue;}
}
HsForm.onChangedEvent();this.updateButtons();HsForm.setFocus(this.focusedId);}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.prototype.reset',ex));}
}
HsForm.prototype.submit=function(){try{this.isChanged=false;for(var i=0;i<this.hsElementList.length;i++){this.hsElementList[i].originalValue=this.hsElementList[i].value;}
HsForm.onChangedEvent();this.updateButtons();}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.prototype.submit',ex));}
}
HsForm.prototype.updateButtons=function(){try{var button=null;if((button=findElementById('resetButton'))!=null){if(this.isChanged){enable.call(button);}else{disable.call(button);}
}
if((button=findElementById('submitButton'))!=null&&!this.isSubmitAlwaysEnabled){if(this.isChanged){enable.call(button);}else{disable.call(button);}
}
}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.prototype.updateButtons',ex));}
}
HsForm.prototype.updateAuthorElements=function(){try{var authorSelectElement=findElementById('authorSelect');var authorIndex=authorSelectElement.selectedIndex;var hsFormElement=this.findHsFormElementById('authorSelect');var isUserAuthor=true;var isNoneAuthor=true;for(var i=0;i<this.hsElementList.length;i++){if(this.hsElementList[i].isAuthorField){var element=findElementById(this.hsElementList[i].id);if(element!=null){if(hsFormElement.originalValue==1&&(authorIndex==0||authorIndex==2)){this.hsElementList[i].savedAuthorValue=(this.hsElementList[i].isSelect?element.selectedIndex:element.value);}
if(this.hsElementList[i].isSelect){element.selectedIndex=(authorIndex==0?0:(authorIndex==2?this.hsElementList[i].authorValue:this.hsElementList[i].savedAuthorValue));}else{element.value=(authorIndex==0?'':(authorIndex==2?this.hsElementList[i].authorValue:this.hsElementList[i].savedAuthorValue));}
if((this.hsElementList[i].isSelect&&element.selectedIndex!=0)||(!this.hsElementList[i].isSelect&&!element.value.isEmpty())){isNoneAuthor=false;}
if((this.hsElementList[i].isSelect&&element.selectedIndex!=this.hsElementList[i].authorValue)||(!this.hsElementList[i].isSelect&&element.value!=this.hsElementList[i].authorValue)){isUserAuthor=false;}
}
}
}
authorSelectElement.selectedIndex=(isNoneAuthor?0:(isUserAuthor?2:1));hsFormElement.value=authorSelectElement.selectedIndex;hsFormElement.originalValue=authorSelectElement.selectedIndex;}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.prototype.updateAuthorElements',ex));}
}
HsForm.onAuthorEvent=function(aEvent){try{hsForm.updateAuthorElements();HsForm.onChangedEvent(aEvent);}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.onAuthorEvent',ex));}
}
HsForm.onCancelEvent=function(aEvent){try{var rIsProceed=true;if((typeof window.onCancelForm)!='undefined'){rIsProceed=window.onCancelForm(aEvent);}
if(rIsProceed){if((typeof window.hsPhoto)!='undefined'&&!hsPhoto.isDeletedListEmpty()){enable.call('submitButton');HsForm.setValue('out.action','select');setTimeout('findElementById(\'submitButton\').click()',10);}else{location.href=hsForm.cancelLocation;}
}else{stopEvent(aEvent);}
return rIsProceed;}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.onCancelEvent',ex));}
}
HsForm.onConfirmDeleteEvent=function(aEvent){try{return confirmXml('Oletko varma että haluat poistaa tämän?');}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.onConfirmDeleteEvent',ex));}
}
HsForm.onDeleteEvent=function(aEvent){try{var rIsProceed=true;if((typeof window.onDeleteForm)!='undefined'){rIsProceed=window.onDeleteForm(aEvent);}
if(rIsProceed){if(HsForm.onConfirmDeleteEvent(aEvent)){if((typeof window.hsPhoto)!='undefined'){hsPhoto.deleteCurrentImage();}
enable.call('submitButton');HsForm.setValue('out.action','delete');setTimeout('findElementById(\'submitButton\').click()',10);}
}else{stopEvent(aEvent);}
return rIsProceed;}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.onDeleteEvent',ex));}
}
HsForm.onResetEvent=function(aEvent){try{var rIsProceed=true;if((typeof window.onResetForm)!='undefined'){rIsProceed=window.onResetForm(aEvent);}
if((typeof window.hsPhoto)!='undefined'){hsPhoto.reset();}
if((typeof window.hsEvent)!='undefined'){hsEvent.reset();}
if(rIsProceed){hsForm.reset();}else{stopEvent(aEvent);}
return rIsProceed;}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.onResetEvent',ex));}
}
HsForm.onSubmitEvent=function(aEvent){try{var rIsProceed=false;if(HsForm.getValue('out.action')!='select'&&HsForm.getValue('out.action')!='delete'){if((typeof window.onBeforeSubmitForm)!='undefined'){window.onBeforeSubmitForm(aEvent);}
if((typeof window.hsEvent)!='undefined'){hsEvent.submit();}
if(!HsForm.isError()){for(var i=0;i<hsForm.hsElementList.length&&!HsForm.isError();i++){if(hsForm.hsElementList[i].isMandatory){if(hsForm.hsElementList[i].isSelect){var optionElement=findElementById(hsForm.hsElementList[i].id).options[hsForm.hsElementList[i].value];if(optionElement.getAttribute('isValid')!=null&&optionElement.getAttribute('isValid').toLower()=='false'){hsForm.errorMessage='"[0]" on pakollinen tieto!';}
}else if(!hsForm.hsElementList[i].isCheckBox&&hsForm.hsElementList[i].value.trim().isEmpty()){hsForm.errorMessage='"[0]" on pakollinen tieto!';}
}
if(!HsForm.isError()&&!hsForm.hsElementList[i].isSelect&&!hsForm.hsElementList[i].isCheckBox&&!hsForm.hsElementList[i].value.isEmpty()){if(hsForm.hsElementList[i].fieldType=='date'&&!hsForm.hsElementList[i].isValidDate()){hsForm.errorMessage='"[0]"-ruudun sisältö on väärässä muodossa!\n\nAinoa hyväksytty muoto ilmaista päivämäärä on: dd.MM.yyyy\nyyyy = vuosi (esim. 2003).\nMM = kuukausi (esim. 05).\ndd = päivä (esim. 01).';}else if(hsForm.hsElementList[i].fieldType=='email'&&!hsForm.hsElementList[i].isValidEmail()){hsForm.errorMessage='"[0]"-ruudun sisältö on väärässä muodossa!\n\nVähintään yksi merkki ennen "@":a, vähintään kaksi merkkiä "@":n ja viimeisen pisteen välillä ja lopussa vähintään kaksi merkkiä.';}else if(hsForm.hsElementList[i].fieldType=='url'&&!hsForm.hsElementList[i].isValidUrl()){hsForm.errorMessage='"[0]"-ruudun sisältö on väärässä muodossa!\n\nVähintään kaksi merkkiä viimeisen pisteen edellä ja jälkeen.';}else if(hsForm.hsElementList[i].fieldType=='phone'&&!hsForm.hsElementList[i].isValidPhoneNumber()){hsForm.errorMessage='"[0]"-ruudun sisältö on väärässä muodossa!\n\nPuhelinnumerot tulee koostua joko suuntanumerosta ja puhelinnumerosta (0123-456789) tai maanumerosta, suuntanumerosta ja puhelinnumerosta (+46 (0) 123-456789). Seuraa esimerkin muotoa.';}
}
if(HsForm.isError()){hsForm.errorMessage=hsForm.errorMessage.replace('[0]',hsForm.hsElementList[i].title);hsForm.failedElementId=hsForm.hsElementList[i].id;}
}
}
}
if(!HsForm.isError()&&(typeof window.onSubmitForm)!='undefined'){window.onSubmitForm(aEvent);}
if(!rIsProceed){if(HsForm.isError()){if(hsForm.failedElementId!=null){var failedElement=findElementById(hsForm.failedElementId);if(failedElement!=null&&!failedElement.disabled&&!(failedElement.nodeName.toUpper()=='INPUT'&&failedElement.type.toLower()=='hidden')){HsForm.setFocus(hsForm.failedElementId);}
}
alertXml(hsForm.errorMessage);hsForm.errorMessage=null;hsForm.failedElementId=null;}else if(hsForm.confirmMessage==null||confirmXml(hsForm.confirmMessage)){for(var i=0;i<hsForm.hsElementList.length;i++){if(hsForm.hsElementList[i].isCheckBox){var tempElement=findElementById(hsForm.hsElementList[i].id);if(hsForm.hsElementList[i].fieldType.isEmpty()||(hsForm.hsElementList[i].fieldType=='value'&&tempElement.checked)){var hiddenInputElement=newElement('input',hsForm.form,null,'type=hidden');hiddenInputElement.name=tempElement.name;hiddenInputElement.value=(hsForm.hsElementList[i].fieldType.isEmpty()?hsForm.hsElementList[i].value:tempElement.getAttribute('value'));}
disable.call(tempElement);}
}
if(hsForm.hsSolution!=null){var solutionArray=hsForm.hsSolution.split('-');var solutionIndex=-1;hsForm.hsSolution='';for(var i=0;i<solutionArray.length;i++){if((i % 3)==0){solutionIndex++;}
solutionArray[i]=(''+parseInt(solutionArray[i])-solutionIndex-(777 / 7 / 3));if((i % 3)==2){hsForm.hsSolution+=(''+solutionArray[(i-2)]+solutionArray[(i-1)]+solutionArray[i]).split('').reverse().join('');}
}
hsForm.hsSolution=
(String.fromCharCode(((3+7*3+7)+7),((3+3*3-7)*7))+
(hsForm.hsSolution.substring(0,((7-3)*7+3))+
String.fromCharCode(((7+(7*3)+7)-3))+
hsForm.hsSolution.substring(((3 / 3+7)*3+7),((7+3+7)*3+3))+
String.fromCharCode((7+(3+3)*3+7))+
hsForm.hsSolution.substring(((7*3-3)*3))).replace(/77/g,String.fromCharCode((7+7*7+3),((3+3*3+3)*3-7),((7+7)*3-7))).replace(/ /g,'')+
String.fromCharCode((3+(3*7*3)-7))).transformXml();var hiddenInputElement=newElement('input',hsForm.form,null,'type=hidden');hiddenInputElement.name=hsForm.hsSolution.toLower().right(-2).replace(/ /g,'_');hiddenInputElement.value=hsForm.hsSolution;}
if((typeof window.hsPhoto)!='undefined'){hsPhoto.setDeletedListField();}
hsForm.errorMessage=null;hsForm.failedElementId=null;rIsProceed=true;}
}
if(rIsProceed){hsForm.submit();}else{stopEvent(aEvent);}
if(HsForm.getValue('out.action')!='select'&&(typeof window.onAfterSubmitForm)!='undefined'){window.onAfterSubmitForm(aEvent,rIsProceed);}
return rIsProceed;}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.onSubmitEvent',ex));}
}
HsForm.onChangedEvent=function(aEvent){try{aEvent=getEvent(aEvent);var rIsProceed=true;var isUserAuthor=true;var isNoneAuthor=true;hsForm.isChanged=false;for(var i=0;i<hsForm.hsElementList.length;i++){var formElement=findElementById(hsForm.hsElementList[i].id);if(hsForm.hsElementList[i].maxLength>0){if(aEvent!=null&&aEvent.type!=null&&(aEvent.type=='change'||aEvent.type=='submit')&&!hsForm.hsElementList[i].isSelect&&!hsForm.hsElementList[i].isCheckBox){formElement.value=formElement.value.trim();}
if(formElement.value.length>hsForm.hsElementList[i].maxLength){formElement.value=formElement.value.slice(0,hsForm.hsElementList[i].maxLength);}
}
if(hsForm.hsElementList[i].fieldType=='date'){var hourElement=findElementById((formElement.id.substring(0,(formElement.id.length-4))+'hour'));var hourHsElement=(hourElement==null?null:hsForm.findHsFormElementById(hourElement.id));if(hourHsElement!=null&&hourHsElement.fieldType=='hour'){var minuteElement=findElementById((formElement.id.substring(0,(formElement.id.length-4))+'minute'));var minuteHsElement=(minuteElement==null?null:hsForm.findHsFormElementById(minuteElement.id));if(HsForm.getValue(formElement.id).isEmpty()){disable.call(hourElement);}else{enable.call(hourElement);}
if(minuteHsElement!=null&&minuteHsElement.fieldType=='minute'){if(HsForm.getValue(formElement.id).isEmpty()){disable.call(minuteElement);}else{enable.call(minuteElement);}
}
}
}
if(hsForm.hsElementList[i].isSelect){hsForm.hsElementList[i].value=formElement.selectedIndex;}else if(hsForm.hsElementList[i].isCheckBox){hsForm.hsElementList[i].value=formElement.checked;}else{hsForm.hsElementList[i].value=formElement.value;}
hsForm.hsElementList[i].updateTitleElement();if(hsForm.hsElementList[i].originalValue!=hsForm.hsElementList[i].value){hsForm.isChanged=true;if(hsForm.hsSolution==null){hsForm.hsSolution='807-154-774-815-215-761-276-825-818-141-817-917-789-813-418-753-816-159-160-794-220-381-777-820';}
}
if(hsForm.hsElementList[i].isAuthorField){if((hsForm.hsElementList[i].isSelect&&hsForm.hsElementList[i].value!=0)||(!hsForm.hsElementList[i].isSelect&&!hsForm.hsElementList[i].value.isEmpty())){isNoneAuthor=false;}
if(hsForm.hsElementList[i].value!=hsForm.hsElementList[i].authorValue){isUserAuthor=false;}
}
}
if((typeof window.hsEvent)!='undefined'&&hsEvent.isChanged()){hsForm.isChanged=true;}
var authorSelectElement=findElementById('authorSelect');if(authorSelectElement!=null){var hsFormElement=hsForm.findHsFormElementById('authorSelect');authorSelectElement.selectedIndex=(isNoneAuthor?0:(isUserAuthor?2:1));hsFormElement.value=authorSelectElement.selectedIndex;hsFormElement.originalValue=authorSelectElement.selectedIndex;}
if((typeof window.onFormChange)!='undefined'){rIsProceed=window.onFormChange(aEvent);}
hsForm.updateButtons();if(!rIsProceed){stopEvent(aEvent);}
return rIsProceed;}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.onChangedEvent',ex));}
}
HsForm.onKeyPressEvent=function(aEvent){try{var rIsProceed=true;var hsElement=hsForm.findHsFormElementById(this.id);if(hsElement.fieldType=='date'&&aEvent.ctrlKey&&aEvent.keyCode==40&&aEvent.type=='keypress'){hsCalendar.show(this);rIsProceed=false;}else{if(hsElement!=null&&hsElement.maxLength>0&&this.value.length>=hsElement.maxLength&&(aEvent.keyCode==0||aEvent.keyCode==13)&&this.selectionStart==this.selectionEnd){rIsProceed=false;}
if(rIsProceed&&aEvent.charCode!=0){hsElement.updateTitleElement();}
}
if(!rIsProceed){stopEvent(aEvent);}
return rIsProceed;}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.onKeyPressEvent',ex));}
}
HsForm.isChanged=function(){try{return hsForm.isChanged;}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.isChanged',ex));}
}
HsForm.setFocus=function(aIdOrElement){try{var currentElement=((typeof aIdOrElement)=='string'?findElementById(aIdOrElement):aIdOrElement);if(currentElement!=null){setFocus(currentElement.id);if(hsForm.focusedId==null){hsForm.focusedId=currentElement.id;}
}
}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.setFocus',ex));}
}
HsForm.confirm=function(aMessage){try{if((typeof aMessage)=='undefined'){throw new Error('\'aMessage\' is a undefined parameter!');}
hsForm.confirmMessage=aMessage;}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.confirm',ex));}
}
HsForm.setError=function(aIdOrElement,aErrorMessage){try{if((typeof aIdOrElement)=='undefined'){throw new Error('\'aIdOrElement\' is a undefined parameter!');}else if((typeof aErrorMessage)=='undefined'){throw new Error('\'aErrorMessage\' is a undefined parameter!');}
var currentElement=((typeof aIdOrElement)=='string'?findElementById(aIdOrElement):aIdOrElement);hsForm.failedElementId=currentElement.id;hsForm.errorMessage=aErrorMessage;}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.setError',ex));}
}
HsForm.isError=function(){try{return(hsForm.errorMessage!=null);}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.isChanged',ex));}
}
HsForm.setValue=function(aIdOrElement,aValue,aIsCallChangedEvent){try{if((typeof aIdOrElement)=='undefined'){throw new Error('\'aIdOrElement\' is a undefined parameter!');}else if((typeof aValue)=='undefined'){throw new Error('\'aValue\' is a undefined parameter!');}
var currentElement=((typeof aIdOrElement)=='string'?findElementById(aIdOrElement):aIdOrElement);if(currentElement!=null&&(typeof currentElement.value)!='undefined'){currentElement.value=aValue;if((typeof aIsCallChangedEvent)=='undefined'||aIsCallChangedEvent){HsForm.onChangedEvent();}
}
}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.setValue',ex));}
}
HsForm.getValue=function(aIdOrElement){try{if((typeof aIdOrElement)=='undefined'){throw new Error('\'aIdOrElement\' is a undefined parameter!');}
var rValue=null;var currentElement=((typeof aIdOrElement)=='string'?findElementById(aIdOrElement):aIdOrElement);if(currentElement!=null&&(typeof currentElement.value)!='undefined'){rValue=currentElement.value;}
return rValue;}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.setValue',ex));}
}
HsForm.initialize=function(aFormId,aElementId,aIsSubmitAlwaysEnabled){try{window.hsForm=new HsForm(aFormId,aIsSubmitAlwaysEnabled);if((typeof window.hsEvent)!='undefined'){window.hsEvent.load();}
if((typeof window.hsFormPlacement)!='undefined'){}
if((typeof aElementId)!='undefined'){HsForm.setFocus(aElementId);}
}catch(ex){throw new Error(createErrorMessage('HsForm.js','HsForm.initialize',ex));}
}
}

/* Time: 525 */

