
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) els=""; //if no element return empty string
	
	JJ.extend(els, JJ.element); //exend one element
	
	if(JJ.type(els, "Array")) 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...
	["p a"]               //return array of <a> (even if one element found)
*/
JJ.getElements={
	parse:function(query, root){
		var return_array_reqired=false;
		if(JJ.type(query, "array")){
			query=query[0];
			return_array_reqired=true;
		}
		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 && !return_array_reqired?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 value!==undefined?obj:function(){}; //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
		if(ev=='onmousewheel' && obj.addEventListener){
			obj.addEventListener('DOMMouseScroll', obj[ev], false);
			obj.removeEventListener('DOMMouseScroll', prev_func, false);
		}

		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 is_unsigned={"width":1, "height":1};
		if(name in is_unsigned && value<0) value=0; 
		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(b, opt);
			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);
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;
	},
	all:function(arr){
		arr=arr || [];
		var i, cookieArray = document.cookie.split(';'), caLength = cookieArray.length, c, eqIndex, name, value;
		for (i = 0; i < caLength; i++) {
			c = cookieArray[i];
			
			// Left Trim spaces
			while (c.charAt(0) === " ") {
					c = c.substring(1, c.length);
			}
			eqIndex = c.indexOf("=");
			if (eqIndex > 0) {
					name = c.substring(0, eqIndex);
					value = c.substring(eqIndex + 1);
					arr[name] = value;
			}
		}
		return arr;
	}
};





//fix ie6 png & css :hover state
function ie6_fixes(root, prop){
	var base=_("base:^").href;
	_(root, "*").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]); });
		}
	});
};


function flashDetect(){
	if(typeof navigator.plugins!=undefined && typeof navigator.plugins["Shockwave Flash"]=="object"){
		var d=navigator.plugins["Shockwave Flash"].description;
		if (d && !(typeof navigator.mimeTypes!=undefined && navigator.mimeTypes["application/x-shockwave-flash"] && !navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)){
			return true;
		}
	}
	else if(typeof window.ActiveXObject!=undefined) {
		try{
			var a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");  //return null when ActiveX is disabled
			if(a){
				var d=a.GetVariable("$version");
				if(d){
					return true;
				}
			}
		}
		catch(e){}
	}
	return false;
}

function _uid(){
	return (new Date()).getTime()+Math.round(Math.random()*1000);
}



//debug output for Array & Hash objects
var o2s = function(o) {
	if(o.constructor == String) return o;
	var cont = [];
	var addslashes=function(s){return s.split('\\').join('\\\\').split('"').join('\\"');};
	for (var k in o) { 
		if (cont.length) cont[cont.length-1] += ",";
		var v = o[k];
		var vs = ''; 
		if (v.constructor == Object || v.constructor == Array) vs=o2s(v);
		else if (v.constructor == String) vs = '"' + addslashes(v) + '"';
		else  vs = v;
		cont[cont.length]=k + ": " + vs;
	}
	cont = "	" + cont.join("\n").split("\n").join("\n	");
	var s = cont;
	if (o.constructor == Object) s = "{\n"+cont+"\n}";
	if (o.constructor == Array) s = "[\n"+cont+"\n]";
	return s;
};


_alert=function(str){alert(o2s(str))};// GLOBAL PARAMETERS

var LANG="de"; //default language

var GLOBAL_URL=location.protocol+"//"+location.host+"/";

var GLOBAL_PATH="front/default/";
var IMGS_PATH=GLOBAL_PATH+"imgs/";

var AJAX_HANDLER = GLOBAL_URL+"index.php?ajax=1";
var CACHE_DEFAULT=60;  //default ajax cache [in minutes]
var DEBUGGER_ENABLED=1;

//© <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").replace(/\+/g, "%2B"));
		}
		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=this.target?this.target.attr("indicator"):0;
		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("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.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){
			if(this.indicatorShow){
				if(!isNaN(this.indicatorShow)){
					if(!this.modal && window.Modal) this.modal=new Modal({opacity:this.indicatorShow, bgcolor:"#fff", loader:""});
					if(this.modal) this.modal.showhide(b);
				}
				else{
					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.indicatorShow);
				}
			}
			else this.target.css({opacity:b?0.5:1});
		}
		return false;
	},
	//parse ajax referer link (ARL=aref)
	url2query:function(url){
		if(!url) return "";
		var file=url.replace(/([^?]*)\??.*/,"$1"); //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);
			if(form.elements[i].type=="checkbox"){ if(form.elements[i].checked) hash[form.elements[i].name]=form.elements[i].value || "on";}
			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.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)).css({position:"absolute", zIndex:1, top:this.img.offsetTop, left:this.img.offsetLeft});
		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.isVisible!=undefined && sm.isVisible===b) return false;
		if(sm.tm) sm.toogle(); //if play is not finished
		else{
			var is_hidden=(obj.css("display")=="none");
			b=sm.isVisible=(b==undefined?(is_hidden?1:0):b);
			if(!is_hidden) obj.css({display:"none"});
			sm.css=obj.css(["overflow", "position", "paddingTop", "paddingBottom", "height"]);
			if(is_hidden) obj.css({position:"absolute"}); //for height init
			obj.css({display:"block"});
			var end=obj.offsetHeight-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.isVisible!=undefined && sm.isVisible===b) return false;
		if(sm.tm) sm.toogle(); //if play is not finished 
		else {
			b=sm.isVisible=(b==undefined?(obj.css("visibility")=="hidden"?1:0):b);
			var end=100;
			sm.start(b?0:end, b?end:0);
		}
		return sm;
	}
};

var Slider=Class({
	_item_active_classname:"act",
	
	init:function(root, opt){
		var _this=this;
		var opt=opt || {}
		this.root=root;
		this.slideshow=opt.slideshow || 0; //autoplay slideshow mode
		this.items=_(this.root, "a");
		this.items
			.repeat(function(i){this.num=i; this.block=_(this.href.replace(/^.*#/, ""))})
			.event({onclick:function(){_this.stop(); return _this.set(this)}});
		this.set(this.items[0]);
	},
	set:function(obj){
		var _this=this;
		if(typeof obj=="number") obj=this.items[obj];
		if(this.cur==obj) return false;
		if(this.cur){
			this.showhide(this.cur.block, 0, function(){_this.showhide(obj.block, 1)});
			this.cur.classname("-"+this._item_active_classname);
		}else{
			obj.block.css({display:'block'})
		}
		obj.classname("+"+this._item_active_classname);
		this.cur=obj;
		if(this.slideshow) this.play();
		return false;
	},
	go:function(d){
		var num=this.cur.num+d;
		if(num>=this.items.length) num=0;
		if(num<0) num=this.items.length-1;
		this.set(this.items[num]);
		return false;
	},
	play:function(d){
		var _this=this;
		if(!this.tm) this.tm=setInterval(function(){_this.play(1)}, this.slideshow);
		if(d) this.go(d);
	},
	stop:function(){
		if(!this.tm) return false;
		clearInterval(this.tm);
		this.tm=null;
	},
	showhide:function(block, b, callback){
		if(this.smooth && this.smooth.tm) this.smooth.end();
		this.smooth=new Smooth({
			dyn:10, 
			speed:b?1:2,
			from:b?0:100,
			to:b?100:0,
			onstart:function(){block.css({opacity:b?0:100, display:'block'});},
			onplay:function(pos){block.css({opacity:pos/100})},
			onend:function(){if(callback) callback()},
			autostart:1
		});
	}
});



var SlideShow=Class({
	init:function(elems){
		var _this=this;
		this.root=_(elems.root);
		this.photoBlock=_(this.root, elems.photo).event({onmouseover:function(){_this.show_hint(1)}, onmouseout:function(){_this.show_hint(0)}});
		this.link=_(this.root, elems.link);
		this.img=_(this.root, elems.image).event({onload:function(){setTimeout(function(){_this.set()}, 100);}});
		this.hint=_(this.root, elems.hint);
		this.title=_(this.root, elems.title);
		this.slider=_(this.root, elems.slider);
		this.slider_canvas=_(this.root, elems.slider_canvas);
		this.slider_items=_(this.root, [elems.slider_items])
			.repeat(function(i){this.i=i; this.alt=_(this, "img").alt;})
			.event({onclick:function(){return _this.go(this)}});
		this.slider_items_img=_(this.root, [elems.slider_items+" img"]).event({onload:function(){ _this.slider_post_init() }});
			
		if(!this.slider_items.length) return this.root.css({display:"none"});
		this.count_slides_loaded=0;
		
		this.slider_init();
		this.fancybox(); //init fansybox controls
		
		
		this.transition=new Transition(this.img, {dyn:10, speed:-1, classname:"disapear"});
		
		this.photoBlock.css({height:this.root.offsetHeight-this.slider.offsetHeight});
		this.cur=this.slider_items[0];
		this.cur.act();
		this.set(); //scale default image oninit
	},
	go:function(obj){
		if(this.cur==obj) return false;
		obj.act();
		this.transition.disappear();
		this.link.href=this.img.src=obj.href;
		this.cur=obj;
		this.inited=1;
		return false;
	},
	set:function(){
		this.title.html(this.cur.alt);
		this.scale();
		if(this.inited) this.transition.appear();
	},
	show_hint:function(b){
		var _this=this;
		if(!this.cur || !this.cur.alt) return false;
		if(b){ if(!_this.tm) this.hint.slide(1); else clearTimeout(this.tm);}
		else this.tm=setTimeout(function(){_this.hint.slide(0); _this.tm=null}, 0);
	},
	scale:function(){
		this.img.css({width:"auto", height:"auto", top:0});
		var dp=this.photoBlock.offsetWidth/this.photoBlock.offsetHeight;
		var di=this.img.offsetWidth/this.img.offsetHeight;
		if(dp>di) this.img.css({width:this.photoBlock.offsetHeight*di, height:this.photoBlock.offsetHeight});
		else this.img.css({width:this.photoBlock.offsetWidth, height:this.photoBlock.offsetWidth/di});
		if(di>1) this.img.css({top:(this.photoBlock.offsetHeight-this.img.offsetHeight)/2});
	},
	
	//slider---------------------------------------
	slider_init:function(){
		var _this=this;
		this.slider.event({onmouseover:null}); //remove init handler
		this.slider.event({
			onmouseover:function(){if(!_this.sliderOver) this.focus(); _this.sliderOver=1; if(_this.stm) clearTimeout(_this.stm); },
			onmouseout:function(){_this.sliderOver=0; _this.stm=setTimeout(function(){_this.slideSpeed=0; _this.stm=null}, 0);},
			onmousemove:function(e){_this.slider_set(e)}
		});
		this.slider.absLeft=this.slider.offset().left;
		this.slideSpeed=0;
	},
	slider_post_init:function(){
		this.count_slides_loaded++;
		if(this.count_slides_loaded!=this.slider_items.length) return false;
		var _this=this;
		var last_item=this.slider_items[this.slider_items.length-1];
		var width=last_item.offsetLeft+last_item.offsetWidth;
		last_item.css({marginRight:0});
		this.slider_canvas.css({width:width});
		if(this.fancy_canvas) this.fancy_canvas.css({width:width});
		//alert(width)
	},
	slider_set:function(e){
		var pos=Event(e).mouse("x")-this.slider.absLeft;
		var zoneSize=this.slider.offsetWidth/3;
		if(pos<zoneSize) this.sliderVector=(pos-zoneSize)/(zoneSize/10); 
		else if(pos>this.slider.offsetWidth-zoneSize) this.sliderVector=(pos-this.slider.offsetWidth+zoneSize)/(zoneSize/10); 
		else this.sliderVector=0;
		if(this.sliderVector && !this.sliderTM) this.slider_play();
	},
	slider_play:function(){
		var _this=this;
		if(this.sliderTM){
			clearTimeout(this.sliderTM);
			this.sliderTM=null;
		}
		if(this.slideSpeed!=this.sliderVector) this.slideSpeed+=(this.slideSpeed<this.sliderVector?1:-1)/5;
		if(!this.sliderOver || !this.slideSpeed) return false;
		this.slider.scrollLeft+=this.slideSpeed;
		this.sliderTM=setTimeout(function(){_this.slider_play()}, 10);
	},
	fancybox:function(){
		if(!window.$)  return false; //if !jQuery
		var _this=this;
		this.fancy_canvas=_(this.slider_canvas.cloneNode(true)).css({position:"absolute", visibility:"hidden", width:this.slider_canvas.offsetWidth});
		this.fancy_items=_(this.fancy_canvas, ["a"]).repeat(function(i){ this.rel="group_slide"});
		$(this.fancy_items).fancybox({'titleShow':false, 'transitionIn':'elastic','transitionOut':'elastic','overlayOpacity':0.7,'overlayColor':'#000'});
		this.slider.insert(this.fancy_canvas);
		this.link.event({onclick:function(){ $(_this.fancy_items[_this.cur.i]).click(); return false;}});
		
	}
});//> Move html objects control
//--------------------------------
//> INITIALIZE
//  obj.move=new Move(obj, {x:[0,100], y:[10,50], disabled:true, parent:obj.parentNode.parentNode});
//  obj.move.onmove=function(per){this.obj.inp.value=Math.round(this.obj.range*per);};

var Move=new Class({
	init:function(obj, opt){
		var _this=this;
		//options
		var opt=opt?opt:{};
		this.disabled=opt.disable!=undefined ? opt.disable : false;
		this.parent=opt.parent ? opt.parent : obj.parentNode; //used for detection parent bounds
		
		if(opt.x) this.x=[opt.x[0]!=undefined?opt.x[0]:0, opt.x[1]!=undefined?opt.x[1]:this.parent.offsetWidth-obj.offsetWidth];
		if(opt.y) this.y=[opt.y[0]!=undefined?opt.y[0]:0, opt.y[1]!=undefined?opt.y[1]:this.parent.offsetHeight-obj.offsetHeight];
		//global
		this.obj=obj;
		this.isDraging=false;
		this.defaultCursor=this.obj.style.cursor;
		this.range={x:(this.x?this.x[1]-this.x[0]:0), y:(this.y?this.y[1]-this.y[0]:0)};
		
		//attach
		this.obj.onmousedown=function(e){_this.start(e)};
		//this.parent.onclick=function(e){_this.start(e)};
	},
	start:function(e){
		if(this.disabled) return false;
		var _this=this;
		this.onstart();
		Event(e).prevent();
		this.obj.style.cursor=this.x && this.y ? "move" : (this.y ? "n-resize" : (this.x ? "e-resize" : "pointer") );
		this.obj.style.margin="0px";
		this.offset={x:Event(e).mouse("x")-this.obj.offsetLeft, y:Event(e).mouse("y")-this.obj.offsetTop};
		this.isDraging=true;
		document.onmousemove=function(e){ _this.move(e)};
		document.onmouseup=function(e){ _this.end(e)};
	},
	move:function(e){
		if(this.isDraging){
			Event(e).prevent();
			this.pos({x:Event(e).mouse("x")-this.offset.x, y:Event(e).mouse("y")-this.offset.y}); //set position
		}
	},
	pos:function(pos, disable_callback){
		var _this=this;
		var per={}; // obj shift in float persent
		if(this.x){
			var val=this.checkBound(pos,"x");
			this.obj.style["left"]=val+"px";
			per.x=(val-this.x[0])/this.range.x;
		}
		if(this.y){
			var val=this.checkBound(pos,"y");
			this.obj.style["top"]=val+"px";
			per.y=(val-this.y[0])/this.range.y;
		}
		if(disable_callback) return;
		this.onmove(this.x&&this.y?per:(this.x?per.x:per.y));
		clearTimeout(this.tm);
		this.tm=setTimeout(function(){_this.onpause()},500);
	},
	end:function(e){
		if(this.isDraging){
			this.isDraging=false;
			this.obj.style.cursor=this.defaultCursor;
			document.onmousemove=null;
			document.onmouseup=null;
			clearTimeout(this.tm);
			this.onend();
		}
	},
	set:function(val, disable_callback){
		var pos={};
		if(this.x) pos.x=(this.range.x*(val.constructor==Array?val[0]:val)+this.x[0]);
		if(this.y) pos.y=(this.range.y*(val.constructor==Array?val[1]:val)+this.y[0]);
		this.pos(pos, disable_callback);
		return false;
	},
	checkBound:function(pos, xy){
		return this[xy][0]>pos[xy] ? this[xy][0] : (this[xy][1]<pos[xy] ? this[xy][1] : pos[xy]);
	},
	onstart:function(){},
	onpause:function(){},
	onmove:function(){},
	onend: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("popup_close").event("onclick", function(){_this.hide()});
		this.buts=this.block.insert("div").classname("popup_buts");
		this.but_ok=this.buts.insert("a").classname("popup_ok").html("OK").event("onclick", function(){_this.hide()});
		this.block.insert("div").classname("popup_top");
		this.body=this.block.insert("div").classname("popup_body");
		this.block.insert("div").classname("popup_bottom");
		_(document).event("onkeydown", function(e){
			if((Event(e).key("escape") || (Event(e).key("enter") && _this.but_ok.isShown)) && _this.isOpen) return _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, buts){
		var _this=this;
		if(!this.inited) this.init();
		this.ok_showhide(buts?1:0);
		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;
	},
	alert:function(content){
		return this.show(content, 1);
	},
	confirm:function(content){
		return this.show(content);
	},
	win:function(content){
		return this.show(content);
	},
	ok_showhide:function(b){
		this.but_ok.isShown=b;
		this.buts.css({display:b?"block":"none"});
		if(!this.body.paddingBottom) this.body.paddingBottom=this.body.css("paddingBottom");
		this.body.css({paddingBottom:this.body.paddingBottom+(b?this.buts.offsetHeight:0)});
	}
};


var Modal=new Class({
	init:function(opt){
		this.block=_(document.body).insert("div").classname("modal");
		this.layer=this.block.insert("span");
		opt=opt||{};
		if(opt.loader!=undefined) this.block.insert("div").classname("loader").html(opt.loader).insert("div");
		if(opt.opacity!=undefined) this.layer.css({opacity:opt.opacity});
		if(opt.bgcolor){ this.layer.css({background:opt.bgcolor});}
		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);	
	}
});
//> 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=false;//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.autocomplete=Class({
	init:function(obj, classname){
		if(obj.autocomplete) return false;
		obj.autocomplete=this;
		var _this=this;
		this.list=_(obj.parentNode).insert("div", _(obj, "+")).classname(classname || "autocomplete").css({display:"none"});
		this.input=_(obj).event({
					  onkeyup:function(e){_this.onkeyup(e)},
					  onfocus:function(e){_this.onkeyup(e); _this.inFocus=true; },
					  onblur:function(e){_this.close(); _this.inFocus=false; },
					  oncomplete:function(e){ if(_this.inFocus){ _this.showhide(1); _this.initItems();}}
					});
		this.input.target=this.list;
		this.input._value=this.input.value;
		this.inFocus=true;
	},
	onkeyup:function(e){
		if(this.isOpen && (Event(e).key("up") || Event(e).key("down"))) return this.act(e);
		if(!this.isOpen && Event(e).key("down")) return this.showhide(1); 
		if(Event(e).key("enter")) return this.exec();
		if(this.input._value==this.input.value) return true;
		if(this.curItem && this.curItem.html()==this.input.value) return true;
		this.input._value=this.input.value; 
		if(this.input.value) GET(this.input);
		else this.close();
		
	},
	exec:function(){
		 if(this.curActIndex) this.input._value=this.input.value;
		 return this.go();		
	},
	initItems:function(){
		var _this=this;
		this.curActIndex=-1;
		this.items=_(this.list, "a").event({
					onmousedown:function(){_this.lock=true},
					onmouseup:function(){_this.lock=false},
					onclick:function(){_this.input.value=this.innerHTML; return _this.go(); }
					});
		if(!this.items.length && this.items.tagName!="A") return this.showhide(0);
	},
	close:function(){
		var _this=this;
		if(!this.lock) setTimeout(function(){_this.showhide(0);},100);
	},
	showhide:function(b){
		this.list.slide(b);
		this.isOpen=b;
	},
	act:function(e){
		if(!this.items || !this.items.length) return false;
		if(this.curItem) this.curItem.classname("-act");
		this.curActIndex+=Event(e).key("down")?1:-1;
		if(this.curActIndex<-1) this.curActIndex=-1;
		if(this.curActIndex>=this.items.length) this.curActIndex=0;
		if(this.curActIndex==-1){
			this.input.value=this.input._value;
			return this.showhide(0);
		}
		this.curItem=this.items[this.curActIndex];
		this.input.value=this.curItem.html();
		this.curItem.classname("+act");
		return false;
	},
	go:function(){
		 this.showhide(0); 
		 if(this.input.event("onenter")) this.input.event("onenter")();
		 return false;
	}
});



Forms.Default=new Class({
	init:function(obj, classname){
		var _this=this;
		this.obj=_(obj);
		this.text=obj.attr("alt") || 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,
			tabindex:obj.attr("tabindex")
		});
		this.input.attr({
			update:function(){_this.update()},
			reset:function(){_this.set(_this.input.options[0])},//_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
		this.root.css({height:this.root.inherit.height});//swap height
		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, marginLeft:-2});/**/
		this.field.css({display:"block", whiteSpace:"nowrap", cursor:"default"});
		this.dropdown.css({position:"relative", visibility:"hidden", overflowX:"hidden", overflowY:"auto", zIndex:2});
		if(BROWSER.opera) this.dropdown.css({display:"table-row-group"});
		this.input.options.css({display:"block", whiteSpace:"nowrap", textDecoration:"none"});
		this.arrow.css({position:"absolute", display:"block", top:this.field.css("borderTopWidth"), right:this.field.css("borderRightWidth"), cursor:"pointer", height:this.root.inherit.line});
		if(this.root.offsetWidth) this.postRender(); //render if element is visible
	},
	
	postRender:function(){
		var field_width=this.root.clientWidth-this.field.css("borderLeftWidth")-this.field.css("borderRightWidth")-this.field.css("marginRight")-this.field.css("marginLeft");
		this.root.css({width:this.root.offsetWidth-this.root.inherit.paddingLR, height:"auto"}); //fix width
		this.field.css({width:field_width, overflow:"hidden"});
		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.clientHeight>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;
		
		if(BROWSER.opera) setTimeout(function(){_this.holder.html(obj.html())},0);  //setTimeout for opera inline select
		else _this.holder.html(obj.html());
		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.aref) GET(this.input); //call ajax
			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") || Event(e).key("ctrl") || Event(e).key("alt") || (Event(e).key()>111 && Event(e).key()<124)) 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;
	}
	
});





Forms.validate=Class({
	init:function(form, opt){
		var _this=this;
		opt=opt || {};
		this.cn_err_field=opt.err_field || "err";
		this.cn_err_block=opt.err_block ||"err_block";
		this.cn_err_mess=opt.err_mess ||"err_mess";
		
		this.err_block=_(form, "."+this.cn_err_block);
		this.form=form.event({onsubmit:function(){return _this.onsubmit()}});
		this.fields=_(form, "input[req], textarea[req]");
		this.fields.repeat(function(){
			this.cn_err=_this.cn_err_field;
			this.req=this.attr("req");
			this.target=_(this, "+."+_this.cn_err_mess);
			var ev="onkeyup";
			if(this.req=="checked") ev="onchange";
			this.event(ev, function(){ _this.verify(this)});
			if(this.attr("aref")){
				this.event({
					onblur:function(){GET(this)}, 
					onstarting:function(){return _this.verify(this)}, 
					oncomplete:function(response){this.ajax_err=!_this.set(this, response.obj.err?0:1, response.obj.err!="0"?response.obj.err:"")}
				});
			}
			else if(ev=="onkeyup"){
				this.event({
					onblur:function(){_this.verify(this)}
				});
			}
			if(this.classname("?"+this.cn_err)) _this.set(this, 0);
		});
		this.check_err_block(); //try to open err_block if err found
	},
	check:function(obj){
		if(/\(\)$/.test(obj.req)){ //custom function handler
			var func=window[obj.req.replace(/\(\)$/, "")];
			return func?func.apply(obj):true;
		}
		var b=true;
		var val=this.trim(obj.value);
		switch(obj.req){
			case "empty": b=(val!=""); break;
			case "email": b=(/^([a-z0-9\-._]+)@([a-z0-9\-._]+)\.([a-z0-9]{2,3})$/i.test(val)); break;
			case "checked": b=(obj.checked); break;
			default://field is equal specified in "req" field 
				var f2=this.form.elements[obj.req];
				b=(f2 && this.trim(f2.value)==val);
		}
		return b;
	},
	trim:function(str){
		return (str||"").replace(/^\s*|\s*$/g,"");
	},
	set:function(obj, b, ajax_title){
		obj.classname((b?"-":"+")+obj.cn_err);
		obj.target.css({display:b?"none":"block"}).html(ajax_title || obj.target.title);
		if(this.err_block.isVisible) this.check_err_block(); //try to close err_block
		return b;
	},
	verify:function(obj){
		return this.set(obj, this.check(obj));
	},
	check_err_block:function(b){
		b=b!=undefined?b:(_(this.form, "input."+this.cn_err_field+", textarea."+this.cn_err_field)?1:0);
		this.err_block.css({display:b?"block":"none"}).html(this.err_block.title);
		this.err_block.isVisible=b;
	},
	onsubmit:function(){
		var _this=this;
		var b=true;
		this.fields.repeat(function(){
			b=_this.verify(this)?b:false;
			if(this.ajax_err) b=false;			
		});
		if(!b) this.check_err_block(1);
		return b;
	}
});

var MAP={
	init:function(id, latlng){
		if (!GBrowserIsCompatible()) return;
		JJ.element.event.exec(window, "onunload", GUnload);
		
		this.block=_(id);
		
		this.map = new GMap2(this.block);
		
		geocoder = new GClientGeocoder();
		
        //this.map.setUIToDefault();

		this.map.addControl(new GSmallZoomControl());
		this.map.enableScrollWheelZoom();
		this.map.enableContinuousZoom();
		this.map.disableInfoWindow();
		
		GEvent.addListener(this.map, "click", function(marker, point){
			//alert(o2s(MAP.getViewPort())+" "+MAP.map.getCenter().lng()+ " "+MAP.map.getCenter().lat()+ " "+MAP.map.getZoom());
		});
		
		this.icon=[];
		this.icon["marker_1"]=this.initIcon("marker_1.png", "marker_1_sh.png", 40, 38, 40, 38, 20, 38);
		this.icon["s1"]=this.initIcon("marker_s1.png", "marker_s_shad.png", 34, 34, 38, 43, 14, 38);
		this.icon["s2"]=this.initIcon("marker_s1.png", "marker_s_shad.png", 34, 34, 38, 43, 14, 38);
		this.icon["s3"]=this.initIcon("marker_s1.png", "marker_s_shad.png", 34, 34, 38, 43, 14, 38);
		
		latlng= latlng || {};
		this.map.setCenter(new GLatLng(latlng.lat || 52.527000, latlng.lng || 13.408000), latlng.zoom || 11);
		
	},
	
	//create single marker and attach event on it
	createMarker:function(point){
		var opts = {
			"icon": this.icon[point.icon || point.marker],	
			"clickable": true,
			"draggable": false
		};
		var marker = new GMarker(new GLatLng(point.lat, point.lng), opts);
		marker.href=point.href;
		marker.title=point.title;
		
		GEvent.addListener(marker, "click", function() {
			if(marker.href) location.href=marker.href;
		});
		GEvent.addListener(marker, "mouseover", function() {
			MAP.tooltip.show(marker);
		});
		GEvent.addListener(marker, "mouseout", function() {
			MAP.tooltip.hide(marker);
		});
	
		return marker;
	},

	// draw/redraw markers on the map
	drawMarkers:function(points, center){
		this.clear();
		var markers=[];
		for(var i in points){
			var marker=this.createMarker(points[i]);
			markers.push(marker);
			if(!this.clustering) this.map.addOverlay(marker);
		}
		if(this.clustering) this.createCluster(markers);
		
		//if(center) mapa.setCenter(new GLatLng(center.lat, center.lng), center.zoom);
		//else 
		this.setViewPort(points);
	},
	
	clear:function clearMarkers(){
		if(this.map) this.map.clearOverlays();
	},
			
	createCluster:function(markers){
		var ClustererStyles=[
			{url:IMGS_PATH+"m1.png", height:57, width:53},
			{url:IMGS_PATH+"m2.png", height:58, width:55},
			{url:IMGS_PATH+"m3.png", height:65, width:66},
			{url:IMGS_PATH+"m4.png", height:65, width:66},
			{url:IMGS_PATH+"m5.png", height:65, width:66},
		];
		return new MarkerClusterer(this.map, markers, {styles: ClustererStyles, gridSize: 70});
		
	},
	
	getViewPort:function(){
		var bounds = this.boundsNormalize(this.map.getBounds());
		var southWest = bounds.getSouthWest();
		var northEast = bounds.getNorthEast();
		return {n:{lng:northEast.lng(),lat:northEast.lat()},s:{lng:southWest.lng(),lat:southWest.lat()}};
	},
	
	setViewPort:function(points){
		if(!points[0])
		//get markers view zone on map, return rectangle bounds
		var exists, n_lng, n_lat, s_lng, s_lat;
		for(var i in points){
			n_lng=!exists || (exists && Number(points[i]["lng"])>n_lng)?Number(points[i]["lng"]):n_lng;
			n_lat=!exists || (exists && Number(points[i]["lat"])>n_lat)?Number(points[i]["lat"]):n_lat;
			s_lng=!exists || (exists && Number(points[i]["lng"])<s_lng)?Number(points[i]["lng"]):s_lng;
			s_lat=!exists || (exists &&  Number(points[i]["lat"])<s_lat)?Number(points[i]["lat"]):s_lat;
			exists=true;
		}
		if(!exists) return false;
	
		var bounds=new GLatLngBounds(new GLatLng(s_lat,  s_lng), new GLatLng(n_lat, n_lng));	
		//bounds=boundsNormalize(bounds);

		//set move/zoom map to ViewPort
		this.map.setCenter(bounds.getCenter(), this.map.getBoundsZoomLevel(bounds));
	},
	
	boundsNormalize:function(bounds){
		var southWest = bounds.getSouthWest();
		var cc=this.map.fromLatLngToDivPixel(southWest);
		southWest=this.map.fromDivPixelToLatLng(new GPoint(cc.x+15, cc.y-40));
		var northEast = bounds.getNorthEast();
		var cc=this.map.fromLatLngToDivPixel(northEast);
		northEast=this.map.fromDivPixelToLatLng(new GPoint(cc.x-15, cc.y+40));
		return new GLatLngBounds(southWest, northEast);
	},
	
	initIcon:function(img, shad, icW, icH, shW, shH, anW, AnH){
		var icon=new GIcon();
		icon.image=IMGS_PATH+img;
		//icon.over=over?IMGS_PATH+over:null;
		icon.iconSize=new GSize(icW, icH);
		icon.shadow=IMGS_PATH+shad;
		icon.shadowSize=new GSize(shW, shH);
		icon.iconAnchor=new GPoint(anW, AnH);
		icon.infoWindowAnchor=new GPoint(0, 0);
		return icon;
	},
	
	set:function(id, sett){
		if(!this.map) this.init(id, sett);
		var marker=this.createMarker(sett);
		this.map.addOverlay(marker);
	},
	
	preload:function(id, sett){
		this.saved={id:id, sett:sett};
	},
	
	execute:function(){
		if(!this.saved) return false;
		var saved=this.saved;
		var _this=this;
		if(!this.inPreload){
			this.inPreload=true;
			//_(document, "head").insert("script").attr({type:"text/javascript", src:"http://maps.google.com/maps?file=api&amp;v=2&amp;key="+saved.sett.key+""});
			document.write('<script type="text/javascript" src="http://maps.google.com/maps?file=api&amp;v=2&amp;key='+saved.sett.key+'"><'+'/script>');
			if(saved.sett.clustering){
				//_(document, "head").insert("script").attr({type:"text/javascript", src:GLOBAL_PATH+"js/markerclusterer_packed.js"});
				document.write('<script type="text/javascript" defer="defer" src="'+GLOBAL_PATH+'js/markerclusterer_packed.js"></'+'script>');
				this.clustering=true;
			}
			var tm=setInterval(function(){if(window.GMap2){ clearInterval(tm); _this.init(saved.id, saved.sett);} }, 100);
		}
		this.saved=null;
	}
};



MAP.tooltip={
	init:function(){
		var _this=this;
		this.tooltip=JJ.create("div").attr({id:'tooltip'});
		this.tooltip.event({onmouseover:function(){_this.show(_this.currentMarker)}, onmouseout:function(){_this.hide(_this.currentMarker)}});
		this.tooltip.content=this.tooltip.insert("a");
		_(MAP.block, "<").insert(this.tooltip);
		this.inited=1;
	},
	show:function(marker){
		var _this=this;
		if(this.currentMarker!=marker && this.currentMarker) this.hideDelay(this.currentMarker);
		this.currentMarker=marker;
		marker.isOver=1;
		clearTimeout(this.tm);
		this.tm=setTimeout(function(){_this.showDelay(marker)}, 200);
	},
	hide:function(marker){
		var _this=this;
		marker.isOver=0;
		clearTimeout(this.tm);
		this.tm=setTimeout(function(){_this.hideDelay(marker)}, 200);
	},
	showDelay:function(marker){
		if(marker.isOver && marker.isShow) return false;
		if(!this.inited) this.init();
		var cc=MAP.map.fromLatLngToContainerPixel(marker.getLatLng());
		this.tooltip.content.html(marker.title);
		if(marker.href) this.tooltip.content.href=marker.href;
		this.tooltip.css({top:cc.y, left:cc.x}).fade(1);
		marker.isShow=1;
	},
	hideDelay:function(marker){
		if(marker.isOver || !marker.isShow) return false;
		this.tooltip.fade(0);
		marker.isShow=0;
	}
};
/* SWFObject v2.1 <http://code.google.com/p/swfobject/>
	Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();


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 Tabs=Class({
	_active_classname:"act",
	_effect:"slide",
	
	init:function(obj){
		var _this=this;
		this.root=obj;
		this._effect=this.root.attr("effect") || this._effect;
		this.items=_(obj, ["dt a"]);
		this.blocks=_(obj, ["dd"]);
		if(this.items.length<=1 || this.blocks.length<=1) return false;
		this.items.repeat(function(i){this.i=i});
		var event_name=this.items[0].attr("aref")?"oncomplete":"onclick";
		var ev={};
		ev[event_name]=function(){_this.set(this.i)};
		this.items.event(ev);
		this.blocks.css({display:"none"});
		this.cur=_(obj, "dt a.act").i || _(obj, "dt.act a").i || 0; //get default active tab
		this.act(this.cur);
		this.blocks[this.cur].css({display:"block"});
	},
	set:function(num){
		if(this.cur==num) return false;
		this.blocks[this.cur][this._effect](0);
		this.act(num, this.cur);
		this.blocks[num][this._effect](1);
		this.cur=num;
	},
	act:function(cur, old){
		_([this.items[cur], _(this.items[cur], "<")]).classname("+"+this._active_classname);
		if(old!=undefined) _([this.items[old], _(this.items[old], "<")]).classname("-"+this._active_classname);
	}
});




var CCal={
	load:function(callback){
		var _this=this;
		if(!this.inLoad){
			var doc=_(document, "head");
			doc.insert("script", {type:"text/javascript", src:GLOBAL_PATH+"mod_cal/script.js"});
			doc.insert("script", {type:"text/javascript", src:GLOBAL_PATH+"mod_cal/lang/de.js"});
			doc.insert("link", {type:"text/css", rel:"stylesheet", href:GLOBAL_PATH+"mod_cal/jscal2.css"});
			this.inLoad=1;
		}
		if(this.tm) clearTimeout(this.tm);
		try{ Calendar.LANG }catch(e){ return this.tm=setTimeout(function(){_this.load(callback)},50) }
		this.isLoaded=1;
		return callback();
	},
	init:function(inp){
		var _this=this;
		inp=_(inp);
		var rand=Math.round(Math.random()*1000000);
		if(!inp.id) inp.id="cal_inp_"+rand;
		inp.cal_cont=_(inp, "<").insert("div", _(inp, "+")).attr({id:"cal_cont_"+rand}).classname("calendar");
		var startDate=new Date();
		if(inp.attr("calendar")){
			inp.int_date=inp.form.elements[inp.attr("calendar")];
			if(inp.int_date.value) startDate=new Date(Number(inp.int_date.value)*1000);
		}
		inp.cal = Calendar.setup({
        	cont: inp.cal_cont.id,
			date:startDate,
			onSelect: function(cal) {             
				var date = Calendar.intToDate(this.selection.get());
				inp.value=Calendar.printDate(date, "%d.%m.%Y"); 
				if(inp.int_date) inp.int_date.value=Calendar.printDate(date, "%s");
				_this.hide(inp);
				inp.classname("-inp_error");
			},
			onBlur: function(){_this.hide(inp); }
		});
	},
	show:function(inp){
		if(inp.isShown) return this.hide(inp);
		var _this=this;
		if(!this.isLoaded) return this.load(function(){_this.show(inp)});
		if(!inp.cal_cont) this.init(inp);
		this.setDate(inp.cal, inp.int_date.value);
		inp.cal_cont.css({visibility:"visible"});
		//inp.cal_cont.fade(1, {speed:BROWSER.ie?-1:-3});
		setTimeout(function(){inp.cal.focus()},10);
		inp.isShown=1;
	},
	hide:function(inp){
		if(!inp.isShown) return false;
		inp.cal_cont.css({visibility:"hidden"});
		//inp.cal_cont.fade(0);
		//inp.blur();
		inp.isShown=0;		
	},
	error:function(inp){
		inp.classname("+inp_error");	
	},
	setDate:function(cal, int_date){
		if(int_date){
			var date=Calendar.dateToInt(new Date(Number(int_date)*1000));
			if(!isNaN(date)){
				cal.moveTo(date);
				cal.selection.set(date);
			}
		}
	}
}


function init_detail_calendar(id, form, field){
	var form=_(form);
	_(id, "i.s").event({onclick:function(){
		form.slide(1); 
		var inp=_(form[field]);
		inp.value=this.innerHTML+"."+this.parentNode.lang;
		
		var yyyy=this.parentNode.lang.replace(/.*\.([0-9]{4})/, "$1");
		var mm=this.parentNode.lang.replace(/^([0-9]{2})\..*/, "$1");
		var dd=new Date();
		dd.setFullYear(yyyy, Number(mm)-1, this.innerHTML);
		if(inp.attr("calendar")){inp.form.elements[inp.attr("calendar")].value=Math.round(dd.getTime()/1000);}
	}});
}

function init_adv_search(obj){
	obj.onclick=function(){_(obj.target).slide(); return false;};
	if(_(obj.target).classname("?advanced_show")){ obj.onclick(); return false;}
	_(obj.target).insert("div").classname("empty");
	obj.onclick();
	GET(obj);
	return false;
}

var Raiting={
	setMI:function(obj){
		_(obj, "<ul li").repeat(function(){
			if(!this.baseCN) this.baseCN=this.classname();
			this.classname(this.baseCN+(this==obj.parentNode?" act":" hid"));
		})
	}
};

var Vote=new Class({
	init:function(root){
		var _this=this;
		this.root=root;
		this.root.vote=this;
		this.status=_(root, "i");
		this.input=_(root, "input");
		this.cur=-1;
		this.items=_(root, "s")
			.repeat(function(i){ this.i=i; if(!this.classname()) _this.cur=i; })
			.event({onmouseover:function(){_this.over(this)}, onclick:function(){_this.click(this)}});
		root.event({
			onmouseout:function(){root.tm=setTimeout(function(){_this.out()},10)}
		});
		this.subItems=[];
		this.target=_(root.attr("target"));
		if(this.target) this.target.vote.subItems[this.target.vote.subItems.length]=root;
	},
	over:function(obj){
		clearTimeout(this.root.tm);
		this.items.repeat(function(i){
			this.classname((i>obj.i?"+":"-")+"off");
		});
	},
	out:function(){
		var cur=this.cur;
		this.items.repeat(function(i){
			this.classname((i>cur?"+":"-")+"off");
		});
	},
	setStatus:function(num){
		var value=(Math.round((num+1)*100)+"").replace(/^([0-9])/, "$1,");
		this.status.html(value);
		this.input.value=value;
	},
	click:function(obj){
		this.cur=obj.i;
		this.setStatus(this.cur);
		if(this.target) this.calcTarget(obj);
		if(this.subItems.length) this.calcSubItems();
	},
	set:function(num){
		this.cur=Math.floor(num);
		this.setStatus(num);
		this.out();
	},
	calcTarget:function(obj){
		var num=0;
		var objs=_(obj, "<div "+this.root.tagName)
		objs.repeat(function(){num+=this.vote.cur;});
		num=num/objs.length;
		this.target.vote.set(num);
	},
	calcSubItems:function(obj){
		var num=this.cur;
		this.subItems.repeat(function(){this.vote.set(num)});
	}
	
});


function show_res_map(obj, map_place, res_map){
	if(!arguments.callee.inited){
		obj.res_map=_("div."+res_map);
		obj.res_map.css({top:_(obj, "<").offsetTop, display:"none", visibility:"visible"});
		obj.onstarting=function(){_(obj.res_map, " .loader").display(1)};
		obj.oncomplete=function(){_(obj.res_map, " .loader").display(0)};
		GET(obj);
		arguments.callee.inited=1;
	}
	_("div.left_abs").css({top:"auto", marginTop:-_("div.left_for_abs<").offsetHeight+_("div.left_for_abs").offsetTop-(BROWSER.ie?(_("map").isOpen?4:26):15)});
	var tmp=_(obj, "b").html();
	_(obj, "b").html(obj.lang);
	obj.lang=tmp;
	_(obj, "b").classname("!active");
	_("div."+map_place).slide();
	obj.res_map.slide();
	_("map").isOpen=_("map").isOpen?false:true;
	return false;
}
document.onload=function(){
	if(arguments.callee.inited) return;
	else arguments.callee.inited=1;
	
	init_content(document);
	
	if(window.jQuery && jQuery.fancybox){
		fancyboxPopupInit();
	}
	
};

function fancyboxPopupInit() {
	jQuery("a[target='popup']").fancybox({
		'overlayShow'	: true,
		'transitionIn'	: 'fade',
		'transitionOut'	: 'fade',
		'speedIn'		: 300,
		'speedOut'		: 300
	});
}


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.alert(response.obj.alert);
	if(response.obj.point) MAP.drawMarkers(response.obj.point, response.obj.center);
	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, "form[aref] *[type=submit]").event({onclick:function(){
		_(this, '<form').onsubmit();
		return false;
	}});
	
	//used for tab focus on button
	_(root, "a.submit input").event({
		onfocus:function(){_(this, "<").classname("+submit_focus")}, 
		onblur: function(){_(this, "<").classname("-submit_focus")}
	});
	
	_(root, "input[calendar]").event({onmousedown:function(){
		CCal.show(this);
	}});

	_(root, "input[alt], textarea[alt]").repeat(function(){
		new Forms.Default(this);
	});

	_(root, "textarea[maxlength]").repeat(function(){
		Forms.maxlength(this);
	});

	
	_(root, "select").repeat(function(){
		new Forms.select(this);
	});
	
	_(root, "dl.tabs, dl.search_tabs").repeat(function(){
		var first=_(this, "dt:0 a:0");
		if(!first.attr("href") || first.attr("aref")) new Tabs(this);
	});
	
	_(root, "form.reg").repeat(function(){
		new Forms.validate(this, {err_field:"err", err_block:"err_block", err_mess:"err_mess"});
	});
	
	_(root, "a[swfupload]").event("onmouseover", function(){
		new Upload(this, window.UPLOAD_HANDLER, this.attr("swfupload"), UPLOAD_CONFIGS[this.attr("config")||"all"]);
	});
	
	_(root, "input[autocomplete]").event("onfocus", function(){
		new Forms.autocomplete(this);
	});
	//document.onmousemove=function(e){var c=Event(e).mouse(); _("mimg").innerHTML=document.elementFromPoint(c.x,c.y).tagName};
	
	
	_(root, ".slider_items").repeat(function(){
		new Slider(this, {slideshow:3000})
	});
	
	if(root.className=="slideshow" || _(root, "div.slideshow .photo")){
		new SlideShow({
			root:   "div.slideshow",
			photo:  ".photo",
			link:   ".photo a:0",
			image:  ".photo img:0",
			hint:   ".photo span",
			title:  ".photo span i",
			slider: ".slider",
			slider_canvas:  ".slider span", 
			slider_items:   ".slider span a"
		})
	}
	
	
	/*if(_("mapia")){
		if(!flashDetect()){
			_("#mapia object").style.display="none";
		}
	}*/
	
	
	//custom: init left panels for search & community pages
	var left_for_abs;
    if(left_for_abs=_(root, "div.left_for_abs")){
		var left_abs=_("div.left_abs");
		if(_("map").isOpen) _("div.map_place").css({display:"block", height:_("div.res_map").offsetHeight});
        left_abs.css({top:left_for_abs.offsetTop, marginTop:0});
        left_for_abs.css({height:left_abs.offsetHeight});
	}
	
	//auto pos for res item icons
	_(root, ".res_item img")
		.repeat(function(){
			this.opt=_(this, "<div .opt"); 
			this.par=_(this, "<div");
			this.is_resized=(this.offsetHeight+1<this.opt.offsetTop);
			if(this.is_resized){
				this.opt.css({position:"absolute", top:105});
			}
		})
		.event({onload:function(){
			if(this.is_resized){
				this.opt.css({top:this.offsetHeight});
				if(this.opt.offsetTop+this.opt.offsetHeight>this.par.offsetHeight) this.par.css({height:this.opt.offsetTop+this.opt.offsetHeight-11});
			}
		}});
	
	MAP.execute(); //load map from saved params if needed
	
	//webbanner change
	if(_(root, "#webbanner_selector")){
		_(root, "#webbanner_selector")
		.event({onchange:function(){
			var value= this.value.split("|");
			var graphicFileName = value[0];
			var graphicFileWidth = value[1];
			var graphicFileHeight = value[2];
			if(!this.defaultCode) this.defaultCode=_(this.attr("code")).value.replace(/^(\s|\t)*/g, "").replace(/&lt;'/g, "<").replace(/&gt;'/g, ">");
			var newCode=this.defaultCode;
			newCode=newCode.replace(/'\s?\+\s?graphicFileName\s?\+\s?'/g, graphicFileName);
			newCode=newCode.replace(/'\s?\+\s?graphicFileWidth\s?\+\s?'/g, graphicFileWidth);
			newCode=newCode.replace(/'\s?\+\s?graphicFileHeight\s?\+\s?'/g, graphicFileHeight);
			_(this.attr("code")).value=newCode;
			_(this.attr("holder")).css({height:graphicFileHeight});
			_(this.attr("holder")).html(newCode);
		}})
		.onchange();
	}
};


