// Put all your lovely jQuery / Javascript goodies right down here.

var hide_arch_menu = false;
var arch_menu_showed = false;

function HideSubmenu() {
    hide_arch_menu = true;
    setTimeout("FinalHide();", 1000);
}

function FinalHide() {
    if(hide_arch_menu)
    {
        document.getElementById('about_submenu').style.display = 'none';
        arch_menu_showed = false;
    }    
}

function ShowSubmenu() {
    hide_arch_menu = false;    
    if(!arch_menu_showed) {
        arch_menu_showed = true;
        document.getElementById('about_submenu').style.display = 'block';
    }
}

var core = {
    common: {
        toggleRcForm: function(el) {
	    $(el).toggle();//is(':visible') ? el.slideUp(200) : el.slideDown(200);
	}
    },

    main_page: {
        setPhotoScroller: function(selector){
            jQuery(selector).mCustomScrollbar(
                "horizontal",
                680,
                "easeOutCirc",
                1,
                "fixed",
                "yes",
                "yes",
                20
            );
        },

        switchPhotos: function(i, obj){
            jQuery('.photos_selector').removeClass('active');

            if(i == 1){
                var o1 = 1;
                var o2 = 2;
            }else{
                var o1 = 2;
                var o2 = 1;
            };

            jQuery(obj).addClass('active');
            jQuery('#photo_scroller'+o2).animate({opacity: 0}, 200, function(){
                jQuery('#photo_scroller'+o2).hide();
                jQuery('#photo_scroller'+o1).css({opacity: 1}).fadeIn(200);
                core.main_page.setPhotoScroller('#photo_scroller'+o1);
            });
        },

        init: function(){
            this.setPhotoScroller('#photo_scroller1');
        }
    }
}

jQuery(document).ready(function($){

//window.setTimeout(function() {
//	$('.skype_pnh_container').html('');
//	$('.skype_pnh_print_container').removeClass('skype_pnh_print_container');
//}, 800);

	core.main_page.init();

    $(".photo_scroller .customScrollBox .content").show();
	$(".photo_scroller .customScrollBox img").hover(function(){
		$(this).animate({opacity: 1});
	}, function(){
		$(this).animate({opacity: 0.7});
	});

	$("a[rel=gallery]").fancybox({
		'overlayColor'		: '#000',
		'overlayOpacity'	: 0.8,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	
	
});

function slideSwitch() {
    var active = $('.slideshow img.active') || $('.slideshow img:first');
    var next =  active.next().length ? active.next() : $('.slideshow img:first');

    active.addClass('last-active');

    next.css({opacity: 0.0})
        .addClass('active')
       	.animate({opacity: 1.0}, 1000, function() {
            active.removeClass('active last-active');
   	});
}

var s;

$(".image_holder").hover(function(){
	s = setInterval( "slideSwitch()", 2000 );
}, function(){
	clearInterval(s);
        $('.slideshow img').each(function() { $(this).removeClass('active last-active')}).eq(0).addClass('active');
});

function ShowSmallWindow(src, width, height) {
	window.open(src+"?village_id=87&page_id=/poselok_ustie", "message","toolbar=0,scrollbars=1,resizable=1,width="+width+",height="+height+",Left=100,Top=50");
}

$(document).ready(function(){
	
	$(".CheckBoxClass").change(function(){
		if($(this).is(":checked")){
			$(this).next("label").addClass("LabelSelected");
		}else{
			$(this).next("label").removeClass("LabelSelected");
		}
	});
	
	$("#tabs").tabs();
	$('#file').customFileInput();
	
});

//jQuery.noConflict();

