$(function(){
	$("#top_menu ul li").hover(
		function(){
			var d = $(this).find("div."+$(this).attr("class"));
			var level = parseInt($(this).attr("class").substr(6));
			if(level>1) {
				d.css("left", $(this).outerWidth());
			}
			
			d.show(300);
		},
		function(){
			$(this).find("div").hide(300);
			//$(this).find("div").slideUp();
		}
	);
	
	$("a.photo").fancybox({
		'autoScale'			: false,
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});
	
	$("a[rel=gallery_photo]").fancybox({
		'autoScale'			: false,
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});
	
	var flashvars = {};
	var params = {wmode: "transparent", allowFullScreen: true, menu: false, scale: "showall", align: "top", quality: "high", salign: "t"};
	var attributes = {id: "top_banner"};
	swfobject.embedSWF("/i/flash/top.swf?cache=" + Math.random(), "top_banner", '1000', '291', "10.0", false, flashvars, params, attributes);
	
	$("button#add_coment").click(function(){
		
	});
	
	$("#tips").animate({opacity: 0}, 10000, function(){$(this).remove();});
	/*
	$("button#order_call").click(function(){
		var name = $("#order_name");
		var phon = $("#order_phone");
		var mail = $("#order_email");
		var cont = $("#order_content");
		var from = $("#oreder_from");
		var to = $("#order_to");
		var valid = true;
		valid = valid && checkLength();
	});
	*/
});

function updateTips( t ) {
	$("#tips").text( t )
		.addClass( "ui-state-highlight" );
	setTimeout(function() {
		tips.removeClass( "ui-state-highlight", 1500 );
	}, 500 );
}

function checkLength( o, n, min, max ) {
	if ( o.val().length > max || o.val().length < min ) {
		o.addClass( "ui-state-error" );
		updateTips( "Length of " + n + " must be between " +
			min + " and " + max + "." );
		return false;
	} else {
		return true;
	}
}

function checkRegexp( o, regexp, n ) {
	if ( !( regexp.test( o.val() ) ) ) {
		o.addClass( "ui-state-error" );
		updateTips( n );
		return false;
	} else {
		return true;
	}
}
