// размеры окна (кроссбраузерно)
function WindowDimensions() {
	if (typeof(window.innerWidth) == 'number') {
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}
	else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	
	return { width: myWidth, height: myHeight };
}

// проверка формы на заполненность обязательных полей
function CheckFieldsForm(fields) {
	fields_error = new Array();
	
	$.each(fields, function(i, val) { if ($(val).val() == '' || $(val).val() == -1) fields_error.push(val); });
	$.each(fields, function(i, val) { $(val).removeClass('f-incorrect'); });	
	
	if (fields_error.length == 0) return true;
	else {	
		$.each(fields_error, function(i, val) { $(val).addClass('f-incorrect'); }); 
		return false;
	}	
}

// правильные падежи
function Plural(num, words) {
    wforms = words.split('|');
    if (wforms.length == 3) {
        plural = ((num % 10 == 1 && num % 100 != 11) ? 0 : ((num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20)) ? 1 : 2));
        return wforms[plural];
    }
    else {
        return '';
    }
}

// CSS fix
var cssFix = function() {
	var u = navigator.userAgent.toLowerCase(),
	
	addClass = function(el,val) {
		if(!el.className) {
			el.className = val;
		}
		else {
      		var newCl = el.className;
			newCl += (" "+val);
			el.className = newCl;
		}
	},

	is = function(t) { return ( u.indexOf(t) != -1) };
	
	addClass(document.getElementsByTagName('html')[0],[	
	(!(/opera|webtv/i.test(u))&&/msie (\d)/.test(u))?('ie ie'+RegExp.$1)	
	  :is('firefox/2')?'gecko ff2'	
	  :is('firefox/3')?'gecko ff3'	
	  :is('gecko/')?'gecko'	
	  :is('opera/9')?'opera opera9':/opera (\d)/.test(u)?'opera opera'+RegExp.$1	
	  :is('konqueror')?'konqueror'	
	  :is('applewebkit/')?'webkit safari'	
	  :is('mozilla/')?'gecko':'',	
	(is('x11')||is('linux'))?' linux'	
	  :is('mac')?' mac'	
	  :is('win')?' win':''	
	].join(" "));
}();

// --------------------------------------------------------

$(document).ready(function() {
						   
	$('#menu .item').hover(
		function() {
			$(this).find('a').addClass('mhover').animate({ marginTop: '0px' }, { duration: 300, queue: false });
		},
		function() {
			$(this).find('a').removeClass('mhover').animate({ marginTop: '9px' }, { duration: 300, queue: false });
		}
	);

});


