document.observe('dom:loaded', function(){
	var lastObj;
	$$('.faq_item').each(function(element){
		element.onclick = function(){
			faqObj = element.up().next();
			Effect.toggle(faqObj, 'blind', { duration: 0.2 });
		};
	});
	$$('.show_form_support').each(function(element){
		element.onclick = function(){
			if(element.rel){
				if ($('form_support').style.height == '0px'){
					new Effect.Morph('form_support', {
						style: 'height:400px;',
						duration: 0.4
					});
				} else {
					new Effect.Morph('form_support', {
						style: 'height:0px;',
						duration: 0.4
					});
				};
			} else {
				if ($('form_support').style.height == '57px'){
					new Effect.Morph('form_support', {
						style: 'height:433px;',
						duration: 0.4
					});
					element.className = 'show_form_support sfs_active';
				} else {
					new Effect.Morph('form_support', {
						style: 'height:57px;',
						duration: 0.4
					});
					element.className = 'show_form_support';
				};
			}
			return false;
		};
	});
	$$('.g_link').each(function(element){
		element.onclick = function(){
			gCounter = element.rel;
			new Effect.Move('g_border', {x: ((gCounter-1)*139), mode: 'absolute', duration: 0.7 });
			showGallery();
			gLast = gCounter;
			return false;
		};
		gSum++;
	});
	$$('.main_full_show').each(function(element){
		element.onclick = function(){
			mText = $('main_full_text');
			Effect.toggle(mText, 'blind', { duration: 1 });
			element.hide();
			$('mfh').show();
			return false;
		};
	});
	$$('.main_full_hide').each(function(element){
		element.onclick = function(){
			mText = $('main_full_text');
			Effect.toggle(mText, 'blind', { duration: 1 });
			element.hide();
			$('mfs').show();
			return false;
		};
	});
});

/*Блокировщик повторных нажатий*/
var unBlocked = true;
function unBlock(){
	unBlocked = true;
}
/*---*/

var gInc = 0;
var gSum = 0;
function gScroll(direct){
	if(direct == 'left' && unBlocked){
		gCounter--;
		unBlocked = false;
		if(gCounter == 0){
			gCounter = gSum;
		}
		new Effect.Move('g_border', {x: ((gCounter-1)*139), mode: 'absolute', duration: 0.7 });
		unBlock.delay(0.8);
	}
	if(direct == 'right' && unBlocked){
		gCounter++;
		unBlocked = false;
		if(gCounter == gSum+1){
			gCounter = 1;
		}
		new Effect.Move('g_border', {x: ((gCounter-1)*139), mode: 'absolute', duration: 0.7 });
		unBlock.delay(0.8);
	}
	showGallery();
	gLast = gCounter;
}

function showGallery(){
	if (gCounter < 6) {
		new Effect.Move('g_block', {x: 0, mode: 'absolute', delay: 0, duration: 0.7 });
	}
	if (gCounter == 6) {
		if ($('g_block').style.left != '0px'){
			new Effect.Move('g_block', {x: 0, mode: 'absolute', delay: 0, duration: 0.7 });
		} else {
			new Effect.Move('g_block', {x: ((gCounter-1)*-139), mode: 'absolute', delay: 0, duration: 0.7 });
		}
	}
	if (gCounter == 11) {
		new Effect.Move('g_block', {x: ((gSum+6-gCounter-1)*-139), mode: 'absolute', delay: 0, duration: 0.7 });
	}
	if (gCounter == 12) {
		new Effect.Move('g_block', {x: ((gSum+7-gCounter-1)*-139), mode: 'absolute', delay: 0, duration: 0.7 });
	}
	if (gCounter > 6 && gCounter < 11) {
		new Effect.Move('g_block', {x: (5*-139), mode: 'absolute', delay: 0, duration: 0.7 });
	}
	if (gCounter == gSum) {
		new Effect.Move('g_block', {x: ((gSum+9-gCounter-1)*-139), mode: 'absolute', delay: 0, duration: 0.7 });
	}
	sLast = $('g'+gLast);
	sCounter = $('g'+gCounter);
	new Effect.Fade(sLast, { to: 0.0, duration: 0.7});
	new Effect.Appear(sCounter, { to: 1.0, duration: 0.7 });
}

var msCounter = 0;
function msScroll(direct){
	if (direct == 'left' && msCounter != 0 && unBlocked){
		unBlocked = false;
		new Effect.Move('scroll_image', {x: 750, y: 0, mode: 'relative', duration: 0.7 })
		msCounter--;
		showArrow('right',msCounter);
		unBlock.delay(0.8);
	}
	if (direct == 'right' && msCounter != 2 && unBlocked){
		unBlocked = false;
		new Effect.Move('scroll_image', {x: -750, y: 0, mode: 'relative', duration: 0.7 })
		msCounter++;
		showArrow('left',msCounter);
		unBlock.delay(0.8);
	}
}

function showArrow(direct,count){
	if (direct == 'left' && count != 0){
		$('ms_larr').show();
	}
	if (direct == 'left' && count == 2){
		$('ms_rarr').hide();
	}
	if (direct == 'right' && count != 2){
		$('ms_rarr').show();
	}
	if (direct == 'right' && count == 0){
		$('ms_larr').hide();
	}
};