$(document).ready(function() {
	$('#menu>li:has(ul)').each(function(i){
		$(this).addClass("has_children");
		$(this).append("<div class='arr'>");
		if(!i){
			$(this).addClass("first_menu_item");
			$(this).append("<div class='modal'>");
		}
		else if($("ul>li:has(ul)", this).length){
			$(this).addClass("nesting_1");
		}
		else if($("ul", this).length){
			$(this).addClass("nesting_2");
		}
	})
	.hover(function(){
		this.isOver=1;
		$(this).addClass("hover");
	},
	function(){
		this.isOver=0;
		if($(this).hasClass("first_menu_item")){
			var _this=this;
			if(_this.tm) clearTimeout(_this.tm);
			_this.tm=setTimeout(function(){if(!_this.isOver) $(_this).removeClass("hover")}, 500);
		}
		else{
			$(this).removeClass("hover")
		}
	});
	
	$('#menu .modal').hover(function(){
		this.parentNode.isOver=0;
		var _this=this;
		if(_this.tm) clearTimeout(_this.tm);
		_this.tm=setTimeout(function(){if(!_this.parentNode.isOver) $(_this).parent().removeClass("hover")}, 500);
	},
	function(){
		this.parentNode.isOver=1;
	});
	
	
	$('#header .lang, #header .office').click(function(){
		$(this).toggleClass("lang_open");
	})
	.hover(function(){
					
	},function(){
		$(this).removeClass("lang_open");
	});
	
	if($.fancybox){
		$("a[rel=popup]").fancybox({
			showCloseButton: true,
			scrolling:'no',
			overlayColor: '#000',
			padding:0
		});
		
		$("a[rel=popup-iframe]").fancybox({
			'width'				: 978,
			'height'			: 522,
			'autoScale'     	: false,
			'scrolling'     	: 'no',
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe',
			'padding'           : 0,
			'overlayColor'      : '#000' 
		});
		$("a[rel=lightbox]").fancybox({
			showCloseButton: true,
			scrolling:'no',
			overlayColor: '#000',
			padding:0
		});
	}
	
	//$('a[rel=lightbox]').lightbox({fixedNavigation:true});

	
	
	
	
	if(!$("div.slider_controls").length){
		var $slider_controls=$('<div class="slider_controls"/>');
		$('div.slider').append($slider_controls);
		$(".slider_canvas div.slide_item").each(function(i){
			this.id="slide_"+(i+1);
			$slider_controls.append($('<a href="#'+this.id+'">'+(i+1)+'</a>'))
		});

	}
	
	$("div.slider_controls").each(function(){
		new Slider(this, {slideshow:10000})
	});
	
	if($("div.gallery_zoom")[0]) Magnifier.init();
	
	
	$("ul.accordion h4").click(function(){
		$(this).next()[!this.isOpen?"slideDown":"slideUp"]();
		$(this).parent().toggleClass("active");
		this.isOpen=this.isOpen?0:1;
	});
	
	$(".page-print table tr:even").addClass("dark");
	
	var block_twice_wrap_prev;
	$(".block_twice_wrap div.item").each(function(i){
			if(block_twice_wrap_prev && block_twice_wrap_prev.offset().top==$(this).offset().top){
				var max=Math.max(block_twice_wrap_prev.height(), $(this).height());
				block_twice_wrap_prev.height(max);
				$(this).height(max);
			}
			else block_twice_wrap_prev=null;
			//$(this).append(i)
			block_twice_wrap_prev=$(this);
			//$(this).height($(this).prev().height()
	})
	
	jQuery('.product_switcher_block_2 .item').click(function(){
		jQuery('.product_switcher_block_2').find('.item.active').removeClass('active');
		jQuery(this).addClass('active');
		jQuery('#product_switcher_block_2_target').html(jQuery(this).find('.info_more').html());
		return false;
	})
	
	jQuery('.product_switcher_block ul li a').click(function(){
		jQuery('.product_switcher_block ul').find('li.active').removeClass('active');
		jQuery(this).parent().addClass('active');
		jQuery('#product_switcher_block_target').html(jQuery(this).parent().find('.descr').html());
		return false;
	})

    jQuery('table.table_standart_2 tr:nth-child(even)').addClass('dark');
	
});


var Magnifier={
	init:function(root){
		var _this=this;
		this.move_pane=$("div.gallery_image");
		this.zoom_pane=$("div.gallery_zoom");
		
		this.bar=$("<span>").appendTo(this.move_pane).css({display:"none", background:"#fff", opacity:0.35, border:"1px solid #777", position:"absolute", top:0, left:0, cursor:"pointer"});
		
		
		this.items=$('.gallery_thumbnails a');
		
		if(!this.items.length) return false;
		
		this.items.click(function(){return _this.set(this)});
		
		this.set(this.items[0]);
		
		this.move_pane
			.hover(function(){_this.over(this)},function(){_this.out(this)})
			.mousemove(function(e){_this.move(e)});
		
	},
	set:function(obj){
		$('div.gallery_thumbnails a.active').removeClass("active");
		$(obj).addClass("active");
		$('div.gallery_image div.active').removeClass("active");
		$(obj.hash).addClass("active");
		this.curent_img_small=$(obj.hash+" img")[0];
		this.curent_img_large=$("#"+obj.target+" img")[0];
		this.curent_zoom_pane=$("#"+obj.target);
		
		return false;
	},
	over:function(obj){
		this.curent_zoom_pane.show();
		var bar_width=Math.round(this.curent_img_small.width/(this.curent_img_large.width/this.zoom_pane.width()));
		var bar_height=Math.round(this.curent_img_small.height/(this.curent_img_large.height/this.zoom_pane.height()));
		this.bar.css({display:"block", width:bar_width, height:bar_height});
	},
	out:function(obj){
		this.curent_zoom_pane.hide();
		this.bar.css({display:"none"});
	},
	move:function(e){
		var top=e.pageY-this.move_pane.offset().top-(this.bar.height()/2);
		var left=e.pageX-this.move_pane.offset().left-(this.bar.width()/2);
		var max_top=this.move_pane.height()-this.bar.height();
		var max_left=this.move_pane.width()-this.bar.width();
		if(top<0) top=0;
		if(top>max_top) top=max_top;
		if(left<0) left=0;
		if(left>max_left) left=max_left;
		this.bar.css({top:top, left:left});
		$(this.curent_img_large).css({top:-top*(this.curent_img_large.height/this.curent_img_small.height), left:-left*(this.curent_img_large.width/this.curent_img_small.width)});
	}
}



 var _=function(c,d){if(!c)return undefined;if(JJ.type(c,"String")){var a;if(/^#?[a-z0-9_]+$/i.test(c))a=document.getElementById(c.replace(/#/,""));if(a)c=a;else{d=c;c=document}}if(!d&&c._extended)return c;var b=c;if(d)b=JJ.getElements.parse(d,c);if(!b)b="";JJ.extend(b,JJ.element);if(JJ.type(b,"Array"))JJ.foreach(b,function(){JJ.extend(this,JJ.element)});return b};var JJ={};JJ.type=function(a,b){var t=typeof a;if(!b)return t;if(a==undefined)return b==undefined;b=b.toLowerCase();switch(b){case"object":return a.constructor==Object;case"array":return a.constructor==Array;case"number":return t=="number"||!isNaN(a);case"element":return t=="object"&&a.nodeType==1;case"date":return a.constructor==Date;case"string":return a.constructor==String;case"boolean":return a.constructor==Boolean;case"function":return t=="function";default:return t==b}};JJ.foreach=function(b,c){if(!JJ.type(b,"Array"))return c.call(b);for(var i=0,a=[],l=b.length;i<l;i++)a.push(c.call(b[i],i));return a};JJ.extend=function(h,j){var f=function(c,d,e){if(!JJ.type(c,"Array")||d=="repeat"){return j[d].exec(c,e[0],e[1],e[2],e[3])}else{var a=JJ.foreach(c,function(){return j[d].exec(this,e[0],e[1],e[2],e[3])});if(a[0]){if(a[0]._extended)JJ.extend(a,j);if(JJ.type(a[0],"Function")&&d=="event"){var b=a;a=function(){for(var i=0,l=b.length;i<l;i++)if(b[i])b[i].apply(c[i],arguments)}}}return a}};var g=function(a,b){a[b]=function(){return f(this,b,arguments)}};if(h._extended)return false;h._extended=true;for(var i in j)g(h,i);return h};JJ.wait=function(a){try{a()}catch(e){setTimeout(a,10)}};JJ.create=function(a){return JJ.extend(document.createElement(a),JJ.element)};JJ.getElements={parse:function(n,o){var a=false;if(JJ.type(n,"array")){n=n[0];a=true}n=n.replace(/((^)|([ ><+\-,]))(([#.:\[,])|($))/g,"$1*$4")+" ";o=o||document;var b=" ><+-,",d=" ><+-,:[",e={"#":d,".":d,":":d,"[":"]"},f={"#":"id",".":"className",":":"pos","[":"attr","<":"parentNode","+":"nextSibling","-":"previousSibling"},i=-1,c,h,j,k=[o],l=[],m=n.length;while(c=n.charAt(++i)){if(h){if(e[h].indexOf(c)!=-1){h=null;if(c=="]")j.attr=this.attr2struct(j.attr);else i--;continue}j[f[h]]+=c}else{if(b.indexOf(c)!=-1){if(j){this.init_match(j);k=this.walk(j,k)}if(c==","){l=l.concat(k);k=[o];j=null;continue}if(i==m-1)break;j={tag:"",child:c!=" ",move_to:f[c]};continue}if(!j){j={tag:c,child:false};continue}if(c in e){j[f[h=c]]="";continue}j.tag+=c}}if(l.length)k=l.concat(k);return k.length==1&&!a?k[0]:(k[0]?k:undefined)},walk:function(f,g){var a,i=0,b=[];while(a=g[i++]){var c,j=0,d=[];if(f.only_id){if(c=document.getElementById(f.id))b[b.length]=c;continue}if(f.move_to){if(c=this.move(f,a))b[b.length]=c;continue}var e=f.child?a.childNodes:a.getElementsByTagName(f.tag);while(c=e[j++]){if(f.single_tag||this.check_filters(f,c))d[d.length]=c}if(f.pos){if(c=this.pos(f,d))b[b.length]=c;continue}b=b.concat(d)}return b},init_match:function(a){a.tag=a.tag.toUpperCase();if(a.tag=="*"&&a.id&&!a.className&&!a.attr)a.only_id=1;if(!a.id&&!a.className&&!a.attr)a.no_prop=1;if(!a.child&&a.no_prop)a.single_tag=1},check_filters:function(b,c){if(b.child&&(c.nodeType!=1||(b.tag!="*"&&b.tag!=c.tagName)))return false;if(b.no_prop)return true;if(b.id&&b.id!=c.id)return false;if(b.className&&!JJ.element.classname.exist(c,b.className))return false;if(b.attr){var a=JJ.element.attr.get(c,b.attr.key,1);if(b.attr.equal==false&&a!=b.attr.value)return false;if(b.attr.equal==true&&a==b.attr.value)return false}return true},attr2struct:function(b){var a;if(b.indexOf("!")==0){b=[b.substr(1)];a=false}else if(b.indexOf("!")>0){b=b.split("!=");a=true}else if(b.indexOf("=")!=-1){b=b.split("=");a=false}else{b=[b];a=true}return{key:b[0],value:b[1],equal:a}},pos:function(b,c){var a;if(b.pos=="^")a=0;else if(b.pos=="$")a=c.length-1;else if(JJ.type(b.pos,"Number"))a=Number(b.pos);if(a!=undefined&&a<c.length)return c[a];return},move:function(b,c){var a=0;while(c=c[b.move_to])if(this.check_filters(b,c))if(Number(b.pos||0)==a++)break;return c}};JJ.element={};JJ.element.repeat={exec:function(a,b){if(JJ.type(a,"String"))return a;JJ.foreach(a,b);return a}};JJ.element.attr={exec:function(b,c,d){if(JJ.type(b,"String"))return b;if(JJ.type(c,"String")){if(d!=undefined)return this.set(b,c,d);else return this.get(b,c)}else if(JJ.type(c,"Object")){for(var i in c)this.set(b,i,c[i]);return b}else if(JJ.type(c,"Array")){var a={};for(var i=0,l=c.length;i<l;i++)a[c[i]]=this.get(b,c[i]);return a}},get:function(b,c,d){var a=b.getAttribute?b.getAttribute(c):undefined;if(a==undefined&&!d)a=b[c];if(a==''&&b.attributes&&b.attributes[c]&&!b.attributes[c].specified)a=undefined;return a},set:function(a,b,c){if(a.setAttribute&&!JJ.type(c,"Function"))a.setAttribute(b,c);a[b]=c;return a}};JJ.element.event={exec:function(b,c,d){if(!b.attachEvent&&!b.addEventListener)return d!==undefined?b:function(){};if(JJ.type(c,"String")){if(d!==undefined)return this.set(b,c,d);else return this.get(b,c)}else if(JJ.type(c,"Object")){for(var i in c)this.set(b,i,c[i]);return b}else if(JJ.type(c,"Array")){var a={};for(var i=0,l=c.length;i<l;i++)a[c[i]]=this.get(b,c[i]);return a}},set:function(e,f,g){if(g===null)return this.remove(e,f);var c=this.get(e,f);g=this.toFunc(g,e);var d=function(a,b){if(c)c.apply(a,b);return g.apply(a,b)};this.rec(e,f,g);e[f]=function(){return d(this,arguments)};if(f=='onmousewheel'&&e.addEventListener){e.addEventListener('DOMMouseScroll',e[f],false);e.removeEventListener('DOMMouseScroll',c,false)}return e},get:function(f,g){if(g.indexOf("(")!=-1){var a=g.split("(");g=a[0];var b=a[1].substr(0,a[1].length-1);var c="";switch(b){case":String":return this.toStr(f["_"+g+"_"]);case":Array":return f["_"+g+"_"];default:c=b}}var d=JJ.element.attr.get(f,g);var e=this.toFunc(d,f,c);return e},remove:function(a,b){a[b]=function(){};return a},toFunc:function(b,c,d){var a;if(!b)return function(){};if(JJ.type(b,"String"))a=new Function(d,b);else a=b;return function(){return a.apply(c,arguments)}},toStr:function(b){if(!b)return'';var a='';for(var i=0,l=b.length;i<l;i++){var s=b[i].toString();s=s.replace(/^function[^{]*\{(.*)/gi,"$1");s=s.substr(0,s.length-2);a+=s+"\n"}a=a.replace(/;([^\n])/gi,";\n$1");return a},rec:function(c,d,e){var a="_"+d+"_";if(!c[a]){c[a]=[];var b=this.get(c,d);if(b)c[a].push(b)}c[a].push(e)}};JJ.element.css={exec:function(c,d,e,f){if(!JJ.type(c,"Element"))return c;if(JJ.type(d,"String")){if(e!=undefined){if(f!=undefined&&this.get(c,d)==e)e=f;return this.set(c,d,e)}else return this.get(c,d)}else if(JJ.type(d,"Object")){for(var i in d)this.set(c,i,d[i]);return c}else if(JJ.type(d,"Array")){var a={};for(var i=0,l=d.length;i<l;i++){var b=this.get(c,d[i]);if(!b&&e)continue;a[d[i]]=b}return a}},js2css:function(a){return a.replace(/([A-Z])/g,"-$1").toLowerCase()},get:function(b,c){var a;if(b.currentStyle)a=b.currentStyle[c];else if(window.getComputedStyle)a=window.getComputedStyle(b,null).getPropertyValue(this.js2css(c));else a=b.style[c];if(/^[0-9]+px/.test(a))a=parseInt(a);return a},set:function(c,d,f){var a={"width":1,"height":1};if(d in a&&f<0)f=0;var b={"zIndex":1,"opacity":1};if(f&&JJ.type(f,"Number")&&!(d in b))f+="px";if(d=="opacity"&&BROWSER.ie){d="filter";f=(f==1?"":"Alpha(opacity="+(f*100)+")")}if(d=="float")d=BROWSER.ie?"styleFloat":"cssFloat";try{c.style[d]=f}catch(e){throw"element.css.set() -> obj.style."+d+"="+f};return c},check:function(a,b){return true}};JJ.element.classname={exec:function(b,d){if(b.className==undefined)return b;if(d==null)return b.className;var c=d.charAt(0);var a=d.substr(1);with(this){switch(c){case"*":return all(b);case"^":return get(b,0);case"$":return get(b,1);case"+":add(b,a);break;case"-":remove(b,a);break;case"!":toogle(b,a);break;case"?":return exist(b,a);default:set(b,d)}}return b},empty:function(a){return a.className.replace(/\s/g,"")==""?true:false},exist:function(a,b){return(new RegExp('((^)|(\\s))'+b+'((\\s)|($))')).test(a.className)},all:function(a){return!this.empty(a)?a.className.split(/\s+/):[]},get:function(b,c){var a=this.all(b);if(!a.length)return"";c=c?a.length-1:0;return a[c]},set:function(a,b){a.className=b},add:function(a,b){this.remove(a,b);a.className+=a.className?' '+b:b},remove:function(a,b){a.className=a.className.replace(new RegExp("((^)|(\\s))"+b+"((\\s)|($))"),"$3")},toogle:function(a,b){this.exist(a,b)?this.remove(a,b):this.add(a,b)}};JJ.element.insert={exec:function(d,e,f){if(!d.appendChild)return d;var a=e;var b;if(JJ.type(e,"String")){if(e.indexOf(":")!=-1){var c=e.split(":");e=c[0];b=JJ.getElements.parse(">:"+c[1],d)}a=document.createElement(e)}if(JJ.type(f,"Object")&&!f.nodeType)JJ.element.attr.exec(a,f);else b=f;b?d.insertBefore(a,b):d.appendChild(a);return _(a)}};JJ.element.html={exec:function(a,b){if(a.innerHTML==undefined)return a;if(b==undefined)return a.innerHTML;a.innerHTML=b;return a}};JJ.element.remove={exec:function(b,c){if(!b.removeChild)return b;if(c==undefined){var a=b.parentNode;a.removeChild(b);return null}else{var el=_(c);b.removeChild(el);return b}}};JJ.element.act={exec:function(c,d){var a=this;if(!c||!c.tagName||!c.parentNode)return false;if(c.attr("noact")!=undefined)return false;var b=_(c,"<");if(b.tagName=="LI"||b.tagName=="DT")b=_(b,"<");if(d!=undefined){b=c;c=_(b,'>a:'+d)}if(!b.deact)b.deact=function(){a.deact(this)};if(b.cur==c)return false;this.act(b,c);c.event("onact")();return false},act:function(a,b){if(!a.cur)a.cur=_(a,">a.act");if(a.cur)a.cur.classname("-act");b.classname("+act");a.cur=b},deact:function(a){if(!a.cur)return false;a.cur.classname("-act");a.cur=null;return false}};JJ.element.offset={exec:function(d){var a=0,b=0;if(d.getBoundingClientRect){var c=d.getBoundingClientRect();a=c.left+Math.max(document.documentElement.scrollLeft,document.body.scrollLeft);b=c.top+Math.max(document.documentElement.scrollTop,document.body.scrollTop)}else{}return{left:a,top:b}}};JJ.element.display={exec:function(d,b,e){var a=(d.css("display")=="none");var c=(d.css("visibility")=="hidden");if(!d.display_default)d.display_default=a?"block":d.css("display");var b=(b==undefined?(a||c?1:0):b);d.css({display:b?d.display_default:"none"});return d}};JJ.element.slide={exec:function(c,b,d){if(!window.EFX)return JJ.element.display.exec(c,b);var a=(c.css("display")=="none");b=(b==undefined?(a?1:0):b);c._slide=EFX.slide(c,b,d);if(c._fade||c.css("visibility")=="hidden"){if(!BROWSER.ie&&!BROWSER.opera)c.fade(b,d);else c.css({visibility:"visible"})}return c}};JJ.element.fade={exec:function(c,b,d){if(!window.EFX)return JJ.element.display.exec(c,b);var a=(c.css("visibility")=="hidden");b=(b==undefined?(a?1:0):b);c._fade=EFX.fade(c,b,d||{dynamic:5});return c}};if(!String.prototype._extend)JJ.extend(String.prototype,JJ.element);document.event=function(a,b){JJ.element.event.exec(document,a,b)};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(b){var a=function(){this.init.apply(this,arguments)};a.prototype=b;a.prototype.constructor=a;return a};var Event=function(e){e=window.event?window.event:e;return{key:function(d){if(typeof d=="string"){var a={ctrl:1,shift:1,alt:1};var b={enter:13,escape:27,space:32,tab:9,left:37,up:38,right:39,down:40};if(d in a)return e[d+"Key"];else if(d in b)d=b[d];else d=d.charCodeAt(0)}var c=window.event?e.keyCode:e.which;return d!=undefined?c==d:c},target:function(){var a=window.event?e.srcElement:e.target;return a},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 Smooth=new Class({dynamic:0,duration:1000,fps:50,algoritm:"fade",inPlay:null,init:function(a,b){a=a||{};this.dynamic=(a.dynamic!=undefined?a.dynamic:0)||0.1;this.duration=a.duration||this.duration;this.algoritm=a.algoritm||this.algoritm;this.onstart=a.onstart||this.onstart;this.onplay=a.onplay||this.onplay;this.onend=a.onend||this.onend;if(b)this.start(b)},start:function(l,m){var a=this;if(this.inPlay)this.end();var b="";if(this.algoritm.constructor==Array)b="custom";else if(typeof this.algoritm=="function")b="function";else b=this.algoritm;var c=1000/this.fps;this.steps=Math.round(this.duration/c);this.half=this.steps/2;this.dynamic_abs=Math.abs(this.dynamic);this.dynamic_reverse_flag=(this.dynamic<0?this.dynamic:0);var d=[];var e,f;for(var i=0;i<=this.steps;i++){d[i]=this.get_algoritm(b,i);if(!i||e<d[i])e=d[i];if(!i||f>d[i])f=d[i]}if(l==undefined)l=[0,100];else if(l.constructor==Number&&m!=undefined)l=[l,m];if(l.constructor==Array)l={_base:l};var g={};for(var h in l)g[h]=l[h][1]-l[h][0];var j;var k=[];this.val=[];for(var i=0;i<=this.steps;i++){this.val[i]={};j=(d[i]-f)/(e-f);k[i]=j;for(var h in l){this.val[i][h]=l[h][0]+g[h]*j;if(l._base)this.val[i]=this.val[i][h]}}if(window.debug&&window.debug==1){debug=0;return alert(o2s(d))}if(window.debug&&window.debug==2){debug=0;return alert(o2s(k))}if(window.debug&&window.debug==3){debug=0;return alert(o2s(this.val))}this.cur=0;this.onstart();this.play();this.tm=setInterval(function(){a.play()},c);this.inPlay=true},get_algoritm:function(a,i){switch(a){case"fade":return Math.atan((this.dynamic_abs/this.steps*i)+this.dynamic_reverse_flag);case"ball":return Math.atan(this.dynamic_abs/this.half*(i-this.half));case"custom":return this.algoritm[i];case"function":return this.algoritm(i,this.steps,this.dynamic);default:return i}},play:function(){this.onplay(this.val[this.cur]);this.cur++;if(this.cur>this.steps)return this.end()},end:function(){clearInterval(this.tm);this.tm=null;this.inPlay=false;this.onend();return false},onstart:function(d){},onplay:function(a){},onend:function(d){}});

var Slider=Class({
	_item_active_classname:"act",
	frames_count:3,
	
	init:function(items_block, opt){
		var _this=this;
		var opt=opt || {}
		this.root=_(items_block.parentNode);
		this.zIndex=1;
		this.slideshow=opt.slideshow || 0; //autoplay slideshow mode
		this.items=_(items_block, "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.fade(this.cur.block, 0);
			this.fade(obj.block, 1);
			//this.fade(this.cur.block, 0, function(){_this.fade(obj.block, 1)});
			//this.framed_slide(obj.block);
			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;
	},
	framed_slide:function(block){
		var _this=this;
		
		if(!this.frames){
			this.frames=[];
			this.overlay=this.root.insert("div").classname("+slider_canvas").css({position:"absolute", top:0, left:0,  zIndex:2, width:this.root.offsetWidth, background:"none"});
			for(var i=0; i<this.frames_count; i++){
				var width=this.overlay.offsetWidth/this.frames_count;
				var frame_block=this.overlay.insert("div").css({width:width, height:this.overlay.offsetHeight, overflow:"hidden", position:"absolute", top:0, left:i*width});
				var frame_canvas=frame_block.insert("div").css({width:width, height:this.overlay.offsetHeight, overflow:"hidden",  position:"absolute", top:0, left:0});
				var frame_content=frame_canvas.insert("div").classname("+slide_item").css({width:this.overlay.offsetWidth, position:"relative", left:-i*width});
				frame_canvas.contentBlock=frame_content;
				this.frames.push(frame_canvas);
			}
		}
		
		if(this.inAnimation){
			_(this.frames).repeat(function(i){
				this.smooth.end();
			});
		}
		
		this.inAnimation=true;
		this.overlay.css({display:'block'});
		
		_(this.frames).repeat(function(i){
			var obj=this;
			obj.contentBlock.innerHTML=block.innerHTML;
			obj.smooth=new Smooth({
				dynamic:2, 
				duration:300*(i+1),
				onstart:function(){obj.css({left:-obj.offsetWidth}); },
				onplay:function(pos){obj.css({left:pos}); },
				onend:function(){ 
					if(i==_this.frames_count-1){ 
						block.css({display:'block', zIndex:_this.zIndex++});
						_this.overlay.css({display:'none'});
						_this.inAnimation=false;
					}
				}
			}, [-obj.offsetWidth, 0]);
		});
	},
	fade:function(block, b, callback){
		var _this=this;
		if(this.smooth && this.smooth.inPlay){ if(this.smooth.callback) return this.smooth.callback=callback;  else this.smooth.end(); }
		this.smooth=new Smooth({
			dynamic:b?5:-5, 
			duration:b?1000:500,
			onstart:function(){if(!callback) block.css({display:'block', zIndex:_this.zIndex++}); },
			onplay:function(pos){block.css({opacity:pos/100})},
			onend:function(){if(this.callback) this.callback();}
		}, [b?0:100, b?100:0]);
		this.smooth.callback=callback;
	}
});
