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

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<3){animate.anim=false}
		for(var a=0;a<e.length;a++){
			e[a].style.margin=0;
			if(a>2){e[a].style.display='none'}
			}
		animate.divsw = 310;
		},
		
	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[2];
					if(b.rel){animate.anim=true}
					else{
						y.style.display='';
						b.style.display='';
						animate.slide(
							f,
							{"marginLeft":-animate.divsw},
							a,
							function(){
								document.getElementById('sitewrap').appendChild(f);
								f.style.cssText='display:none;margin-left:0;';
								animate.anim=true;
								}
							)
						} 
					if(animate.divs[3].rel){z.style.display='none'}
					
					break;
				
				case'right':
				
					var f=animate.divs[1],
						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=-animate.divsw+'px';
						animate.slide(f,{"marginRight":-animate.divsw},a);
						c.style.display='';
						animate.slide(c,{"marginLeft":0},a,function(){animate.anim=true;animate.finddivs()})
						
						}break;
				
				default:alert('Не указано направление!');break
				}
			}
		}
	};
	
core = {
	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)}
		}
	};
