
var BROWSER={
	ie:document.all && !window.opera,
	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 _=function(obj,route){
	if(!obj) return null;
	if(typeof obj=="string" && document.getElementById) obj=document.getElementById(obj);
	if(obj) return route?_DOM(obj,route):obj;
	else return null;
};


//Linguistic DOM objects search functionality
// ">" - next sibling tag
// "<" - prefious sibling tag
// "^" - first child tag
// "$" - last child tag
// "/" - parent node
// "~" - search  in child nodes
// "@" - return array matches
// "." - className property
// ":" - id property
// "#" - name property
// ----- RegExp to search _\(\'?\"?[a-zA-Z0-9_]+\'?\"?,
function _DOM(obj,route){
	route=route.replace(/[^<>\^$\/~a-z0-9_@.:# ]/gi,""); //clear uncorrect instructions
	route=route.replace(/(^[a-z@.:#].*)/i,"^$1"); //normalize inctructions (start with firstChild)
	route=route.replace(/((\<+)|(\>+)|(\^)|(\$)|(\/)|(\~)|(\@))/g,"$1*").replace(/\*([a-z0-9_@.:# ])/gi,"$1"); //add "any tag" (*) pointer
	var tags=route.toUpperCase().match(/([a-z0-9_*.:# ]+)/gi) || []; //create tags array
	var pointer=route.replace(/[^<>\^$\/~@]+/g,"+"); //split inctructions
	
	//alert(route+" ||| "+tags+" ||| "+pointer+" ||| ")
	var fit={
		">":"nextSibling",
		"<":"previousSibling",
		"^":"firstChild",
		"$":"lastChild",
		"/":"parentNode",
		".":BROWSER.ie6||BROWSER.ie7?"className":"class",
		":":"id",
		"#":"name"
	};
	var tagPos=0, childPos=0;
	var char, tag, tagName, propKey, propValue, found, childNodes;
	var matches=[];

	while((char=pointer.charAt(0))){
		if(char=="+"){//change filter by "tag"
			if(tags[tagPos+1]) tagPos++;
			pointer=pointer.substr(1);
			continue;
		}
		
		tagName=tags[tagPos];
		propKey="";
		
		//if property exist
		if(tagName && (/[.:#]/.test(tagName))){
			propKey=fit[tagName.replace(/[^.:#]/g,"")];
			tag=tagName.match(/([a-z1-6_]*)[.:#]([a-z0-9_ ]*)/i);
			tagName=tag[1] || "*";
			propValue=tag[2];
			//alert(tagName+" "+propKey+" "+propValue)
		}
		
		//search in child nodes
		if(char=="~"){
			if(!childNodes) childNodes=obj.getElementsByTagName(tagName);
			else childPos++;
		}
		else if(childNodes){
			childNodes=null;
			childPos=0;
		}
		
		if(!(obj=obj[fit[char]] || (childNodes && childNodes[childPos]))) return matches.length?matches:null; //set next object
		found=!(obj.nodeType!=1 || (tagName!="*" && obj.tagName!=tagName) || (propKey && (!obj.getAttribute(propKey) || typeof obj.getAttribute(propKey)!="string" || obj.getAttribute(propKey).toUpperCase()!=propValue)));
		if(found) pointer=pointer.substr(1);
		
		//if first/last child not found in first step
		if((char=="^" || char=="$") && !found){
			pointer=pointer.replace(/./,(char=="^"?">":"<"));
		}
		
		//if matches symbol was found (return array of matches)
		if(pointer.charAt(0)=="@"){
			if(char=="^" && found) char=">";
			pointer=char+pointer;
			matches[matches.length]=obj;
		}
	}
	return obj;
};




function addEvent(el, evname, func) {
	if(!el["on"+evname] && el!=window && el!=document) return el["on"+evname]=func;
	if(el.attachEvent) el.attachEvent("on"+evname, func); // IE
	else if(el.addEventListener) el.addEventListener(evname, func, true); // Gecko / W3C
	else el["on"+evname]=func;
};

function removeEvent(el, evname, func) {
	//if(el["on"+evname]) return el["on"+evname]=null;
	if(el.detachEvent) el.detachEvent("on" + evname, func); // IE
	else if (el.removeEventListener) el.removeEventListener(evname, func, true); // Gecko / W3C
	else el["on"+evname]=null;
};



//get tag Attribute
function _ATTR(obj,attr){
	obj=_(obj);
	if(!obj || !attr) return null;
	return obj.getAttribute && obj.getAttribute(attr)!=undefined ? obj.getAttribute(attr) : (obj[attr]!=undefined ? obj[attr] : null);
};

//get tag Event
function _EV(obj,attr,args){
	var _prop_=_ATTR(obj,attr);
	if(_prop_ && /^on[a-z]+/.test(attr))
		return  typeof _prop_=="function" ? _prop_ : function(){return (new Function(args,_prop_)).apply(obj, arguments)};
	else 
		return function(){};
};



// element className & style functions
var Style=function(obj){
	obj=_(obj);
	return {
		empty:function(){
			return obj.className.replace(/\s/g,"")==""?true:false;
		},
		all:function(name){
			return !this.empty()?obj.className.split(/\s+/):[];
		},
		exist:function(name){
			for(var i=0, c=this.all(name), l=c.length; i<l; i++)
				if(c[i]==name) 
					return true;
			return false;
		},
		set:function(name){
			obj.className=name;
		},
		add:function(name){
			this.remove(name);
			obj.className+=obj.className?' '+name:name;
			return true;
		},
		remove:function(name){
			obj.className=obj.className.replace(new RegExp("((^)|(\\s))"+name+"((\\s)|($))"),"$3");
			return false;
		},
		invert:function(name){
			return this.exist(name) ? this.remove(name) : this.add(name);
		},
		clear:function(){
			obj.className='';
		}
	}
};


//Element styles functions
var CSS=function(obj){
	obj=_(obj);
	return {
		//convert js style property to css property (zIndex -> z-index)
		js2css:function(prop){
			return prop.replace(/([A-Z])/g,"-$1").toLowerCase();
		},
		//get style|styles value from css element (arguments=[string|hash|array])
		get:function(prop){
			if(typeof prop=="string"){
				if(obj.currentStyle) return obj.currentStyle[prop];
				if(window.getComputedStyle) return window.getComputedStyle(obj,null).getPropertyValue(this.js2css(prop));
			}
			else if(prop){
				var style={};
				for(var i in prop){
					if(prop.length) i=prop[i]; //get prop if array
					style[i]=this.get(i);
				}
				return style;
			}
			else return 0;
		},
		//set new styles to element & return old styles (arguments=[hash])
		set:function(hash){
			var style={};
			for(var i in hash){
				if(i=="opacity" && BROWSER.ie){
					var val=Number(hash[i])*100;
					i="filter";
					hash[i]=(val==100?"":"Alpha(opacity="+val+")");
				}
				style[i]=this.get(i);
				obj.style[i]=hash[i];
			}
			return style;
		},
		//copy style|styles from obj to anoter element & return this styles (arguments=[string|array])
		copy:function(prop,to){
			if(typeof prop=="string")
				return (to.style[prop]=this.get(prop));
			else if(prop){
				var style=this.get(prop);
				for(var i in style)
					to.style[i]=style[i];
				return style;
			}
			return null;
		},
		//check current element style|styles (arguments=[hash])
		check:function(hash){
			for(var i in hash)
				if(hash[i]!=this.get(i))
					return false;
			return true;
		}
	}
};



// universal HTML creator
function makeHTML(OBJ,root,before){
	var tag=root;
	for(var i in OBJ){
		if(i=="tag") tag=document.createElement(OBJ[i]);
		else if(i=="append") 
			for(var j in OBJ[i]){ 
				if(OBJ[i][j].tag) 
					tag.appendChild(makeHTML(OBJ[i][j]));
			}
		else if(tag) tag[i]=OBJ[i];
	}
	if(root && root!=tag){
		if(before) root.insertBefore(tag, before);
		else root.appendChild(tag);
	}
	return tag;
};






//-----------------------------------------------------------

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;
	}
};




//js include
document.include=function(src){
	if(!document.includes) document.includes={};
	if(document.includes[src]) return false;
	document.includes[src]=1;
	src=(/^https?:\/\/.+/.test(src)?src:GLOBAL_PATH+src);
	if(src.indexOf(".css")==-1) document.write('<'+'script type="text/javascript" src="'+src+'"><'+'/script>');
	else document.write('<link type="text/css" rel="stylesheet" href="'+src+'" />');
};






function Num(val){
	if(isNaN(val)) val=val.replace(/,/,"."); //if float [,]
	if(isNaN(val)) val=parseInt(val); //if [px]
	if(isNaN(val)) val=0;
	return Number(val);
};


function Coord(e){
	return {x:BROWSER.ie?event.clientX+document.documentElement.scrollLeft:e.pageX, y:BROWSER.ie?event.clientY+document.documentElement.scrollTop:e.pageY};
};



//Hash functions
function Hash(h){
	var _h={};
	for(var i in h) _h[i]=h[i];
	
	return {
		clone:function(){
			return _h;
		},
		count:function(){
			var k=0;
			for(var i in _h) k++;
			return k;
		},
		branch:function(){
			var h=this.clone();
			while(typeof h=="object") 
				for(var i in h){ 
					h=h[i]; 
					break;
				}
			return h;
		},
		merge:function(){
			for(var i=0, l=arguments.length; i<l; i++)
				for(var j in arguments[i])
					_h[j]=arguments[i][j];
			return _h;
		},
		replace:function(key,value){
			if(typeof key=="number") key=this.key(key);
			_h[''+key]=value;
			return	_h;
		},
		record:function(at){
			var k=0;
			for(var i in _h) if(at==k++) return [i, _h[i]];
			return [null,null];
		},
		key:function(at){
			return this.record(at)[0];
		},
		value:function(at){
			return this.record(at)[1];
		}
	}
};



//init  png images in IE6
function ie6_fixes(root, prop){
	var base=_(document, "~base").href;
	var tags=root.getElementsByTagName("*");
	for(var i=0, l=tags.length; i<l ;i++){
		if(!tags[i]) continue;
		if(prop.png && tags[i].currentStyle[prop.png]){
			var src=base+GLOBAL_PATH+tags[i].currentStyle[prop.png].replace(/url\(['"]?([^'"]*)['"]?\)$/i,"$1");
			tags[i].style["filter"]='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+src+'",sizingMethod='+'crop'+')';
			tags[i].style["background"]="none";
		}
		if(prop.hover && tags[i].currentStyle[prop.hover]) {
			addEvent(tags[i], 'mouseover', function(){ Style(this).add(this.currentStyle[prop.hover]); })
			addEvent(tags[i], 'mouseout', function(){ Style(this).remove(this.currentStyle[prop.hover]); })
		}
	}
};



//debug output for Array & Hash objects (crusial in Chrome)
if(!BROWSER.chrome && !BROWSER.safari)
Array.prototype.toString =
Object.prototype.toString = function() {
	var cont = [];
	var addslashes=function(s){return s.split('\\').join('\\\\').split('"').join('\\"');};
	for (var k in this) { 
		if (cont.length) cont[cont.length-1] += ",";
		var v = this[k];
		var vs = ''; 
		if (v.constructor == String) vs = '"' + addslashes(v) + '"';
		else vs=v.toString();
		cont[cont.length]=k + ": " + vs;
	}
	cont = "	" + cont.join("\n").split("\n").join("\n	");
	var s = cont;
	if (this.constructor == Object) s = "{\n"+cont+"\n}";
	if (this.constructor == Array) s = "[\n"+cont+"\n]";
	return s;
};


var o2s = function(o) {
	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;
};// GLOBAL PARAMETERS

var LANG="de"; //default language

var GLOBAL_PATH="front/default/";
var IMGS_PATH=GLOBAL_PATH+"img/";


var AJAX_HANDLER = "?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=function(opt){this.init.apply(this, arguments)}).prototype={
	
	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){
							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
							_this.ondata(response);
						}
					};
					request.send(this.query); //request send 
					break;
				}
				
			case "script":
				request=document.createElement("script");
				if(request){
					request.id=SID;
					var src=this.file+"?"+"_scriptID_="+request.id+"&"+this.query;
					if(BROWSER.ie) request.src=src.substr(0,2048); //MAX msie:2kb
					else{request.src=src; request.src=request.src.substr(0,4096)}; //MAX gesko:4Kb
					request.onreadystatechange=function(response){
						if(response && !response.initEvent){
							_this.ondata(response);
							setTimeout(function(){request.parentNode.removeChild(request)},13);
						}
					};
					document.body.appendChild(request); //request send 
					break;
				}
				
			case "form":
				var request=document.createElement(BROWSER.ie?"<iframe name="+SID+">":"iframe");
				if(request){
					request.name=SID;
					request.style.position="absolute";
					request.style.visibility="hidden";
					this.form.appendChild(request);
					//this.form.encoding="multipart/form-data";
					this.form.method="post";
					this.form.target=request.name;
					this.form.action=this.file+this.form.action.replace(/.*(\?.*)$/,"$1");
					request.onreadystatechange=request.onload=function(response){
						if(!request.readyState || request.readyState=="complete"){
							_this.ondata((new Function('return '+request.contentWindow.document.body.innerHTML))());
							setTimeout(function(){request.parentNode.removeChild(request)},13);
						}
					};
					this.form.submit(); //request send 
					break;
				}
				
			default: return request;
		}
	},
	
	ondata:function(response){
		if(this.caching || this.CACHE[this.query]) this.CACHE[this.query]=response; //cache response data
		this.response=response;
		this.onready(response);
	},
	
	json2query:function(hash, pref){
		var query="";
		for(var i in hash){
			if(!i) continue;
			var key=(pref?pref+"["+i+"]":i);
			query+=(typeof hash[i]=="object" ? this.json2query(hash[i],key) : "&"+key+"="+hash[i].toString().replace(/&/g, "%26"));
		}
		return query;
	},
	
	xml2json:function(request){
		var parseXML=function(node){
			if(node.childNodes.length==1 && (node.firstChild.nodeType==3 || node.firstChild.nodeType==4)) return node.firstChild.data; //if text node
			var hash={};
			for(var i=0, childs=node.childNodes, l=childs.length; i<l; i++)
				if(childs[i].nodeType==1)
					if(hash[childs[i].tagName]){ //if node has array type
						if(typeof hash[childs[i].tagName]=="string" || (typeof hash[childs[i].tagName]=="object" && !hash[childs[i].tagName].length)) 
							hash[childs[i].tagName]=[hash[childs[i].tagName]]; //reinit node (set array type)
						hash[childs[i].tagName][hash[childs[i].tagName].length]=parseXML(childs[i]);
						}
					else hash[childs[i].tagName]=parseXML(childs[i]);
			return hash;
		};
		var doc=BROWSER.ie?request.responseXML:(new DOMParser()).parseFromString(request.responseText, "text/xml"); //get XML content
		var response={obj:{}, text:''};
		if(doc && doc.documentElement) response.obj=parseXML(doc);
		return response;
	},
	
	onerror:function(message){alert("Server output error...\n"+message)}
};//© <stipuha /> development (2008)
//--------------------------------
//CLIENT CONFIGURATION
//--------------------
// define aref="?key1=value&key2=(this.value)&key3=(func())" (get query)
// define target="uid123" (unique tag id for ajax content)
// define autoload (automatic send get query on load content)
// define onstarting="func()" (event calling before ajax sending)
// define oncomplete="func()" (event calling when content already loaded)

//SERVER CONFIGURATION
//--------------------
// define $RESPONSE["complete"]=1 (condition for execute oncomplete function after POST query)
// define $RESPONSE["alert"]="message message message" (condition for open system information popup)



//> HTMLAJAX functionality
//----------------------------------
var HTMLAJAX=function(obj){
	var _this=this;
	
	this.init=function(){	
		this.obj=obj;
		//init vars
		this.target=_(_ATTR(obj,"target"));
		this.indicatorShow=eval(_ATTR(obj,"indicator"));
		this.onstarting=_EV(obj,'onstarting','request');
		this.oncomplete=_EV(obj,'oncomplete','response');
		this.onfailure=_EV(obj,'onfailure','response');	
		//init ajax
		(this.req=new AJAX()).onready=function(response){_this.onready(response)};
		this.cache_time=_ATTR(obj,"cache")||_ATTR(obj.cache_obj,"cache");

		return this;
	};

	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.req.hash)==false) return false; //break if onstarting event return false
		
		//execute predefined basic operations
		if(this.constructor.onrequest(this.req.hash, this)==false) return false; //break if onbeforesend function  return false
		
		//try to set cache
		if(this.cache_time) this.constructor.cache.set(this.cache_time, this.req, this.obj||this.obj.cache_obj); 
		
		this.indicator(1);
		
		if(this.obj.in_process) return false;
		this.obj.in_process=true;
		
		this.req.send();
		return false;
	};
	
	this.onready=function(response){
		if(window.DEBUGGER_ENABLED)
			this.constructor.debug.add(response?"(target="+this.obj.target+")\n"+"["+this.req.query+"]\n"+"\n----------\n"+response.obj+"\n----------\n"+response.text:"\nNO RESPONSE!\n");
		
		this.command_failure=!response || (response.obj.complete!=undefined && !Number(response.obj.complete)) || (response.obj.failure!=undefined && Number(response.obj.failure)); 
		
		if(this.target && !this.command_failure){
			this.target.innerHTML=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(this.target);
		}
		
		this.indicator(0);
		this.obj.in_process=false;
		
		//execute predefined basic operations
		this.constructor.onresponse(response, this);
		
		//execute sender callback function
		if(!this.command_failure) this.oncomplete(response);
		else this.onfailure(response);
		
	};
	
	this.targetProp=function(target, props){
		if(props)
			for(var i in props)
				target[i]=props[i];
	};
	
	//show global ajax loading icon
	this.indicator=function(b){
		if(this.constructor.loader) this.constructor.loader.style.display=b?"block":"none";
		if(this.target){
			CSS(this.target).set({opacity:b?0.5:1});
			if(this.indicatorShow){
				if(b) this.target.defaultHeight=this.target.style.height || "auto";
				this.target.style.height=b?this.target.clientHeight+"px":this.target.defaultHeight;
				if(b) this.target.innerHTML=this.constructor.loader?this.constructor.loader.alt:"...";
			}
		}
		return false;
	};
	
	//parse ajax referer link (ARL=aref)
	this.url2query=function(url){
		if(!url) return "";
		var file=url.replace(/([^?]*\/)*([^?]*)\??.*/,"$2"); //get file name
		if(file) this.req.file=file; //overwrite ajax handler file name
		url=url.replace(/[^?]*\??/,""); //get query [a=1&b=2&c=3]
		if(!url) return "";
		url=this.func2query(url); //check & try to execute function in query
		return url;
	};
	
	//parse form fields & create hash params
	this.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") continue;			
			if(form.elements[i].type=="checkbox") hash[form.elements[i].name]=(form.elements[i].checked?1:0);
			else if(form.elements[i].type=="radio"){ if(form.elements[i].checked) hash[form.elements[i].name]=form.elements[i].value;}
			else if(form.elements[i].type=="file") hash[form.elements[i].name]=form.elements[i];
			else hash[form.elements[i].name]=form.elements[i].value;
		}
		return hash;
	};
	
	//for function in query (dynamic executeble query)
	this.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(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;
	};
	
	return this.init();
};

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

//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=="*"?CACHE_DEFAULT: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:'',
	init:function(){
		var _this=this;
		//attach debugger window call on key combination
		addEvent(document, "keyup", 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();
		txt=txt.replace(/={20,}/g,"");
		txt=txt.replace(/</g,"&lt;");
		txt=txt.replace(/>/g,"&gt;");
		txt=txt.replace(/\t/g,"&nbsp; ");
		var now=new Date();
		this.data+="["+this._0(now.getHours())+":"+this._0(now.getMinutes())+":"+this._0(now.getSeconds())+"]\n";
		this.data+="====================\n";
		this.data+=o2s(txt)+"\n\n\n";
		
		this.data=this.data.replace(/\n/g,"<br />");
	},
	
	_0:function(num){return (num<10?"0"+num:num)}
};



// main handler
function GET(obj){
	if(!window.AJAX_HANDLER) return false;
	//HTMLAJAX.lastCall=function(e){window["GET"](obj,e)};
		
	var htmlajax=new HTMLAJAX(obj); /*init parent class*/
	htmlajax.req.file=AJAX_HANDLER;
	htmlajax.req.query=htmlajax.url2query(obj.ref||obj.aref||_ATTR(obj,"aref")||_ATTR(obj,"href")||_ATTR(obj,"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();
};

//Â© <stipuha /> development (2007)
//> Custom forms controls

var Forms={};


// check single value
Forms.checkValue=function(value,rule){
	var rules=[];
	var reg_ext=/.+\.([A-Za-z0-9]+)/;
	var reg_url=/^http:\/\/.+\..+/;
	rules["video_ext"]={"avi":1,"mpe":1,"mpeg":1,"wmv":1,"aif":1,"mov":1,"mkv":1,"flv":1,"mp2":1,"mp4":1,"rm":1,"dv":1,"yuv":1,"3gp":1,"3gp2":1};
	rules["image_ext"]={"jpg":1,"jpeg":1,"gif":1,"eps":1,"pcx":1,"raw":1,"pct":1,"pict":1,"pxr":1,"png":1,"pbm":1,"pgm":1,"ppm":1,"pnm":1,"pfm":1,"pam":1,"tga":1,"vda":1,"icb":1,"vst":1,"tif":1,"tiff":1,"bmp":1,"apx":1,"cpt":1,"gbr":1,"iff":1,"img":1,"jp2":1,"jpc":1,"j2c":1,"jpx":1,"kdc":1,"qti":1,"qtif":1,"xcf":1};
	rules["audio_ext"]={"mp3":1,"wav":1,"mid":1};
	if(rule=="video_ext") return rules["video_ext"][value.replace(reg_ext, "$1").toLowerCase()];
	if(rule=="image_ext") return rules["image_ext"][value.replace(reg_ext, "$1").toLowerCase()];
	if(rule=="audio_ext") return rules["audio_ext"][value.replace(reg_ext, "$1").toLowerCase()];
	if(rule=="url") return reg_url.test(value);
	return false;
};



Forms.checkFields=function(obj){
	function concat(arrarr){
		var outarr=[];
		for(var i=0, l=arrarr.length; i<l; i++)
			for(var j=0, ll=arrarr[i].length; j<ll; j++)
				outarr.push(arrarr[i][j]);
		return outarr;
	};
	var form=obj;
	while(form.tagName.toLowerCase()!="form") form=form.parentNode; //find form element in parent nodes
	var els=concat([form.getElementsByTagName("input"),form.getElementsByTagName("textarea"),form.getElementsByTagName("select")]);
	var req;
	for(var i=0, l=els.length; i<l; i++){
		if(req=els[i].getAttribute("require")){
			if(els[i].getAttribute("send")!=undefined && !eval(els[i].getAttribute("send"))) continue; //if field is not to send
			if(req=="empty" && els[i].value.replace(/\s+/,"")=="") return document.alert(els[i].lang);
			if(req=="checked" && !els[i].checked) return document.alert(els[i].lang);
			if(req=="video_ext" && !Forms.checkValue(els[i].value,"video_ext")) return document.alert(els[i].lang);
			if(req=="image_ext" && !Forms.checkValue(els[i].value,"image_ext")) return document.alert(els[i].lang);
			if(req=="audio_ext" && !Forms.checkValue(els[i].value,"audio_ext")) return document.alert(els[i].lang);
			if(req=="url" && !Forms.checkValue(els[i].value,"url")) return document.alert(els[i].lang);
		}
	}
	return true;
};

// reset form fields
Forms.fieldsReset=function(root){
	function clearInputFile(inp){
		var par=inp.parentNode;
		inp.parentNode.innerHTML=inp.parentNode.innerHTML;
		return par.getElementsByTagName("input")[0];
	};
	var els=root.getElementsByTagName("*");
	for(var i=0, l=els.length; i<l; i++){
		if(!els[i] || _ATTR(els[i],"reset")=="false") continue;
		
		if(els[i].getAttribute("temporary")!=undefined) els[i].innerHTML="";
		if(els[i].getAttribute("disabled")!=undefined) els[i].disabled=els[i].getAttribute("disabled")?1:0;
		if(els[i].getAttribute("send")!=undefined) els[i].setAttribute("send",0);
		if(_ATTR(els[i],"type")=="file") clearInputFile(els[i]);
		if(_ATTR(els[i],"type")=="checkbox") els[i].checked=0;
		//if(els[i].onfocus){ els[i].onfocus(); }
		if(_ATTR(els[i],"type")=="text" || els[i].tagName.toLowerCase()=="textarea"){
			els[i].value="";
			if(els[i].def_value && els[i].onblur) els[i].onblur();
		}
		if(els[i].reset) els[i].reset(); //for custom select
		if(_ATTR(els[i],"onreset")) els[i][_ATTR(els[i],"onreset")](); //start onreset event
	}
	return false;
};


//fix textarea length
Forms.maxlength=function(obj, len){
	obj.value=obj.value.substr(0,len)
};




Forms.dropAjaxFilter=function(input){
	//return false;
	var list=document.createElement("div");
	list.className="drop_filter";
	input.parentNode.insertBefore(list,input.nextSibling);
	CSS(input.parentNode).set({zIndex:1}); //IE fix
	list.style.display="none";
	input.inFocus=true;
	input.isOpen=false;
	input.onkeydown=function(e){if(Key(e).is(13)) return input.onenter(); } //lock form autosend
	input.onkeyup=function(e){
		if(this.isOpen && (Key(e).is(40) || Key(e).is(38) || Key(e).is(13))) return list.act(Key(e).code());
		this._value=this.value; 
		if(this.value) GET(this);
		else list.close();
	}; 
	addEvent(input, "focus", function(){ this.onkeyup(); this.inFocus=true});
	addEvent(input, "blur", function(){ list.close(); this.inFocus=false;});
	input.oncomplete="if(this.inFocus){ this.list.showhide(1); this.list.init(); }";
	input.onenter=_EV(input, "onenter");
	input.setAttribute("indicator","0");
	input.target=input.list=list;
	list.input=input;
	list.init=function(){
		var items=_(list, "~@a");
		if(!items) return list.showhide(0);
		for(var i=0; i<items.length; i++){
			items[i].onmousedown=function(){list.lock=true};
			items[i].onclick=function(){input.value=this.innerHTML; return list.go(); };
			items[i].onmouseup=function(){list.lock=false};
		}
	};
	list.close=function(){
		if(!list.lock) setTimeout(function(){list.showhide(0);},100);
	};
	list.showhide=function(b){
		input.isOpen=showhide(list,b);
	};
	list.act=function(code){
		if(code==13){
			 if(list.cur) input._value=input.value;
			 return list.go();
		}
		if(!list.firstChild) return false;
		var next;
		list.cur=_(list, "~a.act");
		if(list.cur) list.cur.className="";
		if(!list.cur) next=list[code==40?"firstChild":"lastChild"];
		else next=list.cur[code==40?"nextSibling":"previousSibling"];
		if(next){
			next.className="act";
			input.value=next.innerHTML;
			list.cur=next;
		}
		else input.value=input._value;
		return false;
	};
	list.go=function(code){
		 list.showhide(0); 
		 return false;
	};
};



//stylizing FileBrowse control (autoreplace)
//expamle: 
//	<span id="upload_img"></span>
//	<a class="but_ort" type="file" name="file_1" target="upload_img">Browse...</a>
Forms.fileBrowse=function(obj){
	this.init=function(){
		this.obj=obj;
		obj.onmouseover=function(){return false};
		obj.onclick=function(){ return false};
		
		var input=document.createElement("input");
		input.type="file";
		input.name=obj.getAttribute("name");
		input._onchange=obj.onchange;
		input.size=1;
		if(obj.getAttribute("lang")) input.setAttribute("lang", obj.getAttribute("lang"));
		if(obj.getAttribute("flag")) input.setAttribute("flag", obj.getAttribute("flag"));
		
	
		var but_browse=document.createElement("div");
		but_browse.className=obj.className;
		but_browse.innerHTML=obj.innerHTML;
		but_browse.target=_ATTR(obj, "target");
		but_browse.sender=_ATTR(obj, "sender");
		but_browse.loader=_ATTR(obj, "loader");
		but_browse.clear=_ATTR(obj, "clear");
		but_browse.onclear=function(){
			if(this.target) _(this.target).innerHTML="&nbsp;"; 
			Forms.fieldsReset(this);
			this.getElementsByTagName("input")[0].onchange=input.onchange;
		};
				
		obj.parentNode.replaceChild(but_browse,obj);
		obj=but_browse;
		input.browse=obj;
		
		if(this.obj.getAttribute("hidden")){
			var input_hidden=document.createElement("input");
			input_hidden.type="hidden";
			input_hidden.name=this.obj.getAttribute("hidden");
			input_hidden.value=0;
			obj.insertBefore(input_hidden, obj.firstChild);
		}
		
		input.onchange=function(){
			if(input._onchange) input._onchange();
			if(obj.target) _(obj.target).innerHTML=Forms.getFileName(this.value); 
			if(input_hidden) input_hidden.value=this.value?1:0;
		};
		
		
		CSS(input).set({fontSize:'100px', position:'absolute', margin:'-30px 0 0 -300px', opacity:0, filter:'Alpha(opacity:0)', cursor:'pointer'});
		CSS(obj).set({overflow:'hidden'});
		if(CSS(obj).check({position:'static'})) CSS(obj).set({position:'relative'});
		obj.insertBefore(input,obj.firstChild);
		
	};
	return this.init();
};


//parse path string
Forms.getFileName=function(value){
	return value.replace(/([^\\]*\\)+([^\\]*\.[A-Za-z]+)/, "$2");
};

//input functions
Forms.input=function(obj){
	
	var _this=this;
	
	this.init=function(){
		obj.onfocus=null;
		if(obj.getAttribute("mask")){
			addEvent(obj, "keyup", function(event){_this.mask(this)});
			addEvent(obj, "blur", function(event){_this.mask(this)});
		}
		if(obj.getAttribute("onenterkey")){
			addEvent(obj, "keyup", function(event){if(_this.isEnter(event)) _EV(this,'onenterkey')()});
		}
		if(obj.getAttribute("default")!=undefined){
			this.setDefault(obj);
		}
		
		return this;
	};
	
	//apply RegExp mask onkey up
	this.mask=function(obj){
		var re=new RegExp("[^"+obj.getAttribute("mask")+"]","gi");
		obj.value=obj.value.replace(re,"");
	};
	
	//check enter key
	this.isEnter=function(event){
		return (window.event?window.event.keyCode:event.which)==13;
	};
	
	//init default input value & input styles
	this.setDefault=function(obj){
		function setOpt(obj){
			if(obj.def_opt) CSS(obj).set(obj.def_value==obj.value?obj.def_style:obj.def_opt);
		};
		//init
		if(!obj.def_value){
			var opt=_ATTR(obj,"default");
			if(opt && /^{[^}]*}$/.test(opt)){ 
				obj.def_opt=(new Function("return "+opt))();
				obj.def_value=obj.value=obj.getAttribute("value") || obj.value;
				obj.def_style=CSS(obj).get(obj.def_opt);
			}
			else if(opt) obj.def_value=obj.def_text=opt;
			addEvent(obj, "focus", function(){_this.setDefault(this)});
			addEvent(obj, "blur", function(){if(!this.value) this.value=this.def_value; setOpt(this)});
		}
		//execute
		//alert(obj.name+": "+obj.def_value+" -- "+obj.value);
		if(obj.def_value==obj.value) obj.value=obj.def_text?obj.def_text:"";
		setOpt(obj);
		
	};
	return this.init();
};




Forms.checkbox=function(obj){
	obj.chb=obj.getElementsByTagName("input")[0];
	if(!obj.classNative){
		CSS(obj.chb).set({opacity:"0", filter:"alpha(opacity:0)", cursor:"pointer"});
		if(!obj.className) obj.className="checkbox";
		obj.classNative=obj.className;
		obj.classAct=obj.className+" "+obj.className+"_act";
		obj._checked=0;
	}
	if(obj.chb.checked){
		obj.className=obj.classAct;
		obj._checked=1;
	}
	obj.onclick=function(e){
		var target=window.event?window.event.srcElement:e.target;
		this._checked=this._checked?0:1;
		this.className=this._checked?this.classAct:this.classNative;
		if(target.tagName==this.tagName){ 
			this.chb.checked=this._checked;
			if(this.chb.onchange) this.chb.onchange(); 
			return false; 
		}
		else if(this.chb.onchange) this.chb.blur(); 
		return true;
	}
};




//Custom select control
//--------------------------------
//> INITIALIZE
//  new Select(select_obj)

Forms.select=function(obj){
	var _this=this,
		cur_act,
		inInit=true,
		isOver=false,
		isOpen=false;
	
	obj.style.display="none";
	
	
	var inherit_width=CSS(obj).get("width");
	
	var block=document.createElement("span");
	block.className="select "+obj.className;
	block.onmouseover=function(){isOver=1};
	block.onmouseout=function(){isOver=0};
			
	//create hidden input element for submit
	var element=document.createElement("input");
	element.type="hidden";
	element.value=obj.value;
	element.name=obj.name;
	element.id=obj.id;
	element.disabled=obj.disabled;
	element.aref=_ATTR(obj, "aref");
	element.target=_ATTR(obj, "target");
	element.title=obj.title;
	element.onchange=obj.onchange;
	element.onblur=obj.onblur;
	element.autoload=(_ATTR(obj,"autoload")!=undefined);
	element.className="";
	element.update=function(){update(element)};
	element.reset=function(){set(element.defaultElement)};
	element.disable=function(b){disable(b)};
	block.input=element;
	block.appendChild(element);
	
	
	var field=document.createElement("span");
	field.className="field";
	var arrow=document.createElement("span");
	arrow.className="arrow";
	field.appendChild(arrow);
	var content=document.createElement("span");
	content.innerHTML="&nbsp;";
	field.appendChild(content);
	block.appendChild(field);
	field.onclick=function(){return showhide()};
								
	var dropdown=document.createElement("span");
	dropdown.className="dropdown";
	
	element.root=block;
	element.field=field;
	element.options=[];
	if(obj.options.length)
		for(var i=0; i<obj.options.length; i++) {
			var a=document.createElement("a");
			a.innerHTML=obj.options[i].innerHTML?obj.options[i].innerHTML:"&nbsp;";
			a.className="item "+obj.options[i].className;
			a.value=obj.options[i].value;
			a.onclick=function(){return set(this);};
			CSS(a).set({display:"block", whiteSpace:"nowrap", textDecoration:"none"});
			//CSS(a).copy("color", obj.options[i]);
			element.options.push(a);
			if(obj.options[i].selected || obj.value==a.value) element.selected=element.defaultElement=a;
			if(_ATTR(obj.options[i],"image")){
				var img=document.createElement("img");
				img.src=_ATTR(obj.options[i],"image");
				a.insertBefore(img, a.firstChild);
			}
			dropdown.appendChild(a);
		}
	block.appendChild(dropdown);
	setTimeout(function(){create()},12); //replace select to custom select after initializing
		

	var create=function(){
		if(!obj || !obj.parentNode) return false;
		
		obj.parentNode.replaceChild(block, obj);
		
		if(!_this.constructor.array) _this.constructor.array=[];
		_this.constructor.array.push(block); //add to constructor array (Forms.select.array)
		
		//overwrite styles
		
		CSS(block).set({position:"relative", textDecoration:"none"});
		if(BROWSER.ie){
			//fix z-index for IE
			var zIndex=100-_this.constructor.array.length;
			CSS(block).set({zIndex:zIndex});
			CSS(block.parentNode).set({zIndex:zIndex});
		} 
		CSS(field).set({whiteSpace:"nowrap", cursor:"default"});
		CSS(content).set({cursor:"default"});
		CSS(dropdown).set({position:"absolute", visibility:"hidden", overflow:"auto", left:"-"+CSS(block).get("borderLeftWidth"), zIndex:2});
		CSS(arrow).set({position:"absolute", display:"block", top:0, right:0, cursor:"pointer", height:block.clientHeight+"px", zIndex:1});

		if(inherit_width!="auto" && block.clientWidth<10){
			block.style.width=inherit_width;
		}
		
		CSS(dropdown).set({top:block.clientHeight+"px"});
		
		if(element.disabled) disable(1);
		
		if(obj.options.length){
			element.selected ? set(element.selected) : set(element.options[0]); //set default or act
			addEvent(document,"mouseup", function(){if(isOpen && !isOver) setTimeout(function(){showhide(0)},40)}); //define exernal click event
		}
		
		CSS(dropdown).set({width:block.clientWidth+"px"});
		autoInlineWidth();
		
		inInit=false;
	};
	
	
	var autoInlineWidth=function(){
		if(CSS(block).check({display:"block"})) return false; //control is block
		field.style["paddingRight"]=0;
		var offset=dropdown.scrollWidth-field.offsetWidth-parseInt(CSS(field).get("marginRight"))-parseInt(CSS(field).get("marginLeft"));
		if(offset>0) field.style["paddingRight"]=offset+"px";
	};
	
	
		
	var showhide=function(d){
		if(element.disabled) return false;
		if(parseInt(CSS(dropdown).get("height"))>=dropdown.scrollHeight) CSS(dropdown).set({height:"auto"}); //if scroll bar = auto height
		if(d==undefined) d=dropdown.style.visibility!="visible";
		dropdown.style.visibility=d?"visible":"hidden";
		
		_this.isOpen=isOpen=d;
		return false;
	};
	
	
	var set=function(obj){
		element.prevValue=element.value;
		element.value=obj.value;
		element.selected=obj;
		content.innerHTML=obj.innerHTML;
		
		autoInlineWidth();
		showhide(0);
		
		if((!inInit && element.prevValue!=element.value) || element.autoload){
			if(element.onchange) element.onchange(); //call onchange event
			if(element.onblur) element.onblur(); //call onchange event
			if(element.aref) GET(element); //call onchange event 
		}
		
		//act element in dropdown
		if(cur_act) Style(cur_act).remove("act");
		Style(obj).add("act");
		cur_act=obj;
		
		return false;
	};
	
	var update=function(element){
		//Style(element.field)[element.disabled?"add":"remove"]("disabled");
		for(var i=0; i<element.options.length; i++) {
			if(element.options[i].value==element.value){
				set(element.options[i]);
				break;	
			}				
		}
	};
	
	var disable=function(b){
		element.disabled=b;
		CSS(block).set({opacity:b?0.5:1});
		block.title=b?element.title:"";
	};
	
	
	
	return this;
};
/*
----------------------------------------------------------------------
EXAMPLE:

smooth=new Smooth({dyn:35, speed:-2, to:300});
smooth.onplay=function(pos){obj.style.height=pos+"px"};
smooth.onend=function(d){ CSS(obj).set({display:d>0?"block":"none"})};

----------------------------------------------------------------------
opt={
	dyn:     [-100..+100]   //dynamic scroling (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=function(opt){
	
	//init values & default styles
	var _this=this;
	var tm, d, range, startPos, curPos, endPos;
	
	opt.dyn=(opt.dyn!=undefined?opt.dyn:-50)/100;
	opt.speed=opt.speed?(opt.speed>0?opt.speed:-1/opt.speed):1;
	
	this.from=opt.from || 0;
	this.to=opt.to || 100;
	
	var start=function(from, to){
		if(tm) end(1);
		d=from<to?1:-1; //direction
		_this.onstart(d);
		startPos=curPos=from;
		endPos=to;
		range=0;
		play(); 
	};
	var play=function(){
		if(opt.dyn!=0) range=Math.round((opt.dyn>0?(endPos-curPos)*opt.dyn:-(curPos-startPos)*opt.dyn)*opt.speed);
		if(range*d<1) range=d*opt.speed;
		curPos+=range;
		if(endPos*d<curPos*d) return end();
		_this.onplay(curPos);
		tm=setTimeout(function(){play()},10);
	};
	var end=function(false_start){
		clearTimeout(tm);
		tm=null;
		curPos=endPos;
		_this.onplay(curPos);
		if(!false_start) _this.onend(d);
		return false;
	};
	

	this.go=function(){start(this.from, this.to)};
	this.back=function(){start(this.to, this.from)};
	this.start=function(from, to){start(from, to)};
	this.onstart=function(){};
	this.onplay=function(){};
	this.onend=function(){};
	
	return this;
}
/*	sIFR v2.0.7 SOURCE
	Copyright 2004 - 2008 Mark Wubben and Mike Davidson. Prior contributions by Shaun Inman and Tomas Jogin.

	This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>
*/

var hasFlash = function(){
	var nRequiredVersion = 6;	
	
	if(navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.indexOf("Windows") > -1){
		document.write('<script language="VBScript"\> \non error resume next \nhasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & ' + nRequiredVersion + '))) \n</script\> \n');
		/*	If executed, the VBScript above checks for Flash and sets the hasFlash variable. 
			If VBScript is not supported it's value will still be undefined, so we'll run it though another test
			This will make sure even Opera identified as IE will be tested */
		if(window.hasFlash != null){
			return window.hasFlash;
		};
	};
	
	if(navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
		var flashDescription = (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description;
		return parseInt(flashDescription.substr(flashDescription.indexOf(".") - 2, 2), 10) >= nRequiredVersion;
	};
	
	return false;
}();

String.prototype.normalize = function(){
	return this.replace(/\s+/g, " ");
};

/* IE 5.0 does not support the push method, so here goes */
if(Array.prototype.push == null){
	Array.prototype.push = function(){
		var i = 0, index = this.length, limit = arguments.length;
		while(i < limit){
			this[index++] = arguments[i++];
		};
		return this.length;
	};
};

/*	Implement function.apply for browsers which don't support it natively
	Courtesy of Aaron Boodman - http://youngpup.net */
if (!Function.prototype.apply){
	Function.prototype.apply = function(oScope, args) {
		var sarg = [];
		var rtrn, call;

		if (!oScope) oScope = window;
		if (!args) args = [];

		for (var i = 0; i < args.length; i++) {
			sarg[i] = "args["+i+"]";
		};

		call = "oScope.__applyTemp__(" + sarg.join(",") + ");";

		oScope.__applyTemp__ = this;
		rtrn = eval(call);
		oScope.__applyTemp__ = null;
		return rtrn;
	};
};

/*	The following code parses CSS selectors.
	This script however is not the right place to explain it,
	please visit the documentation for more information. */
var parseSelector = function(){
	var reParseSelector = /^([^#.>`]*)(#|\.|\>|\`)(.+)$/;
	function parseSelector(sSelector, oParentNode){
		var listSelectors = sSelector.split(/\s*\,\s*/);
		var listReturn = [];
		for(var i = 0; i < listSelectors.length; i++){
			listReturn = listReturn.concat(doParse(listSelectors[i], oParentNode));
		};
		
		return listReturn;
	};
	
	function doParse(sSelector, oParentNode, sMode){
		sSelector = sSelector.replace(" ", "`");
		var selector = sSelector.match(reParseSelector);
		var node, listNodes, listSubNodes, subselector, i, limit;
		var listReturn = [];
		
		if(selector == null){ selector = [sSelector, sSelector] };
		if(selector[1] == ""){ selector[1] = "*" };
		if(sMode == null){ sMode = "`" };
		if(oParentNode == null){
			oParentNode = document;
		};

		switch(selector[2]){
			case "#":
				subselector = selector[3].match(reParseSelector);
				if(subselector == null){ subselector = [null, selector[3]] };
				node = 	document.getElementById(subselector[1]);
				if(node == null || (selector[1] != "*" && !matchNodeNames(node, selector[1]))){
					return listReturn;
				};
				if(subselector.length == 2){
					listReturn.push(node);
					return listReturn;	
				};
				return doParse(subselector[3], node, subselector[2]);
			case ".":
				if(sMode != ">"){
					listNodes = getElementsByTagName(oParentNode, selector[1]);
				} else {
					listNodes = oParentNode.childNodes;
				};
				
				for(i = 0, limit = listNodes.length; i < limit; i++){
					node = listNodes[i];
					if(node.nodeType != 1){
						continue;	
					};
					subselector = selector[3].match(reParseSelector);
					if(subselector != null){
						if(node.className == null || node.className.match("(\\s|^)" + subselector[1] + "(\\s|$)") == null){
							continue;
						};
						listSubNodes = doParse(subselector[3], node, subselector[2]);
						listReturn = listReturn.concat(listSubNodes);	
					} else if(node.className != null && node.className.match("(\\s|^)" + selector[3] + "(\\s|$)") != null){
						listReturn.push(node);
					};
				};
				return listReturn;
			case ">":
				if(sMode != ">"){
					listNodes = getElementsByTagName(oParentNode, selector[1]);
				} else {
					listNodes = oParentNode.childNodes;
				};
								
				for(i = 0, limit = listNodes.length; i < limit; i++){
					node = listNodes[i];
					
					if(node.nodeType != 1){
						continue;	
					};
					
					if(!matchNodeNames(node, selector[1])){
						continue;
					};
					listSubNodes = doParse(selector[3], node, ">");
					listReturn = listReturn.concat(listSubNodes);	
				};
				return listReturn;
			case "`":
				listNodes = getElementsByTagName(oParentNode, selector[1]);
				for(i = 0, limit = listNodes.length; i < limit; i++){
					node = listNodes[i];
					listSubNodes = doParse(selector[3], node, "`");
					listReturn = listReturn.concat(listSubNodes);	
				};
				return listReturn;
			default:
				if(sMode != ">"){
					listNodes = getElementsByTagName(oParentNode, selector[1]);
				} else {
					listNodes = oParentNode.childNodes;
				};

				for(i = 0, limit = listNodes.length; i < limit; i++){
					node = listNodes[i];
					if(node.nodeType != 1){
						continue;	
					};
					if(!matchNodeNames(node, selector[1])){
						continue;
					};
					listReturn.push(node);
				};
				return listReturn;
		};
	};
	
	function getElementsByTagName(oParentNode, sTagName){
		/*	IE5.x does not support document.getElementsByTagName("*")
			therefore we're falling back to element.all */
		if(sTagName == "*" && oParentNode.all != null){
			return oParentNode.all;
		};
		return oParentNode.getElementsByTagName(sTagName);
	};
	
	function matchNodeNames(node, sMatch){
		if(sMatch == "*"){
			return true;
		};
		return node.nodeName.toLowerCase().replace("html:", "") == sMatch.toLowerCase();
	};
	
	return parseSelector;
}();

/*	Adds named arguments support to JavaScript. */
function named(oArgs){ 
	return new named.Arguments(oArgs);
};

named.Arguments = function(oArgs){
	this.oArgs = oArgs;
};

named.Arguments.prototype.constructor = named.Arguments;

named.extract = function(listPassedArgs, oMapping){
	var oNamedArgs, passedArg;
	
	var i = listPassedArgs.length;
	while(i--){
		passedArg = listPassedArgs[i];
		if(passedArg != null && passedArg.constructor != null && passedArg.constructor == named.Arguments){
			oNamedArgs = listPassedArgs[i].oArgs; /* oNamedArgs isn't the named.Arguments class! */
			break;
		};
	};

	if(oNamedArgs == null){ return };
	
	for(sName in oNamedArgs){
		if(oMapping[sName] != null){
			oMapping[sName](oNamedArgs[sName]);
		};
	};
	
	return;
};

/*	Executes an anonymous function which returns the function sIFR (defined inside the function).
	You can replace elements using sIFR.replaceElement()
	All other variables and methods you see are private. If you want to understand how this works you should
	learn more about the variable-scope in JavaScript. */
var sIFR = function(){
	/* Opera and Mozilla require a namespace when creating elements in an XML page */
	var sNameSpaceURI = "http://www.w3.org/1999/xhtml";
	var bIsInitialized = false;
	var bIsSetUp = false;
	var bInnerHTMLTested = false;
	var sDocumentTitle;
	var stackReplaceElementArguments = [];
	var UA = function(){
		var sUA = navigator.userAgent.toLowerCase();
		var oReturn =  {
			bIsWebKit : sUA.indexOf("applewebkit") > -1,
			bIsSafari : sUA.indexOf("safari") > -1,
			bIsKonq: navigator.product != null && navigator.product.toLowerCase().indexOf("konqueror") > -1,
			bIsOpera : sUA.indexOf("opera") > -1,
			bIsXML : document.contentType != null && document.contentType.indexOf("xml") > -1,
			bHasTransparencySupport : true,
			bUseDOM : true,
			nFlashVersion : null,
			nOperaVersion : null,
			nGeckoBuildDate : null,
			nWebKitVersion : null
		};
		
		oReturn.bIsKHTML = oReturn.bIsWebKit || oReturn.bIsKonq;
		oReturn.bIsGecko = !oReturn.bIsWebKit && navigator.product != null && navigator.product.toLowerCase() == "gecko";
		if(oReturn.bIsGecko && sUA.match(/.*gecko\/(\d{8}).*/)){ oReturn.nGeckoBuildDate = new Number(sUA.match(/.*gecko\/(\d{8}).*/)[1]) };
    if(oReturn.bIsOpera && sUA.match(/.*opera(\s|\/)(\d+\.\d+)/)){ oReturn.nOperaVersion = new Number(sUA.match(/.*opera(\s|\/)(\d+\.\d+)/)[2]) };
		oReturn.bIsIE = sUA.indexOf("msie") > -1 && !oReturn.bIsOpera && !oReturn.bIsKHTML && !oReturn.bIsGecko;
		oReturn.bIsIEMac = oReturn.bIsIE && sUA.match(/.*mac.*/) != null;
		if(oReturn.bIsIE || (oReturn.bIsOpera && oReturn.nOperaVersion < 7.6)){ oReturn.bUseDOM = false };
		if(oReturn.bIsWebKit && sUA.match(/.*applewebkit\/(\d+).*/)){ oReturn.nWebKitVersion = new Number(sUA.match(/.*applewebkit\/(\d+).*/)[1]) };
		if(window.hasFlash && (!oReturn.bIsIE || oReturn.bIsIEMac)){ 
			var flashDescription = (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description;
			oReturn.nFlashVersion = parseInt(flashDescription.substr(flashDescription.indexOf(".") - 2, 2), 10);
		};
		if(sUA.match(/.*(windows|mac).*/) == null || 
		oReturn.bIsIEMac || oReturn.bIsKonq || 
		(oReturn.bIsOpera && oReturn.nOperaVersion < 7.6) || 
		(oReturn.bIsSafari && oReturn.nFlashVersion < 7) ||
		(!oReturn.bIsSafari && oReturn.bIsWebKit && oReturn.nWebKitVersion < 312) || 
		(oReturn.bIsGecko && oReturn.nGeckoBuildDate < 20020523)){
			oReturn.bHasTransparencySupport = false;
		};

		if(!oReturn.bIsIEMac && !oReturn.bIsGecko && document.createElementNS){
			try {
				document.createElementNS(sNameSpaceURI, "i").innerHTML = "";
			} catch(e){
				oReturn.bIsXML = true;
			};
		};
		
		oReturn.bUseInnerHTMLHack = oReturn.bIsKonq || (oReturn.bIsWebKit && oReturn.nWebKitVersion < 312);
		
		return oReturn;
	}();
	
	/*	Disable sIFR for non-Flash or old browsers
		Also disable it for IE and KHTML browsers in XML mode, since we are using innerHTML for those browsers */
	if(window.hasFlash == false || !document.createElement || !document.getElementById || (UA.bIsXML && (UA.bUseInnerHTMLHack || UA.bIsIE))){
		return {UA:UA};
	};
	
	function sIFR(e){
		if((!self.bAutoInit && (window.event || e) != null) || !mayReplace(e)){
			return;	
		};
		bIsInitialized = true;
		
		for(var i = 0, limit = stackReplaceElementArguments.length; i < limit; i++){
			replaceElement.apply(null, stackReplaceElementArguments[i]);
		};
		stackReplaceElementArguments = [];
	};
	
	var self = sIFR;

	function mayReplace(e){
		if(bIsSetUp == false || self.bIsDisabled == true || ((UA.bIsXML && UA.bIsGecko || UA.bIsKHTML) && e == null && bIsInitialized == false) || document.getElementsByTagName("body").length == 0){
			return false;
		};
		return true;
	};
	
	function escapeHex(sHex){
		if(UA.bIsIE){ /* The RegExp for IE breaks old Gecko's, the RegExp for non-IE breaks IE 5.01 */
			return sHex.replace(new RegExp("%\d{0}", "g"), "%25");
		}
		return sHex.replace(new RegExp("%(?!\d)", "g"), "%25");
	};
	
	function matchNodeNames(node, sMatch){
		if(sMatch == "*"){
			return true;
		};	
		return node.nodeName.toLowerCase().replace("html:", "") == sMatch.toLowerCase();
	};

	function fetchContent(node, nodeNew, sCase, nLinkCount, sLinkVars){
		var sContent = "";
		var oSearch = node.firstChild;
		var oRemove, nodeRemoved, oResult, sValue;

		if(nLinkCount == null){ nLinkCount = 0 };
		if(sLinkVars == null){ sLinkVars = "" };

		while(oSearch){
			if(oSearch.nodeType == 3){
				sValue = oSearch.nodeValue.replace("<", "&lt;");
				switch(sCase){
					case "lower":
						sContent += sValue.toLowerCase();
						break;
					case "upper":
						sContent += sValue.toUpperCase();
						break;
					default:
						sContent += sValue;
				};
			} else if(oSearch.nodeType == 1){
				if(matchNodeNames(oSearch, "a") && !oSearch.getAttribute("href") == false){
					if(oSearch.getAttribute("target")){
						sLinkVars += "&sifr_url_" + nLinkCount + "_target=" + oSearch.getAttribute("target");
					};
					sLinkVars += "&sifr_url_" + nLinkCount + "=" + escapeHex(oSearch.getAttribute("href")).replace(/&/g, "%26");
					sContent += '<a href="asfunction:_root.launchURL,' + nLinkCount + '">';
					nLinkCount++;
				} else if(matchNodeNames(oSearch, "br")){
					sContent += "<br/>";
				};
				if(oSearch.hasChildNodes()){
					/*	The childNodes are already copied with this node, so nodeNew = null */
					oResult = fetchContent(oSearch, null, sCase, nLinkCount, sLinkVars);
					sContent += oResult.sContent;
					nLinkCount = oResult.nLinkCount;
					sLinkVars = oResult.sLinkVars;
				};
				if(matchNodeNames(oSearch, "a")){
					sContent += "</a>";
				};
			};
			oRemove = oSearch;
			oSearch = oSearch.nextSibling;
			if(nodeNew != null){
				nodeRemoved = oRemove.parentNode.removeChild(oRemove);
				nodeNew.appendChild(nodeRemoved);	
			};
		};
		
		return {"sContent" : sContent, "nLinkCount" : nLinkCount, "sLinkVars" : sLinkVars};
	};
	
	function createElement(sTagName){
		if(document.createElementNS && UA.bUseDOM){
			return document.createElementNS(sNameSpaceURI, sTagName);	
		} else {
			return document.createElement(sTagName);
		};
	};

	function createObjectParameter(nodeObject, sName, sValue){
		var node = createElement("param");
		node.setAttribute("name", sName);	
		node.setAttribute("value", sValue);
		nodeObject.appendChild(node);
	};
	
	/*	Konqueror does not treat empty classNames as strings, so we need a workaround */
	function appendToClassName(node, sAppend){
		var sClassName = node.className;
		if(sClassName == null){
			sClassName = sAppend;
		} else {
			sClassName = sClassName.normalize() + (sClassName == "" ? "" : " ") + sAppend;
		};
		node.className = sClassName;
	};
	
	function prepare(bNow){
		var node = document.documentElement;
		if(self.bHideBrowserText == false){
			node = document.getElementsByTagName("body")[0];
		};
		if((self.bHideBrowserText == false || bNow) && node){
			if(node.className == null || node.className.match(/\bsIFR\-hasFlash\b/) == null){
				appendToClassName(node, "sIFR-hasFlash");
			};
		};
	};
	
	function replaceElement(sSelector, sFlashSrc, sColor, sLinkColor, sHoverColor, sBgColor, nPaddingTop, nPaddingRight, nPaddingBottom, nPaddingLeft, sFlashVars, sCase, sWmode){
		if(!mayReplace()){
			return stackReplaceElementArguments.push(arguments);	
		};

		prepare();
		
		/*	Extract any named arguments.	*/
		named.extract(arguments, {
			sSelector : function(value){ sSelector = value },
			sFlashSrc : function(value){ sFlashSrc = value },
			sColor : function(value){ sColor = value },
			sLinkColor : function(value){ sLinkColor = value },
			sHoverColor : function(value){ sHoverColor = value },
			sBgColor : function(value){ sBgColor = value },
			nPaddingTop : function(value){ nPaddingTop = value },
			nPaddingRight : function(value){ nPaddingRight = value },
			nPaddingBottom : function(value){ nPaddingBottom = value },
			nPaddingLeft : function(value){ nPaddingLeft = value },
			sFlashVars : function(value){ sFlashVars = value },
			sCase : function(value){ sCase = value },
			sWmode : function(value){ sWmode = value }
		});

		/* Check if we can find any nodes first */
		var listNodes = parseSelector(sSelector);
		if(listNodes.length == 0){ return false };

		/*	Set default values. */
		if(sFlashVars != null){
			sFlashVars = "&" + sFlashVars.normalize();
		} else {
			sFlashVars = "";	
		};
		
		if(sColor != null){sFlashVars += "&textcolor=" + sColor};
		if(sHoverColor != null){sFlashVars += "&hovercolor=" + sHoverColor};
		if(sHoverColor != null || sLinkColor != null){sFlashVars += "&linkcolor=" + (sLinkColor || sColor)};
		
		if(nPaddingTop == null){ nPaddingTop = 0 };
		if(nPaddingRight == null){ nPaddingRight = 0 };
		if(nPaddingBottom == null){ nPaddingBottom = 0 };
		if(nPaddingLeft == null){ nPaddingLeft = 0 };

		if(sBgColor == null){ sBgColor = "#FFFFFF" };
		
		if(sWmode == "transparent"){
			if(!UA.bHasTransparencySupport){
				sWmode = "opaque";
			} else {
				sBgColor = "transparent";
			};
		};
		
		if(sWmode == null){ sWmode = "" };
	
		/*	Do the actual replacement. */
		var node, sWidth, sHeight, sMargin, sPadding, sVars, nodeAlternate, nodeFlash, oContent;
		var nodeFlashTemplate = null;

		for(var i = 0, limit = listNodes.length; i < limit; i++){
			node = listNodes[i];

			/* Prevents elements from being replaced multiple times. */
			if(node.className != null && node.className.match(/\bsIFR\-replaced\b/) != null){ continue };
			
			sWidth = node.offsetWidth - nPaddingLeft - nPaddingRight;
			sHeight = node.offsetHeight - nPaddingTop - nPaddingBottom;
			
			if(isNaN(sWidth) || isNaN(sHeight)){
				self.bIsDisabled = true;
				document.documentElement.className = document.documentElement.className.replace(/\bsIFR\-hasFlash\b/, "");
				return;
			};

			nodeAlternate = createElement("span");
			nodeAlternate.className = "sIFR-alternate";

			oContent = fetchContent(node, nodeAlternate, sCase);
			sVars = "txt=" + escapeHex(oContent.sContent).replace(/\+/g, "%2B").replace(/&/g, "%26").replace(/\"/g, "%22").normalize() + sFlashVars + "&w=" + sWidth + "&h=" + sHeight + oContent.sLinkVars;
			
			appendToClassName(node, "sIFR-replaced");

			/*	Opera only supports the object element, other browsers are given the embed element,
				for backwards compatibility reasons between different browser versions.
				Opera versions below 7.60 use innerHTML, from 7.60 and up we use the DOM */

			if(nodeFlashTemplate == null || !UA.bUseDOM){
				if(!UA.bUseDOM){
				  if(!UA.bIsIE)
  					node.innerHTML = ['<embed class="sIFR-flash" type="application/x-shockwave-flash" src="', sFlashSrc, '" quality="best" wmode="', sWmode, '" bgcolor="', sBgColor, '" flashvars="', sVars, '" width="', sWidth, '" height="', sHeight, '" sifr="true"></embed>'].join("");
  				else
  				  node.innerHTML = ['<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" sifr="true" width="', sWidth, '" height="', sHeight, '" class="sIFR-flash">',
    				                    '<param name="movie" value="', sFlashSrc, '"></param>',
    				                    '<param name="flashvars" value="', sVars, '"></param>',
    				                    '<param name="quality" value="best"></param>',
    				                    '<param name="wmode" value="', sWmode, '"></param>',
    				                    '<param name="bgcolor" value="', sBgColor, '"></param>',
    				                  '</object>'].join('');
				} else {
					if(UA.bIsOpera){
						nodeFlash = createElement("object");
						nodeFlash.setAttribute("data", sFlashSrc);
						createObjectParameter(nodeFlash, "quality", "best");
						createObjectParameter(nodeFlash, "wmode", sWmode);
						createObjectParameter(nodeFlash, "bgcolor", sBgColor);
				  } else {
						nodeFlash = createElement("embed");
						nodeFlash.setAttribute("src", sFlashSrc);
						nodeFlash.setAttribute("quality", "best");
						nodeFlash.setAttribute("flashvars", sVars);
						nodeFlash.setAttribute("wmode", sWmode);
						nodeFlash.setAttribute("bgcolor", sBgColor);
						nodeFlash.setAttribute("pluginspace", "http://www.macromedia.com/go/getflashplayer");
						nodeFlash.setAttribute("scale", "noscale");
					};
					nodeFlash.setAttribute("sifr", "true");
					nodeFlash.setAttribute("type", "application/x-shockwave-flash");
					nodeFlash.className = "sIFR-flash";
					if(!UA.bIsKHTML || !UA.bIsXML){
						nodeFlashTemplate = nodeFlash.cloneNode(true);
					};
				};
			} else {
				nodeFlash = nodeFlashTemplate.cloneNode(true);
			};
			if(UA.bUseDOM){
				/* General settings */
				if(UA.bIsOpera){
					createObjectParameter(nodeFlash, "flashvars", sVars);
				} else {
					nodeFlash.setAttribute("flashvars", sVars);
				};
				nodeFlash.setAttribute("width", sWidth);
				nodeFlash.setAttribute("height", sHeight);
				nodeFlash.style.width = sWidth + "px";
				nodeFlash.style.height = sHeight + "px";
				node.appendChild(nodeFlash);
			};
			
			node.appendChild(nodeAlternate);

			/*	Workaround to force KHTML-browsers to repaint the document. 
				Additionally, IE for both Mac and PC need this.
				See: http://neo.dzygn.com/archive/2004/09/forcing-safari-to-repaint */

			if(UA.bUseInnerHTMLHack){
				node.innerHTML += "";
			};
		};
		
		if(UA.bIsIE && self.bFixFragIdBug){
			setTimeout(function(){document.title = sDocumentTitle}, 0);
		};
	};
	
	function updateDocumentTitle(){
		sDocumentTitle = document.title;
	};
	
	function setup(){
		if(self.bIsDisabled == true){ return };

		bIsSetUp = true;
		/*	Providing a hook for you to hide certain elements if Flash has been detected. */
		if(self.bHideBrowserText){
			prepare(true);
		};
		
		if(window.attachEvent){
			window.attachEvent("onload", sIFR);
		} else if(!UA.bIsKonq && (document.addEventListener || window.addEventListener)){
			if(document.addEventListener){
				document.addEventListener("load", sIFR, false);	
			};
			if(window.addEventListener){
				window.addEventListener("load", sIFR, false);	
			};
		} else {
			if(typeof window.onload == "function"){
				var fOld = window.onload;
				window.onload = function(){ fOld(); sIFR(); };
			} else {
				window.onload = sIFR;
			};
		};
		
		if(!UA.bIsIE || window.location.hash == ""){
			self.bFixFragIdBug = false;
		} else {
			updateDocumentTitle();
		};
	};
	
	function debug(){
		prepare(true);
	};
	
	debug.replaceNow = function(){
		setup();
		sIFR();
	};
	
	/* Public Fields */
	self.UA = UA;
	self.bAutoInit = true;
	self.bFixFragIdBug = true;
	self.replaceElement = replaceElement;
	self.updateDocumentTitle = updateDocumentTitle;
	self.appendToClassName = appendToClassName;
	self.setup = setup;
	self.debug = debug;
	self.bIsDisabled = false;
	self.bHideBrowserText = true;
	
	return self;
}();
      
/*	sIFR setup. You can add browser detection here. 
	sIFR's browser detection is exposed through sIFR.UA. */


if(typeof sIFR == "function" && !sIFR.UA.bIsIEMac && (!sIFR.UA.bIsWebKit || sIFR.UA.nWebKitVersion >= 100)){
	sIFR.setup();
};



var Slider={
	init:function(id){
		var _this=this;
		this.id=id;
		this.root=_(id);
		this.root.defaultHeight=this.root.style.height;
		
		this.arr_prev=_(id, "^a.arr_left");
		this.arr_prev.onclick=function(){return _this.move(-1)};
		this.arr_next=_(id, "^a.arr_right");
		this.arr_next.onclick=function(){return _this.move(1)};
		
		this.lock_layer=_(id, "^div.lock");
		
		this.uploadFiles=[];
		
		this.canvas=_(id, "^div.canvas");
		this.canvas.ondelete=_EV(this.canvas, "ondelete");
		this.canvas.onmouseover=function(){this.focus()};
		this.canvas.onscroll=function(){_this.scrollTM()};
		this.smooth=new Smooth({dyn:35, speed:1});
		this.smooth.onplay=function(pos){_this.canvas.scrollLeft=pos};
		
		this.field=_(this.canvas, "^div");
		this.reset();
		
		this.preState=0;
		this.imgLoader();
		
		this.inited=true;
	},
	setWidth:function(){
		var width=0;
		var inc=0;
		this.steps=[0];
		this.span=_(this.field, "~@span");
		CSS(this.root).set({height:this.span?this.root.defaultHeight:0}); //slider visibile if elements exists
		if(!this.span) return 0;
		for(var i=0;i<this.span.length; i++){
			var w=this.span[i].offsetWidth;
			if(inc+w>this.canvas.offsetWidth){
				this.steps[this.steps.length]=width;
				inc=0;
			}
			width+=w;
			inc+=w;
		}
		this.field.style.width=width+"px";
		return width;
	},
	getPage:function(offset){
		for(var i=0;i<this.steps.length; i++){
			if(offset<this.steps[i]){
				//check if half of page are manualy scrolled
				if(i && offset>this.steps[i]-Math.round((this.steps[i]-this.steps[i-1])/2)) return i;
				//default page return
				else return i-1;
			}
		}
		return i;
	},
	move:function(d){
		if((d<0 && this.canvas.scrollLeft==0) || (d>0 && this.canvas.scrollLeft+this.canvas.offsetWidth==this.field.offsetWidth)) return false;
		var page=this.getPage(this.canvas.scrollLeft);
		if(page+d>=0 && page+d<this.steps.length) page+=d;
		this.smooth.start(this.canvas.scrollLeft, this.steps[page]);
		return false;
	},
	getLastVisibleImg:function(){
		for(var i=this.preState;i<this.span.length; i++){
			if(this.canvas.scrollLeft+this.canvas.offsetWidth<this.span[i].offsetLeft){
				break;
			}
		}
		return i;
	},
	imgLoader:function(){
		if(!this.span || this.preState==this.span.length) return false; //break if all imgs are loaded
		
		var to=this.getLastVisibleImg();
		if(to<=this.preState) return false;  //break if range imgs are loaded
		
		for(var i=this.preState;i<to; i++){
			var img=_(this.span[i], "~img");
			if(!img.loaded){
				img.src=_ATTR(img, "presrc");
				this.initItem(this.span[i]);
				img.loaded=1;
			}
		}
		this.preState=to;
	},
	initItem:function(span){
		var _this=this;
		var a=_(span, "~a.delete");
		if(a){
			a.onclick=function(){return GET(this)};
			a.onstarting=function(){if(!_this.canvas.ondelete()) return false; span.className="disable"}; //disabled view status on deleting start
			a.oncomplete=function(){_this.removeItem(a)};
		}
	},
	removeItem:function(obj){
		this.preState--; //update preload state position
		this.field.removeChild(obj.parentNode); //remove node
		this.setWidth(); //field pane width reset
		this.imgLoader(); //load new visible image
		return false;
	},
	lock:function(b){
		this.lock_layer.style.display=b?"block":"none";
	},
	reset:function(){
		this.canvas.scrollLeft=0;
		this.setWidth();
		this.lock(0); //lock slider after changes
		this.onreset();
	},
	add:function(id, img){
		if(!img){
			this.lock(1); //lock slider while uploading
			this.canvas.scrollLeft=0;
			this.field.style.width=Number(this.field.clientWidth+500)+"px"; //IE fix
			this.uploadFiles[id]=document.createElement("span");
			this.uploadFiles[id].className="fixed";
			this.field.insertBefore(this.uploadFiles[id], this.field.firstChild);
		}
		else{
			this.uploadFiles[id].innerHTML=img;
			this.uploadFiles[id].className="";
			this.initItem(this.uploadFiles[id]);
			_(this.uploadFiles[id], "~img").loaded=1;
		}
	},
	scrollTM:function(){
		var _this=this;
		if(this.tm) clearTimeout(this.tm);
		this.tm=setTimeout(function(){_this.onscroll()}, 100);
	},
	onscroll:function(){
		this.imgLoader();
	},
	onreset:function(){}
};
startList = function() {

      if (document.all&&document.getElementById){
            var LI = document.getElementById("nav").getElementsByTagName('LI');
            for (i=0; i < LI.length; i++) {
                LI[i].onmouseover=function() {
					this.className+=" act";
                };
                LI[i].onmouseout=function() {
					this.className=this.className.replace(" act", "");
                };
            }
      }
};

function show_menu(id) {
	var obj=document.getElementById(id);
	
	if ((obj.style.display=='none') || (obj.style.display=='')) {
		obj.style.display='block';
	} else {
		obj.style.display='none';
		//obj.parentNode.className = "";
	}
	return false;
};

function set_active_class(obj, store_target) {
	
	if (!store_target.prev_el)
	{
		store_target.prev_el = obj;
		for (var i=0; i<=store_target.getElementsByTagName('a').length-1; i++) {
			store_target.getElementsByTagName('a')[i].className = "";
		}
		
		
	} else {
		store_target.prev_el.className = '';
		store_target.prev_el = obj;
	}

	obj.className += "active";
	
	return false;
}

function get_slideshow_active_el(obj) {
	
	for (var i=0; i<=obj.getElementsByTagName('a').length-1; i++) {
		if (obj.getElementsByTagName('a')[i].className == "active") {
			return i;
		}
	}
	
	return false;
}

function hideShowImageOpacity(id, obj, millisec) { 
	
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
	var opacStart = 100;
	var opacEnd = 0;
    
    for(i = opacStart; i >= opacEnd; i--) { 
        setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
        timer++; 
    }

    setTimeout(function(){document.getElementById(id).src = obj.target;}, millisec);
    
    for(i = opacEnd; i <= opacStart; i++) { 
        setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
        timer++; 
    }

    return false;
    
}

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}

function showStartImagesAuto() {
	if (_('slideshow_box')) {
		autoSlideShow = setInterval ("showStartImages()", 5000);
	}
}

function showStartImages () {

	var cur_selected_image = get_slideshow_active_el(_('slideshow_box'));
	var counter = cur_selected_image;
	counter++;
	
	if (counter == document.getElementById('slideshow_box').getElementsByTagName('a').length) {
		counter = 0;
	}

	object = _('slideshow_box').getElementsByTagName('a')[counter];
	hideShowImageOpacity('target_image', object, 500); 
	set_active_class(object, object.parentNode);

}

var lang_select = {
	init:function(obj){
		this.block=_(obj.target);
		this.inited = 1;
		var _this = this;
		_this.object = obj;
		addEvent(document, 'mouseup', function(){ if (!_this.isOver && _this.isOpen) setTimeout(function(){_this.hide(_this.object)},40)})
		addEvent(obj, 'mouseover', function(){_this.isOver = 1;})
		addEvent(obj, 'mouseout', function(){_this.isOver = 0;})
	},
	showhide:function(b, obj){
		this.block.style.display=b?"block":"none";
		obj.className =b?'lang_dropdown_opened':'lang_dropdown';
		this.isOpen=b;	
	},
	show:function(obj){
		/*if(!this.inited) 
		{ 
			this.init(obj);
		}
		else
		{
			if ((this.block.id != obj.target)) {
				//alert(_(this.block.id));
				this.hide(_(this.block.id));
				this.init(obj);
			}
		};
		*/
		this.init(obj);
		var b = this.isOpen?0:1;
		this.showhide(b, obj);
		return false;
	},
	hide:function(obj){
		this.showhide(0, obj);	
	}
};

function set_selected_lang(obj, id_control) {
	_('selected_lang').value = obj.target;
	_(id_control).innerHTML = obj.innerHTML;
	return true;
}

var Modal={
	create:function(){
		this.block=makeHTML({tag:"div", id:"modal", append:[
			{tag:"span"}
		]}, document.body);
		this.inited=1;
	},
	showhide:function(b){
		if(!this.inited) this.create();
		this.block.style.display=b?"block":"none";
		this.isOpen=b;	
	},
	show:function(){
		this.showhide(1);
	},
	hide:function(){
		this.showhide(0);	
	}
};

var Class=function(proto){
	var obj=function(){this.init.apply(this, arguments)};
	obj.prototype=proto;
	obj.prototype.constructor=obj;
	return obj;
};


var Popup={
	init:function(){
		var _this=this;
		this.block=makeHTML({tag:"div", id:"popup", append:[
			{tag:"a", className:"close", onclick:function(){_this.hide()}},
			{tag:"div", className:"top"},
			{tag:"div", className:"body"},
			{tag:"div", className:"bottom"}
		]}, document.body);
		this.body=_(this.block, "~div.body");
		addEvent(document, "keydown", function(e){
			if((Key(e).isEscape() || (Key(e).isEnter() && _this.hasOkButton())) && _this.isOpen) _this.hide()
		});
		this.inited=1;
	},
	showhide:function(b){
		Modal.showhide(b);
		this.block.style.visibility=b?"visible":"hidden";
		this.isOpen=b;
	},
	show:function(content, skin){
		if(!this.inited) this.init();
		this.block.className=skin?skin:"";
		this.body.innerHTML=content;
		if(window.init_content) init_content(this.body);
		this.block.style.marginTop=-Math.round(this.block.offsetHeight/2)+"px";
		this.showhide(1);
		return false;
	},
	hide:function(){
		this.showhide(0);
		this.body.innerHTML="";
		return false;
	},
	hasOkButton:function(){
		var okButton=_(this.block, "~div.buts^a");
		if(okButton && okButton.className=="but but_ok") return true;
		else return false;
	},
	alert:function(content){
		return this.show(content);
	},
	confirm:function(content){
		return this.show(content);
	},
	win:function(content){
		return this.show(content, "popup_syswin");
	}
};

var PopupSyswin=Class(Popup);


var Key=function(event){
	return {
		code:function(){return window.event?window.event.keyCode:event.which;},
		is:function(num){return this.code()==num},
		isEnter:function(){return this.code()==13},
		isEscape:function(){return this.code()==27}
	}
};


// show/hide single block (e.g. password forgot block in menu_login)
function showhide(obj,args){
	obj=_(obj);
	var show=(args!=undefined && typeof args=="object")?args.show:args;
	if(show!=undefined) obj.style.display=(show?"block":"none");
	else obj.style.display=(CSS(obj).check({display:'block'})?"none":"block");
	show=CSS(obj).check({display:'block'});
	if(args!=undefined && typeof args=="object" && args.sender) Checkbox(args.sender, show);
	return show;
};



// activate item on click (set className="act")
function _act(obj){
	if(!obj || !obj.parentNode) return false;
	if(_ATTR(obj, "noact")!=undefined) return false;
	var par=(obj.parentNode.tagName=="LI" || obj.parentNode.tagName=="VAR" ? obj.parentNode.parentNode : obj.parentNode);
	if(!par.set) par.set=function(i){return _(par, '~@a')[i].onclick();}; //init funtion [set]
	if(!par.act) par.act=function(i){return _act(_(par, '~@a')[i]);}; //init funtion [set]
	if(!par.unset) par.unset=function(){Style(par.cur).remove("act"); par.cur=null; return false;}; //init funtion [set]
	if(par.cur==obj) return false;
	if(!par.cur) par.cur=_(par, "a.act"); // if no [cur] try to find it
	if(par.cur) Style(par.cur).remove("act");
	Style(obj).add("act");
	par.cur=obj;
	(_ATTR(obj, "onact") || function(){})(); //call [onact] event
	if(obj.tagName=="A") obj.blur();
	return false;
};


function init_reg_form(form_id, query){
	var form=_(form_id);
	form.refs=[];
	for(var i=0;i<form.elements.length;i++){
		var el=form.elements[i];
		var par=_(el, "/");
		var is_require=_(_(el, "/~label"), "~span.req");
		if(is_require && is_require.lang!="disable"){
			el.activating_element=_(_(el, "/~label"), "~input");
			if(el==el.activating_element) continue;
			
			el.group=el.name.replace(/([^\]]+)\[.*/, "$1");
			form.refs[el.name]=query.replace(/{name}/, el.group);
			par.err=_(el, "/~i.error_mes"); //error message block
			par.check_group=function(par){
				var group_error_el=_(par, "/~div.error_title");
				if(!group_error_el || group_error_el.style.display!="block") return false;
				if(!_(par, "/~.error")) group_error_el.style.display="none"; //if no error class in block - hide message container
			};
			par.complete=function(obj, response){
				var par=_(obj, "/div");
				if(par.err) par.err.innerHTML=response.obj.error?response.obj.error:par.err.lang;
				
				//set status for element or elements group
				var err=false;
				var sib=par.getElementsByTagName("input");
				for(var j=0;j<sib.length;j++){
					if(obj.group==sib[j].group){
						Style(sib[j].root || sib[j])[response.obj.error!=undefined?"add":"remove"]("error");
					}
					if(Style(sib[j]).exist("error")) err=true;
				}
				
				Style(par)[response.obj.error!=undefined || err?"add":"remove"]("error_block");
				
				par.check_group(par);
			};
			el.onblur=function(){
				if(el.activating_element && !el.activating_element.checked) return false;
				obj=this;
				var val="";				
				//create element value or value of elements group
				var sib=_(obj, "/div").getElementsByTagName("input");
				for(var j=0;j<sib.length;j++)
					if(obj.group==sib[j].group) 
						val+=(val?";":"")+sib[j].value;
				
				//send ajax or show error "empty"
				var par=_(obj, "/div");
				if(val) GET({ref:obj.form.refs[obj.name].replace(/{value}/, val), oncomplete:function(response){par.complete(obj, response)}});
				else par.complete(obj, {obj:{error:''}})
			};
		}
	}
};



function set_params(form_name, params){
		var form=document.forms[form_name];
		if(params) 
			for(var i in params)
				if(form[i]) 
					form[i].value=params[i];
		return false;
};


var fileBrowse={
	set:function(obj){
		var par=_(obj, "//");
		_(obj, "/").style.visibility="hidden";
		_(par, "^i.input").innerHTML=obj.value.replace(/([^\\]*\\)+([^\\]*\.[A-Za-z]+)/, "$2");
		_(par, "^input").value=1;
	},
	remove:function(obj){
		var par=_(obj, "/");
		_(par, "^div").style.visibility="visible";
		_(par, "^i.input").innerHTML="";
		this.clearInputFile(_(par, "^div~input"));
		var img=_(par, "/~img");
		img.src=_ATTR(img, "empty");
		return false;
	},	
	clearInputFile:function(inp){
		var par=inp.parentNode;
		inp.parentNode.innerHTML=inp.parentNode.innerHTML;
		return par.getElementsByTagName("input")[0];
	}
};


var Editor={
	init:function(id){
		new nicEditor({
			iconsPath : IMGS_PATH+'nicEditorIcons.gif',
			buttonList : ['bold','italic','underline','ul','ol','link','unlink']
		}).panelInstance(id);
		
	},
	save:function(id){
		nicEditors.findEditor(id).saveContent();
		return true;
	}
};


var Vote=function(obj, e){
	if(obj.voted) return false;
	if(obj.tm) clearTimeout(obj.tm);
	
	//init block
	if(!obj.onmouseout){
		obj.onmouseout=function(){this.tm=setTimeout(function(){Vote(obj)},50)};
		obj.set=function(num){for(i=0; i<5; i++) obj.elements[i].className=num>i?'':'off';}
		obj.minValue=0;
		obj.elements=_(obj, '~@s');
		
		var elementClick=function(){
			if(!_ATTR(obj, "aref")){
				if(_(obj, "~input")) _(obj, "~input").value=this.num;
				obj.set(this.num);
				obj.minValue=this.num;
				return false;	
			}
			if(obj.voted) return false;
			obj.voted=true;
			GET({ref:_ATTR(obj, "aref")+this.num, oncomplete:function(response){obj.set(response.obj.UFCRating)}})
		}
		
		for(var i=0; i<obj.elements.length; i++){
			obj.elements[i].num=i+1;
			obj.elements[i].style.cursor="pointer";
			obj.elements[i].onclick=elementClick;
			if(!obj.elements[i].className) obj.cur=obj.elements[i];
		}
	}
	
	//execute block
	var target=e?(window.event?event.srcElement:e.target):obj.cur;
	var state=target?'':'off';
	for(var i=0; i<obj.elements.length; i++){
		if(!target) state=obj.minValue>i?'':'off';
		obj.elements[i].className=state;
		if(obj.elements[i]==target || !target)	state='off';
	}
};



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.innerHTML=mail;
};

function set_inputs_disabled (targetCont, activatorCont) {

	/* disable */
	for (var i=0; i<=_(targetCont).getElementsByTagName('input').length-1; i++) {
		_(targetCont).getElementsByTagName('input')[i].disabled = true;
	}
	
	for (var i=0; i<=_(targetCont).getElementsByTagName('select').length-1; i++) {
		_(targetCont).getElementsByTagName('select')[i].disabled = true;
	}
	_(targetCont).className = 'act';
	/* enable */
	for (var i=0; i<=_(activatorCont).getElementsByTagName('input').length-1; i++) {
		_(activatorCont).getElementsByTagName('input')[i].disabled = false;
	}
	
	for (var i=0; i<=_(activatorCont).getElementsByTagName('select').length-1; i++) {
		_(activatorCont).getElementsByTagName('select')[i].disabled = false;
	}
	
	_(activatorCont).className = '';
	
	return true;
}

function set_offer_request_inputs_disabled_auto() {
	if (_('offer_edit_cont') || _('request_edit_cont') || _('offer_add_cont') || _('request_add_cont')) {
		if (_("radio_price_type_1").checked == true) {
			_("radio_price_type_1").onclick();
			
		} else {
			_("radio_price_type_2").onclick();
		}
	}
}

function show_spend_a_friend_popup (obj, mes) {
	if (obj.checked) 
		Popup.show(mes);
	return true;
}

function function_exists (function_name) {
    if (typeof function_name == 'string'){
        return (typeof this.window[function_name] == 'function');
    } else{
        return (function_name instanceof Function);
    }
}
function areYouSure(confirmText, text)
{
    if (text==undefined)
        text='';
    else
        text = '\r\n'+text;
    if (confirm(confirmText+text))
        return true;
    return false;
}

//includes
if(window.GOOGLE_ANALYTICS) document.include(("https:"==document.location.protocol?"https://ssl.":"http://www.")+"google-analytics.com/ga.js");


//onload
document.onload=function(){	
	
	HTMLAJAX.loader=_("loader_ico");	
	init_content(document); 
	
	if(window.GOOGLE_ANALYTICS) {
		try {
			window.pageTracker = _gat._getTracker(GOOGLE_ANALYTICS);
			pageTracker._trackPageview();
		} catch(err) {}
	}
	
	showStartImagesAuto();
	set_offer_request_inputs_disabled_auto();
};


addEvent(window, "load", function(){
	

});



		
//---------AJAX response listeners 

//process the responce variables (json structure)
HTMLAJAX.onresponse=function(response, htmlajax){
	if(!response || !response.obj) return;
	if(htmlajax.obj && htmlajax.obj.tagName) _act(htmlajax.obj);
	if(response.obj.syswin){  popup_syswin=new PopupSyswin(); popup_syswin.win(response.obj.syswin);}
	if(response.obj.alert) Popup.alert(response.obj.alert);
	
};



//initialize output content
function init_content(root){
	
	var tags;
	
	if(BROWSER.ie6) ie6_fixes(root, {png:"ie6-png-background", hover:'ie6-hover-class'});
	
	if(tags=_(root, "~@script")){
		for(var i=0, l=tags.length; i<l; i++){
			//if((tags[i].type=="ajax/javascript")){
			if(root!=document){
				var func=(new Function(tags[i]?tags[i].innerHTML:""));
				if(!tags[i].src) func.apply(tags[i]); //normal script execution
				else try{func.apply(tags[i])}catch(e){Script.preload(tags[i])}; //modular script execution
			}
		}
	}
	
	if(tags=_(root, "~@form")){
		for(var i=0, l=tags.length; i<l; i++){
			var form=tags[i];
			if(_ATTR(form, "type")=="ajax"){
				var func_submit=form.onsubmit;
				form.onsubmit=function(){if(!func_submit || (func_submit && func_submit())) GET(this); return false};
				if(_ATTR(form, "autoload")!=undefined) form.onsubmit();
			}
		}
	}
	
	if(tags=_(root, "~@a")){
		for(var i=0, l=tags.length; i<l ;i++){
			var tag=tags[i];
			
			if(_ATTR(tag, "aref")) tag.aref=_ATTR(tag, "aref");
			//if(!tag.aref && tag.href.indexOf("?")!=-1) tag.aref=tag.href;				
			if(tag.aref && !tag.href && !tag.onclick) tag.href="#"; //set empty href value <a href="#"> (for non IE)
			
			if(tag.aref && tag.aref.indexOf("?")!=-1 && !tag.onclick && tag.target.indexOf("_")!=0) tag.onclick=function(e){ return GET(this,e)}; //attach ajax GET handler	
		
			
			if(_ATTR(tag, "autoload")!=undefined && tag.onclick!=undefined){// automatic execute tag onload
				var _tag=tag;
				if(_ATTR(tag, "autoload")) setTimeout(function(){if(_tag && _tag.parentNode) _tag.onclick()}, _ATTR(_tag, "autoload")*1000);
				else _tag.onclick();
			}
			
			//if(!tag.onfocus) tag.onfocus=function(){this.blur()};
			
		}
	}
	

	if(tags=_(root, "~@select")){
		for(var i=0, l=tags.length; i<l ;i++){
			new Forms.select(tags[i]);
		}
	}
	
	font_file_name = 'font_isonorm_dot_regular_title.swf';
	font_file_name = (LANG.toLowerCase()=='ru')?'font_isonorm_dot_regular_ru.swf':'font_isonorm_dot_regular_title.swf';
	
	if (function_exists(sIFR.replaceElement)) {
		sIFR.replaceElement("samp.white", named({sFlashSrc:GLOBAL_PATH+font_file_name, sColor:"#ffffff", sCase:"", sWmode:"transparent"}));
		sIFR.replaceElement("samp.white_17px", named({sFlashSrc:GLOBAL_PATH+font_file_name, sColor:"#ffffff", sCase:"", sWmode:"transparent"}));
		sIFR.replaceElement("samp.blue", named({sFlashSrc:GLOBAL_PATH+font_file_name, sColor:"#8dc1c8", sCase:"", sWmode:"transparent"}));
		sIFR.replaceElement("samp", named({sFlashSrc:GLOBAL_PATH+font_file_name, sColor:"#c30000", sCase:"", sWmode:"transparent", css: [ '.sIFR-flash {cursor: pointer;}' ]}));
	}
	/**/
};

