
var prevDownElement = null;

function initMenu() {
	$('#mainMenu ul').hide();
	//$('#menu ul:first').show();
	$('#mainMenu li a').click(
		function() {
			var checkElement = $(this).next();
			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				$('#mainMenu ul:visible').slideUp('fast');
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				if (prevDownElement != null) prevDownElement.slideUp('fast');
				//checkElement.show();
				checkElement.slideDown('slow', function(){
					theObj = $(this);
					setTimeout(
						function(){
							theObj.hide();
							theObj.show();
						},1);
					});
				prevDownElement = checkElement;
			}
			if(checkElement.is('ul')) {
				return false;
			}
		}
	);
	showCurrentSubmenu();
}

function showCurrentSubmenu() {
	return false;
}

$(document).ready(function(){ 
	//$(document).pngFix(); 
	$('.png, #mainMenu li div, #mainMenu li a, #mainPage, #contacts').ifixpng();
	initMenu();
	if ( !($.browser.msie && parseInt($.browser.version) <= 6) ){
		$('#email').focus(function() {
				if($(this).attr('value') == "Ваш e-mail") {
					$(this).attr({value:''});
				}
			}
		);
		$('#email').blur(function() {
				if($(this).attr('value') == "") {
					$(this).attr({value:'Ваш e-mail'});
				}
			}
		);
	}
	//Pretty Photo lightbox initialisation

	//		$("a[rel^='prettyPhoto']").prettyPhoto({
	//			animationSpeed: 'normal', /* fast/slow/normal */
	//			padding: 40, /* padding for each side of the picture */
	//			opacity: 0.35, /* Value betwee 0 and 1 */
	//			showTitle: true, /* true/false */
	//			allowresize: true, /* true/false */
	//			counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
	//			theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
	//			callback: function(){}
	//		});
	
	$("a[rel^='prettyPhoto']").prettyPhoto({
		padding: 40,
		opacity: 0.5,
		allowresize: true,
		counter_separator_label: ' из ',
		theme: 'light_square',
		showTitle: false,
		animationSpeed: 'normal'
	});

});
