
/*
 Libreria OM ver. 1.00   11/12/2008  by giulio de feudis http://ombremosse.it 

  Author:giulio de feudis 2008 copyright ombremosse.it
  ver. 2.00 28/08/2007
*/
Object.prototype.extend=function(destination,source){
	for(var property in source) destination[property]=source[property];return destination
}
Object.prototype.clone=function(obj){return Object.extend({},obj)};
//
if(typeof Array.prototype.concat==='undefined'){
	Array.prototype.concat=function(a){for(var i=0,b=this.copy();i<a.length;i++){b[b.length]=a[i]}return b}
}
if(typeof Array.prototype.copy==='undefined'){
	Array.prototype.copy=function(a){var a=[],i=this.length;while(i--){a[i]=(typeof this[i].copy!=='undefined')?this[i].copy():this[i]}return a}
}
if(typeof Array.prototype.pop==='undefined'){
	Array.prototype.pop=function(){var b=this[this.length-1];this.length--;return b}
}
if(typeof Array.prototype.push==='undefined'){
	Array.prototype.push=function(){for(var i=0,b=this.length,a=arguments;i<a.length;i++){this[b+i]=a[i]}return this.length}
}
if(typeof Array.prototype.shift==='undefined'){
	Array.prototype.shift=function(){
	for(var i=0,b=this[0];i<this.length-1;i++){this[i]=this[i+1]}this.length--;return b}
}
if(typeof Array.prototype.slice==='undefined'){
	Array.prototype.slice=function(a,c){var i=0,b,d=[];if(!c){c=this.length}if(c<0){c=this.length+c}if(a<0){a=this.length-a}if(c<a){b=a;a=c;c=b}for(i;i<c-a;i++){d[i]=this[a+i]}return d}
}
if(typeof Array.prototype.splice==='undefined'){
	Array.prototype.splice=function(a,c){var i=0,e=arguments,d=this.copy(),f=a;if(!c){c=this.length-a}for(i;i<e.length-2;i++){this[a+i]=e[i+2]}for(a;a<this.length-c;a++){this[a+e.length-2]=d[a-c]}this.length-=c-e.length+2;return d.slice(f,f+c)}
}
if(typeof Array.prototype.unshift==='undefined'){
	Array.prototype.unshift=function(a){this.reverse();var b=this.push(a);this.reverse();return b}
}
Object.extend(Array.prototype,{
	indexOf:function(n){for(var i=0;i<this.length;i++){if(this[i]===n){return i}}return-1},
	lastIndexOf:function(n){var i=this.length;while(i--){if(this[i]===n){return i}}return-1},
// define later
	foreach:function(f){var i=this.length,j,l=this.length;for(i=0;i<l;i++){if((j=this[i])){f(j)}}},
	insert:function(i,v){if(i>=0){var a=this.slice(),b=a.splice(i);a[i]=value;return a.concat(b)}},
	shuffle:function(){var i=this.length,j,t;while(i--){j=Math.floor((i+1)*Math.random());t=arr[i];arr[i]=arr[j];arr[j]=t}},
	unique:function(){var a=[],i;this.sort();for(i=0;i<this.length;i++){if(this[i]!==this[i+1]){a[a.length]=this[i]}}return a},
	exist:function(x){for(var i in this)if(this[i]===x)return true;return false},
	remove:function(x){for(var i in this)if(this[i]===x){this.splice(i,1);return}},
// aggiunge correttamente la funzione in array 
	addFunc:function(p){
			var t=typeof(p);
			if(t=='string')this.push(function(){$process(p)});
			if(t=='function')this.push(p);
			if(t=='array'||t=='object')
				 for(var i=0;i<p.length;i++)
					if(typeof(p[i])=='string')this.push(function(){$process(p[i])});
					else this.push(p[i])
	}
});
// Dichiarazione array multidimensionali var pippo=new ArrayDim(3,3,3,3);==matrice 4x4
var ArrayDim=function(){
	var dime=arguments.length,
		el=new Array(dime),
		temp,
		str="";
	for(var i=1;i<dime;i++)if(isNaN(el[i]=parseInt(arguments[i-1],10)))dime=0;
	do{
		temp="";
		for(el[--i];el[i]>1;--el[i])temp+="new Array("+str+"),";
		temp+="new Array("+str+")";
		str=temp;
	
	} while(--dime>1&& 0!=i);
	str="new Array("+str+")";
	return eval(str)
}
// extend String
Object.extend(String.prototype,{
// return true if s exist
	find:function(s){if(s) return this.indexOf(s)>-1;else false},
// replace all c in d destination 
	charsub:function(d,c){var s=this;if(d!=c)while(s.indexOf(d)>-1){s=s.substring(0,s.indexOf(d))+c+s.substring(s.indexOf(d)+d.length,s.length);}return s},
	reverse:function(){var s="",i=this.length;while(i>0){s+=this.substring(i-1,i);i--}return s},
	repeat:function(s,count){var ret='';for(var i=0;i<count;i++)ret+=s;return ret},
	isblank:function(){return(this===null||!this.match(/\s\n\r\t\S/))},
// Give string object the trim all and left/right trim method.
	trim:function(){return(this.replace(new RegExp("^([\\s]+)|([\\s]+)$","gm"),""))},
	ltrim:function(){return(this.replace(new RegExp("^[\\s]+","gm"),""))},
	rtrim:function(){return(this.replace(new RegExp("[\\s]+$","gm"),""))},
// String return from left/right n caratteri
	left:function(s,length){return s.substring(0,length)},
	right:function(s,length){return s.substring((s.length-length),s.length)}
});
// extend Math

Object.extend(Math,{
	Round:function(decimalpos){var i=this*Math.pow(10,decimalpos);return Math.round(i)/ Math.pow(10,decimalpos)},
	quadratic:function(frame,begin,increment,total){if((frame /=total)<1)return Math.round(increment  * frame * frame+begin)},
	linear:function(frame,begin,increment,total){if(frame /=total)return increment*frame+begin},
	diffPoint:function(v1,v2){return {x:(v1.x-v2.x),y:(v1.y-v2.y)}},
	addPoint:function(v1,v2){return {x:(v1.x+v2.x),y:(v1.y+v2.y)}},
	multiplyPoint:function(v1,v2){return {x:(v1.x*v2.x),y:(v1.y*v2.y)}},
	scalePoint:function(v,scale){return {x:Math.round(v.x*scale), y:Math.round(v.y*scale)}},
	minPoint:function(v1,v2){return {x:Math.min(v1.x,v2.x),y:Math.min(v1.y,v2.y)}},
	maxPoint:function(v1,v2){return {x:Math.max(v1.x,v2.x),y:Math.max(v1.y,v2.y)}},
	constrainTo:function(source,one,two){var min=this.minPoint(one,two),max=this.maxPoint(one,two),tmp=this.maxPoint(source,min);return this.minPoint(tmp,max)}
});
// extended typeof()
function TypeOf(o){
	var result=o? typeof(o):'null';
	if(result=='object'){
		switch(o.nodeName){
		case 'IMG':
		return 'image';
		case 'DIV'||'SPAN':
		return 'div';
		case 'IFRAME':
		return 'iframe';
		case 'TABLE'||'TD'||'TR'||'THEAD'||'TFOOT'||'TBODY':
		return 'table'
		case 'FONT':
		case 'FORM'||'SELECT'||'INPUT'||'BUTTON'||'TEXTAREA':
		return 'form';
		}
		if(result=='object'){
			switch(o.parentNode.nodeName){
				case 'FORM':
				return 'form';
			}
		}
	}
	return result
}
//
//  function
//
// $ definition
var $$=function(s){if(typeof(s)=='string'){try{return window[s]}catch(e){return $(s)}}else return false}
var $=function(s){
    var _el=(typeof(s)=='string')? ((document.getElementById)? document.getElementById(s):(document.all? document.all[s]:false)):((typeof (s)=='object')? s:false),
		ammmessi=['div','image','iframe','table','object','form']; 
	if(ammmessi.exist(TypeOf(_el))){
		Object.extend(_el,{
			timeline:null,
			doTimeline:OM.doTimeline,
			isImage:function(){return(TypeOf(_el)=='image')},
			isDiv:function(){return(TypeOf(_el)=='div')},
			isIframe:function(){return(TypeOf(_el)=='iframe')},
			isObject:function(){return(TypeOf(_el)=='object')},
			isTable:function(){return(TypeOf(_el)=='table')},
			isForm:function(){return(TypeOf(_el)=='form')}
		});
		if(_el.isIframe()){
			Object.extend(_el,{
				load:function(url,callMsg,func){
					this.write((callMsg? callMsg:OM.utility.loadingText('sto caricando: '+url,'testoload')));
					_el.onload=function(){if(func)$process(func);this.onload=null};
					_el.src=!url.match(/http:\/\//)? "http://"+url:url
				}
			})
		}
		if(_el.isDiv()||_el.isTable()){
			Object.extend(_el,{
				load:function(url,callMsg,func){
					var _funcs=new Array;
					_funcs.addFunc(func);
					_funcs.addFunc(OM.batch.doIt);
					OM.batch.add(function (){OM.ajax.call(url,_el,(callMsg? callMsg:OM.utility.loadingText('sto caricando: '+url,'testoload')),'<h1>Pagina non ricevuta dal server.</h1>',_funcs)});
					OM.batch.doIt()
				}
			})
		}
		Object.extend(_el,OM.domEvent);
		Object.extend(_el,OM.cssElement);
		if(!_el.isImage()){
			Object.extend(_el,{imageLoader:new OM.loader});
			Object.extend(_el,OM.domElement);
			if(!_el.isForm()){
				Object.extend(_el,OM.cssDiv);
				_el.allowDimension();
			}
		}
	}
	return _el
}
// crea  Elements $
function $E(id,tag,destination){
	if(!id)return false;
	tag=tag? tag:'div';
	if(document.getElementById){
		var el=document.createElement(tag);
		el.id=id;
		destination=(typeof(destination)=='object')? destination:document.getElementsByTagName('body').item(0);
		destination.appendChild(el)
	} else if(document.all){
		destination=(typeof(destination)=='object')? destination:document.body;
		destination.insertAdjacentHTML('beforeEnd','<'+tag+' '+OM.utility.naming(id)+'></'+tag+'>')
	}
	var self=$(id);
	self.destroy=function(){if(OM.is.msie)this.removeNode(true);else destination.removeChild(this)}
	return self
}
// embeds/object flash
function $Flash(id){
	this.movie=(OM.is.opera||OM.is.msie? window.document[id]:document.embeds[id]);
	if(!this.movie)return
	// type flash
	this.PassVar=function(o,var_name,value){this.movie.SetVariable(var_name,value)}
	this._Play=function(){this.movie.Play()};
	this._Stop=function(){this.movie.StopPlay()};
	this._Rewind=function(){this.movie.Rewind()};
	return this
}
// esegue funzioni da stringhe obj e array
function $process(p){
	if (p==null) return;
	var t=typeof (p);
	if(t=='string')eval(p);
	else if(t=='function')p();
	  else if(t=='array'||t=='object')
		for(var i=0;i<p.length;i++)$process(p[i])
}
// ritorna un array da qualsiasi contenuto
function $A(iterable){
	if(!iterable)return [];
	if(!(typeof(iterable)=='object'||typeof(iterable)=='function')&&iterable.split(''))return iterable.split('');
	var length=iterable.length||0,
		results=new Array(length);
	while(length--)results[length]=iterable[length];
	return results
}
// cerca nel dom
function $_TagNames(tag,o){o=(o? o:document);return o.getElementsByTagName(tag)}
function $_ClassNames(o,tag,className){
	var el=new Array(),
		els=$_TagNames((tag? tag:"*"),o),
		pattern=className? new RegExp("\\b"+className+"\\b") : '';
	for(var i=0,j=0;els.length>i;i++)
		if(className){
			if(pattern.test(els[i].className))el[j++]=els[i];
		}else if(els[i].className)el[j++]=els[i];
	return el
}
function $_Targets(target,source){
	var fin=new Array(),
		elm=$_TagNames('A',source);
	for(var i=0,j=0;i<elm.length;i++)
		if(elm[i].target==target)fin[j++]=elm[i];
	return fin
}
// cerca la classe o il target  definita e assegna al tag la funzione 
function $do_TagClass_function(source,tag,className,func){
	source=$_ClassNames(source,className,tag);
	if(source)
		for(var i=0;i<source.length;i++)source[i].onclick=function(){$process(func);return false}
}
function $do_Target_function(source,target,func){
	source=$_Targets(terget,source);
	if(source)
		for(var i=0;i<source.length;i++)source[i].onclick=function(){$process(func);return false}
}
// retrieve first parent of obj
function getparent(obj){return (obj.parentElement||obj.parentNode)}
// retrieve first child of obj
function FirstChild(el,tagName){var els = el.getElementsByTagName(tagName);return els && els.length>0 ? els[0] : null;}
// Adds a new class to an object, preserving existing classes
function AddClass(obj,cName){ KillClass(obj,cName); return obj && (obj.className+=(obj.className.length>0?' ':'')+cName); }
// Removes a particular class from an object, preserving other existing classes.
function KillClass(obj,cName){ return obj && (obj.className=obj.className.replace(new RegExp("^"+cName+"\\b\\s*|\\s*\\b"+cName+"\\b",'g'),'')); }
// Returns true if the object has the class assigned, false otherwise.
function HasClass(obj,cName){ return (!obj || !obj.className)? false : (new RegExp("\\b"+cName+"\\b")).test(obj.className) }

// location.searching value
function $url_value(s,d){var re=new RegExp(s+"=([^\\&]*)","i"),a=re.exec((d?d:document.location.search));return(a!=null? unescape(a[1]):'')}
// multimedia
function $_embed(link,w,h,id,bgcolor,tipo){return('<embed id="'+id+'" name="'+name+'" src="'+link+'" width="'+w+'" height="'+h+'" bgcolor="'+bgcolor+'" type="'+tipo+'" cache="true" controller="false" autoplay="false"></embed>\n')}
function $_flash(link,w,h,id,bgcolor,play_stop,scale,align){
	link=link.find(".flv")? link+'&showdigits=true&autostart=false"':link;	
	var txt1='<embed id="'+id+'" name="'+id+'"'+
	    (align? ' align="'+align+'"' : '')+
	    ' src="'+link+'"'+
		' width="'+w+'" height="'+h+'" bgcolor="'+bgcolor+'" scale="'+scale+'"'+
		' play="'+((play_stop==true)? 'true':'false')+'" quality="high" swLiveConnect="true" allowScriptAccess="sameDomain" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>';	
	var  txt=''+
	'<object name="'+id+'" height="'+h+'" width="'+w+'" '+(align? 'align="'+align+'"' : '')+
	' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0">'+
		'<param name="allowScriptAccess" value="sameDomain" />'+
		'<param name="swLiveConnect" value="true" />'+
		'<param name="play" value="'+((play_stop==true)? 'true':'false')+'" />'+
		'<param name="quality" value="high" />'+
		'<param name="scale" value="'+(scale? scale: 'exactfit')+'" />'+
		'<param name="bgcolor" value="'+bgcolor+'" />'+
		'<param name="movie" value="'+link+'" />'+
		'<param name="id" value="'+id+'" />'+txt1+'</object>';
	if(OM.is.msie&&OM.is.check("Windows")&&!OM.is.check("Windows 3.1")) txt+='<SCRIPT LANGUAGE="VBScript"'+'>\n on error resume next\n Sub '+id+'_FSCommand(ByVal command,ByVal args)\n call '+id+'_DoFSCommand(command,args)\n end sub\n </SCRIPT'+'>\n';
	return (OM.is.msie? txt:txt1)
}
//
// namespace
//
var OM={
	menus:[],
	menuItem:[],
	dropTargets:[],
// browser detect
	is:{
	// public
		agent:navigator.userAgent.toLowerCase(),
		app:navigator.appVersion.toLowerCase(),
		lang:navigator.appVersion.substring(navigator.appVersion.indexOf(")")-2,navigator.appVersion.indexOf(")")),
		dom:(document.getElementById? true:false),
		browser:null,
		os:"unknow",
		ver:"unknow",
	//  method
		init:function(){
			this._findbrowser();
			this._findos();
			this._findver()
		},
	// private
		_browsers:[
			"konqueror",
			"chrome",
			"safari",
			"opera",
			"msie",
			"omniweb",
			"icab",
			"firefox",
			"camino",
			"gecko",
			"netscape",
			"mozilla"
		],
		_os:[
			"win98",
			"windows",
			"vista",
			"os x",
			"linux"
		],
	// method
		_findver:function(){
			var ag=this.agent.indexOf("msie"),
				ap=this.app.indexOf("msie");	
			if(this.app)this.ver=parseFloat((ap>-1? this.app.substring(ap+5,ap+8):this.app.substring(0,this.app.indexOf("("))));
			else this.ver=parseFloat((ag>-1? this.agent.substring(ag+5,ag+8):this.agent.substring(this.agent.indexOf("/")+1,this.agent.indexOf("("))));
		},
		_findbrowser:function(){
			var trovato=-1;
			for(var i=0;i<this._browsers.length;i++){
				if(this.agent.find(this._browsers[i])&& trovato==-1)trovato=i;
				this[this._browsers[i]]=this.agent.find(this._browsers[i])
			}
			this.browser=(trovato>-1)? this._browsers[trovato]:"unknow";
		},			
		_findos:function(){for(var os in this._os)if(this.agent.find(this._os[os])){this.os=this._os[os];break}}
	},
	_events:{
	// start addLoadEvent(func)function-design by Simon Willison 
		addOnLoad:function(fn){
		    var oldonload=window.onload;   
		    if(typeof window.onload!='function')window.onload=fn;       
		    else{   
		        window.onload=function(){       
		            if(oldonload)oldonload();              
		            fn()         
		       }
		   }
		},
	// Created by:Caleb Duke | http://www.askapache.com/ 
		add:function(obj,type,fn){
			if(obj.addEventListener)obj.addEventListener(type,fn,false);
			else if(obj.attachEvent){
				obj["e"+type+fn]=fn;
				obj[type+fn]=function(){obj["e"+type+fn](window.event)}
				obj.attachEvent("on"+type,obj[type+fn])
				}
		},
		remove:function(obj,type,fn){
			if(obj.removeEventListener)obj.removeEventListener(type,fn,false);
			else if(obj.detachEvent){
				obj.detachEvent("on"+type,obj[type+fn]);
				obj[type+fn]=null;
				obj["e"+type+fn]=null
				}
		},
		fix:function(e){ return (e = e || OM._events.fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event)) },
		fixEvent: function (e) {
	// add W3C standard event methods
			e.preventDefault = OM._events.preventDefault;
			e.stopPropagation = OM._events.stopPropagation;
			return e;
		},
		stopPropagation:function() {  this.cancelBubble = true },
		preventDefault:function() { this.returnValue = false },
		stop: function (e){e=OM._events.fix(e); e.preventDefault();e.stopPropagation();},
		_Target:function(e){return(window.event? window.event.srcElement:e.target)}
	},
	world:{
		_Tpath:'themes/',
		_path:'',
	// document dimension
		X:0,
		Y:0,
		Width:function(){return(window.innerWidth||document.documentElement['clientWidth']||document.body['clientWidth'])},
	 	Height:function(){return(window.innerHeight||document.documentElement['clientHeight']||document.body['clientHeight'])},
	// document scroll position
		scrollX:function(){return(window.pageXOffset ? window.pageXOffset:(document.documentElement? document.documentElement.scrollLeft:(document.body? document.body.scrollLeft-document.body.clientLeft:0)))},
		scrollY:function(){return(window.pageYOffset ? window.pageYOffset:(document.documentElement? document.documentElement.scrollTop:(document.body? document.body.scrollTop-document.body.clientTop:0)))},
	    	scrollHeight: function() {return (document.body.scrollHeight)?  document.body.scrollHeight : document.documentElement.offsetHeight;},
	// vect
		scrollPos:function(){return {x:OM.world.scrollX(),y:OM.world.scrollY()}},
		dimension:function(){return {x:OM.world.Width(),y:OM.world.Height()}},
		size:function(){return {w:OM.world.Width(),h:OM.world.Height()}},
		origine:function(){return {x:OM.world.X,y:OM.world.Y}},
	//
	// todo!  for detect on dropped target
		addDropTarget:function(dropTarget){OM.world.dropTargets.push(dropTarget)},
		init:function(Drag_func,Resize_func,End_move_func,W_resize_func){
			if(W_resize_func)window.onresize=W_resize_func;
			document.onmousemove=function(e){OM.mouse.Move(e,Drag_func,Resize_func)};
			document.onmouseup=function(e){OM.mouse.EndMove(e,End_move_func)};
			if(OM.is.msie)document.onselectstart=function(){return!(OM.mouse.dragObject||OM.mouse.resizeObject)};
			document.onmousedown=function(){return!(OM.mouse.dragObject||OM.mouse.resizeObject)}
		}
	},
	mouse:{
		dragObject:null,
		resizeObject:null,
		mouseOffset:null,
	// resize direction
		c_est:"E",
		c_ovest:"O",
		c_nord:"N",
		c_nordest:"NE",
		c_nordovest:"NO",
	// mouse
		Pos:function(e){e=OM._events.fix(e);return (e.pageX||e.pageY)? {x:e.pageX,y:e.pageY}:Math.diffPoint({x:e.clientX,y:e.clientY},OM.world.scrollPos())},
		targetPos:function(o){var p={x:0,y:0};while(o){p=Math.addPoint({x:o.offsetLeft,y:o.offsetTop},p);o=o.offsetParent}return p},
	// offset position target
		Offset:function(target,e){return Math.diffPoint(this.Pos(e),this.targetPos(target))},
	//
	// dropping todo!!!
		drop:function(e){
			var mouse=this.Pos(e);
			for(var i=0;i<OM.dropTargets.length;i++){
				var curTarget=OM.dropTargets[i];
				var targPos=this.targetPos(curTarget);
				var targWidth=parseInt(curTarget.offsetWidth);
				var targHeight=parseInt(curTarget.offsetHeight);
				if(
					(mouse.x>targPos.x)              &&
					(mouse.x<(targPos.x+targWidth))&&
					(mouse.y>targPos.y)              &&
					(mouse.y<(targPos.y+targHeight))){
	// dragObject was dropped onto curTarget!
			    		var target=OM._events._Target(e);
						alert(curTarget.id+' droppedfrom '+target.id);	
				}
			}
		},
	// move mouse
		Move:function(e,drag_func,resize_func){
			var w=OM.world,
				mouse=this.Pos(e),
				d=null;
			e=OM._events.fix(e);
			if(d=this.dragObject){
				if(drag_func)drag_func(d,e);
				else{
		    		var x=(x>w.X+w.scrollX()&& x<w.Width()-d.Width()+w.scrollX())? x:(x>w.X+w.scrollX()?(w.Width()-d.Width()+w.scrollX()):w.scrollX()),
		    			y=(y>w.Y+w.scrollY()&& y<w.Height()-d.Height()+w.scrollY())? y:(y>w.Y+w.scrollY()?(w.Height()-d.Height()+w.scrollY()):w.scrollY());
		    		d.move(x,y)
				return OM._events.stop(e)
		    	}
			}
			if(this.resizeObject!=null){
				if(resize_func)resize_func(d,e);
				else if(d=this.resizeObject)d.size((mouse.x-d.x),(mouse.y-d.y))
				return OM._events.stop(e)
			}
		},
		EndMove:function(e,fn){
			e=OM._events.fix(e);
	/* find is dropping
			var target=m.drop(e)
	*/
			if(fn)fn(e);
			this.dragObject=this.resizeObject=this.mouseOffset=null
		},
		InitMove:function(o,e){this.dragObject=o;this.mouseOffset=this.Offset(o,e);return OM._events.stop(e)},
		wheel:function(e,fn){
			var delta=0;
			e=OM._events.fix(e)
			if(e.wheelDelta){
				delta=e.wheelDelta/120;
				if(window.opera)delta=-delta
			}else if(e.detail)delta=-e.detail/3;
				this.wheelDelta=delta;
				if(delta&&fn)fn();
				return OM._events.stop(e)
			},
		wheelDelta:null
	},
	batch:{
	// private
		_action:new Array(),
		_cookieValue:new Array,
		_numAction:0,
		_openCookie:function(){
		    if(OM.batch._cookieValue.length){
	   			var s=unescape(OM.batch._cookieValue[OM.batch._cookieValue.length-1]);
				OM.batch._cookieValue.pop();
				var end_i=s.indexOf('='),
					name=s.substring(0,end_i);
				name=name.trim();
				var set_id=Number(name.substring(3,name.length)),
					set_value=s.substring(end_i+1),
					v=set_value.split(',');
				if(name.find(OM.is.window_cookieName))PopURL(v[0],v[1],v[2],v[3],v[4],v[5],v[6],set_id,'','',v[7]);
				if(name.find(OM.is.alias_cookieName))OM.Alias({href:decode_virgola(v[1]),title:v[0],text:v[5].trim(),target:v[6]},v[2],v[3],v[4],set_id,OM.batch.doIt);
			}
		},
		_execute:function(){
			if(this._action.length){
				OM.progress.showit(this.progressbar);
				OM.progress.percent(this.progressimages,this._numAction,this._numAction-this._action.length,0);
		    	var s=this._action[this._action.length-1];
				this._action.pop();
				if(typeof(s)=='string')eval(s);
				else s()
		  }else{
				OM.progress.hide(this.progressbar);
				OM.progress.percent(this.progressimages,0,0);
				this._numAction=0
			}
		},
	// public
		progressbar:null,
		progressimages:'_progress_batch',
		addcookie:function(){
			var sets=document.cookie.split(';');
			if(sets.length&&sets[0]!=''){
				for(var i=0;sets.length>i;i++){
					var end_i=sets[i].find('=')? sets[i].indexOf('='):0,
						name=sets[i].substring(0,end_i);
					name=name.trim();
					if(name.find(OM.is.window_cookieName)||name.find(OM.is.alias_cookieName)){
						this._cookieValue.push(sets[i]);
						this.add(OM.batch._openCookie)
					}
				}
			} else this.add(OM.batch.doIt)
		},
		add:function(action){
		  	if(typeof action=='string'|| typeof action=='function')this._action.push(action);
			if(typeof action=='array'||typeof action=='object')
			    for(var i=0;action.length>i;i++)this._action.push(action[i]);
		    this._numAction=this._action.length
		},
		doIt:function(){OM.batch._execute()}
	},
	progress:{
		showit:function(o){if(o)o.visible(true)},
		hide:function(o){if(o)o.visible(false)},
		percent:function(image,actions,current){
			image=$(image);
			if(image) {
				if(actions>0)image.move(Math.round(((200/actions)*current)),0);
				else image.move(0,0);
			}
		}
	},
	loader:function(){
	// public variable
		this.loaded=new Array;
		this.progressbar=false;
		this.progressimage=false;
		this.loadmessage = '<span>...sto caricando...</span>';
	// private
		var _p=OM.progress,
			_callbacks=new Array,
			_images=new Array,
			_imagesLoaded=0,
			_toLoad=0,
			_loader=this,
			_checkFinished=function(){
				_p.percent(_loader.progressimage,_toLoad,++_imagesLoaded);
				if(_imagesLoaded==_images.length)_fireFinish();
				this.onload=null
			},
			_error=function(){alert('Impossibile caricare immagine ['+this.src+']');_checkFinished()},
			_fireFinish=function(){
				_p.hide(_loader.progressbar);
				for(var i=0;i<_callbacks.length;i++)_callbacks[i]();
				_images=[];
				_toLoad=_imagesLoaded=0;
				_callbacks=[]
			};
	// public methods 
		this.display = function (msg){
			_loader.progressbar = $E('progress_loader');
			_loader.progressbar.position(true);
			_loader.progressbar.move(OM.world.X, OM.world.Y);
			_loader.progressbar.className = 'progressGallery';
			_loader.progressbar.write(msg +
'<div class="progressBar"><span><em '+OM.utility.naming('progress_line')+' style="position:absolute; top:0; left:8; ">&nbsp;</em></span></div>'
			);
			this.progressimage=$('progress_line');
		};
   		this.load=function(){
			this.loaded=[];
			_p.showit(_loader.progressbar);
			_p.percent(_loader.progressimage,0,0);
			for(var i=0;i<_images.length;i++){
				this.loaded[i]=new Image();
				this.loaded[i].onerror=_error;
				this.loaded[i].onload=_checkFinished;// need image obj too
				this.loaded[i].src=_images[i]
			}
		}
		this.add=function(image,path){
			path=path?  path:'';
		    if(typeof image=='string')_images.push(path+image);
		    if(typeof image=='array'||typeof image=='object')
		    	for(var i=0;i<image.length;i++)_images.push(path+image[i]);
		    _toLoad=_images.length
		}
		this.onFinish=function(fn){
		    if(typeof fn=='function')_callbacks.push(fn);
		    if(typeof fn=='array'||typeof fn=='object'){
		      for(var i=0;i<fn.length;i++){
		        _callbacks.push(fn[i])
		     }
		   }
		}
		return this
	},
	Xml:{
		parsing:function(o,i){
			var NODE_TEXT=3,
				NODE_DATA=4,
				NODE_COMMENT=7,
				NODE_ELEMENT=1,
				id,oT;
			while(i!=null){
				id=i.nodeName;
				if(i.nodeType==NODE_COMMENT)return;
				if(i.nodeType==NODE_ELEMENT){
					oT=OM.Xml.parsing({},i.firstChild);
					if(i.attributes&& i.attributes.length)for(var at=0;i.attributes.length>at;at++)if(i.attributes[at].nodeName!=null||i.attributes[at].nodeValue!=null)oT[i.attributes[at].nodeName]=i.attributes[at].nodeValue;
					if(i.nodeValue===null){
						if(i.firstChild&&(i.nodeType==NODE_TEXT||i.nodeType==NODE_DATA)&&!(i.firstChild.nodeValue.indexOf('\n')==0))
							oT=i.firstChild.nodeValue;
						else if(i.lastChild&& i.lastChild.nodeType==NODE_TEXT)
					 			oT['text']=i.lastChild.nodeValue
					}else if(i.nodeValue)oT=i.nodeValue;
					if(o[id]!=null){
						if(typeof(o[id])!="object" ||!o[id].length)o[id]=[o[id]];
						o[id][o[id].length ]=oT
					}else o[id]=oT
				}
				i=i.nextSibling
			}
			return o
		},	
		toObj:function(oXML){return((oXML!=null && oXML.firstChild!=null)? OM.Xml.parsing(oXML.firstChild):null)}
	},
 	cssDiv:{
		allowDimension:function(){
			if(typeof(this.width)=='string'||typeof(this.width)==null)return;
			this.height=function(h){h=OM.utility.integer(h);if(h>=0)this.style.height=h+'px';return parseInt(this.style.height)}
			this.width=function(w){w=OM.utility.integer(w);if(w>=0)this.style.width=w+'px';return parseInt(this.style.width)}
		},
		size:function(w,h){return(typeof(this.width)!='function'? {x:this.width=(OM.utility.integer(w)>0? OM.utility.integer(w):0),y:this.height=(OM.utility.integer(h)>0? OM.utility.integer(h):0)}:{x:this.width(w),y:this.height(h)})},
		position:function(v){if(typeof v=='boolean')this.style.position=v? 'absolute':'relative'},
		x:function(x){x=OM.utility.integer(x);if(x!=null)this.style.left=x+'px';return parseInt(this.style.left)},
		y:function(y){y=OM.utility.integer(y);if(y!=null)this.style.top=y+'px';return parseInt(this.style.top)},
		move:function(x,y){return{x:this.x(x),y:this.y(y)}},
	// clipping div
		clip:function(w,h){
			var ww=(typeof(w)=='number')? w+'px':((typeof(w)=='string'&& w.find('%'))? w:null),
				hh=(typeof(h)=='number')? h+'px':((typeof(h)=='string'&& h.find('%'))? w:null);
			if(ww&& hh)this.style.clip="rect(0px "+w+" "+h+" 0px)";
			return this.style.clip
		},
	// vector function
		point:function (){ return {x:0,y:0,w:0,h:0,a:100}},
		psize:function(p){return this.size(p.w||p.x,p.h||p.y)},
		pmove:function(p){return{x:this.x(p.x),y:this.y(p.y)}},
		pos:function(){return{x:this.x(),y:this.y()}}
	},
	cssElement:{
		show:function(v){if(typeof v=='boolean'){with(this.style){visibility=(v? 'visible':'hidden')}}return(this.style.visibility=='visible')},
		display:function(v){if(typeof v=='boolean'){with(this.style){display=(v? 'block':'none')}}else if(typeof v=='string')this.style.display=v;return(this.style.display!='none'? this.style.display:false)},
		visible:function(v){this.show(!(v==false));this.display(v)},
		overflow:function(v){if(typeof v=='boolean')this.style.overflow=(v? 'visible':'hidden');else return this.style.overflow},
		zIndex:function(z){if(typeof(z)=='number'&&z>=0)this.style.zIndex=z;return this.style.zIndex},
		cursor:function(cur){if(!(OM.is.msie&&OM.is.ver<6)&&!OM.is.opera)this.style.cursor=cur},
		alpha:function(alfa){
			if(typeof(alfa)=='number'&& alfa>=0){
				if(OM.is.msie)this.style.filter=("Alpha(Opacity="+alfa+")");
				else{
					this.style.filter=("Alpha(Opacity="+alfa+")");
					alfa=(alfa/100);
					this.style.opacity=alfa;
					this.style['-moz-opacity']=alfa;
					this.style['-khtml-opacity']=alfa
				}
			}
			if(OM.is.msie){
				try{alfa=this.filters.item('DXImageTransform.Microsoft.Alpha').opacity}
				catch(e){try{alfa=this.filters.item('alpha').opacity;}catch(e){}}
			}else if(this.style.opacity)alfa=this.style.opacity
			return alfa
		}
	},
	domElement:{
	// scrollmove return value position = {x, y}
		scrollmove:function(x,y){return this.scrollpos(this.scrollLeft+x,this.scrollTop+y)},
	// scrollpos return value position = {x, y}
		scrollpos:function(x,y){x=OM.utility.integer(x);y=OM.utility.integer(y);if(x!=null)this.scrollLeft=x;if(y!=null)this.scrollTop=y;return{x:this.scrollLeft,y:this.scrollTop}},
	// vector scrollmove p = {x, y} return value scrollposition = {x, y}
		scrollpmove:function(p){return this.scrollmove(p.x,p.y)},
	// Position  o=object return value absposition = {x, y}
		Position:function(o){var p={x:0,y:0},o=o? o:this;while(o){p=Math.addPoint(p,{x:o.offsetLeft,y:(o.offsetTop+(OM.is.mac&&OM.is.msie? o.parentNode.offsetTop:0))});o=o.offsetParent}return p},
	// return obj dimension
		Height:function(){return OM.utility.integer(this.offsetHeight||this.clientHeight)},
		Width:function(){return OM.utility.integer(this.offsetWidth||this.clientWidth)},
	// Dimension return value to {x, y} 
		Dimension:function(){return{x:this.Width(),y:this.Height()}},
	// Size return value to {w, h}	
		Size:function(){return{w:this.Width(),h:this.Height()}},
	// contents
		write:function(s){if(typeof(s)=='string')this.innerHTML=s},
		read:function(){var t=this.innerHTML;return t? t:''},
	// obj module
		TagClassAction:function(tag,classe,fn){$do_TagClass_function(this,tag,classe,fn)},
		append:function(html,tag){
			html=(typeof(html)=='string')? html:null;
			if(document.getElementById){
				var elm=document.createElement((tag? tag:'div'));
				this.appendChild(elm);
				if(html!=null)elm.innerHTML=html;
			}else if(document.all) this.insertAdjacentHTML('beforeEnd',html)
		},
		prepend:function(html,tag){
			html=(typeof(html)=='string')? html:null;
			var elm=document.createElement((tag? tag:'div'));
			if(document.getElementById){
				this.parentNode.appendChild(elm);
				if(html!=null)elm.innerHTML=html;
			}else if(document.all) this.insertAdjacentHTML('afterBegin',html)
		},
		remove:function(obj){
			if(OM.is.msie)obj.removeNode(true);
			else obj.parentNode.removeChild(obj)}
	},
	domEvent:{
		addEvent:function(type,fn){if(type=='mousewheel'&&this.addEventListener)OM._events.add(this,'DOMMouseScroll',fn);OM._events.add(this,type,fn)},
		removeEvent:function(type,fn){if(type=='mousewheel'&&this.addEventListener)OM._events.add(this,'DOMMouseScroll',fn);OM._events.remove(this,type,fn)}
	},
	utility:{
		naming:function(id){return (id? 'id="'+id+'" name="'+id+'" ':'')},
		integer:function(n){
			if(n==null) return;
			n=(typeof(n)=='string'? parseInt(n):(typeof(n)=='number'? Math.round(n): null));
			if(n==null) return;
			return(!isNaN(n)&&typeof(n)=='number'? n:0)
		},
		loadingText:function(titolo,stili){return '<table width="100%" height="90%" '+(stili? 'class="'+stili+'"': '')+'><tr><td align="center" valign="middle">'+this.img(OM.world._path+'progress.gif')+'</br><p><b> sto caricando '+titolo+'.</b></p></td></tr></table>'},
		img:function(src,id,alt,w,h,extra){if(src)return '<img '+(id?'id="'+id+'" name="'+id+'" ':"")+'src="'+src+'" alt="'+(alt?alt:"")+'" '+(w?'width="'+w+'" ':'')+(h?'height="'+h+'" ':'')+(extra?extra:'')+' border="0" />'}
	}
};
/*
 Simulates the Adobe Flash timeline. You define the amount of frames,the speed in fps(frames per second)and, at each frame passage an event is called,useful for animations.
 
 method	this.start(),this.stop(),this.run()
 event	o.onframe=samething to do,o.onstart o.onstop
 property	this.current
*/
OM.timeline=function(fps,f){this.fps=fps;this.frames=f}
Object.extend(OM.timeline,{
	EaseLinear:function(frame,start,finish,begin ,end) {
		return (frame<start? begin:(frame>finish? end:Math.round((end-begin)*((frame-start)/finish-start-1)+begin)))
	},
	Ease:function(frame,start,finish,begin,end){return (frame<start? begin:(frame>finish? end:Math.round(Math.quadratic((frame-start),begin,(end-begin),(finish-start-1)))))},
	EasePoint:function(frame,start,finish,begin,end){//{x:,y:,w:,h;,a:}
		var first=(frame-start),
			total=(finish-start-1);
		return (frame<start? begin:(frame>finish? end :{
			x:Math.round(Math.quadratic(first,begin.x,(end.x-begin.x),total)),
			y:Math.round(Math.quadratic(first,begin.y,(end.y-begin.y),total)),
			w:Math.round(Math.quadratic(first,begin.w,(end.w-begin.w),total)),
			h:Math.round(Math.quadratic(first,begin.h,(end.h-begin.h),total)),
			a:Math.round(Math.quadratic(first,begin.a,(end.a-begin.a),total))
		}))
	},
	//
	// da colore begin a colore end in total frame            
	EaseColor:function(frame,start,finish,begin,end){
		var total=(finish-start-1),
			first=frame-start;
		end=this.cssColorDifferenza(begin,end);
		begin=this.cssColor2rgb(begin);
		if(frame<start)return this.write_rgb(begin);
		if(frame>finish)return this.write_rgb(cssColor2rgb(end));
		return 'rgb('+Math.round(Math.linear(first,begin[0],end[0],total))+','+Math.round(Math.linear(first,begin[1],end[1],total))+','+Math.round(Math.linear(first,begin[2],end[2],total))+')'
	},
	write_rgb:function(rgb){if(rgb)return 'rgb('+rgb[0]+','+rgb[1]+','+rgb[2]+')'},
	write_hex:function(rgb){if(rgb)return '#'+rgb[0]+rgb[1]+rgb[2]},
	dec2hex:function(dec){return dec.toString(16)},
	hex2dec:function(hex){return parseInt(hex,16)},
	rgb2hex:function(r,g,b){return [this.dec2hex(r),this.dec2hex(g),this.dec2hex(b)]},
	hex2rgb:function(h,e,x){return [this.hex2dec(h),this.hex2dec(e),this.hex2dec(x)]},
	cssColor2rgb:function(color){return (!color.find('rgb')? this.hex2rgb(color.substring(1,3),color.substring(3,5),color.substring(5,7)):color.substring(4,color.length-1).split(','))},
	cssColorDifferenza:function(begin,end){var b=this.cssColor2rgb(begin),e=this.cssColor2rgb(end);return [e[0]-b[0],e[1]-b[1],e[2]-b[2]]}
});
//
OM.doTimeline=function(flp,frames){if(flp&& frames)this.timeline=new OM.timeline(flp,frames)};
with({o:OM.timeline,$:OM.timeline.prototype}){
	o.timers=[];
	$.running=!!($.current=+(o.timer=$.time=null));
	o.run=function(){
		var o=this;
		o.timer ||(o.timer=setInterval(function(){
			for(var h,d=+(new Date),t=o.timers,i=t.length;i--;){
				(!t[i].running ||((d-t[i].time)/(1e3 / t[i].fps)>t[i].current+1&&
				t[i].onframe(++t[i].current),t[i].current>=t[i].frames))&&
				(h=t.splice(i,1)[0],h.stop(1))
			}
		},1))
	}
	$.start=function(c){
		var o=this,t=OM.timeline;
		if(o.running)return;
		o.running=true,o.current=c||0;
		o.time=new Date,o.onstart&& o.onstart();
		if(!o.onframe||o.frames<=0||o.fps<=0)return o.stop(1);
		t.timers.push(this),t.run()
	}
	$.stop=function(){
		var o=this;
		o.running=false;
		if(!OM.timeline.timers.length)	OM.timeline.timer=clearInterval(OM.timeline.timer),null;
		arguments.length&& o.onstop&& o.onstop()
	}
};
//
Object.extend(OM,{
ajax:{
	call:function(url,dest,callMsg,errorMsg,fn){
		var parms=false,
			page=$(dest),
			versions=["Msxml2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],
			metodo=(parms)? "POST":"GET";
		if(url in document.forms){
		   parms=getquerystring(url);
		   url=url.action;
		}
		if(url.lastIndexOf('://')>-1){
		   url=url.substring(8,url.length);
		   url=url.substring(url.indexOf('/')+1,url.length);
		}
		var self=this;
		if(window.XMLHttpRequest)self.AJAX=new XMLHttpRequest();
		else if(window.ActiveXObject){
				for(var i=0;i<versions.length ;i++){
					try{
						self.AJAX=new ActiveXObject(versions[i]);
						if(self.AJAX){
							_ms_XMLHttpRequest_ActiveX=versions[i];
							break
						}
				   } catch(objException){}
			   }
			}
		if(page)page.write(callMsg);
		self.AJAX.onreadystatechange=function(){OM.ajax.response(self.AJAX,url,dest,errorMsg,fn)}
		self.AJAX.open(metodo,url,true);
		if(metodo=="POST"){
			self.AJAX.setRequestHeader("content-type","application/x-www-form-urlencoded");
			self.AJAX.send(parms)
		} else self.AJAX.send(null)
	},
// evento risposta richiesta http
	response:function(AJAX,file,dest,errorMsg,fn){
		var xml=file.toLowerCase(),
			page=((typeof(dest)=='object'||typeof(dest)=='string')? $(dest):null),
			errore='';
		if(AJAX.readyState==4){
			if(AJAX.status==200||AJAX.status==0){
				if(AJAX.responseText){
					if((xml.find('.xml'))){
						if(AJAX.responseXML.firstChild&& endObj){
							var obj=OM.Xml.toObj(AJAX.responseXML);
							if(eval('obj.'+dest))eval(dest+'=obj.'+dest);
							else eval(dest+'=obj')
						}else eval(dest+'=null')
					} else if(page)page.write(AJAX.responseText);
							else eval(dest+'=AJAX.responseText');
					$process(fn)
				}
			}else{
				errore='<p>'+errorMsg+'</p>'+
						'file:'+file+'<br/>'+
						'next proc:'+fn+'<br/>'+
						'readyState:'+AJAX.readyState+'<br/>'+
						'status:'+AJAX.status+'<br/>'+
						(AJAX.responseText? 'responseText:'+AJAX.responseText+'<br/>':'');		
				if(page)page.write(errore);
				else PopUP('Errore Server',errore)
			}
		}
	}
}
});
//
Object.extend(OM,{
cookie:{
	write:function(Name,Value,expires,path,domain,secure){
	   var expired=new Date(expires);
	   if(Value){
			document.cookie=escape(Name)+'='+escape(Value)+(expires? ';expires='+expired.toGMTString():'')+(path? ';path='+path:'')+(domain? ';domain='+domain:'')+(secure? ';secure':'')
	  }else{
			Value='';
			var posName=document.cookie.indexOf(escape(Name)+'=');
			if(posName!=-1){
				var posValue=posName+(escape(Name)+'=').length;
				var endPos=document.cookie.indexOf(';',posValue);
				if(endPos!=-1)Value=unescape(document.cookie.substring(posValue,endPos));
				else Value=unescape(document.cookie.substring(posValue))
			}
			return(Value)
		}
	},
	clear:function(Name){var expired=new Date();OM.cookie.write(Name,'cancella',expired.setDate(expired.getDate()-1))}
}
});

// Dean's forEach: http://dean.edwards.name/base/forEach.js
/*
	forEach, version 1.0
	Copyright 2006, Dean Edwards
	License: http://www.opensource.org/licenses/mit-license.php
*/

// array-like enumeration
if (!Array.forEach) { // mozilla already supports this
	Array.forEach = function(array, block, context) {
		for (var i = 0; i < array.length; i++) {
			block.call(context, array[i], i, array);
		}
	};
}

// generic enumeration
Function.prototype.forEach = function(object, block, context) {
	for (var key in object) {
		if (typeof this.prototype[key] == "undefined") {
			block.call(context, object[key], key, object);
		}
	}
};

// character enumeration
String.forEach = function(string, block, context) {
	Array.forEach(string.split(""), function(chr, index) {
		block.call(context, chr, index, string);
	});
};

// globally resolve forEach enumeration
var forEach = function(object, block, context) {
	if (object) {
		var resolve = Object; // default
		if (object instanceof Function) {
			// functions have a "length" property
			resolve = Function;
		} else if (object.forEach instanceof Function) {
			// the object implements a custom forEach method so use that
			object.forEach(block, context);
			return;
		} else if (typeof object == "string") {
			// the object is a string
			resolve = String;
		} else if (typeof object.length == "number") {
			// the object is array-like
			resolve = Array;
		}
		resolve.forEach(object, block, context);
	}
};


