
var _=function(root, query){
	if(!root) return undefined;
	if(JJ.type(root, "String")){
		var el;
		if(/^#?[a-z0-9_]+$/i.test(root)) el=document.getElementById(root.replace(/#/,"")); //root as id
		if(el) root=el;
		else{query=root; root=document;} //root as query
	}
	if(!query && root._extended) return root;
	var els=root;
	if(query) els=JJ.getElements.parse(query, root);
	
	if(!els) return ""; //if no element return empty string
	
	if(!JJ.type(els, "Array")) JJ.extend(els, JJ.element); //exend one element
	else JJ.foreach(els, function(){ JJ.extend(this, JJ.element)}); //exend elements group (array object)
	return els;
};

//-------------------------------------------- JJ ------------------------------------------------
var JJ={};

//Base JJ function

JJ.type=function(obj, _type){
	var t=typeof obj;
	if(!_type) return t;
	if(obj==undefined) return _type==undefined;
	_type=_type.toLowerCase();
	switch(_type){
		case "object":   return obj.constructor==Object;
		case "array":    return obj.constructor==Array; //t=="object" && obj.length; 
		case "number":   return t=="number" || !isNaN(obj);
		case "element":  return t=="object" && obj.nodeType==1;
		case "date":     return obj.constructor==Date;
		case "string":     return obj.constructor==String;
		case "boolean":     return obj.constructor==Boolean;
		case "function":     return t=="function";
		default: return t==_type; 
	}
};
JJ.foreach=function(obj, func){
	if(!JJ.type(obj, "Array")) return func.call(obj);
	for(var i=0, arr=[], l=obj.length; i<l; i++)
		arr.push(func.call(obj[i], i));
	return arr;
};
JJ.extend=function(obj, methods){
	var call=function(obj, name, args){
		if(!JJ.type(obj, "Array") || name=="repeat"){
			return methods[name].exec(obj, args[0], args[1], args[2], args[3]);
		}
		else{
			//execute functions and return elements
			var res=JJ.foreach(obj, function(){ return methods[name].exec(this, args[0], args[1], args[2], args[3])});
			if(res[0]){
				if(res[0]._extended) JJ.extend(res, methods); //re-extend root element
				
				//play elements group events (overload result with functions)
				if(JJ.type(res[0], "Function") && name=="event"){ 
					var _res=res; 
					res=function(){
						for(var i=0, l=_res.length; i<l; i++) 
							if(_res[i]) 
								_res[i].apply(obj[i], arguments); 
					};
				}
			}
			return res;
		}
	};
	var attach=function(obj, name){
		//attach property to element or to elements group
		obj[name]=function(){return call(this, name, arguments)};
	};
	
	if(obj._extended) return false;
	obj._extended=true;
	for(var i in methods) attach(obj, i);
	
	return obj;
};

//wait for loading needed function or from other file
JJ.wait=function(func){
	try{ func() }catch(e){ setTimeout(func,10) }
};

JJ.create=function(tag){
	return JJ.extend(document.createElement(tag), JJ.element);
};


/*
Find Elements in DOM
	"*"                   //any tags
	"h1"                  //all <h1>
	"p a"                 //all nesting childs A <p><b><a>
	"p>a"                 //all siblings A <p><a>
	"p>*"                 //all siblings
	"p a, div a"          //multiply selection
	"#id"                 //id="id"
	".classname"          //class="classname"
	"[attr]"              //has this attr
	"[!attr]"             //hasn't this attr
	"[attr=value]"        //attr=value
	"[attr!=value]"       //attr!=value
	":^" ":0"             //first child
	":$"                  //last child
	":4"                  //child in position 4 (from 0)
	"<"                   //parent node
	"<div.classname"      //search div parent node with className
	"<:1"                 //return second parent node
	"+a"                  //next sibling element
	"+a:2"                //next (nearest with position) sibling element
	"-.classname"         //previous sibling element
	"()"                  //groups...
*/
JJ.getElements={
	parse:function(query, root){
		
		query=query.replace(/((^)|([ ><+\-,]))(([#.:\[,])|($))/g, "$1*$4")+" "; //set * for any tag
		root=root || document;
		
		var sep=" ><+-,", //levels separations
			breakset=" ><+-,:[", // breakset for conditions
			cond={"#":  breakset, ".":  breakset, ":":  breakset, "[":  "]"}, //out of fit condition
			prop={"#":"id", ".":"className", ":":"pos", "[":"attr", "<":"parentNode", "+":"nextSibling", "-":"previousSibling"}, //operations

			i=-1, c, fit, match, root_arr=[root], multi_arr=[], len=query.length;
		while(c=query.charAt(++i)){
			if(fit){
				if(cond[fit].indexOf(c)!=-1){ //out from fit
					fit=null;
					if(c=="]") match.attr=this.attr2struct(match.attr); //parse attribute
					else i--;
					continue;
				}
				match[prop[fit]]+=c; //add filter chars if in fit
			}
			else{
				if(sep.indexOf(c)!=-1){//if find separator
					if(match){
						this.init_match(match);
						root_arr=this.walk(match, root_arr); //search previous match
					}
					if(c==","){ //set next matches set
						multi_arr=multi_arr.concat(root_arr);
						root_arr=[root];
						match=null; 
						continue;
					}
					if(i==len-1) break; //exit if this is last instruction
					match={tag:"", child:c!=" ", move_to:prop[c]}; //init match if first sep
					continue;
				}
				if(!match){ //init match if first tag
					match={tag:c, child:false};
					continue;
				}
				if(c in cond){ //find filter fit
					match[prop[fit=c]]=""; //init current filter & set current prop
					continue;
				}
				match.tag+=c;
			}
		}
		if(multi_arr.length) root_arr=multi_arr.concat(root_arr);
			////alert(MATCH_DEBUG+"\n"+(root_arr.length==1?root_arr[0]:root_arr));
		return root_arr.length==1?root_arr[0]:(root_arr[0]?root_arr:undefined); //element or array
	},
	walk:function(match, root_arr){
			////MATCH_DEBUG.push(match);
		var root_el, i=0, new_arr=[];
		while(root_el=root_arr[i++]){
			var el, j=0, match_arr=[];
			if(match.only_id){
				if(el=document.getElementById(match.id)) new_arr[new_arr.length]=el;
				continue;
			}
			if(match.move_to){
				if(el=this.move(match, root_el)) new_arr[new_arr.length]=el;
				continue;
			}
			var nodes=match.child?root_el.childNodes:root_el.getElementsByTagName(match.tag); //get elements
			//filter nodes
			while(el=nodes[j++]){
				if(match.single_tag || this.check_filters(match, el))
					match_arr[match_arr.length]=el;
			}
			//position filter 
			if(match.pos){
				if(el=this.pos(match, match_arr)) new_arr[new_arr.length]=el;
				continue;
			}
			new_arr=new_arr.concat(match_arr); //add all mathes to array
		}
		return new_arr;
	},
	init_match:function(match){
		match.tag=match.tag.toUpperCase();
		if(match.tag=="*" && match.id && !match.className && !match.attr) match.only_id=1;
		if(!match.id && !match.className && !match.attr) match.no_prop=1;
		if(!match.child && match.no_prop) match.single_tag=1;
	},
	check_filters:function(match, el){
		if(match.child && (el.nodeType!=1 || (match.tag!="*" && match.tag!=el.tagName))) return false;
		if(match.no_prop) return true; //fast instruction [no_prop]
		if(match.id && match.id!=el.id) return false;
		if(match.className && !JJ.element.classname.exist(el, match.className)) return false;
		if(match.attr){
			var attr=JJ.element.attr.get(el, match.attr.key, 1);
			if(match.attr.equal==false && attr!=match.attr.value) return false;
			if(match.attr.equal==true && attr==match.attr.value) return false;
		}
		return true;
	},
	attr2struct:function(expr){
		var equal;
		if(expr.indexOf("!")==0){ expr=[expr.substr(1)]; equal=false;}
		else if(expr.indexOf("!")>0){ expr=expr.split("!="); equal=true;}
		else if(expr.indexOf("=")!=-1){ expr=expr.split("="); equal=false;}
		else {expr=[expr]; equal=true;}
		return {key:expr[0], value:expr[1], equal:equal};
	},
	pos:function(match, match_arr){ //return element by some position
		var pos;
		if(match.pos=="^") pos=0;
		else if(match.pos=="$") pos=match_arr.length-1;
		else if(JJ.type(match.pos, "Number")) pos=Number(match.pos);
		if(pos!=undefined && pos<match_arr.length) return match_arr[pos]; //match element
		return;
	},

	move:function(match, el){ //go to parentNode||nextSibling||previousSibling
		var pos=0;
		while(el=el[match.move_to])
			if(this.check_filters(match, el))
				if(Number(match.pos||0)==pos++) 
					break;
		return el;
	}
};

//Base methods for elements-----------------------------------------------------------------
JJ.element={};


/*
*Element foreach function
*(function(){})
*/
JJ.element.repeat={
	exec:function(obj, func){
		if(JJ.type(obj, "String")) return obj; //check obj for compatibility
		JJ.foreach(obj, func);
		return obj;
	}
};



/*
*Element attributes functions
*("id")                         //get attribute  #String
*(["id", "name", "href"])       //get attributes  #Hash
*("id", "ppp")                  //set attribute "id"="ppp"  #Element
*({name:"abc", param:1})        //set attributes from hash  #Element
*/
JJ.element.attr={
	exec:function(obj, name, value){
		if(JJ.type(obj, "String")) return obj; //check obj for compatibility
		if(JJ.type(name, "String")){
			if(value!=undefined) return this.set(obj, name, value);
			else return this.get(obj, name);
		}
		else if(JJ.type(name, "Object")){
			for(var i in name)
				this.set(obj, i, name[i]);
			return obj;
		}
		else if(JJ.type(name, "Array")){
			var hash={};
			for(var i=0, l=name.length; i<l; i++)
				hash[name[i]]=this.get(obj, name[i]);
			return hash;
		}
	},
	get:function(obj, name, only_tag_attr){
		var attr=obj.getAttribute?obj.getAttribute(name):undefined;
		if(attr==undefined && !only_tag_attr) attr=obj[name];
		if(attr=='' && obj.attributes && obj.attributes[name] && !obj.attributes[name].specified) attr=undefined; //for IE 
		return attr;
	},
	set:function(obj, name, value){
		if(obj.setAttribute && !JJ.type(value, "Function")) obj.setAttribute(name, value);
		obj[name]=value;
		return obj;
	}
};


/*
*Element events functions
*("onclick", function(){})                      //set event  #Element
*("onclick", "alert(1)")                        //set event  #Element
*({onclick:function(){}, onblur:"alert(1)"})    //set event set  #Element
*("onclick", null)                              //remove event  #Element
*("oncomplete")                                 //return event  #Function [default]
*("oncomplete(arg1, arg2,... )")            //return event and init arguments  #Function [default]
*("oncomplete(:Array)")                         //return all event entries  #Array of functions
*("oncomplete(:String)")                        //return event body  #String
*(["onclick","oncomplete"])                     //return set of events in Array #Array of functions [default]
*/
JJ.element.event={
	exec:function(obj, name, value){
		if(!obj.attachEvent && !obj.addEventListener) return obj; //check obj for compatibility
		if(JJ.type(name, "String")){
			if(value!==undefined) return this.set(obj, name, value);
			else return this.get(obj, name); 
		}
		else if(JJ.type(name, "Object")){
			for(var i in name)
				this.set(obj, i, name[i]);
			return obj;
		}
		else if(JJ.type(name, "Array")){
			var hash={};
			for(var i=0, l=name.length; i<l; i++)
				hash[name[i]]=this.get(obj, name[i]);
			return hash;
		}
	},
	set:function(obj, ev, func){
		if(func===null) return this.remove(obj, ev);
		var prev_func=this.get(obj, ev);
		func=this.toFunc(func, obj);
		var call=function(_this, args){
			if(prev_func) prev_func.apply(_this, args);
			return func.apply(_this, args);
		};
		this.rec(obj, ev, func); //write event to data array _onevent_=[]
		obj[ev]=function(){return call(this, arguments)}; //reinit element event
		return obj;
	},
	get:function(obj, ev){
		if(ev.indexOf("(")!=-1){
			var param=ev.split("(");
			ev=param[0];
			var _return=param[1].substr(0, param[1].length-1);
			var args="";
			switch(_return){
				case ":String": return this.toStr(obj["_"+ev+"_"]);
				case ":Array": return obj["_"+ev+"_"];
				default: args=_return;
			}
		}
		var attr=JJ.element.attr.get(obj, ev);
		var func=this.toFunc(attr, obj, args);
		return func;
	},
	remove:function(obj, ev){
		obj[ev]=function(){};
		return obj;
	},
	toFunc:function(attr, obj, args){
		var func;
		if(!attr) return function(){};
		if(JJ.type(attr, "String")) func=new Function(args, attr);
		else func=attr;
		return function(){return func.apply(obj, arguments)};
	},
	toStr:function(_evs){
		if(!_evs) return '';
		var str='';
		for(var i=0, l=_evs.length; i<l; i++){
			var s=_evs[i].toString();
			s=s.replace(/^function[^{]*\{(.*)/gi,"$1");
			s=s.substr(0, s.length-2);
			str+=s+"\n";
		}
		str=str.replace(/;([^\n])/gi,";\n$1");
		return str;
	},
	rec:function(obj, ev, func){

		var _ev="_"+ev+"_";
		if(!obj[_ev]){
			obj[_ev]=[];
			var prev_func=this.get(obj, ev);
			if(prev_func) obj[_ev].push(prev_func);
		}
		obj[_ev].push(func);
	}
};


/*
*Element styles functions (with isNaN check)
*("top")                           //get: "top"  #String or #Number
*(["top", "left"])                 //get: ["top", "left"]  #Hash     
*(["marginLeft", "height"], true)  //get all not empty: ["height"]  #Hash     
*("top", "20")                     //set: "top"="20px"  #Element
*("display", "none", "block")      //toogle: if(display==none) display=block  #Element
*({top:100,left:50})               //set: {top:"20px", left:"10px"}  #Element
*/
JJ.element.css={
	exec:function(obj, name, value, value2){
		if(!JJ.type(obj, "Element")) return obj; //check obj for compatibility
		if(JJ.type(name, "String")){
			if(value!=undefined){
				if(value2!=undefined && this.get(obj, name)==value) value=value2;
				return this.set(obj, name, value);
			}
			else return this.get(obj, name); 
		}
		else if(JJ.type(name, "Object")){
			for(var i in name)
				this.set(obj, i, name[i]);
			return obj;
		}
		else if(JJ.type(name, "Array")){
			var hash={};
			for(var i=0, l=name.length; i<l; i++){
				var val=this.get(obj, name[i]);
				if(!val && value) continue; //if (["top", "left"], true) - return only not empty values 
				hash[name[i]]=val;
			}
			return hash;
		}
	},
	//convert js style property to css property (zIndex -> z-index)
	js2css:function(prop){
		return prop.replace(/([A-Z])/g,"-$1").toLowerCase();
	},
	//get style
	get:function(obj, name){
		var value;
		if(obj.currentStyle) value=obj.currentStyle[name]; //IE, opera
		else if(window.getComputedStyle) value=window.getComputedStyle(obj, null).getPropertyValue(this.js2css(name)); //other Gesco
		else value=obj.style[name]; //other
		if(/^[0-9]+px/.test(value)) value=parseInt(value); //remove "px" [default] from number
		return value;
	},
	//set style 
	set:function(obj, name, value){
		var no_px={"zIndex":1, "opacity":1};
		if(value && JJ.type(value, "Number") && !(name in no_px)) value+="px"; //add "px" [default] to number
		if(name=="opacity" && BROWSER.ie){
			name="filter";
			value=(value==1?"":"Alpha(opacity="+(value*100)+")");
		}
		if(name=="float") name=BROWSER.ie?"styleFloat":"cssFloat";
		try{obj.style[name]=value;}catch(e){throw "element.css.set() -> obj.style."+name+"="+value};
		return obj;
	},
	//check style
	check:function(obj, name){
		return true;
	}
};


/*
*Element className functions
*()             //get className  #String
*("*")          //get all defined names in className  #Array
*("^")          //get first name  #String
*("$")          //get last name  #String
*("+name")      //add name to className  #Element
*("-name")      //remove name from className  #Element
*("!name")      //toogle name  #Element
*("?name")      //check name existing  #Boolean
*("name")       //set className  #Element
*("")           //clear className  #Element
*/
JJ.element.classname={
	exec:function(obj, query){
		if(obj.className==undefined) return obj; //check obj for compatibility
		if(query==null) return obj.className;
		var c=query.charAt(0);
		var name=query.substr(1);
		with(this){
			switch(c){
				case "*": return all(obj);
				case "^": return get(obj, 0);
				case "$": return get(obj, 1);
				case "+": add(obj, name); break;
				case "-": remove(obj, name); break;
				case "!": toogle(obj, name); break;
				case "?": return exist(obj, name);
				default:  set(obj, query);
			}
		}
		return obj;
	},
	empty:function(obj){
		return obj.className.replace(/\s/g,"")==""?true:false;
	},
	exist:function(obj, name){
		return (new RegExp('((^)|(\\s))'+name+'((\\s)|($))')).test(obj.className);
	},
	all:function(obj){
		return !this.empty(obj)?obj.className.split(/\s+/):[];
	},
	get:function(obj, pos){
		var arr=this.all(obj);
		if(!arr.length) return "";
		pos=pos?arr.length-1:0;
		return arr[pos];
	},
	set:function(obj, name){
		obj.className=name;
	},
	add:function(obj, name){
		this.remove(obj, name);
		obj.className+=obj.className?' '+name:name;
	},
	remove:function(obj, name){
		obj.className=obj.className.replace(new RegExp("((^)|(\\s))"+name+"((\\s)|($))"),"$3");
	},
	toogle:function(obj, name){
		this.exist(obj, name) ? this.remove(obj, name) : this.add(obj, name);
	}
};


/*
*Element insert functions
*("span")                       //append <span>
*("span:^")("span:0")           //insert <span> before first element
*("span:2")                     //insert <span> before second sibling
*("span", beforeElement)        //insert <span> before beforeElement
*("input", {type:"submit"})     //insert <input> and set attribute "type" before insert
*/
JJ.element.insert={
	exec:function(obj, tag, opt){
		if(!obj.appendChild) return obj; //check obj for compatibility
		var elem=tag;
		var beforeElement;
		if(JJ.type(tag, "String")){
			if(tag.indexOf(":")!=-1){
				var params=tag.split(":");
				tag=params[0];
				beforeElement=JJ.getElements.parse(">:"+params[1], obj);
			}
			elem=document.createElement(tag);
		}
		
		if(JJ.type(opt, "Object") && !opt.nodeType) JJ.element.attr.exec(elem, opt); //set element attributes before insert
		else beforeElement=opt; 
		
		beforeElement ? obj.insertBefore(elem, beforeElement) : obj.appendChild(elem);
		return _(elem);
	}
};

/*
*Element inner html
*("code")             //set innerHTML
*()                   //get innerHTML
*/
JJ.element.html={
	exec:function(obj, str){
		if(obj.innerHTML==undefined) return obj; //check obj for compatibility
		if(str==undefined) return obj.innerHTML;
		obj.innerHTML=str;
		return obj;
	}
};

/*
*Element remove function
*()                   //remove current element & return parent
*(child_el)           //remove child element & return current element
*/
JJ.element.remove={
	exec:function(obj, child_el){
		if(!obj.removeChild) return obj; //check obj for compatibility
		if(child_el==undefined){
			var par=obj.parentNode;
			par.removeChild(obj);
			return null;
		}
		else{
			var el=_(child_el);
			obj.removeChild(el);
			return obj;
		}
	}
};


/*
*Element activate or activate child (set classname="act")
*()                   //activate current element
*(2)                  //activate specified child element 
*/
JJ.element.act={
	exec:function(obj, num){
		var _this=this;
		if(!obj || !obj.tagName || !obj.parentNode) return false;
		if(obj.attr("noact")!=undefined) return false;
		var par=_(obj, "<");
		if(par.tagName=="LI" || par.tagName=="DT") par=_(par, "<");
		if(num!=undefined){
			par=obj; 
			obj=_(par, 'a:'+num);
		}
		if(!par.deact) par.deact=function(){_this.deact(this)}; //init funtion [set]
		if(par.cur==obj) return false;
		this.act(par, obj);
		obj.event("onact")(); //call [onact] event
		return false;
	},
	
	act:function(par, obj){
		if(!par.cur) par.cur=_(par, "a.act"); // if no [cur] try to find it
		if(par.cur) par.cur.classname("-act");
		obj.classname("+act");
		par.cur=obj;
	},
	deact:function(par){
		if(!par.cur) return false;
		par.cur.classname("-act");
		par.cur=null; 
		return false;
	}
};


JJ.element.offset={
	exec:function(obj){
		var left=0, top=0;
		if(obj.getBoundingClientRect){
			var box=obj.getBoundingClientRect();
			left=box.left+Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
			top=box.top+Math.max(document.documentElement.scrollTop, document.body.scrollTop);
		}
		else{
			
		}
		return {left:left, top:top};
	}
};



JJ.element.display={
	exec:function(obj, b, sender){
		var no_display=(obj.css("display")=="none");
		var no_visibility=(obj.css("visibility")=="hidden");
		if(!obj.display_default) obj.display_default=no_display?"block":obj.css("display");
		var b=(b==undefined?(no_display||no_visibility?1:0):b);
		obj.css({display:b?obj.display_default:"none"});
		return obj;
	}	
};

//element effects--------------------
JJ.element.slide={
	exec:function(obj, b, opt){
		if(!window.EFX) return obj;
		obj.smooth_slide=EFX.slide(obj, b, opt);
		//fade effect for Gesco
		if(obj.smooth_fade || obj.css("visibility")=="hidden"){
			if(!BROWSER.ie && !BROWSER.opera) obj.fade();
			else obj.css({visibility:"visible"});
		}
		return obj;
	}
};
JJ.element.fade={
	exec:function(obj, b, opt){
		if(!window.EFX) return obj;
		obj.smooth_fade=EFX.fade(obj, b, opt || {dyn:30});
		return obj;
	}
};
//---------------------------------------



//DOM extends
if(!String.prototype._extend) JJ.extend(String.prototype, JJ.element);
if(!Array.prototype._extend) JJ.extend(Array.prototype, JJ.element);
document.event=function(ev, func){JJ.element.event.exec(document, ev, func)};





//Externals-----------------------------------------------------------

var BROWSER={
	ie:(document.all && !window.opera)?true:false,
	ie6:navigator.appVersion.indexOf("MSIE 6")!=-1,
	ie7:navigator.appVersion.indexOf("MSIE 7")!=-1,
	chrome:navigator.appVersion.indexOf("Chrome")!=-1,
	safari:navigator.appVersion.indexOf("Safari")!=-1 && navigator.appVersion.indexOf("Chrome")==-1,
	opera:window.opera
};



var Class=function(proto){
	var obj=function(){this.init.apply(this, arguments)};
	obj.prototype=proto;
	obj.prototype.constructor=obj;
	return obj;
};



var Event=function(e){
	e=window.event?window.event:e;
	return {
		key:function(key){
			if(typeof key=="string"){
				var sysKey={ctrl:1, shift:1, alt:1};
				var customKey={enter:13, escape:27, space:32, tab:9, left:37, up:38, right:39, down:40};
				if(key in sysKey) return e[key+"Key"];
				else if(key in customKey) key=customKey[key];
				else key=key.charCodeAt(0);
			}
			var code=window.event?e.keyCode:e.which; 
			return key!=undefined?code==key:code;
		},
		target:function(){
			var target=window.event?e.srcElement:e.target; 
			return target;
		},
		mouse:function(v){ 
			var c={
				x:window.event?e.clientX+document.documentElement.scrollLeft:e.pageX, 
				y:window.event?e.clientY+document.documentElement.scrollTop:e.pageY
			};
			return v!=undefined?c[v]:c;
		},
		prevent:function(){ 
			if(window.event){ e.cancelBubble=true; e.returnValue=false;} 
			else if(e.preventDefault) e.preventDefault();
		},
		stop:function(){ 
			if(window.event){ e.cancelBubble=true; e.returnValue=false;} 
			else if(e.preventDefault) e.stopPropagation();
		}
	}
};



var COOKIE={
	set:function(name, value, expire) {
		if(expire){
			var d=new Date();
			d.setTime(d.getTime()+expire*1000);
			expire="; expires="+d.toUTCString();
		}
		else expire="";
		document.cookie=name+"="+escape(value)+expire+"; path=/";
	},
	get:function(name) {
		if(document.cookie.length==0) return false;
		var offset=document.cookie.indexOf(name+"=");
		if(offset!=-1) { 
			offset+=name.length+1;
			var end=document.cookie.indexOf(";", offset);
			if (end==-1) end=document.cookie.length;
			return unescape(document.cookie.substring(offset, end)) 
		}
		return false;
	}
};





//fix ie6 png & css :hover state
function ie6_fixes(root, prop){
	var base=_("base:^").href;
	_("*").repeat(function(){
		if(!this || ! this.currentStyle) return;
		if(prop.png && this.currentStyle[prop.png]){
			var src=base+(window.GLOBAL_PATH?GLOBAL_PATH:"")+this.currentStyle[prop.png].replace(/url\(['"]?([^'"]*)['"]?\)$/i,"$1");
			this.css({filter:'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+src+'",sizingMethod='+'crop'+')', background:"none"});
		}
		if(prop.hover && this.currentStyle[prop.hover]) {
			this.event("onmouseover", function(){ Style(this).add(this.currentStyle[prop.hover]); });
			this.event("onmouseout", function(){ Style(this).remove(this.currentStyle[prop.hover]); });
		}
	});
};


//debug output for Array & Hash objects (crusial in Chrome)
if(!BROWSER.chrome && !BROWSER.safari)
Array.prototype.toString =
Object.prototype.toString = function() {
	var cont = [];
	var addslashes=function(s){return s.split('\\').join('\\\\').split('"').join('\\"');};
	for (var k in this) { 
		if (cont.length) cont[cont.length-1] += ",";
		var v = this[k];
		var vs = ''; 
		if (v.constructor == String) vs = '"' + addslashes(v) + '"';
		else vs=v.toString();
		cont[cont.length]=k + ": " + vs;
	}
	cont = "	" + cont.join("\n").split("\n").join("\n	");
	var s = cont;
	if (this.constructor == Object) s = "{\n"+cont+"\n}";
	if (this.constructor == Array) s = "[\n"+cont+"\n]";
	return s;
};// GLOBAL PARAMETERS

var LANG="ua"; //default language

var GLOBAL_PATH="site/";
var IMGS_PATH=GLOBAL_PATH+"imgs/";

var AJAX_HANDLER=GLOBAL_PATH+"ajax.exe.php";
var CACHE_DEFAULT=60;  //default ajax cache [in minutes]
var DEBUGGER_ENABLED=1;

var UPLOAD_HANDLER="../../"+GLOBAL_PATH+"upload.php";//© <stipuha /> development (2008)
//> AJAX
//-------------------------------- 
//  ___example#1___
//  (req=new Ajax()).onready=function(response){ready_func(response)};
//	req.file="index.php";
//	req.query="abc=123&def=456";
//	req.send();
//
//  ___example#2___
//	new Ajax({
//		file:"index.php", 
//		query:"abc=123&def=456",
//		onready:function(response){ready_func(response)},
//		send:1
//	});


AJAX=new Class({
	
	CACHE:{},
	
	init:function(opt){
		opt=opt || {};
		this.method=opt.method || "http";
		this.file=opt.file || "";
		this.query=opt.query || "";
		this.caching=opt.caching || false;
		this.hash=opt.hash || {};
		this.onready=opt.onready || function(){};
		if(opt.onready) this.send();
	},
		
	send:function(){
		//add hash to query
		this.query+=this.json2query(this.hash);
		//if cache==true > call data from cache & return
		try{if(this.caching && this.CACHE[this.query]) return this.ondata(this.CACHE[this.query]);}catch(e){};
		
		var _this=this;
		var request, response;
		var SID=(new Date()).getTime()+Math.round(Math.random()*1000);
		
		switch(this.method){
			case "http":
				request=window.XMLHttpRequest?new XMLHttpRequest():(new ActiveXObject("Msxml2.XMLHTTP") || null); // ||"Microsoft.XMLHTTP" - ie5x
				if(request){
					request.open('POST', this.file, true);
					request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); // $_POST[] || $_REQUEST[]
					request.onreadystatechange=function(){
						if(request.readyState==4){
							try{
								if(request.getResponseHeader('Content-Type') && request.getResponseHeader('Content-Type').indexOf("/xml")!=-1) 
									response=_this.xml2json(request); //xml
								else 
									response=(new Function('return '+request.responseText))(); //json
							}
							catch(e){_this.onerror(request.responseText)}
							_this.ondata(response);
						}
					};
					request.send(this.query); //request send 
					break;
				}
				
			case "script":
				request=document.createElement("script");
				if(request){
					request.id=SID;
					var src=this.file+"?"+"_scriptID_="+request.id+"&"+this.query;
					if(BROWSER.ie) request.src=src.substr(0,2048); //MAX msie:2kb
					else{request.src=src; request.src=request.src.substr(0,4096)}; //MAX gesko:4Kb
					request.onreadystatechange=function(response){
						if(response && !response.initEvent){
							_this.ondata(response);
							setTimeout(function(){request.parentNode.removeChild(request)},13);
						}
					};
					document.body.appendChild(request); //request send 
					break;
				}
				
			case "form":
				var request=document.createElement(BROWSER.ie?"<iframe name="+SID+">":"iframe");
				if(request){
					request.name=SID;
					request.style.position="absolute";
					request.style.visibility="hidden";
					this.form.appendChild(request);
					//this.form.encoding="multipart/form-data";
					this.form.method="post";
					this.form.target=request.name;
					this.form.action=this.file+this.form.action.replace(/.*(\?.*)$/,"$1");
					request.onreadystatechange=request.onload=function(response){
						if(!request.readyState || request.readyState=="complete"){
							_this.ondata((new Function('return '+request.contentWindow.document.body.innerHTML))());
							setTimeout(function(){request.parentNode.removeChild(request)},13);
						}
					};
					this.form.submit(); //request send 
					break;
				}
				
			default: return request;
		}
	},
	
	ondata:function(response){
		if(this.caching || this.CACHE[this.query]) this.CACHE[this.query]=response; //cache response data
		this.response=response;
		this.onready(response);
	},
	
	json2query:function(hash, pref){
		var query="";
		for(var i in hash){
			if(!i) continue;
			var key=(pref?pref+"["+i+"]":i);
			query+=(typeof hash[i]=="object" ? this.json2query(hash[i],key) : "&"+key+"="+hash[i].toString().replace(/&/g, "%26"));
		}
		return query;
	},
	
	xml2json:function(request){
		var parseXML=function(node){
			if(node.childNodes.length==1 && (node.firstChild.nodeType==3 || node.firstChild.nodeType==4)) return node.firstChild.data; //if text node
			var hash={};
			for(var i=0, childs=node.childNodes, l=childs.length; i<l; i++)
				if(childs[i].nodeType==1)
					if(hash[childs[i].tagName]){ //if node has array type
						if(typeof hash[childs[i].tagName]=="string" || (typeof hash[childs[i].tagName]=="object" && !hash[childs[i].tagName].length)) 
							hash[childs[i].tagName]=[hash[childs[i].tagName]]; //reinit node (set array type)
						hash[childs[i].tagName][hash[childs[i].tagName].length]=parseXML(childs[i]);
						}
					else hash[childs[i].tagName]=parseXML(childs[i]);
			return hash;
		};
		var doc=BROWSER.ie?request.responseXML:(new DOMParser()).parseFromString(request.responseText, "text/xml"); //get XML content
		var response={obj:{}, text:''};
		if(doc && doc.documentElement) response.obj=parseXML(doc);
		return response;
	},
	
	onerror:function(message){alert("Server output error...\n"+message)}
});//© <stipuha /> development (2008)
//--------------------------------
//CLIENT CONFIGURATION
//--------------------
// define aref="?key1=value&key2=(this.value)&key3=(func())" (get query)
// define target="uid123" (unique tag id for ajax content)
// define autoload (automatic send get query on load content)
// define onstarting="func()" (event calling before ajax sending)
// define oncomplete="func()" (event calling when content already loaded)

//SERVER CONFIGURATION
//--------------------
// define $RESPONSE["complete"]=1 (condition for execute oncomplete function after POST query)
// define $RESPONSE["alert"]="message message message" (condition for open system information popup)



//> HTMLAJAX functionality
//----------------------------------
var HTMLAJAX=new Class({
	
	init:function(obj, ev){
		var _this=this;
		this.obj=_(obj);
		this.ev=ev;
		//init vars
		this.target=_(this.obj.attr("target"));
		this.append=this.obj.attr("append");
		this.indicatorShow=eval(this.obj.attr("indicator"));
		this.onstarting=this.obj.event("onstarting(event, request)");
		this.oncomplete=this.obj.event("oncomplete(response)");
		this.onfailure=this.obj.event("onfailure(response)");	
		
		//init ajax
		(this.req=new AJAX()).onready=function(response){_this.onready(response)};
		this.cache_time=this.obj.attr(obj,"cache")||this.obj.attr(obj.cache_obj,"cache");

		return this;
	},
	exec:function(){
		if(this.target) this.target.call_func=this.constructor.lastCall; //attach call ajax on target
		
		//execute sender callback function
		if(this.onstarting(this.ev, this.req.hash)==false) return false; //break if onstarting event return false
		
		//execute predefined basic operations
		if(this.constructor.onrequest(this.req.hash, this)==false) return false; //break if onbeforesend function  return false
		
		//try to set cache
		if(this.cache_time) this.constructor.cache.set(this.cache_time, this.req, this.obj||this.obj.cache_obj); 
		
		this.indicator(1);
		
		if(this.obj.in_process) return false;
		this.obj.in_process=true;
		
		this.req.send();
		return false;
	},
	onready:function(response){
		if(window.DEBUGGER_ENABLED)
			this.constructor.debug.add(response?"[target=\""+this.obj.target+"\"]\n"+"[ref=\""+this.req.query+"\"]\n"+"\n----------\n"+response.obj+"\n----------\n"+response.text:"\nNO RESPONSE!\n");
		
		this.failure=!response || response.obj.failure;
		this.complete=!this.failure && (response.obj.complete==undefined || (!isNaN(response.obj.complete) && Number(response.obj.complete))); 

		if(this.target && !this.failure){
			var holder=this.target;
			if(this.append)	holder=this.target.insert(this.append);
			holder.html(response.text); //if echo -- write innerHTML
			if(response.obj) this.targetProp(this.target, response.obj.target); //if target properties in response exist set properties to target
			if(window.init_content) init_content(holder);
		}
		
		this.indicator(0);
		this.obj.in_process=false;
		
		if(!this.failure) this.obj.act();
		
		//execute predefined basic operations
		this.constructor.onresponse(response, this);
		
		//execute sender callback function
		if(this.complete) this.oncomplete(response);
		else this.onfailure(response);
		
	},
	targetProp:function(target, props){
		if(props)
			for(var i in props)
				target[i]=props[i];
	},
	//show global ajax loading icon
	indicator:function(b){
		if(this.constructor.loader) _(this.constructor.loader).css({display:b?"block":"none"});
		if(this.target){
			this.target.css({opacity:b?0.5:1});
			if(this.indicatorShow){
				if(b) this.target.defaultHeight=this.target.css("height") || "auto";
				this.target.css("height", b?this.target.clientHeight:this.target.defaultHeight);
				if(b) this.target.html(this.constructor.loader?this.constructor.loader.alt:"...");
			}
		}
		return false;
	},
	//parse ajax referer link (ARL=aref)
	url2query:function(url){
		if(!url) return "";
		var file=url.replace(/([^?]*\/)*([^?]*)\??.*/,"$2"); //get file name
		if(file) this.req.file=file; //overwrite ajax handler file name
		url=url.replace(/[^?]*\??/,""); //get query [a=1&b=2&c=3]
		if(!url) return "";
		url=this.func2query(url); //check & try to execute function in query
		return url;
	},
	//parse form fields & create hash params
	form2query:function(form){
		if(!form.elements) return {};
		var hash={};
		for(var i=0;i<form.elements.length;i++){
			if(!form.elements[i]) continue;	
			if(form.elements[i].tagName=="FIELDSET" || form.elements[i].tagName=="OBJECT") continue;			
			if(form.elements[i].type=="checkbox") hash[form.elements[i].name]=(form.elements[i].checked?1:0);
			else if(form.elements[i].type=="radio"){ if(form.elements[i].checked) hash[form.elements[i].name]=form.elements[i].value;}
			else if(form.elements[i].type=="file") hash[form.elements[i].name]=form.elements[i];
			else hash[form.elements[i].name]=form.elements[i].value;
		}
		return hash;
	},
	//for function in query (dynamic executeble query)
	func2query:function(url){
		var dyn=url.match(/&?[a-z0-9_]+=\(%?[^&]+\)/gi);
		if(dyn && dyn.length){
			for(var i=0,a,l=dyn.length;i<l;i++){
				a=dyn[i].split(/=/);
				var ue=false;
				if(ue=/^\(%/.test(a[1]))a[1]=a[1].replace(/^\(%/, "("); //unescape definition
				var hash={};
				var key=a[0].replace(/&/,"");
				var value=(new Function('return '+a[1])).apply(this.obj);
				hash[key]=value;
				var res="";
				res=this.req.json2query(hash);
				if(ue && typeof res=="string") res=unescape(res);
				url=url.replace(/&?[a-z0-9_]+=\(%?[^&]+\)/i, res); //add value to query
			}
		}
		return url;
	}
});

//HTMLAJAX CACHE control functionality
HTMLAJAX.cache={
	MULTIPLIER:60*1000, // set cache in [minutes]
	from:(new Date()).getTime(),
	init:function(cache_time){
		var cache_param={};
		var ts=(new Date()).getTime();
		cache_param.period=Number(cache_time=="*"?(window.CACHE_DEFAULT?CACHE_DEFAULT:60):cache_time);
		cache_param.start=ts;
		cache_param.end=ts+cache_param.period*this.MULTIPLIER;
		return cache_param;
	},
	expire:function(cache_param){ //check cache time out
		var ts=(new Date()).getTime();
		if(cache_param.end<ts || cache_param.start<this.from){ //if cache time out replace cache params (start & end)
			cache_param.start=ts;
			cache_param.end=this.init(cache_param.period).end;
			return true;
		}
		return false;
	},
	set:function(cache_time, ajax, cache_obj){
		// from tag:  cache="5" (5 minutes cache) || cache="*" (default cache)
		if(cache_time && cache_obj){
			if(!cache_obj.cache_param) cache_obj.cache_param=this.init(cache_time);
			if(!this.expire(cache_obj.cache_param) && !cache_obj.nocaching) ajax.caching=true;
		}
	},
	reset:function(){this.from=(new Date()).getTime()}
};



//>-------------------------------
//> AJAX debugger console
//> Calling: ctrl+shift+q
HTMLAJAX.debug={
	win:null,
	data:'',
	limit:100*1024, //bytes [100Kb]
	init:function(){
		var _this=this;
		//attach debugger window call on key combination
		_(document).event("onkeyup", function(e){
			var ev=e?e:window.event;
			var key=ev.keyCode?ev.keyCode:ev.which;  
			//alert(ev.ctrlKey+","+ev.shiftKey+","+ev.altKey+","+key);	//ctrl+shift+q
			if(ev.ctrlKey  && ev.shiftKey  && (key==113 || key==81 || key==17) ) _this.winopen();
		});
		this.inited=1;
	},
	winopen:function(){
		this.win=window.open('', 'debug', 'scrollbars=no,status=yes,resizable=yes,width=780,height=560');
		this.load();
	},
	
	load:function(){
		this.win.document.open();
		this.win.document.write("<title>AJAX debugger</title><input type='button' value='refresh' onclick='window.opener.HTMLAJAX.debug.load()' /><div style='width:100%;height:95%;overflow-y:auto; border:1px solid #555; font:12px \"Courier New\"'>"+this.data+"</div>");
		this.win.document.close();
	},
	
	add:function(txt){
		if(!this.inited) this.init();
		if(this.data.length>this.limit) this.data=this.data.substr(-this.limit, this.limit).replace(/^.*<hr \/>/m, "...<br />"); //data limit
		txt=txt.replace(/={20,}/g,"");
		txt=txt.replace(/</g,"&lt;");
		txt=txt.replace(/>/g,"&gt;");
		txt=txt.replace(/\t/g,"&nbsp; ");
		txt=txt.replace(/\n/g,"<br />");
		var now=new Date();
		this.data+="<hr />";
		this.data+="["+this._0(now.getHours())+":"+this._0(now.getMinutes())+":"+this._0(now.getSeconds())+"]<br />";
		this.data+=txt+"<br /><br /><br />";
	},
	
	_0:function(num){return (num<10?"0"+num:num)}
};


HTMLAJAX.loader=null; //ajax loader icon
HTMLAJAX.lastCall=null; //last request which call ajax
HTMLAJAX.onrequest=function(request, htmlajax){}; //function is called before request sended
HTMLAJAX.onresponse=function(response, htmlajax){}; //function is called when response complete

//attach ajax handler for element (FORM or A)
HTMLAJAX.attach=function(obj){
	if(obj.attr("aref").indexOf("?")==-1) return false;
	if(obj.tagName=="FORM"){
		var func_submit=obj.onsubmit ? obj.event("onsubmit") : null;
		obj.onsubmit=function(e){if(!func_submit || (func_submit && func_submit())) GET(this, e); return false};
		if(obj.attr("autoload")!=undefined) obj.onsubmit();
	}
	else{
		if(obj.tagName=="A" && !obj.href) obj.href="#"; //set empty href value <a href="#"> (for non IE)
		if(!obj.onclick) obj.event("onclick", function(e){ return GET(this, e)});
		if(obj.attr("autoload")!=undefined) obj.onclick();
	}
};

// main handler
function GET(obj, event){
	if(!window.AJAX_HANDLER) return false;
	//HTMLAJAX.lastCall=function(e){window["GET"](obj,e)};
	obj=_(obj);
	var htmlajax=new HTMLAJAX(obj, event); /*init parent class*/
	htmlajax.req.file=AJAX_HANDLER;
	htmlajax.req.query=htmlajax.url2query(obj.ref||obj.aref||obj.attr("aref")||obj.attr("href")||obj.attr("action")); //set query params
	if(obj.tagName=="FORM") htmlajax.req.hash=htmlajax.form2query(obj);
	if(obj.nodeType!=1 && obj.hash) htmlajax.req.hash=obj.hash;
	if(!htmlajax.req.query && !obj.hash) return false; //exit if no parameters
	return htmlajax.exec();
};

/*
----------------------------------------------------------------------
EXAMPLE:

smooth=new Smooth({dyn:35, speed:-2, to:300});
smooth.onplay=function(pos){obj.style.height=pos+"px"};
smooth.onend=function(d){ _(obj).css({display:d>0?"block":"none"})};

----------------------------------------------------------------------
opt={
	dyn:     [-100..+100]   //dynamic scrolling (default:50)
	speed:   [-10..+10]     //scrolling speed (default:1)
	from:    [number]       //start position  (default:0)
	to:      [number]       //end position  (default:100)
}
methods={	
	go:      function(){};
	back:    function(){};
	start:   function(from, to){};
}
events={
	onstart: function(){};
	onplay:  function(){};
	onend:   function(){};
}
----------------------------------------------------------------------
*/

var Smooth=new Class({
	dyn:0,
	speed:1,
	from:0,
	to:100,
	init:function(opt){
		this.dyn=(opt.dyn!=undefined?opt.dyn:-50)/100;
		this.speed=opt.speed?(opt.speed>0?opt.speed:-1/opt.speed):1;
		this.from=opt.from!=undefined?opt.from:this.from;
		this.to=opt.to!=undefined?opt.to:this.to;
		this.onstart=opt.onstart || this.onstart;
		this.onplay=opt.onplay || this.onplay;
		this.onend=opt.onend || this.onend;
		if(opt.autostart) opt.autostart>0?this.start():this.toogle();
	},
	start:function(from, to){
		if(from!=undefined) this.from=from;
		if(to!=undefined) this.to=to;
		this.d=this.from<this.to?1:-1; //direction
		this.startPos=this.from;
		this.endPos=this.to;
		this.range=0;
		if(this.tm){
			clearTimeout(this.tm);
			this.tm=null;
		}
		else{
			this.onstart(this.d);
			this.curPos=this.from;
		}
		this.onplay(this.curPos);
		this.play(); 
	},
	play:function(){
		var _this=this;
		if(this.dyn!=0) this.range=Math.round((this.dyn>0?(this.endPos-this.curPos)*this.dyn:-(this.curPos-this.startPos)*this.dyn)*this.speed);
		if(this.range*this.d<1) this.range=this.d*this.speed;
		this.curPos+=this.range;
		if(this.endPos*this.d<this.curPos*this.d) return this.end();
		this.onplay(this.curPos, this.curPos/this.endPos);
		this.tm=setTimeout(function(){_this.play()}, 0);
	},
	end:function(){
		clearTimeout(this.tm);
		this.tm=null;
		this.curPos=this.endPos;
		this.onend(this.d);
		return false;
	},
	toogle:function(){
		var t=this.from;
		this.from=this.to;
		this.to=t;	
		this.start();
	},
	onstart:function(d){},
	onplay:function(curPos){},
	onend:function(d){}
});



var Transition=new Class({
	init:function(img, opt){
		var _this=this;
		this.img=img;
		this.dyn=opt.dyn!=undefined?opt.dyn:10;
		this.speed=opt.speed!=undefined?opt.speed:1;
		this.classname=opt.classname!=undefined?opt.classname:"disapear";
		this.hardhide=opt.hardhide?1:0;
		this.smooth=new Smooth({
			dyn:_this.dyn, 
			speed:_this.speed,
			onstart:function(){_this.inTransition=1},
			onplay:function(pos){img.css({opacity:pos/100})},
			onend:function(){_this.inTransition=0}
		});
	},
	appear:function(){
		var _this=this;
		if(this.hardhide && this.smooth_disapear) this.smooth_disapear.end(); //hardhide disappearing if new appear (appear new from dark)
		setTimeout(function(){_this.smooth.start()}, 0); //setTimeout used for IE
	},
	disappear:function(){
		var _this=this;
		if(this.inTransition) this.smooth.end();
		if(this.smooth_disapear) this.smooth_disapear.end();
		this.img_disapear=this.img.parentNode.insert(this.img.cloneNode(true)).classname(this.classname);
		this.smooth_disapear=new Smooth({
			dyn:_this.dyn, 
			speed:_this.speed,
			onplay:function(pos){_this.img_disapear.css({opacity:pos/100})},
			onend:function(pos){_this.smooth_disapear=_this.img_disapear=_this.img_disapear.remove();  },
			autostart:-1
		});
		this.img.css({opacity:0});
	}
});



var EFX={
	slide:function(obj, b, opt){
		var sm=obj._efx_slide;
		if(!sm){
			opt=opt || {};
			opt.dyn=opt.dyn!=undefined?opt.dyn:50;
			opt.speed=opt.speed!=undefined?opt.speed:-1;
			opt.onstart=function(d){obj.css({overflow:"hidden", paddingBottom:0, paddingTop:d<0?0:sm.css.paddingTop, height:sm.from, position:sm.css.position});};
			opt.onplay=function(pos){obj.css({height:pos}); };
			opt.onend=function(d){obj.css(sm.css); if(d<0) obj.css({display:"none"});};
			sm=obj._efx_slide=new Smooth(opt);
		}
		if(sm.tm) sm.toogle(); //if play is not finished
		else{
			var b=(b==undefined?(obj.css("display")=="none"?1:0):b);
			sm.css=obj.css(["overflow", "position", "paddingTop", "paddingBottom"]);
			if(obj.css("display")=="none") obj.css({position:"absolute", display:"block"}); //for height init
			sm.css.height=obj.css("height"); //fix for opera
			var end=obj.clientHeight-sm.css.paddingTop;
			sm.start(b?0:end, b?end:0);
		}
		return sm;
	},
	fade:function(obj, b, opt){
		var sm=obj._efx_fade;
		if(!sm){
			opt=opt || {};
			opt.dyn=opt.dyn!=undefined?opt.dyn:50;
			opt.speed=opt.speed!=undefined?opt.speed:-1;
			opt.onstart=function(d){obj.css({visibility:"visible", opacity:sm.from/100});};
			opt.onplay=function(pos){obj.css({opacity:pos/100}); };
			opt.onend=function(d){if(d<0) obj.css({visibility:"hidden"});};
			sm=obj._efx_fade=new Smooth(opt);
		}
		if(sm.tm) sm.toogle(); //if play is not finished 
		else {
			var b=(b==undefined?(obj.css("visibility")=="hidden"?1:0):b);
			var end=100;
			sm.start(b?0:end, b?end:0);
		}
		return sm;
	}
}

var Slider={
	init:function(id){
		var _this=this;
		this.id=id;
		this.root=_(id);
		this.root.defaultHeight=this.root.css("height");
		
		this.arr_prev=_(this.root, "a.arr_left");
		this.arr_prev.onclick=function(){return _this.move(-1)};
		this.arr_next=_(this.root, "a.arr_right");
		this.arr_next.onclick=function(){return _this.move(1)};
		
		this.lock_layer=_(this.root, "div.lock");
		
		this.uploadFiles=[];
		
		this.canvas=_(this.root, "div.canvas")
		this.canvas.event({ondelete:_this.canvas.attr("ondelete"), onmouseover:function(){this.focus()}, onscroll:function(){_this.scrollTM()} });
		this.smooth=new Smooth({dyn:35, speed:1});
		this.smooth.onplay=function(pos){_this.canvas.scrollLeft=pos};
		
		this.field=_(this.canvas, "div:^");
		this.reset();
		
		this.preState=0;
		this.imgLoader();
		
		this.inited=true;
	},
	setWidth:function(){
		var width=0;
		var inc=0;
		this.steps=[0];
		this.span=_(this.field, "span");
		this.root.css({height:this.span?this.root.defaultHeight:0}); //slider visibile if elements exists
		if(!this.span) return 0;
		for(var i=0;i<this.span.length; i++){
			var w=this.span[i].offsetWidth;
			if(inc+w>this.canvas.offsetWidth){
				this.steps[this.steps.length]=width;
				inc=0;
			}
			width+=w;
			inc+=w;
		}
		this.field.css({width:width});
		return width;
	},
	getPage:function(offset){
		for(var i=0;i<this.steps.length; i++){
			if(offset<this.steps[i]){
				//check if half of page are manualy scrolled
				if(i && offset>this.steps[i]-Math.round((this.steps[i]-this.steps[i-1])/2)) return i;
				//default page return
				else return i-1;
			}
		}
		return i;
	},
	move:function(d){
		if((d<0 && this.canvas.scrollLeft==0) || (d>0 && this.canvas.scrollLeft+this.canvas.offsetWidth==this.field.offsetWidth)) return false;
		var page=this.getPage(this.canvas.scrollLeft);
		if(page+d>=0 && page+d<this.steps.length) page+=d;
		this.smooth.start(this.canvas.scrollLeft, this.steps[page]);
		return false;
	},
	getLastVisibleImg:function(){
		for(var i=this.preState;i<this.span.length; i++){
			if(this.canvas.scrollLeft+this.canvas.offsetWidth<this.span[i].offsetLeft){
				break;
			}
		}
		return i;
	},
	imgLoader:function(){
		if(!this.span || this.preState==this.span.length) return false; //break if all imgs are loaded
		
		var to=this.getLastVisibleImg();
		if(to<=this.preState) return false;  //break if range imgs are loaded
		
		for(var i=this.preState;i<to; i++){
			var img=_(this.span[i], "img:^");
			if(!img.loaded){
				img.src=_(img).attr("presrc");
				this.initItem(this.span[i]);
				img.loaded=1;
			}
		}
		this.preState=to;
	},
	initItem:function(span){
		var _this=this;
		_(span, "a.delete").event({
			onclick:function(){return GET(this)},
			onstarting:function(){if(!_this.canvas.ondelete()) return false; span.className="disable"}, //disabled view status on deleting start
			oncomplete:function(){_this.removeItem(a)}
		});
	},
	removeItem:function(obj){
		this.preState--; //update preload state position
		this.field.removeChild(obj.parentNode); //remove node
		this.setWidth(); //field pane width reset
		this.imgLoader(); //load new visible image
		return false;
	},
	lock:function(b){
		this.lock_layer.css({display:b?"block":"none"});
	},
	reset:function(){
		this.canvas.scrollLeft=0;
		this.setWidth();
		this.lock(0); //lock slider after changes
		this.onreset();
	},
	add:function(id, img){
		if(!img){
			this.lock(1); //lock slider while uploading
			this.canvas.scrollLeft=0;
			this.field.css({width:Number(this.field.clientWidth+500)}); //IE fix
			this.uploadFiles[id]=this.field.insert("span", this.field.firstChild).classname("fixed");
		}
		else{
			this.uploadFiles[id].html(img).classname("");
			this.initItem(this.uploadFiles[id]);
			_(this.uploadFiles[id], "img:^").loaded=1;
		}
	},
	scrollTM:function(){
		var _this=this;
		if(this.tm) clearTimeout(this.tm);
		this.tm=setTimeout(function(){_this.onscroll()}, 100);
	},
	onscroll:function(){
		this.imgLoader();
	},
	onreset:function(){}
};


var Popup={
	init:function(){
		var _this=this;
		this.block=_(document.body).insert("div").attr({id:"popup"});
		this.but_close=this.block.insert("a").classname("close").event("onclick", function(){_this.hide()});
		this.block.insert("div").classname("top");
		this.body=this.block.insert("div").classname("body");
		this.block.insert("div").classname("bottom");
		_(document).event("onkeydown", function(e){
			if((Event(e).key("escape") || (Event(e).key("enter") && _this.hasOkButton())) && _this.isOpen) _this.hide();
		});
		this.modal=new Modal();
		this.inited=1;
	},
	showhide:function(b){
		this.modal.showhide(b);
		this.block.css({visibility:b?"visible":"hidden"});
		this.isOpen=b;
	},
	show:function(content){
		if(!this.inited) this.init();
		this.body.html(content);
		if(window.init_content) init_content(this.body);
		this.block.css({marginTop:-Math.round(this.block.offsetHeight/2)});
		this.showhide(1);
		return false;
	},
	hide:function(){
		this.showhide(0);
		this.body.html("");
		return false;
	},
	hasOkButton:function(){
		var okButton=_(this.block, "div.buts a");
		if(okButton && okButton.classname("?but_ok")) return true;
		else return false;
	},
	alert:function(content){
		return this.show(content);
	},
	confirm:function(content){
		return this.show(content);
	},
	win:function(content){
		return this.show(content);
	}
};


var Modal=new Class({
	init:function(opt){
		this.block=_(document.body).insert("div").classname("modal");
		this.layer=this.block.insert("span");
		if(opt && opt.opacity) this.layer.css({opacity:opt.opacity});
		this.inited=1;
	},
	showhide:function(b){
		this.block.css({display:b?"block":"none"});
		this.isOpen=b;	
	},
	show:function(opt){
		this.showhide(1);
	},
	hide:function(){
		this.showhide(0);	
	}
});
var IFS={
	list:{},
	create:function(){
		var _this=this;
		this.root=_(document.body).insert("div").attr({id:"ifs"});
		this.block=this.root.insert("div").classname("block");
		this.title=this.block.insert("div").classname("title");
		this.but={
			next:this.root.insert("a").classname("next").event("onclick", function(){_this.go(1)}),
			prev:this.root.insert("a").classname("prev").event("onclick", function(){_this.go(-1)}),
			close:this.block.insert("a").classname("close").event("onclick", function(){_this.hide()})
		};
		this.but.next.insert("i");
		this.but.prev.insert("i");
		this.body=this.block.insert("div").classname("body");
		this.img=this.body.insert("img").event("onload", function(){setTimeout(function(){_this.set()}, 100);});
		
		this.set_block(this.body.offsetWidth, this.body.offsetHeight);
		
		_(document).event("onkeydown", function(e){
			if(_this.isOpen){
				if(Event(e).key("escape")) _this.hide(); //escape
				if(Event(e).key("left")) _this.go(-1); //arr left
				if(Event(e).key("right")) _this.go(1); //arr right
			}
		});
		
		this.transition=new Transition(this.img, {speed:1, classname:"disapear"});
		this.modal=new Modal({opacity:0.8});
		this.inited=1;
	},
	init:function(obj){
		var _this=this;
		obj=_(obj);
		obj.group=obj.attr("ifs");
		if(!this.list[obj.group]) this.list[obj.group]=[];
		this.list[obj.group].push(obj);
		obj.event("onclick", function(){return _this.show(this, 1)});
	},
	showhide:function(b){
		this.modal.showhide(b);
		this.root.css({visibility:b?"visible":"hidden"});
		this.isOpen=b;
	},
	show:function(obj){
		if(!this.inited) this.create();
		this.img.src=obj.href;
		this.cur_pos=this.pos(obj);
		this.cur_list=this.list[obj.group];
		this.showhide(1);
		return false;
	},
	hide:function(){
		this.transition.disappear();
		this.img.classname("");
		this.title.html("");
		this.showhide(0);
		return false;
	},
	pos:function(obj){
		var group=this.list[obj.group];
		for(var i in group)
			if(group[i]==obj)
				return Number(i);
		return 0;
	},
	go:function(d){
		if(this.cur_pos+d<0 || this.cur_pos+d>this.cur_list.length-1) return false;
		this.cur_pos+=d;
		this.transition.disappear();
		this.img.classname("");
		this.img.src=this.cur_list[this.cur_pos].href;
		return false;
	},
	buts:function(){
		this.but.prev.classname((this.cur_pos==0?"+":"-")+"disable");
		this.but.next.classname((this.cur_pos==this.cur_list.length-1?"+":"-")+"disable");
	},
	set:function(){
		if(!this.isOpen) return false;
		var _this=this;
		if(this.cur_list && this.cur_pos!=undefined){
			this.title.html(this.cur_list[this.cur_pos].title);
			this.buts();
		}
		this.set_block(this.img.width, this.img.height);
		this.transition.appear();
		this.img.classname("show");
		this.onset(this);
	},
	set_block:function(w, h){
		var top=Math.round((document.documentElement.clientHeight-h)/2)-this.block.css("paddingTop");
		var scrollTop=document.documentElement.scrollTop;
		var left=-Math.round(w/2)-this.block.css("paddingLeft");
		this.root.css({top:(top>0?top+scrollTop:scrollTop)});
		this.block.css({width:w});
		this.body.css({width:w, height:h});
	},
	onset:function(_this){}
}
//> created by <stipuha />
//> Custom forms controls

var Forms={};


// reset form fields
Forms.reset=function(root){
	_(root, "input, select, textarea").repeat(function(){
		if(!this || this.attr("reset")=="false") return false;
		if(this.type=="file") this.parentNode.innerHTML=this.parentNode.innerHTML;
		if(this.type=="checkbox" || this.type=="radio") this.checked=this.getAttribute("checked");
		if(this.type=="text" || this.type=="password" || this.tagName=="TEXTAREA") this.value="";
		if(typeof this.reset=="function") this.reset(); //for custom select
		if(this.event("onreset")) this.event("onreset")(); //start onreset event
	});
	return false;
};


//fix textarea length
Forms.maxlength=function(obj){
	obj.maxlength=obj.attr("maxlength");
	var func=function(){if(this.value.length>this.maxlength) this.value=this.value.substr(0, this.maxlength)}
	obj.event({onkeyup:func, onkeypress:func});
};



Forms.dropAjaxFilter=function(input){
	//return false;
	var list=document.createElement("div");
	list.className="drop_filter";
	input.parentNode.insertBefore(list,input.nextSibling);
	list.style.display="none";
	input.inFocus=true;
	input.isOpen=false;
	input.onkeydown=function(e){if(Event(e).key("enter")) return false; } //lock form autosend
	input.onkeyup=function(e){
		if(this.isOpen && (Event(e).key("down") || Event(e).key("up"))) return list.act(e);
		if(Event(e).key("enter")) return list.exec();
		this._value=this.value; 
		if(this.value) GET(this);
		else list.close();
	}; 
	input.onfocus=function(){ this.onkeyup(); this.inFocus=true};
	input.onblur=function(){ list.close(); this.inFocus=false;};
	input.oncomplete="if(this.inFocus){ this.list.showhide(1); this.list.init(); }";
	input.onenter=_EV(input, "onenter");
	input.setAttribute("indicator","0");
	input.target=input.list=list;
	list.input=input;
	list.init=function(){
		var items=_(list, "~@a");
		if(!items) return list.showhide(0);
		for(var i=0; i<items.length; i++){
			items[i].onmousedown=function(){list.lock=true};
			items[i].onclick=function(){input.value=this.innerHTML; return list.go(); };
			items[i].onmouseup=function(){list.lock=false};
		}
	};
	list.close=function(){
		if(!list.lock) setTimeout(function(){list.showhide(0);},100);
	};
	list.showhide=function(b){
		input.isOpen=showhide(list,b);
	};
	list.exec=function(){
		 if(list.cur) input._value=input.value;
		 return list.go();
	};
	list.act=function(code){
		if(!list.firstChild) return false;
		var next;
		list.cur=_(list, "~a.act");
		if(list.cur) list.cur.className="";
		if(!list.cur) next=list[Event(e).key("down")?"firstChild":"lastChild"];
		else next=list.cur[Event(e).key("down")?"nextSibling":"previousSibling"];
		if(next){
			next.className="act";
			input.value=next.innerHTML;
			list.cur=next;
		}
		else input.value=input._value;
		return false;
	};
	list.go=function(code){
		 list.showhide(0); 
		 input.onenter();
		 return false;
	};
};



Forms.Default=new Class({
	init:function(obj, classname){
		var _this=this;
		this.obj=_(obj);
		this.text=obj.attr("default");
		this.classname=classname || "default";
		obj.event({
			onfocus:function(){_this.set(0)},
			onblur:function(){_this.set(1)}
		});
		this.set(1);
	},
	set:function(b){
		if(b && this.obj.value && this.obj.value!=this.text) b=0;
		this.obj.value=b?this.text:(this.obj.value==this.text?"":this.obj.value);
		this.obj.classname((b?"+":"-")+this.classname);
	}
});



//Custom select control
//--------------------------------
//> INITIALIZE
//  new Forms.Select(select_obj)

Forms.select=new Class({
	init:function(obj, active_classname){
		var _this=this;
		
		this.obj=_(obj);
		this.active_classname=active_classname || "select_active";
		
		this.root=JJ.create("span").classname("select "+obj.classname());
		this.root.event({
			onclick:function(){ if(!_this.renderComlete) _this.showhide(); _this.input.focus(); }, 
			onmousedown:function(){_this.lockBlur=1}, 
			onmouseup:function(){_this.lockBlur=0}
			});
		this.field=this.root.insert("span").classname("field").event({onclick: function(){if(_this.renderComlete) _this.showhide()}});
			
		//create hidden input element for submit
		this.input=this.field.insert("input", {type:"text"});
		this.input.attr({
			value:obj.value
		});
		this.input.attr({
			update:function(){_this.update()},
			reset:function(){_this.set(_this.input.defaultElement)},
			disable:function(b){_this.disable(b)}
		});
		//external events
		this.input.event({
			onchange:obj.onchange,
			onfocus:obj.onfocus,
			onblur:obj.onblur
		});
		this.input.event({
			onfocus:function(){ _this.active(1); },
			onblur:function(){if(!_this.lockBlur) _this.active(0)},
			onkeydown: function(e){ return _this.onkey(e)}
		});
		//copy all inline external attributes from select to input
		for(var i in obj.attributes){
			var item=obj.attributes[i];
			if(!item || !item.specified || (obj[item.name] && typeof obj[item.name]!="string" && typeof obj[item.name]!="boolean")) continue;
			this.input[item.name]=item.value;
		}
		
		this.holder=this.field.insert("span").classname("holder").attr({classdef:"holder"}).html("&nbsp;");
		this.arrow=this.field.insert("span").classname("arrow");
		this.dropdown=this.root.insert("span").classname("dropdown");
		
		this.root.input=this.input;
		this.input.root=this.root;
		
		this.input.options=[];
		if(obj.options.length)
			for(var i=0; i<obj.options.length; i++) {
				var el=_(obj.options[i]);
				var a=this.dropdown.insert("a")
					.classname(el.classname())
					.attr({value:el.value, i:i})
					.html(el.html()?el.html():"&nbsp;")
					.event({onclick:function(){return _this.set(this)}})
					;
				this.input.options.push(a);
				if(el.selected || obj.value==a.value) this.input.selected=this.input.defaultElement=a;
				if(el.attr("image")) a.insert("img", a.firstChild).attr({src:el.attr("image")});
			}
		
		//rendering ------------------------------------------------------------------------------
		this.obj.css({display:"none"});
		this.inherit={
			width:this.obj.css("width"),
			margin:this.obj.css(["marginTop", "marginRight", "marginBottom", "marginLeft"], true)
		};
		this.obj.parentNode.replaceChild(this.root, this.obj);
		
		if(!this.constructor.array) this.constructor.array=[];
		this.constructor.array.push(this.root); //add to constructor array (Forms.select.array)
		
		if(this.input.options.length) this.set(this.input.selected?this.input.selected:this.input.options[0]); //set default or act
		
		this.preRender(); //css rendering
		
		if(this.input.disabled) this.disable(1);
		this.isCreated=true;
	},
	
	preRender:function(){
		this.root.inherit={
			line:this.root.css("lineHeight"),
			paddingTB:this.root.css("borderTopWidth")+this.root.css("borderBottomWidth"),
			paddingLR:this.root.css("borderLeftWidth")+this.root.css("borderRightWidth")
		}
		this.root.inherit.height=this.root.inherit.line+this.root.inherit.paddingTB;
		if(this.root.css("position")=="static") this.root.css({position:"relative"});
		if(this.root.css("display")=="inline") this.root.css({display:"inline-block"});
		if(this.inherit.width && !isNaN(this.inherit.width)) this.root.css({width:this.inherit.width}); //set inherit width if exist
		this.root.css(this.inherit.margin); //set inherit not empty margins
		if(BROWSER.ie) [this.root, _(this.root, "<")].css({zIndex:100-this.constructor.array.length}); //fix z-index for IE
		this.input.css({position:"absolute", border:0, padding:0/*});*/, width:1, height:1, opacity:0});/**/
		this.field.css({display:"block", whiteSpace:"nowrap", cursor:"default"});
		this.dropdown.css({position:"relative", visibility:"hidden", overflowX:"hidden", overflowY:"auto", zIndex:2});
		this.input.options.css({display:"block", whiteSpace:"nowrap", textDecoration:"none"});
		this.arrow.css({position:"absolute", display:"block", top:0, right:0, cursor:"pointer", height:this.root.inherit.height});
		//*/fix
		this.dropdown_inherit=this.dropdown.css(["display", "marginLeft", "height"]);
		this.dropdown.css({display:BROWSER.ie?"":"table-row-group",  marginLeft:-this.root.inherit.paddingLR, height:0});
		this.root_inherit=this.root.css(["verticalAlign"]);
		this.root.css({height:this.root.inherit.height, verticalAlign:"middle"});/**/
		
		if(this.root.offsetWidth) this.postRender(); //render if element is visible
	},
	
	postRender:function(){
		//*/unfix
		this.root.css(this.root_inherit);
		this.root.css({height:"auto"});
		this.dropdown.css(this.dropdown_inherit);/**/
		
		this.root.css({width:this.root.offsetWidth-this.root.inherit.paddingLR}); //fix width
		this.field.css({width:this.root.clientWidth-this.field.css("borderLeftWidth")-this.field.css("borderRightWidth")-this.field.css("marginRight")-this.field.css("marginLeft")});
		this.dropdown.css({position:"absolute"});
		this.dropdown.css({top:this.root.clientHeight, left:-this.root.css("borderLeftWidth"), width:this.root.clientWidth});
		if(BROWSER.ie6 && this.dropdown.currentStyle["max-height"]) this.dropdown.css({height:this.dropdown.currentStyle["max-height"]}); //fix for ie6
		this.renderComlete=true;
	},
	
	showhide:function(d){
		if(this.input.disabled) return false;
		if(d==undefined) d=this.dropdown.css("visibility")!="visible";
		this.dropdown.css({visibility:d?"visible":"hidden"});
		this.isOpen=d;
		return false;
	},
	
	set:function(obj, lock_hide){
		var _this=this;
		this.input.prevValue=this.input.value;
		this.input.value=obj.value;
		this.input.selected=obj;
		
		setTimeout(function(){_this.holder.html(obj.html())},0);
		this.holder.classname(this.holder.classdef+" "+obj.classname());
		
		if(!lock_hide && this.isCreated) this.showhide(0);
		
		if((this.isCreated && this.input.prevValue!=this.input.value) || (!this.isCreated && this.input.autoload!=undefined)){
			if(this.input.onchange) this.input.onchange(); //call onchange event
		}
		
		//act element in dropdown
		if(this.cur) this.cur.classname("-act");
		this.cur=obj;
		this.cur.classname("+act");
		
		return false;
	},
	
	update:function(){
		for(var i=0; i<this.input.options.length; i++) {
			if(this.input.options[i].value==this.input.value){
				this.set(this.input.options[i]);
				break;	
			}				
		}
	},
	
	disable:function(b){
		this.input.disabled=b;
		this.root.css({opacity:b?0.5:1});
	},
	
	active:function(b){
		if(!this.renderComlete) this.postRender();
		this.root.classname((b?"+":"-")+this.active_classname);
		if(!b && this.isOpen) this.showhide(0); //hide dropdown if select blur
	},
	
	onkey:function(e){
		if(Event(e).key("tab")) return true;
		if(Event(e).key("up") && this.cur.i) this.set(this.input.options[this.cur.i-1], true);
		if(Event(e).key("down") && this.cur.i<this.input.options.length-1) this.set(this.input.options[this.cur.i+1], true);
		if(Event(e).key("enter") || Event(e).key("space")) this.showhide(this.isOpen?0:1);
		if(Event(e).key("escape") && this.isOpen) this.showhide(0);
		return false;
	}
	
});

function slideshow(obj, count){
	var root=_(obj, "<");
	//init
	if(count){
		root.index=0;
		root.loop=1;
		root.count=count;
		root.cur=_(obj);
		root.create=function(index){
			var src=root.cur.src.replace(/s[0-9]+/, "s"+Number(index+1));
			root.insert("img").attr({src:src}).css({opacity:0}).event("onload", function(){root.next()});
		}
		root.playStart=function(next, index){
			var prev=root.cur;
			root.cur=next;
			root.index=index;
			root.cur.css({zIndex:root.loop++});
			var smooth=new Smooth({dyn:0, speed:1.5});
			smooth.onplay=function(pos){root.cur.css({opacity:pos/100})};
			smooth.onend=function(){root.playEnd(prev)};
			smooth.start();
		}
		root.playEnd=function(prev){
			prev.css({opacity:0});
			root.next();
		}
		root.next=function(){
			var index=root.index+1;
			if(index>=root.count) index=0;
			var next=_(root, "img:"+index);
			if(next) setTimeout(function(){root.playStart(next, index)}, 4000);
			else root.create(index);
		}
		root.next();
	}
	
};



function init_mail(id) {
	var obj=_(id);
	var mail=obj.lang+"@"+obj.href.replace(/http:\/\/([^\/]*)\/?/, "$1");
	obj.href="mailto:"+mail;
	//if(obj.innerHTML == '') obj.innerHTML=mail;
	if(!obj.getElementsByTagName("*")[0]) obj.html(mail);
};



var imageCategories={
	change_post_param:function (obj, param, value){
		obj.target=obj.target.replace(/_[0-9]+$/, "_"+value);
		if(!obj.swf) obj.onmouseover();
		JJ.wait(function(){obj.swf.addPostParam(param, value)});
	},
	add:function (obj, target, response){
		_(target).insert("option").attr({value:response.obj.id}).html(obj.title.value);
		obj.title.value='';
	}
};



var TableFilter={
	init:function(id){
		var _this=this;
		this.root=_(id);
		this.blocks=_(id, "tr.filters td").repeat(function(){this.div=_(this,"div")});
		this.rows=_(id, "tr.link").repeat(function(){this.td=_(this,"td")});
		this.filters=_(id, "tr.filters a").event("onclick", function(){_this.set(this)});
	},
	set:function(obj){
		obj.act();
		var par=obj.parentNode;
		par.value=par.cur.attr("value");
		this.build();
	},
	build:function(){
		for(var j=0;j<this.rows.length;j++)
			this.rows[j].lock=false;
			
		for(var i=0;i<this.blocks.length;i++){
			if(!this.blocks[i].div) continue;
			for(var j=0, b;j<this.rows.length;j++){
				if(this.blocks[i].div.attr("type")=="group") b=this.blocks[i].div.value==this.rows[j].td[i].innerHTML;
				if(this.blocks[i].div.attr("type")=="range") b=Number(this.blocks[i].div.value)>=Number(this.rows[j].td[i].innerHTML.replace(/([0-9]+).*/, "$1"));
				b=b || !this.blocks[i].div.value;
				if(!this.rows[j].lock && b) this.rows[j].css({display : BROWSER.ie?"":"table-row"});
				if(!b) this.rows[j].css({display : "none"});
				this.rows[j].lock=true;
			}
		}
		document.documentElement.scrollTop=this.root.offsetTop+400;
	}
};if(GOOGLE_ANALYTICS) document.write('<script type="text/javascript" src="http://www.google-analytics.com/ga.js"></script>');

document.onload=function(){
	if(arguments.callee.inited) return;
	else arguments.callee.inited=1;
	if(GOOGLE_ANALYTICS) GA();
	init_content(document);
};



var pageTracker;
function GA(){
	try {
		pageTracker = _gat._getTracker(GOOGLE_ANALYTICS);
		pageTracker._trackPageview();
	} catch(err) {}
}

JJ.element.event.set(window, "onload", function(){
});




//AJAX response listeners
HTMLAJAX.onresponse=function(response, htmlajax){
	if(!response || !response.obj) return;
	if(response.obj.alert) Popup.show(response.obj.alert);
	if(response.obj.redirect!=undefined) location.href=response.obj.redirect;
};



//initialize output content
function init_content(root){
	
	
	if(BROWSER.ie6) ie6_fixes(root, {png:"ie6-png-background", hover:"ie6-hover-class"});
	
	
	_(root, "script").repeat(function(){
		//if((tags[i].type=="ajax/javascript")){
		if(root!=document){
			var func=(new Function(this?this.innerHTML:""));
			if(!this.src) func.apply(this); //normal script execution
			else try{func.apply(this)}catch(e){Script.preload(this)}; //modular script execution
		}
	});
	

	_(root, "form[aref], a[aref]").repeat(function(){
		HTMLAJAX.attach(this);
	});
	
	_(root, "a[type=submit]").repeat(function(){
		this.event("onclick", function(){_(this, "<form").onsubmit()}).insert("input", {type:"submit"}).css({width:1, height:1, border:0, opacity:0,  position:"absolute"});
	});
	
	_(root, "a[ifs]").repeat(function(){
		IFS.init(this);
	});
	
	_(root, "a[swfupload]").event("onmouseover", function(){
		new Upload(this, this.attr("swfupload"));
	});
	
	_(root, "table.catalog tr.link").event("onclick", function(){location.href=_("base").href+this.attr("href")});
	
	
	_(root, "select").repeat(function(){
		new Forms.select(this);
	});
	
	//document.onmousemove=function(e){var c=Coord(e); _("mimg").innerHTML=document.elementFromPoint(c.x,c.y).tagName};
	
};


