jQuery(function (){
	'use strict';
	var $ = jQuery;

	var hp_container = $('#pix-hp-container'),
		body = $('body'),
		popup = $('.pix-halloween-pandas-popup');

	if (hp_container.length) {
		var hp_container_class = hp_container.attr('data-class'),
			hp_image = hp_container.attr('data-image'),
			hp_fall = hp_container.attr('data-fall');
		if (hp_fall == 'yes') {
			$('body').snowfall({image: [hp_image+'_1.svg', hp_image+'_2.svg', hp_image+'_3.svg', hp_image+'_4.svg', hp_image+'_5.gif', hp_image+'_6.gif', hp_image+'_7.svg', hp_image+'_8.svg', hp_image+'_9.svg', hp_image+'_10.svg'], minSize: 50, maxSize: 100, flakeCount: 15, minSpeed: 1, maxSpeed: 3});
			setTimeout(function () {
				$('body').snowfall('clear');
			}, 1000*60);
		}
		if (hp_container_class) {
			body.addClass(hp_container_class);
		}
	}

	if (popup.length) {
		var popup_is_hidden = Cookies.get('px_hp_popup_hidden');
		if ('1' !== popup_is_hidden) {
			popup.fadeIn(500);
		}
	}

	$(document).on('click', '.px-popup-close', function (e){
		e.preventDefault();
		Cookies.set('px_hp_popup_hidden', '1', { expires: 1});
		if (popup.length) {
			popup.fadeOut(500);
		}
	})
})
