$(window).load(function() {
	$(".modal").fancybox({
		scrolling: "no", 
		transitionIn: 'none',
		//showCloseButton: false,
		autoDimensions: true
		//width: 750,
		//height: 530
	});

    $('#largeImg a').lightBox({
        txtImage: '', 
        txtOf: 'из',
        imageBtnPrev: '/assets/i/lightbox_bt_prev.png',
        imageBtnNext: '/assets/i/lightbox_bt_next.png',
        imageBtnClose: '/assets/i/lightbox_bt_close.png'
    });	
});

if(window.opera) {
	$(function() {
	    $('#largeImgW a').lightBox({
			txtImage: '', 
			txtOf: 'из',
			imageBtnPrev: '/assets/i/lightbox_bt_prev.png',
			imageBtnNext: '/assets/i/lightbox_bt_next.png',
			imageBtnClose: '/assets/i/lightbox_bt_next.png'
		});
	});
}
$(document).ready(function(){
	var mtext;
    $("#Menu ul li ul li a").hover(
		function(){
			mtext = $(this).text();

			$(this).wrapInner("<span></span>");
			$(this).addClass("hover");
    	}, function() {
			$(this).removeClass("hover");	
			$(this).html(mtext);
    	}
	);

    $('#TopMenu li').hover(
        function() {
            $(this).addClass("hover");
            $(this).find('span').addClass("hover");
        },
        function() {
            $(this).removeClass("hover");
            $(this).find('span').removeClass("hover");
        }
    );

	// работы
	$(".thumbs a").click(function(){
		var bigImg = $(this).attr("rel");
		var largePath = $(this).attr("href");
		var largeAlt = $(this).attr("title");

		$("#largeImgW img").attr({ src: largePath, alt: largeAlt, width: 426, height: 338 });
		$("#largeImgW a.active").attr({ href: bigImg});

		$(".thumbs a").attr('class','');
		$(this).attr('class', 'current');

		$("h1 em").html(" (" + largeAlt + ")"); 
		return false;
	});

	//$("a[rel='big']").colorbox();

	// эскизы
	$("#eskiz .thumbs a").click(function(){

		var largePath = $(this).attr("href");
		var largeAlt = $(this).attr("title");
		var largeImage = $(this).find('span').html();

		$("#largeImg img").attr({ src: largePath, alt: largeAlt, width: 318, height: 252 });
		$("#largeImg a").attr({ href: largeImage });

		$("h1 em").html(" (" + largeAlt + ")"); return false;
	});

	// ===================
	if ($('#fio').val() != '') $("label#lfio").css({'display':'none'});
	$('#fio').blur( function() { if (this.value == '') $("label#lfio").css({'display':'block'}); });
	$('#fio').focus(function() { if ($("label#lfio").show()) $("label#lfio").css({'display':'none'}); });

	if ($('#email').val() != '') $("label#lemail").css({'display':'none'});
	$('#email').blur( function() { if (this.value == '') $("label#lemail").css({'display':'block'}); });
	$('#email').focus(function() { if ($("label#lemail").show()) $("label#lemail").css({'display':'none'}); });

	if ($('#phone').val() != '') $("label#lphone").css({'display':'none'});
	$('#phone').blur( function() { if (this.value == '') $("label#lphone").css({'display':'block'}); });
	$('#phone').focus(function() { if ($("label#lphone").show()) $("label#lphone").css({'display':'none'}); });

	if ($('#message').val() != '') $("label#lmessage").css({'display':'none'});
	$('#message').blur( function() { if (this.value == '') $("label#lmessage").css({'display':'block'}); });
	$('#message').focus(function() { if ($("label#lmessage").show()) $("label#lmessage").css({'display':'none'}); });
	
	if($('#depth')) {
		if ($('#width').val() != '') $("label#lwidth").css({'display':'none'});
		$('#width').blur( function() { if (this.value == '') $("label#lwidth").css({'display':'block'}); });
		$('#width').focus(function() { if ($("label#lwidth").show()) $("label#lwidth").css({'display':'none'}); });

		if ($('#height').val() != '') $("label#lheight").css({'display':'none'});
		$('#height').blur( function() { if (this.value == '') $("label#lheight").css({'display':'block'}); });
		$('#height').focus(function() { if ($("label#lheight").show()) $("label#lheight").css({'display':'none'}); });

		if ($('#depth').val() != '') $("label#ldepth").css({'display':'none'});
		$('#depth').blur( function() { if (this.value == '') $("label#ldepth").css({'display':'block'}); });
		$('#depth').focus(function() { if ($("label#ldepth").show()) $("label#ldepth").css({'display':'none'}); });
	}
	
	

	$("a#toogle").click(function () {
		$("#container").toggle();
	});

	
});


