/* CMS */
var CMS={
	defaultlangid:'it',

	uniqueid:0,http_request:new Array(),http_request_mutex:false,curchildtree:1,

	/* Menu */
	neosideamenu:{
		enableshim: false,
		arrowpointers:{
			downarrow: ['PUBLIC/IMAGES/cms/arrow-down.png', 11,7],
			rightarrow: ['PUBLIC/IMAGES/cms/arrow-right.png', 12,12],
			showarrow: {toplevel: true, sublevel: true}
		},
		hideinterval: 200,
		effects: {enableswipe: true, enablefade: true, duration: 200},

		topmenuids: [],topitems: {},subuls: {},lastactivesubul: {},topitemsindex: -1,ulindex: -1,hidetimers: {},
		httpsiframesrc: "blank.htm",
		shimadded: false,nonFF: !/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent),

		getoffset:function(what, offsettype){return ((what.offsetParent)? what[offsettype]+this.getoffset(what.offsetParent, offsettype) : what[offsettype]);},
		getoffsetof:function(el){el._offsets={left:this.getoffset(el, 'offsetLeft'), top:this.getoffset(el, 'offsetTop')}},
		addshimmy:function(target){var shim=((!window.opera)? document.createElement('iframe') : document.createElement('div'));shim.className='ddiframeshim';shim.setAttribute('src', location.protocol=='https:'? this.httpsiframesrc : 'about:blank');shim.setAttribute('frameborder', '0');target.appendChild(shim);try{shim.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';}catch(e){};return shim;},
		positionshim:function(header, submenu, dir, scrollX, scrollY){if (header._istoplevel){var scrollY=(window.pageYOffset? window.pageYOffset : this.standardbody.scrollTop);var topgap=header._offsets.top-scrollY;var bottomgap=scrollY+this.docheight-header._offsets.top-header._dimensions.h;if (topgap>0){this.shimmy.topshim.style.left=scrollX+'px';this.shimmy.topshim.style.top=scrollY+'px';this.shimmy.topshim.style.width='99%';this.shimmy.topshim.style.height=topgap+'px' ;}if (bottomgap>0){this.shimmy.bottomshim.style.left=scrollX+'px';this.shimmy.bottomshim.style.top=header._offsets.top + header._dimensions.h +'px';this.shimmy.bottomshim.style.width='99%';this.shimmy.bottomshim.style.height=bottomgap+'px';}}},
		hideshim:function(){this.shimmy.topshim.style.width=this.shimmy.bottomshim.style.width=0;this.shimmy.topshim.style.height=this.shimmy.bottomshim.style.height=0;},
		getwindowsize:function(){this.docwidth=(window.innerWidth? window.innerWidth-10 : this.standardbody.clientWidth-10);this.docheight=(window.innerHeight? window.innerHeight-15 : this.standardbody.clientHeight-18);},
		gettopitemsdimensions:function(){for (var m=0; m<this.topmenuids.length; m++){var topmenuid=this.topmenuids[m];for (var i=0; i<this.topitems[topmenuid].length; i++){var header=this.topitems[topmenuid][i];var submenu=document.getElementById(header.getAttribute('rel'));header._dimensions={w:header.offsetWidth, h:header.offsetHeight, submenuw:submenu.offsetWidth, submenuh:submenu.offsetHeight};}}},
		isContained:function(m, e){var e=(window.event || e);var c=(e.relatedTarget || ((e.type=='mouseover')? e.fromElement : e.toElement));while (c && c!=m)try {c=c.parentNode;} catch(e){c=m;}if (c==m)return true;else return false;},
		addpointer:function(target, imgclass, imginfo, BeforeorAfter){var pointer=document.createElement('img');pointer.src=imginfo[0];pointer.style.width=imginfo[1]+'px';pointer.style.height=imginfo[2]+'px';if(imgclass=='cmsrightarrow')pointer.style.left=target.offsetWidth-imginfo[2]-2+'px';pointer.className=imgclass;var target_firstEl=target.childNodes[target.firstChild.nodeType!=1? 1 : 0];if (target_firstEl && target_firstEl.tagName=='SPAN')target=target_firstEl;if (BeforeorAfter=='before')target.insertBefore(pointer, target.firstChild);else target.appendChild(pointer);},
		css:function(el, targetclass, action){var needle=new RegExp('(^|\\s+)'+targetclass+'($|\\s+)', 'ig');if (action=='check')return needle.test(el.className);else if (action=='remove')el.className=el.className.replace(needle, '');else if (action=='add' && !needle.test(el.className))el.className+=' '+targetclass;},
		buildmenu:function(mainmenuid, header, submenu, submenupos, istoplevel, dir){header._master=mainmenuid;header._pos=submenupos;header._istoplevel=istoplevel;if (istoplevel){this.addEvent(header, function(e){CMS.neosideamenu.hidemenu(CMS.neosideamenu.subuls[this._master][parseInt(this._pos)]);}, 'click');}this.subuls[mainmenuid][submenupos]=submenu;header._dimensions={w:header.offsetWidth, h:header.offsetHeight, submenuw:submenu.offsetWidth, submenuh:submenu.offsetHeight};this.getoffsetof(header);submenu.style.left=0;submenu.style.top=0;submenu.style.visibility='hidden';this.addEvent(header, function(e){if (!CMS.neosideamenu.isContained(this, e)){var submenu=CMS.neosideamenu.subuls[this._master][parseInt(this._pos)];if (this._istoplevel){CMS.neosideamenu.css(this, 'selected', 'add');clearTimeout(CMS.neosideamenu.hidetimers[this._master][this._pos]);}CMS.neosideamenu.getoffsetof(header);var scrollX=window.pageXOffset? window.pageXOffset : CMS.neosideamenu.standardbody.scrollLeft;var scrollY=window.pageYOffset? window.pageYOffset : CMS.neosideamenu.standardbody.scrollTop;var submenurightedge=this._offsets.left + this._dimensions.submenuw + (this._istoplevel && dir=='topbar'? 0 : this._dimensions.w);var submenubottomedge=this._offsets.top + this._dimensions.submenuh;var menuleft=(this._istoplevel? this._offsets.left + (dir=='sidebar'? this._dimensions.w : 0) : this._dimensions.w);if (submenurightedge-scrollX>CMS.neosideamenu.docwidth){menuleft+= -this._dimensions.submenuw + (this._istoplevel && dir=='topbar' ? this._dimensions.w : -this._dimensions.w);}submenu.style.left=menuleft+'px';var menutop=(this._istoplevel? this._offsets.top + (dir=='sidebar'? 0 : this._dimensions.h) : this.offsetTop);if (submenubottomedge-scrollY>CMS.neosideamenu.docheight){if (this._dimensions.submenuh<this._offsets.top+(dir=='sidebar'? this._dimensions.h : 0)-scrollY){menutop+= - this._dimensions.submenuh + (this._istoplevel && dir=='topbar'? -this._dimensions.h : this._dimensions.h);}else{menutop+= -(this._offsets.top-scrollY) + (this._istoplevel && dir=='topbar'? -this._dimensions.h : 0);}}submenu.style.top=menutop+'px';if (CMS.neosideamenu.enableshim && (CMS.neosideamenu.effects.enableswipe==false || CMS.neosideamenu.nonFF)){CMS.neosideamenu.positionshim(header, submenu, dir, scrollX, scrollY);}else{submenu.FFscrollInfo={x:scrollX, y:scrollY};}CMS.neosideamenu.showmenu(header, submenu, dir);}}, 'mouseover');this.addEvent(header, function(e){var submenu=CMS.neosideamenu.subuls[this._master][parseInt(this._pos)];if (this._istoplevel){if (!CMS.neosideamenu.isContained(this, e) && !CMS.neosideamenu.isContained(submenu, e))CMS.neosideamenu.hidemenu(submenu);}else if (!this._istoplevel && !CMS.neosideamenu.isContained(this, e)){CMS.neosideamenu.hidemenu(submenu);}}, 'mouseout');},
		setopacity:function(el, value){el.style.opacity=value;if (typeof el.style.opacity!='string'){el.style.MozOpacity=value;if (el.filters){el.style.filter='progid:DXImageTransform.Microsoft.alpha(opacity='+ value*100 +')';}}},
		showmenu:function(header, submenu, dir){if (this.effects.enableswipe || this.effects.enablefade){if (this.effects.enableswipe){var endpoint=((header._istoplevel && dir=='topbar')? header._dimensions.submenuh : header._dimensions.submenuw);submenu.style.width=submenu.style.height=0;submenu.style.overflow='hidden';}if (this.effects.enablefade){this.setopacity(submenu, 0);}submenu._curanimatedegree=0;submenu.style.visibility='visible';clearInterval(submenu._animatetimer);submenu._starttime=new Date().getTime();submenu._animatetimer=setInterval(function(){CMS.neosideamenu.revealmenu(header, submenu, endpoint, dir);}, 10);}else{submenu.style.visibility='visible';}},
		revealmenu:function(header, submenu, endpoint, dir){var elapsed=new Date().getTime()-submenu._starttime;if (elapsed<this.effects.duration){if (this.effects.enableswipe){if (submenu._curanimatedegree==0){submenu.style[header._istoplevel && dir=='topbar'? 'width' : 'height']='auto';}submenu.style[header._istoplevel && dir=='topbar'? 'height' : 'width']=(submenu._curanimatedegree*endpoint)+'px';}if (this.effects.enablefade){this.setopacity(submenu, submenu._curanimatedegree);}}else{clearInterval(submenu._animatetimer);if (this.effects.enableswipe){submenu.style.width='auto';submenu.style.height='auto';submenu.style.overflow='visible';}if (this.effects.enablefade){this.setopacity(submenu, 1);submenu.style.filter='';}if (this.enableshim && submenu.FFscrollInfo)this.positionshim(header, submenu, dir, submenu.FFscrollInfo.x, submenu.FFscrollInfo.y);}submenu._curanimatedegree=(1-Math.cos((elapsed/this.effects.duration)*Math.PI)) / 2;},
		hidemenu:function(submenu){if (typeof submenu._pos!='undefined'){this.css(this.topitems[submenu._master][parseInt(submenu._pos)], 'selected', 'remove');if (this.enableshim)this.hideshim();}clearInterval(submenu._animatetimer);submenu.style.left=0;submenu.style.top='-1000px';submenu.style.visibility='hidden';},
		addEvent:function(target, functionref, tasktype) {if (target.addEventListener)target.addEventListener(tasktype, functionref, false);else if (target.attachEvent)target.attachEvent('on'+tasktype, function(){return functionref.call(target, window.event);});},
		init:function(mainmenuid, dir){this.standardbody=((document.compatMode=='CSS1Compat')? document.documentElement : document.body);this.topitemsindex=-1;this.ulindex=-1;this.topmenuids.push(mainmenuid);this.topitems[mainmenuid]=[];this.subuls[mainmenuid]=[];this.hidetimers[mainmenuid]=[];if (this.enableshim && !this.shimadded){this.shimmy={};this.shimmy.topshim=this.addshimmy(document.body);this.shimmy.bottomshim=this.addshimmy(document.body);this.shimadded=true;}var menubar=document.getElementById(mainmenuid);var alllinks=menubar.getElementsByTagName('a');this.getwindowsize();for (var i=0; i<alllinks.length; i++){if (alllinks[i].getAttribute('rel')){this.topitemsindex++;this.ulindex++;var menuitem=alllinks[i];this.topitems[mainmenuid][this.topitemsindex]=menuitem;var dropul=document.getElementById(menuitem.getAttribute('rel'));document.body.appendChild(dropul);dropul.style.zIndex=2000;dropul._master=mainmenuid;dropul._pos=this.topitemsindex;this.addEvent(dropul, function(){CMS.neosideamenu.hidemenu(this);}, 'click');var arrowclass=((dir=='sidebar')? 'cmsrightarrow' : 'cmsdownarrow');var arrowpointer=((dir=='sidebar')? this.arrowpointers.rightarrow : this.arrowpointers.downarrow);if (this.arrowpointers.showarrow.toplevel)this.addpointer(menuitem, arrowclass, arrowpointer, (dir=='sidebar')? 'before' : 'after');this.buildmenu(mainmenuid, menuitem, dropul, this.ulindex, true, dir);dropul.onmouseover=function(){clearTimeout(CMS.neosideamenu.hidetimers[this._master][this._pos]);};this.addEvent(dropul, function(e){if (!CMS.neosideamenu.isContained(this, e) && !CMS.neosideamenu.isContained(CMS.neosideamenu.topitems[this._master][parseInt(this._pos)], e)){var dropul=this;CMS.neosideamenu.hidetimers[this._master][this._pos]=setTimeout(function(){CMS.neosideamenu.hidemenu(dropul);}, CMS.neosideamenu.hideinterval);}}, 'mouseout');var subuls=dropul.getElementsByTagName('ul');for (var c=0; c<subuls.length; c++){this.ulindex++;var parentli=subuls[c].parentNode;if (this.arrowpointers.showarrow.sublevel)this.addpointer(parentli.getElementsByTagName('a')[0], 'cmsrightarrow', this.arrowpointers.rightarrow, 'before');this.buildmenu(mainmenuid, parentli, subuls[c], this.ulindex, false, dir);}}}this.addEvent(window, function(){CMS.neosideamenu.getwindowsize(); CMS.neosideamenu.gettopitemsdimensions();}, 'resize');},
		setup:function(mainmenuid, dir){CMS.neosideamenu.init(mainmenuid, dir);}
	},

	menubuildsubtree:function(toid,stid,stp){
		var tmpul=document.createElement('ul');
		tmpul.setAttribute('id',stid);
		if(navigator.userAgent.toLowerCase().indexOf( "msie" )!=-1)
			tmpul.className='cmssubmenu';
		else
			tmpul.setAttribute('class','cmssubmenu');
		if(stp.hasChildNodes()){
			for(var tmpc=0;tmpc<stp.childNodes.length;tmpc+=1){
				if(stp.childNodes[tmpc].tagName=='page'){
					var newpage=document.createElement('li');
					var pagelink=document.createElement('a');
					pagelink.setAttribute('href',this.esc(this.getXMLUrl()+'?IdPage='+stp.childNodes[tmpc].getAttribute('idpage')+'&Title='+stp.childNodes[tmpc].getAttribute('title')));
					if(navigator.userAgent.toLowerCase().indexOf( "msie" )!=-1)
						pagelink.style.setAttribute('cssText',this.esc('text-decoration:none;cursor:pointer;'));
					else
						pagelink.setAttribute('style',this.esc('text-decoration:none;cursor:pointer;'));
					var pagename=document.createTextNode(stp.childNodes[tmpc].getAttribute('title'));
					if(stp.childNodes[tmpc].getAttribute('idpage')==this.getCurPageId()){
						if(navigator.userAgent.toLowerCase().indexOf( "msie" )!=-1)
							newpage.className='cmscurmenuelement';
						else
							newpage.setAttribute('class','cmscurmenuelement');
					}else{
						if(navigator.userAgent.toLowerCase().indexOf( "msie" )!=-1)
							newpage.className='cmsgenericmenuelement';
						else
							newpage.setAttribute('class','cmsgenericmenuelement');
					}
					pagelink.appendChild(pagename);
					newpage.appendChild(pagelink);
					if(stp.childNodes[tmpc].hasChildNodes()){
						var tmpchildtree='pagelist_'+toid+'_'+this.getnextchildid();
						pagelink.setAttribute('rel',this.esc(tmpchildtree));
						var st=this.menubuildsubtree(toid,tmpchildtree,stp.childNodes[tmpc]);
						newpage.appendChild(st);
					}
					tmpul.appendChild(newpage);
				}
			}
		}
		return tmpul;
	},

	/* Utilities */
	getnextchildid:function(){var u=CMS.curchildtree;CMS.curchildtree+=1;return u},
	getUniqueId:function(){
		if(navigator.userAgent.toLowerCase().indexOf('msie 6.0')!=-1) return CMS.uniqueid;
		else{var u=CMS.uniqueid;CMS.uniqueid+=1;return u;}
	},
	getCurLang:function(){return this.defaultlangid;},
	getXMLUrl:function(){return 'index.php';/*TODO*/var l=document.location.href;var p=l.indexOf('?');if(p<0)return l;return l.substr(0,p);},
	getCurPageId:function(){var l=document.location.href;var p=l.lastIndexOf('&IdPage=');if(p<0)p=l.lastIndexOf('?IdPage=');if(p<0)return 0;var e=l.substr(p+1).indexOf('&');var i=null;if(e<0)i=parseInt(l.substr(p+8));else i=parseInt(l.substr(p+8,e-7));if(isNaN(i))return 0;return i;},
	esc:function(s,c){if(s==null)return s;s=String(s);if(c==null)c='\'';var slash=new RegExp(/\\/g);var mychar=new RegExp(c,'g');s=s.replace(slash,'\\\\');s=s.replace(mychar,'\\'+c);return s;},

	/* XML utilities */
	copyXMLtree:function(from,to){
		if(from.nodeType==3){// && to.tagName!='SCRIPT'){//TEXT_NODE
			if(to.tagName=='SCRIPT' && navigator.userAgent.toLowerCase().indexOf('msie')!=-1){
				to.text=from.nodeValue.replace('//<![CDATA[','').replace('//]]>','').replace('<![CDATA[','').replace(']]>','');
			}else
			to.appendChild(document.createTextNode(from.nodeValue));
		//}else if(from.nodeType==7 || (from.nodeType==3 && to.tagName=='SCRIPT')){//PROCESSING INSTRUCTION
		//	to.appendChild(document.createProcessingInstruction(from.nodeValue));
		}else if(from.nodeType==1){//ELEMENT_NODE
			var no=document.createElement(from.tagName);
			//if(from.hasAttributes()){
				for(var a=0;a<from.attributes.length;a+=1)
					no.setAttribute(from.attributes[a].name,this.esc(from.attributes[a].value));
			//}
			//if(no.tagName=='SCRIPT' && navigator.userAgent.toLowerCase().indexOf('msie')!=-1){
			//	no.type='text/javascript';
				//no.text=from.childNodes[0].nodeValue;
				
			/*}*/if(from.hasChildNodes()){
				for(var c=0;c<from.childNodes.length;c+=1)
					this.copyXMLtree(from.childNodes[c],no);
			}
			to.appendChild(no);
		}else if(from.nodeType==4){//CDATA NODE
			if(to.tagName=='SCRIPT' && navigator.userAgent.toLowerCase().indexOf('msie')!=-1){
				to.text=from.nodeValue.replace('//<![CDATA[','').replace('//]]>','').replace('<![CDATA[','').replace(']]>','');
			}else{
			//to.appendChild(document.createTextNode('<![CDATA['+from.nodeValue+']]>'));
			//to.appendChild(document.createCDATASection(from.nodeValue));
			if(to.tagName=='SCRIPT')
				to.appendChild(document.createTextNode(from.nodeValue));
			else
				to.appendChild(document.createComment(from.nodeValue));
			}
		}else if(from.nodeType==8){//COMMENT NODE
			to.appendChild(document.createComment(from.nodeValue));
		}else{
			//TODO
			//alert('Found node2 '+from.nodeType);
			// see http://www.w3schools.com/Dom/dom_nodetype.asp
		}
	},

	XMLNodetoStr:function(myxmlnode){
		if(myxmlnode.nodeType==3){//TEXT_NODE
			return myxmlnode.nodeValue;
		}else if(myxmlnode.nodeType==4){
			if(navigator.userAgent.toLowerCase().indexOf('msie')!=-1)
				return '<![CDATA[ \n'+myxmlnode.nodeValue.replace('//<![CDATA[','').replace('//]]>','').replace('<![CDATA[','').replace(']]>','')+' ]]>';
			//return document.createCDATASection(myxmlnode.nodeValue);
			if(to.tagName=='SCRIPT')
				return document.createTextNode(myxmlnode.nodeValue);
			else
				return document.createComment(myxmlnode.nodeValue);
			//return '\n'+myxmlnode.nodeValue;
		}else if(myxmlnode.nodeType==1){//ELEMENT_NODE
			var txt='<'+myxmlnode.tagName;
			//if(myxmlnode.hasattributes){
				for(var attr=0;attr<myxmlnode.attributes.length;attr+=1)
					txt+=' '+myxmlnode.attributes[attr].name+'=\''+this.esc(myxmlnode.attributes[attr].value)+'\'';
			//}
			if(myxmlnode.hasChildNodes()){
				txt+=' >';
				for(var child=0;child<myxmlnode.childNodes.length;child+=1)
					txt+=this.XMLNodetoStr(myxmlnode.childNodes[child]);
				txt+='</'+myxmlnode.tagName+'>';
			}else txt+=' />';
			return txt;
		}else if(myxmlnode.nodeType==8){// COMMENT NODE
			return '<!--'+myxmlnode.nodeValue+'-->';
		}else{
			//TODO
			//alert('Found node '+myxmlnode.nodeType+' with value: '+myxmlnode.nodeValue);
			// see http://www.w3schools.com/Dom/dom_nodetype.asp
		}
	},


	/* XML HTTP Request */
	xmlhttpreq:function(getreq,postreq,handler,unique){
		if(navigator.userAgent.toLowerCase().indexOf('msie 6.0')!=-1){
			if(CMS.http_request_mutex){
				setTimeout('CMS.xmlhttpreq(\''+this.esc(getreq)+'\',\''+this.esc(postreq)+'\',\''+this.esc(handler)+'\','+this.esc(unique)+');',100);
				return;
			}
		}
		CMS.http_request_mutex=true;
		if(window.XMLHttpRequest) CMS.http_request[unique] = new XMLHttpRequest();
		else if (window.ActiveXObject && typeof ActiveXObject != undefined){
			try{
				CMS.http_request[unique]=new ActiveXObject('Msxml2.XMLHTTP');
			}catch(e){
				try{
					CMS.http_request[unique]=new ActiveXObject('Microsoft.XMLHTTP');
				}catch(e){
					try{
						CMS.http_request[unique]=new ActiveXObject("Msxml2.XMLHTTP.4.0");
					}catch(e){}
				}
			}
		}
		if(CMS.http_request[unique]){
			if(navigator.userAgent.toLowerCase().indexOf('msie 6.0')!=-1);else CMS.http_request[unique].uniqueid=unique;
			CMS.http_request[unique].onreadystatechange=function(){if(navigator.userAgent.toLowerCase().indexOf('msie 6.0')!=-1)var unique=0;else var unique=this.uniqueid;if(typeof(CMS.http_request[unique].readyState)==='undefined' || CMS.http_request[unique].readyState == 4){if(CMS.http_request[unique].status==200){var c=CMS.http_request[unique].responseXML.getElementsByTagName('cmsresponse')[0];eval(handler);}else alert('Errore di Connessione ');CMS.http_request_mutex=false;}};
			CMS.http_request[unique].open('POST',getreq,true);
			CMS.http_request[unique].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			CMS.http_request[unique].setRequestHeader('If-Modified-Since','Tue, 04 Apr 2006 00:00:00 GMT');
			CMS.http_request[unique].setRequestHeader("Content-length", postreq.length);
			if(!document.all){CMS.http_request[unique].setRequestHeader("Connection", "close");}
			if (CMS.http_request[unique].overrideMimeType) CMS.http_request[unique].overrideMimeType('text/xml');
			CMS.http_request[unique].send(postreq);
		}else alert('Il tuo browser non supporta le chiamate AJAX.');
	},

	/* Public APIs */
	handleListPages:function(toid,horiz,unique){
		if(toid==null)return;
		if(horiz==null)horiz=true;
		var target=document.getElementById(toid);
		target.innerHTML='';
		var mul=document.createElement('ul');
		if(horiz)
			mul.setAttribute('class','cmshorizmenu');
		else
			mul.setAttribute('class','cmsvertmenu');
		mul.setAttribute('id','pagelist_'+toid);
		var response=CMS.http_request[unique].responseXML;
		var elems=response.getElementsByTagName('cmsresponse')[0];
		if(elems){
			if(elems.hasChildNodes()){
				for(var curelem=0;curelem<elems.childNodes.length;curelem+=1){
					if(elems.childNodes[curelem].tagName=='pages'){
						if(elems.childNodes[curelem].hasChildNodes()){
							for(var curpage=0;curpage<elems.childNodes[curelem].childNodes.length;curpage+=1){
								if(elems.childNodes[curelem].childNodes[curpage].tagName=='page'){
									var newpage=document.createElement('li');
									var pagelink=document.createElement('a');
									pagelink.setAttribute('href',this.esc(this.getXMLUrl()+'?IdPage='+elems.childNodes[curelem].childNodes[curpage].getAttribute('idpage')+'&title='+elems.childNodes[curelem].childNodes[curpage].getAttribute('title')));
									if(navigator.userAgent.toLowerCase().indexOf( "msie" )!=-1)
										pagelink.style.setAttribute('cssText',this.esc('text-decoration:none;cursor:pointer;'));
									else
										pagelink.setAttribute('style',this.esc('text-decoration:none;cursor:pointer;'));
									var pagename=document.createTextNode(elems.childNodes[curelem].childNodes[curpage].getAttribute('title'));
									if(elems.childNodes[curelem].childNodes[curpage].getAttribute('idpage')==this.getCurPageId()){
										if(navigator.userAgent.toLowerCase().indexOf( "msie" )!=-1)
											newpage.className='cmscurmenuelement';
										else
											newpage.setAttribute('class','cmscurmenuelement');
									}else{
										if(navigator.userAgent.toLowerCase().indexOf( "msie" )!=-1)
											newpage.className='cmsgenericmenuelement';
										else
											newpage.setAttribute('class','cmsgenericmenuelement');
									}
									if(elems.childNodes[curelem].childNodes[curpage].hasChildNodes()){
										var tmpchildtree='pagelist_'+toid+'_'+this.getnextchildid();
										pagelink.setAttribute('rel',this.esc(tmpchildtree));
										var st=this.menubuildsubtree(toid,tmpchildtree,elems.childNodes[curelem].childNodes[curpage]);
										target.appendChild(st);
									}
									pagelink.appendChild(pagename);
									newpage.appendChild(pagelink);
									mul.appendChild(newpage);
								}
							}
						}
					}
				}
			}
		}
		target.appendChild(mul);
		var s=document.createElement('script');
		s.setAttribute('type','text/javascript');
		s.setAttribute('language','javascript');
		if (null == s.canHaveChildren || s.canHaveChildren) { 
			var is=document.createTextNode('CMS.neosideamenu.setup(\'pagelist_'+toid+'\', \''+(horiz?'topbar':'sidebar')+'\');');
			s.appendChild(is);
		}else
			s.text='CMS.neosideamenu.setup(\'pagelist_'+toid+'\', \''+(horiz?'topbar':'sidebar')+'\');';
		target.appendChild(s);
	},

	listPages:function(toid,frompageid,horiz,onelevel,withparent){
		if(toid==null)return;
		if(frompageid==null)frompageid=0;
		if(horiz==null)horiz=true;
		if(onelevel==null)onelevel=false;
		if(withparent==null)withparent=false;
		var u=this.getUniqueId();
		var txtreq='<?xml version=\'1.0\' ?><cmsrequest ><action >listpages</action><languageid >'+this.getCurLang()+'</languageid><uniqueid >'+u+'</uniqueid><options onelevel=\''+this.esc(onelevel?'true':'false')+'\''+(isNaN(frompageid)?'':' parentid=\''+this.esc(frompageid)+'\'')+' withparent=\''+this.esc(withparent?'true':'false')+'\' /></cmsrequest>';
		this.xmlhttpreq(this.getXMLUrl()+'?CMSXMLRequest=1',txtreq,'CMS.handleListPages(\''+this.esc(toid)+'\','+this.esc(horiz?true:false)+','+this.esc(u)+')',u);
	},

	handleShowBody:function(toid,unique,curpage){
		if(toid==null)return;
		var target=document.getElementById(toid);
		target.innerHTML='';
		var response=CMS.http_request[unique].responseXML;
		var elems=response.getElementsByTagName('cmsresponse')[0];
		if(elems){
			if(elems.hasChildNodes()){
				for(var curelem=0;curelem<elems.childNodes.length;curelem+=1){
					if(elems.childNodes[curelem].tagName=='body'){
						if(elems.childNodes[curelem].hasChildNodes()){
							for(var c=0;c<elems.childNodes[curelem].childNodes.length;c+=1)
								if(navigator.userAgent.toLowerCase().indexOf( "msie" )!=-1/* && typeof document.body.style.maxHeight == 'undefined'*/){
									target.innerHTML+=this.XMLNodetoStr(elems.childNodes[curelem].childNodes[c]);
								}else{
									this.copyXMLtree(elems.childNodes[curelem].childNodes[c],target);
								}
						}
					}
				}
			}
		}
	},

	handlePageInfo:function(unique){
		var response=CMS.http_request[unique].responseXML;
		var elems=response.getElementsByTagName('cmsresponse')[0];
		if(elems){
			if(elems.hasChildNodes()){
				for(var curelem=0;curelem<elems.childNodes.length;curelem+=1){
					if(elems.childNodes[curelem].tagName=='title'){
						document.title=elems.childNodes[curelem].childNodes[0].nodeValue;
					}/*else if(elems.childNodes[curelem].tagName=='description'){
						var fd=false;
						var rootNode=null;
						var headNode=null;
						//if(document.childNodes[0].tagName=='html')
						rootNode=document.childNodes[0];
						if(rootNode!=null){
							if(rootNode.childNodes[0].tagName=='head')headNode=rootNode.childNodes[0];
							if(headNode==null){headNode=document.createElement('head');rootNode.insertChild(headNode);}
							for(var c=0;c<headNode.childsNodes.length;c+=1){
								if(headNode.childsNodes[c].tagName=='META' && headNode.childsNodes[c].getAttribute('name')=='description'){
									headNode.childsNodes[c].setAttribute('content',elems.childNodes[curelem].childNodes[0].nodeValue);
									fd=true;
									break;
								}
							}
							if(!fd){
								var m=document.createElement('META');
								m.setAttribute('name','description');
								m.setAttribute('content',elems.childNodes[curelem].childNodes[0].nodeValue);
								headNode.appendChild(m);
							}
						}
					}else if(elems.childNodes[curelem].tagName=='keywords'){
						var fd=false;
						var rootNode=null;
						var headNode=null;
						//if(document.childNodes[0].tagName=='html')
						rootNode=document.childNodes[0];
						if(rootNode!=null){
							if(rootNode.childNodes[0].tagName=='head')headNode=rootNode.childNodes[0];
							if(headNode==null){headNode=document.createElement('head');rootNode.insertChild(headNode);}
							for(var c=0;c<headNode.childsNodes.length;c+=1){
								if(headNode.childsNodes[c].tagName=='META' && headNode.childsNodes[c].getAttribute('name')=='keywords'){
									headNode.childsNodes[c].setAttribute('content',elems.childNodes[curelem].childNodes[0].nodeValue);
									fd=true;
									break;
								}
							}
							if(!fd){
								var m=document.createElement('META');
								m.setAttribute('name','keywords');
								m.setAttribute('content',elems.childNodes[curelem].childNodes[0].nodeValue);
								headNode.appendChild(m);
							}
						}

					}*/
				}
			}
		}
	},


	showbody:function(toid,curpage){
		if(toid==null)return;
		if(curpage==null)return;
		var u=this.getUniqueId();
		var txtreq='<?xml version=\'1.0\' ?><cmsrequest ><action >showbody</action><languageid >'+this.getCurLang()+'</languageid><uniqueid >'+u+'</uniqueid><options >'+curpage+'</options></cmsrequest>';
		this.xmlhttpreq(this.getXMLUrl()+'?CMSXMLRequest=1',txtreq,'CMS.handleShowBody(\''+this.esc(toid)+'\','+this.esc(u)+','+this.esc(curpage)+')',u);
	},

	list:function(p){
		toid=null;
		frompageid=0;
		horiz=true;
		onelevel=false;
		withparent=false;
		if('id' in p)toid=p['id'];
		if('parentid' in p)frompageid=p['parentid'];
		if('horizontal' in p)horiz=p['horizontal'];
		if('onelevel' in p)onelevel=p['onelevel'];
		if('withparent' in p)withparent=p['withparent'];
		return this.listPages(toid,frompageid,horiz,onelevel,withparent);
	},

	body:function(p){
		toid=null;
		var curpage=this.getCurPageId();
		if(p){
			if('id' in p)toid=p['id'];
			if('pageid' in p)curpage=p['pageid'];
		}
		return this.showbody(toid,curpage);
	},

	pageinfo:function(){
		var curpage=this.getCurPageId();
		var u=this.getUniqueId();
		var txtreq='<?xml version=\'1.0\' ?><cmsrequest ><action >getpageinfo</action><languageid >'+this.getCurLang()+'</languageid><uniqueid >'+u+'</uniqueid><options >'+curpage+'</options></cmsrequest>';
		this.xmlhttpreq(this.getXMLUrl()+'?CMSXMLRequest=1',txtreq,'CMS.handlePageInfo('+this.esc(u)+')',u);
	},

	init:function(p){
		if(p!=null){
			if('menudownarrow' in p) this.neosideamenu.arrowpointers['downarrow'][0]=p['menudownarrow'];
			if('menurightarrow' in p) this.neosideamenu.arrowpointers['rightarrow'][0]=p['menurightarrow'];
			if('animationinterval' in p){
				this.neosideamenu.hideinterval=p['animationinterval'];
				this.neosideamenu.effects['duration']=p['animationinterval'];
			}
			if('language' in p)this.defaultlangid=p['language'];
			if('enableflashhack' in p)this.neosideamenu.enableshim=true;
		}
		if(this.neosideamenu.arrowpointers['downarrow'][0]==null) this.neosideamenu.arrowpointers['showarrow']['toplevel']=false;
		if(this.neosideamenu.arrowpointers['rightarrow'][0]==null) this.neosideamenu.arrowpointers['showarrow']['sublevel']=false;
		this.pageinfo();
	}

};

