// ниже - анимация слайдеров в портфолио

animate={
	animtypes:'smooth',
	animator:[],ie:/*@cc_on!@*/false,animtype:function(b){switch(this.animtypes){case'simple':return b;break;case'compress':var c=2;return Math.pow(b,2)*((c+1)*b-c);break;case'smooth':function h(e){return Math.pow(e,3)};if(b<0.5){return h(2*b)/2}else{return(2-h(2*(1-b)))/2};break;case'jump':function g(e){for(var a=0,f=1;1;a+=f,f/=2){if(e>=(7-4*a)/11)return-Math.pow((11-6*a-11*e)/4,2)+Math.pow(f,2)}};return 1-g(1-b);break;default:return b;break}},slide:function(d,i,k,j){for(key in i){l(key,i[key])}function l(b,c){var h,g;h=d+b;switch(b){case'opacity':if(animate.ie){g=d.style.filter?parseFloat(d.style.filter.match(/[0-9]+/)):100}else{g=d.style.opacity?parseFloat(d.style.opacity):1;c=c/100};break;case'marginLeft':g=parseInt(d.style.marginLeft?d.style.marginLeft:0);break;case'marginRight':g=parseInt(d.style.marginRight?d.style.marginRight:0);break;default:g=0;break}if(h in animate.animator){clearInterval(animate.animator[h].timer)}animate.animator[h]={start:new Date().getTime(),timer:setInterval(function(){var e=(new Date().getTime())-animate.animator[h].start;var a=e/k;if(b=='opacity'){var f=(c-g)*a+g;if(animate.ie){d.style.filter="alpha(opacity="+f+")"}else{d.style.opacity=f}}else{var f=(c-g)*animate.animtype(a)+g;d.style[b]=f+"px"}if(a>=1){clearInterval(animate.animator[h].timer);if(b=='opacity'){if(animate.ie){d.style.filter="alpha(opacity="+c+")"}else{d.style.opacity=c}}else{d.style[b]=c+"px"}if(j){j()}}},10)}}},
	anim:true,
	divs:'',
	
	scrolprepare:function(){
		animate.finddivs();
		animate.divs[0].rel='1';
		},
	finddivs:function(){
		var e=document.getElementById('sitewrap').getElementsByTagName('div');
		animate.divs=e;
		if(animate.divs.length<4){animate.anim=false}
		for(var a=0;a<e.length;a++){
			e[a].style.margin=0;
			if(a>2){e[a].style.display='none'}
			}
		},
		
	scrol:function(e){
	var a = 500,
		z = document.getElementById('goforw'),
		y = document.getElementById('goback');
		if(animate.anim){
			animate.anim=false;
			switch(e){
			
				case'left':
				
					var f=animate.divs[0],b=animate.divs[3];
					if(b.rel){animate.anim=true}
					else{y.style.display='';b.style.display='';animate.slide(f,{"marginLeft":-264},a,function(){document.getElementById('sitewrap').appendChild(f);f.style.cssText='display:none;margin-left:0;';animate.anim=true;})}
					if(animate.divs[(animate.divs[4]?4:0)].rel){z.style.display='none'}
					
					break;
				
				case'right':var f=animate.divs[2],b=animate.divs[0];if(animate.divs[animate.divs.length-1].rel){y.style.display='none'}if(b.rel){animate.anim=true}else{z.style.display='';var c=animate.divs[animate.divs.length-1];document.getElementById('sitewrap').insertBefore(c,b);c.style.marginLeft=-264+'px';animate.slide(f,{"marginRight":-264},a);c.style.display='';animate.slide(c,{"marginLeft":0},a,function(){animate.anim=true;animate.finddivs()})}break;
				
				default:alert('Не указано направление!');break
				}
			}
		}
	};

	
	

core = {
	onload:function(b){
		function init(){if(arguments.callee.done){return}arguments.callee.done=true;b()};if(document.addEventListener){document.addEventListener("DOMContentLoaded",init,false)}if(/*@cc_on!@*/false){document.write("<script id=\"__ie_onload\" defer=\"defer\" src=\"javascript:void(0)\"><\/script>");var a=document.getElementById("__ie_onload");a.onreadystatechange=function(){if(this.readyState=="complete"){init()}}}if(/WebKit/i.test(navigator.userAgent)){var c=setInterval(function(){if(/loaded|complete/.test(document.readyState)){clearInterval(c);init()}},10)}window.onload=init;
		},
	randomHeader:function(){
		document.getElementById('wrapper').className+=' header'+Math.floor(Math.random()*7);
		},
	partners:function(){
		$('#partners li img').each(function(){
			var a = $(this);
			//это было бы по уму...
			//this.parentNode.style.cssText = ('background:url("/img/partner/partner' + a.attr('src').match(/partner(\d+)__/)[1] + '__hover.jpg")').toString();
			a.hover(function(){a.stop().fadeTo(500,0)},function(){a.stop().fadeTo(500,1)});
			});
		},
	block:{
		open:function(num){
			if(num!=1)core.block.close(1);
			if(num!=2)core.block.close(2);
			if(num!=3)core.block.close(3);
			if(num!=4)core.block.close(4);
			var a =$('#block'+num);
			a.css('opacity',0).css('display','block');
			a.animate({opacity:1,marginLeft:0},500)
			},
		close:function(num){
			var a =$('#block'+num);
			if(num<=2){a.animate({opacity:0,marginLeft:-50},500,function(){
				a.css('display','none');
				})}else{a.animate({opacity:0,marginLeft:50},500,function(){
				a.css('display','none');
				})}
			},
		preload:function(){
			var a = new Image();
			a.src='/img/block.png';
			}
		},
	hiders:function(){
		$('.hider li a').each(function(){
			var a = $(this);
			a.find('span').css('opacity',0);
			a.hover(function(){
				a.find('span').stop().fadeTo(300,1)
				},function(){
					a.find('span').stop().fadeTo(300,0)
					});
			});
		},
	dropmenu:function(){
		$('#dropmenu li ul')
			.parent()
			.each(function(){
				(function(a,b){
					a.hover(
						function(){b.stop().animate({top:-8},700)},
						function(){b.stop().animate({top:-(b.height()+38)},700)}
						);
					})($(this),$(this).find('ul'))
				});
		},
	switcher:function(){var q ={
		sO:document.getElementById('switcherO'),
		sR:document.getElementById('switcherR'),
		s0:document.getElementById('switcher0'),
		s1:document.getElementById('switcher1'),
		s2:document.getElementById('switcher2'),
		s3:document.getElementById('switcher3'),
		s4:document.getElementById('switcher4'),
		s5:document.getElementById('switcher5'),
		one:function(){if(core.switcher.s1.style.display=='block'){core.switcher.original()}else{core.switcher.all();core.switcher.si1.src=core.switcher.si1o;core.switcher.s1.style.display='block'}},
		two:function(){if(core.switcher.s2.style.display=='block'){core.switcher.original()}else{core.switcher.all();core.switcher.si2.src=core.switcher.si2o;core.switcher.s2.style.display='block'}},
		three:function(){if(core.switcher.s3.style.display=='block'){core.switcher.original()}else{core.switcher.all();core.switcher.si3.src=core.switcher.si3o;core.switcher.s3.style.display='block'}},
		original:function(){core.switcher.all();try{core.switcher.sO.className='still';}catch(e){};core.switcher.s0.style.display='block'},
		regions:function(){core.switcher.all();try{core.switcher.sR.className='still';}catch(e){};core.switcher.s4.style.display='block';try{core.switcher.s5.style.display='block';}catch(e){}},
		all:function(){
			try{core.switcher.sO.className='';}catch(e){}
			try{core.switcher.sR.className='';}catch(e){}
			try{core.switcher.si1.src=core.switcher.si1s;}catch(e){}
			try{core.switcher.si2.src=core.switcher.si2s;}catch(e){}
			try{core.switcher.si3.src=core.switcher.si3s;}catch(e){}
			try{core.switcher.s0.style.display='none';}catch(e){}
			try{core.switcher.s1.style.display='none';}catch(e){}
			try{core.switcher.s2.style.display='none';}catch(e){}
			try{core.switcher.s3.style.display='none';}catch(e){}
			try{core.switcher.s4.style.display='none';}catch(e){}
			try{core.switcher.s5.style.display='none';}catch(e){}
			}
		};
		try{q.si1=document.getElementById('swImage1');q.si1s=q.si1.src;q.si1o=q.si1s.replace(/gray_/,'');}catch(e){};
		try{q.si2=document.getElementById('swImage2');q.si2s=q.si2.src;q.si2o=q.si2s.replace(/gray_/,'');}catch(e){};
		try{q.si3=document.getElementById('swImage3');q.si3s=q.si3.src;q.si3o=q.si3s.replace(/gray_/,'');}catch(e){};
		core.switcher = q;
		},
	check:function(form,fields,mail){
		var message='',errors=[];
		if(fields){for(var i=fields.length;i--;){if(form[fields[i]].value=='')errors.push(fields[i])}}
		if(mail){if(!/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/i.test(form[mail].value))errors.push(mail)}
		for(var i=errors.length;i--;){
			switch(errors[i]){
				case "data[company]" : message += 'У вас не заполнено поле "Компания" !\r\n';break;
				case "data[username]" : message += 'У вас не заполнено поле "Контактное лицо" !\r\n';break;
				case "data[email]" : message += 'У вас не правильно заполнено поле "Электронная почта" !\r\n';break;
				case "data[m_phone]" : message += 'У вас не заполнено поле "Телефон" !\r\n';break;
				case "data[comment]" : message += 'У вас не заполнено поле "Сообщение" !\r\n';break;
				case "data[validimg]" : message += 'У вас не заполнено поле с проверочным кодом !\r\n';break;
				case "data[dir_fio]" : message += 'У вас не заполнено поле "Ф.И.О. руководителя" !\r\n';break;
				case "data[dir_phone]" : message += 'У вас не заполнено поле "Телефон офиса" !\r\n';break;
				case "data[fio]" : message += 'У вас не заполнено поле "Ф.И.О. участника" !\r\n';break;
				case "data[phone]" : message += 'У вас не заполнено поле "Телефон участника" !\r\n';break;
				case "captcha" : message += 'У вас не заполнено поле с проверочным кодом !\r\n';break;
				}
			}
		if(message==''){form.submit()}else{alert(message)}
		}
	};
