$(window).load(function() { 
	/* Main page 3 Blocks Effects */
	
	$('.cellsarea .cells .cell').mouseover(function() {
		var className = $(this).attr('class');
		var pos = className.indexOf('selected');
		if (pos == -1) {
			$(this).css('left', parseInt($(this).css('left')) - 1);
			$(this).attr('class',className + ' selected');
		}
	});
	
	$('.cellsarea .cells .cell').mouseout(function() {
		var className = $(this).attr('class');
		var pos = className.indexOf('selected');
		if (pos != -1) {
			$(this).css('left', parseInt($(this).css('left')) + 1);
			$(this).attr('class',className.substr(0, pos));
		}
	});
	
	
	/* Main menu Effects */
	
	$('.body .contentarea .mainmenu div').mouseover(function() {
		var className = $(this).attr('class');
		var pos = className.indexOf('hover');
		if (pos == -1) {
			$(this).attr('class',className + ' hover');
		}
	});
	
	$('.body .contentarea .mainmenu div').mouseout(function() {
		var className = $(this).attr('class');
		var pos = className.indexOf('hover');
		if (pos != -1) {
			$(this).attr('class',className.substr(0, pos));
		}
	});
	
	$('.body .contentarea .mainmenu div').click(function() {
		location.href = $(this).children('a').attr('href');
		return false;
	});
	
	
	/* inner news Effects */
	
	$('.innerContent .main .newsitem').mouseover(function() {
		var className = $(this).attr('class');
		var pos = className.indexOf('newsitemHover');
		if (pos == -1) {
			$(this).attr('class',className + ' newsitemHover');
		}
	});
	$('.innerContent .main .newsitem').mouseout(function() {
		var className = $(this).attr('class');
		var pos = className.indexOf('newsitemHover');
		if (pos != -1) {
			$(this).attr('class',className.substr(0, pos));
		}
	});
	$('.innerContent .main .newsitem').click(function() {
		location.href = $(this).children('.description').children('a').attr('href');
		return false;
	});
	
	
	/* Pages Effects */
	
	$('.body .pagesContainer .pages .page').mouseover(function() {
		var className = $(this).attr('class');
		var pos = className.indexOf('pageHover');
		if (pos == -1) {
			$(this).attr('class',className + ' pageHover');
		}
	});
	$('.body .pagesContainer .pages .page').mouseout(function() {
		var className = $(this).attr('class');
		var pos = className.indexOf('pageHover');
		if (pos != -1) {
			$(this).attr('class',className.substr(0, pos));
		}
	});
	$('.body .pagesContainer .pages .page').click(function() {
		location.href = $(this).children('a').attr('href');
		return false;
	});
	

	/* contact form */
	
	$('input').focus(function() {
		var className = $(this).attr('class');
		var pos = className.indexOf('onfocus');
		if (pos == -1) {
			$(this).attr('class',className + ' onfocus');
		}
	});
	$('input').blur(function() {
		var className = $(this).attr('class');
		var pos = className.indexOf('onfocus');
		if (pos != -1) {
			$(this).attr('class',className.substr(0, pos));
		}
	});
	$('textarea').focus(function() {
		var className = $(this).attr('class');
		var pos = className.indexOf('onfocus');
		if (pos == -1) {
			$(this).attr('class',className + ' onfocus');
		}
	});
	$('textarea').blur(function() {
		var className = $(this).attr('class');
		var pos = className.indexOf('onfocus');
		if (pos != -1) {
			$(this).attr('class',className.substr(0, pos));
		}
	});
	
	/* submit form */
	
	$('#conactform').submit(function() {
		var msg = "Все поля обязательны для заполнения.";
		if (!$('#fname').val()) {
			alert(msg);
			document.getElementById('fname').focus();
			return false;
		}
		if (!$('#fphone').val()) {
			alert(msg);
			document.getElementById('fphone').focus();
			return false;
		}
		if (!$('#fmessage').val()) {
			alert(msg);
			document.getElementById('fmessage').focus();
			return false;
		}
		if (!$('#captcha').val()) {
			alert(msg);
			document.getElementById('captcha').focus();
			return false;
		}
		return true;
	});
	
	
	/* pagesContainer width */
	
	$('.pagesContainer').each(function(i) {
		var c2 = $($(this).children('.pc2'));
		var ch = c2.children('.pages').children('.page');
		if (ch.length) {
			c2.css('width',ch.length * 27);
			c2.children('.bgpages').css('background','#FFFFFF');
		}
	});
});