jQuery.noConflict();


/**
   * PK Init Vars
*/

	var pk_stage_width = 0;
	var pk_stage_height = 0;
	var pk_new_item = -1;
	var pk_old_item = 0;
	var pk_new_type = "";
	var pk_old_type = "";
	var pk_slide_verse = "next";
	var pk_slide_restart = false;
	var pk_thumbs_open = false;
	var pk_info_open = false;
	var pk_image_width = 0;
	var pk_image_height = 0;
	var pk_is_first = true;
	var pk_is_loader = false;
	var pk_interval = null;
	var pk_deep_link_change_item = false;

	var pk_video_width = pk_gallery_video_width;
	var pk_video_height = pk_gallery_video_height;
	var pk_info_max_height = pk_gallery_info_max_height;
	var pk_thumbs_width = pk_gallery_thumbs_width;
	var pk_thumbs_height = pk_gallery_thumbs_height;
	var pk_thumbs_visible = pk_gallery_thumbs_visible;
	var pk_shadow = pk_gallery_shadow;
	var pk_images_up_scale = pk_gallery_images_up_scale;
	var pk_videos_up_scale = pk_gallery_videos_up_scale;
	var pk_button_info_open_label = pk_gallery_button_info_open_label;
	var pk_button_info_close_label = pk_gallery_button_info_close_label;
	var pk_button_slideshow_on_label = pk_gallery_button_slideshow_on_label;
	var pk_button_slideshow_off_label = pk_gallery_button_slideshow_off_label;
	var pk_is_slideshow = pk_gallery_slideshow_auto_start;
	var pk_interval_timer = pk_gallery_slideshow_interval * 1000;

	var pk_media = [];
	var pk_infos = [];


/*
  * Document / Window Events
*/

	jQuery(document).ready(function() {

		jQuery("body").removeClass("pk_standard_pages");
		jQuery("#wrapper").css("visibility", "hidden").removeClass("pk_center_box").show();

		pk_stage_width = jQuery(window).width();
		pk_stage_height = jQuery(window).height();

		pkInitDeepLink();

		pkCreateMainMenu();
		pkCreateGallery();
		pkCreateControls();
		pkCreateThumbs(pk_thumbs_width, pk_thumbs_height, pk_thumbs_visible);
		
		jQuery("#wrapper").css("visibility", "visible");

	});

	jQuery(window).resize(function() {

		pk_stage_width = jQuery(window).width();
		pk_stage_height = jQuery(window).height();

		pkResizeMainMenu();
		pkResizeControls();
		pkResizeGallery();
		pkResizeThumbs();
		pkResizeInfo();
		
		pkResizePreloader();

		pkSlideshow();

	});


/**
   * PK Init Deep Link
*/

	function pkInitDeepLink() {

		jQuery.address.externalChange(function(event) {

			pk_deep_link_change_item = true;

			if(event.value == "" || event.value == "/") {
				
				pk_is_first = true;

				jQuery("#pk_thumbs li a").filter(":eq(0)").trigger("click", [true]);

			} else {

				jQuery("#pk_thumbs li a").each(function() {

					if(jQuery(this).attr("data-deepLinking") == event.pathNames[0]) {

						jQuery(this).trigger("click", [true]);

					}
				});

			}

 		});

	}


/**
   * PK Create Main Menu
*/

	function pkCreateMainMenu() {

		var menu = jQuery("nav");
		var logo = jQuery("header h1");

		menu.hide();
		logo.hide();;

		menu.css({ "position" : "absolute", "left" : Math.round((pk_stage_width / 2) - (menu.outerWidth() / 2)) + "px", "top" : 0 + "px"}).show();
		logo.css({ "position" : "absolute", "left" : "0px", "top" : Math.round(pk_stage_height / 8) + "px" }).show();

	}


/**
   * PK Resize Main Menu
*/

	function pkResizeMainMenu() {

		var menu = jQuery("nav");
		var logo = jQuery("header h1");
	
		menu.css({ "left" : Math.round((pk_stage_width / 2) - (menu.outerWidth() / 2)) + "px", "top" : 0 + "px" });
		logo.css({ "position" : "absolute", "left" : "0px", "top" : Math.round(pk_stage_height / 8) + "px" }).show();
		
	}


/**
   * PK Create Gallery
*/

	function pkCreateGallery() {

		var gallery_item = jQuery("#pk_gallery ul:first li");

		gallery_item.each(function(e) {

			pk_media[e] = jQuery("div:first", this).html();
			pk_infos[e] = jQuery(".pk_description", this).html();
			
			jQuery("div:first", this).removeClass("pk_alignnone");

			jQuery("div:first", this).empty();
			jQuery(".pk_description", this).empty().hide();
			jQuery(this).css({ "position" : "absolute", "width" : 0 + "px", "height" : 0 + "px" });
			
			(pk_shadow == true) ? jQuery(this).addClass("pk_shadow") : jQuery(this).css({ "background" : "none" });
			
			jQuery(this).hide();

		});

	}


/**
   * PK Resize Gallery
*/

	function pkResizeGallery() {

		var gallery_items = jQuery("#pk_gallery ul:first li");
		var current_mask = gallery_items.filter(":eq(" + pk_new_item + ")");
		var current_mask_type = current_mask.find("div:first").attr("class");

		var current_image = gallery_items.filter(":eq(" + pk_new_item + ")").find("div:first img");
		var current_video = gallery_items.filter(":eq(" + pk_new_item + ")").find("div:first");
		
		for(var i = 0; i < gallery_items.length; i++) {

			if(i == pk_new_item) {

				(pk_new_type == "image") ? pkResizeObject(current_image, current_mask, "image", current_image.width(), current_image.height(), false) : pkResizeObject(current_video, current_mask, "video", pk_video_width, pk_video_height, false);

				pkPositionObject(current_mask);

			} else {
				
				gallery_items.filter(":eq(" + i + ")").find("div:first").empty();
				gallery_items.filter(":eq(" + i + ")").css({ "width" : 0 + "px", "height" : 0 + "px" });
				gallery_items.filter(":eq(" + i + ")").hide();

			}
		}

	}


/**
   * PK Create Controls
*/

	function pkCreateControls() {

		var footer = jQuery("footer");
		var controls = jQuery("#pk_controls");
		var button_info = jQuery("#pk_button_info");
		var button_slideshow = jQuery("#pk_button_slideshow");
		var gallery_tot_items = jQuery("#pk_gallery ul:first li").length;
		var buttons = jQuery("#pk_button_next, #pk_button_prev, #pk_button_thumbs, #pk_button_info, #pk_button_slideshow");

		if(gallery_tot_items == 1) {
			if(pk_infos[0] == null) {

				controls.css({ "width" : 0 + "px", "padding" : 0 + "px", "border" : "none" });
				button_slideshow.hide();
				button_info.hide();

			} else {

				controls.css({ "width" : 0 + "px", "padding" : 0 + "px", "border-right" : "none" });
				button_slideshow.hide();

			}
		}

		controls.css({ "position" : "absolute", "left" : Math.round((pk_stage_width / 2) - (controls.outerWidth() / 2)) + "px", "top" : 0 + "px" });
		button_info.css({ "position" : "absolute", "left" : Math.round((pk_stage_width / 2) + (controls.outerWidth() / 2)) + "px", "top" : 0 + "px" });
		button_slideshow.css({ "position" : "absolute", "left" : Math.round((pk_stage_width / 2) - (controls.outerWidth() / 2) - 110) + "px", "top" : 0 + "px" });
		footer.css({ "position" : "absolute", "top" : Math.round(pk_stage_height - 30) + "px" });

		buttons.each(function() {
			jQuery(this).removeAttr("href");
			jQuery(this).css({ "cursor" : "pointer" });
			
 			jQuery(this).click(function(e) {
				switch(jQuery(e.currentTarget).attr("id")) {

					case "pk_button_next":

						var item_index = pk_new_item;

						if(item_index + 1 > gallery_tot_items - 1) {

							pk_slide_restart = true;
							item_index = 0;
 
						} else {

							pk_slide_restart = false;
							item_index = item_index + 1;

						}

						pk_slide_verse = "next";
						jQuery("li a", "#pk_thumbs").filter(":eq("+ item_index +")").trigger("click", [true]);

						break;

					case "pk_button_prev":

						var item_index = pk_new_item;

						if(item_index - 1 < 0) {

							pk_slide_restart = true;
							item_index = gallery_tot_items - 1;

						} else {

							pk_slide_restart = false;
							item_index = item_index - 1;

						}

						pk_slide_verse = "prev";
						jQuery("li a", "#pk_thumbs").filter(":eq("+ item_index +")").trigger("click", [true]);

						break;

					case "pk_button_thumbs":

						(pk_thumbs_open == false) ? pkManageThumbs("show") : pkManageThumbs("hide", jQuery("#pk_thumbs").height());

						break;

					case "pk_button_info":

						if(pk_infos[pk_new_item] == null || pk_is_loader == true) {

							return true;

						}

						if(pk_thumbs_open == true) { pkManageThumbs("hide", jQuery("#pk_thumbs").height()); }
						(pk_info_open == false) ? pkShowInfo() : pkHideInfo("info");

						break;

					case "pk_button_slideshow":

						if(pk_is_slideshow == false) {

							pk_is_slideshow = true;
							jQuery(this).text(pk_button_slideshow_on_label);
							jQuery("#pk_button_next").trigger("click", [true]);

						} else {

							pk_is_slideshow = false;
							clearInterval(pk_interval);
							jQuery(this).text(pk_button_slideshow_off_label);
							jQuery("#pk_slideshow_bar").stop().animate({ "width" : 0 + "px" }, 400, "easeOutExpo");

						}

						break;
				}
			});
		});

		button_info.text(pk_button_info_open_label);
		(pk_is_slideshow == false) ? button_slideshow.text(pk_button_slideshow_off_label) : button_slideshow.text(pk_button_slideshow_on_label);
		
		if ((navigator.userAgent.indexOf('iPhone') != -1) ||  (navigator.userAgent.indexOf('iPod') != -1) ||  (navigator.userAgent.indexOf('iPad') != -1)) { 
			
			jQuery("#pk_gallery").touchwipe({
				wipeLeft: function() { jQuery("#pk_button_next").trigger("click", [true]); },
				wipeRight: function() { jQuery("#pk_button_prev").trigger("click", [true]); },
				min_move_x: 20,
				min_move_y: 20,
				preventDefaultEvents: true
			});
			
		}

	}


/**
   * PK Resize Controls
*/

	function pkResizeControls() {

		var footer = jQuery("footer");
		var controls = jQuery("#pk_controls");
		var controls_width = controls.outerWidth();
		var button_info = jQuery("#pk_button_info");
		var button_slideshow = jQuery("#pk_button_slideshow");

		controls.css({ "position" : "absolute", "left" : Math.round((pk_stage_width / 2) - (controls_width / 2)) + "px", "top" : 0 + "px" });
		button_info.css({ "position" : "absolute", "left" : Math.round((pk_stage_width / 2) + (controls_width / 2)) + "px", "top" : 0 + "px" });
		button_slideshow.css({ "position" : "absolute", "left" : Math.round((pk_stage_width / 2) - (controls_width / 2) - 110) + "px", "top" : 0 + "px" });
		footer.css({ "position" : "absolute", "top" : Math.round(pk_stage_height - 30) + "px" });

	}


/**
   * PK Create Thumbs
*/

	function pkCreateThumbs(thumbs_width, thumbs_height, visible) {

		var root = jQuery("#pk_thumbs");
		var gallery_items = jQuery("#pk_gallery ul:first li");
		var thumbs = jQuery("li", root);
		var tot_thumbs = thumbs.length;
		var root_width = (tot_thumbs >= visible) ? (thumbs_width * visible) + (1 * visible) : (thumbs_width * tot_thumbs) + (1 * tot_thumbs);

		jQuery("ul", root).css({"top" : thumbs_height + "px", "width" : Math.round((thumbs_width * tot_thumbs) + (1 * tot_thumbs)) + "px" });

		var ul_width = jQuery("ul", root).width();

		root.css({ "width" : root_width + "px", "height" : thumbs_height + "px", "left" : Math.round((pk_stage_width / 2) - (root_width / 2)) + "px", "top" : Math.round(pk_stage_height - (root.height() + thumbs_height)) + "px" });

		thumbs.each(function(i) {
			jQuery(this).css({ "width" : thumbs_width + "px", "height" : thumbs_height + "px" });

			jQuery('a', this).address(function() {

				if(pk_is_first == false && pk_is_loader == false) {

					return jQuery(this).attr('data-deepLinking');

				}

			});

			jQuery("a", this).click(function(e) {
				if(pk_is_loader == true || i == pk_new_item) {

					return true;

				}

				pk_old_item = pk_new_item;
				pk_new_item = i;

				pk_new_type = gallery_items.filter(":eq(" + pk_new_item + ")").find("div:first").attr("class").split("_")[1];
				if(pk_old_item != -1) { pk_old_type = gallery_items.filter(":eq(" + pk_old_item + ")").find("div:first").attr("class").split("_")[1]; }

				gallery_items.filter(":eq(" + pk_new_item + ")").show();

				if(pk_new_type == "image") {

					var dalay = (jQuery.browser.opera) ? 200 : 0;

					if(pk_slide_restart == false) {
						(pk_new_item > pk_old_item) ? pk_slide_verse = "next" : pk_slide_verse = "prev";
					}

					gallery_items.filter(":eq(" + pk_new_item + ")").find(".pk_image").html(pk_media[pk_new_item]);
					gallery_items.filter(":eq(" + pk_new_item + ")").find(".pk_image img").pk_preloader({
						beforeLoading:function(){ pk_is_loader = true; pkShowPreloader(); },
						afterLoading:function(){ 

							pkPngFix();
							(pk_deep_link_change_item == false) ? pkChangeItem("slide") : pkChangeItem("direct");
							pkHidePreloader();

						},
						delay:dalay,
						speedIn:0
					});
					
				} else {

					if(pk_slide_restart == false) {
						(pk_new_item > pk_old_item) ? pk_slide_verse = "next" : pk_slide_verse = "prev";
					}

					(pk_deep_link_change_item == false) ? pkChangeItem("slide") : pkChangeItem("change");

				}

				(pk_infos[pk_new_item] == null) ? jQuery("#pk_button_info").fadeOut(200) : jQuery("#pk_button_info").fadeIn(200);

				pk_slide_restart = false;
				
				thumbs.removeClass("current");
				jQuery(this).parent().addClass("current");

				pkUpDateCounter(pk_new_item, gallery_items.length);
			});

		});

		root.mousemove(function(e){
			if(ul_width > root_width) {

				var distance = e.pageX - root.offset().left;
				var percentage = distance / root_width;
				var targetX = 10 - Math.round(((ul_width + 20) - root_width) * percentage);
				jQuery("ul", root).animate({left : [targetX + "px", "easeOutBack"]}, {queue : false, duration : 800});

			}
    		});

	}


/**
   * PK Resize Thumbs
*/

	function pkResizeThumbs() {

		var div = jQuery("#pk_thumbs");
		div.css({ "position" : "absolute", "left" : Math.round((pk_stage_width / 2) - (div.width() / 2)) + "px", "top" : Math.round(pk_stage_height - (div.height() + 80)) + "px" });

	}


/**
   * PK Manage Thumbs
*/

	function pkManageThumbs(actionType, value) {

		if(pk_info_open == true) {

			return true;

		}

		jQuery("#pk_thumbs").show()

		if(actionType == "show") {

			pk_thumbs_open = true;
			jQuery("#pk_thumbs ul").css("position", "absolute").stop().animate({ "top" : 0 + "px" }, 800, "easeOutExpo");

		} else {

			pk_thumbs_open = false;
			jQuery("#pk_thumbs ul").css("position", "absolute").stop().animate({ "top" : value  + "px"}, 800, "easeOutExpo", function() {

				jQuery("#pk_thumbs").hide();

			});

		}

	}


/**
   * PK Png Fix
*/

	function pkPngFix() {
		
		if(jQuery.browser.msie && parseInt(jQuery.browser.version) < 9) {
			jQuery("#pk_gallery li img").css({
		
				"background" : "transparent",
				"-ms-filter": "progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF)",   
				"filter" : "progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF)",    
				"zoom" : 1
			
			});
		}		
	}


/**
   * PK Init PrettyPhoto
*/

	function pkInitPrettyPhoto() {

		if(pk_new_type != "video") {
			jQuery("a[data-prettyPhoto^='prettyPhoto']").prettyPhoto({
				default_width:800,
				default_height:450,
				allow_resize: true,
				autoplay_slideshow: false,
				slideshow: 5000,
				opacity: 0.8,
				theme: 'dark_square'
			});
		}

	}


/**
   * PK Change Item
*/

	function pkChangeItem(change_type) {

		var new_mask = jQuery("#pk_gallery ul:first li").filter(":eq(" + pk_new_item + ")");
		var old_mask = jQuery("#pk_gallery ul:first li").filter(":eq(" + pk_old_item + ")");
		var new_image = jQuery("div:first img", new_mask);
		var old_image = jQuery("div:first img", old_mask);
		var new_video = jQuery("div:first", new_mask);
		var old_video = jQuery("div:first", old_mask);
		
		pk_image_width = new_image.width();
		pk_image_height = new_image.height();
		
		(pk_new_type == "image") ? pkResizeObject(new_image, "", "image", new_image.width(), new_image.height(), false) : pkResizeObject(new_video, "", "video", pk_video_width, pk_video_height, false);

		var new_width = (pk_new_type == "image") ? new_image.width() : new_video.width();
		var new_height = (pk_new_type == "image") ? new_image.height() : new_video.height();
		var old_width = (pk_old_type == "image") ? old_image.width() : old_video.width();

		if(change_type == "slide") {
			new_mask.css({ "visibility" : "visible", "opacity" : 0, "width" : new_width + "px", "height" : new_height + "px" });

 			pkPositionObject(new_mask);
			
			old_mask.stop().animate({ "opacity" : 0 }, 250, "easeOutExpo", function() { 

				if(pk_old_type == "video") { jQuery(".pk_video", old_mask).empty(); } else { jQuery(".pk_image", old_mask).empty(); }
				jQuery(this).hide();

			});
			
 			new_mask.stop().delay(50).animate({ "opacity" : 1 }, 500, "easeInOutExpo", function() {

 				if(pk_new_type == "video") { jQuery("#pk_gallery ul:first li").filter(":eq(" + pk_new_item + ")").find(".pk_video").html(pk_media[pk_new_item]); }

				pk_is_loader = false;

				pkInitPrettyPhoto();
				pkSlideshow();

			}).show();

		} else {

			jQuery("#pk_gallery ul:first li").each(function(i) {

				if(i != pk_new_item) { 

					jQuery(this).css({ "width" : 0 + "px", "left" : "0px" })
					jQuery(".pk_image, .pk_video", this).empty(); 

				}

			});

			new_mask.css({ "opacity" : 1, "width" : new_width + "px", "height" : new_height + "px" });
			if(pk_new_type == "video") { jQuery("#pk_gallery ul:first li").filter(":eq(" + pk_new_item + ")").find(".pk_video").html(pk_media[pk_new_item]); }
			
			pkPositionObject(new_mask);

			setTimeout(function() {
				pk_is_loader = false;
				pk_is_first = false;

				pkInitPrettyPhoto();
				pkSlideshow();
			}, 200);

		}

		if(pk_info_open == true) { pkHideInfo("slide"); }
		if(pk_is_slideshow == true) {
			clearInterval(pk_interval);
			jQuery("#pk_slideshow_bar").stop().css({ "width" : 0 + "px" });
		}

		pk_deep_link_change_item = false;

	}


/**
   * PK Slideshow
*/

	function pkSlideshow() {

		clearInterval(pk_interval);

		if(pk_is_slideshow == false || pk_new_type == "video" || jQuery("#pk_gallery ul:first li").length <= 1) {

			return true;

		}

		var bar = jQuery("#pk_slideshow_bar");
		var current_item = jQuery("#pk_gallery ul:first li").filter(":eq(" + pk_new_item + ")");

		bar.css({ "width" : 0 + "px", "top" : Math.round(pk_stage_height - 1) + "px", "left" : "0px"}).show();
		bar.stop().animate({ "width" : pk_stage_width + "px" }, pk_interval_timer, "linear", function() {

			bar.css({ "width" : 0 + "px" });

		});

		pk_interval = setInterval(function() {

		 	clearInterval(pk_interval);
			jQuery("#pk_button_next").trigger("click", [true]);

		}, pk_interval_timer);

	}


/**
   * PK Resize Info
*/

	function pkResizeInfo() {

		pkResizeObject("#pk_info", "", "", "", "", true);
		pkPositionObject("#pk_info");

		jQuery("#pk_info_wrapper").css({ "height" : (jQuery("#pk_info").height() - 80) + "px" });
		var margin_top = Math.round((jQuery("#pk_info_wrapper").height() / 2) - (jQuery("#pk_info_content").height() / 2));
		(margin_top <= 0) ? jQuery("#pk_info_content").css({ "margin-top" : 0 + "px", "width" : 580 + "px" }) : jQuery("#pk_info_content").css({ "margin-top" : margin_top + "px", "width" : 600 + "px" });
		
		jQuery('#pk_info_wrapper').jScrollPane();

	}


/**
   * PK Show Info
*/

	function pkShowInfo() {

		pk_info_open = true;

		pkResizeObject("#pk_info", "", "", "", "", true);
		pkPositionObject("#pk_info");

		var info_width = jQuery("#pk_info").width();
		var current_item = jQuery("#pk_gallery ul:first li").filter(":eq(" + pk_new_item + ")");

		jQuery("#pk_button_info").text(pk_button_info_close_label);

		setTimeout(function() {
			pkAttachInfo();
		}, 250);
		
		
		if(jQuery.browser.msie && parseInt(jQuery.browser.version) < 9) {
			
			current_item.stop().css({ "visibility" : "hidden", "opacity" : 0 });
			jQuery("#pk_info").show();
			
		} else {
			
			current_item.stop().animate({ "opacity": 0 }, 250, "easeOutExpo");

			jQuery("#pk_info").css({ "opacity" : 0 }).show();
			jQuery("#pk_info").stop().delay(50).animate({ "opacity" : 1 }, 500, "easeInOutExpo", function() {
			
				current_item.css("visibility" , "hidden");
				
			});
		
		}

		if(pk_is_slideshow == true) {
			clearInterval(pk_interval);
			jQuery("#pk_slideshow_bar").stop().css({ "width" : 0 + "px" });
		}

	}


/**
   * PK Attach Info
*/

	function pkAttachInfo() {

		jQuery("#pk_info_wrapper, #pk_info_content").remove();
		jQuery("#pk_info").append("<div id='pk_info_wrapper'></div>");
		jQuery("#pk_info_wrapper").append("<div id='pk_info_content'>" + pk_infos[pk_new_item] + "</div>");
		jQuery("#pk_info_wrapper").css({ "margin-top" : 40 + "px" , "height" : (jQuery("#pk_info").height() - 80) + "px" });

		var margin_top = Math.round((jQuery("#pk_info_wrapper").height() / 2) - (jQuery("#pk_info_content").height() / 2));

		(margin_top <= 0) ? jQuery("#pk_info_content").css({ "margin-top" : 0 + "px", "width" : 580 + "px" }) : jQuery("#pk_info_content").css({ "margin-top" : margin_top + "px", "width" : 600 + "px" });
		jQuery('#pk_info_wrapper').jScrollPane();

	}


/**
   * PK Hide Info
*/

	function pkHideInfo(click_type) {

		pk_info_open = false;

		var info_width = jQuery("#pk_info").width();
		var current_item = jQuery("#pk_gallery ul:first li").filter(":eq(" + pk_new_item + ")");
		var current_item_width = (pk_new_type == "image") ? jQuery("div:first img", current_item).width() : jQuery("div:first", current_item).width();

		jQuery("#pk_button_info").text(pk_button_info_open_label);

		if(pk_deep_link_change_item == true) {

			jQuery("#pk_info").stop().css({ "left": Math.round((pk_stage_width / 2) - (current_item_width / 2) - 60) + "px", width: "0px" }).hide();
			jQuery("#pk_info_wrapper").remove();

			return true;

		}
		
		if(click_type == "info") {
			current_item.css("visibility" , "visible");
			current_item.stop().delay(50).animate({ "opacity" : 1 }, 500, "easeInOutExpo", function() {

				if(pk_is_slideshow == true && pk_new_type == "image") { pkSlideshow(); }

			});
		}
		
		if(jQuery.browser.msie && parseInt(jQuery.browser.version) < 9) {
			
			jQuery("#pk_info").hide();
			jQuery("#pk_info_wrapper").remove();
			
		} else {
			
			jQuery("#pk_info").stop().animate({ "opacity" : 0 }, 250, "easeOutExpo", function() {

				jQuery("#pk_info").hide();
				jQuery("#pk_info_wrapper").remove();

			});
		
		}

	}

	
/**
   * PK Show Preloader
*/

	function pkShowPreloader() {
		
		jQuery("#pk_gallery").append('<span id="pk_preloader"></span>');
		
		jQuery("#pk_preloader").css({ "left" : ((pk_stage_width / 2) - (jQuery("#pk_preloader").width() / 2)) + "px", "top" : ((pk_stage_height / 2) - (jQuery("#pk_preloader").height() / 2)) + "px" });
		
	}
	

/**
   * PK Hide Preloader
*/

	function pkHidePreloader() {
		
		jQuery("#pk_preloader").remove();
		
	}


/**
   * PK Resize Preloader
*/

	function pkResizePreloader() {
		
		jQuery("#pk_preloader").css({ "left" : ((pk_stage_width / 2) - (jQuery("#pk_preloader").width() / 2)) + "px", "top" : ((pk_stage_height / 2) - (jQuery("#pk_preloader").height() / 2)) + "px" });
		
	}


/**
   * PK Resize Object
*/

	function pkResizeObject(object, object_mask, object_type, width, height, info) {

		var obj = jQuery(object);
		var mask = jQuery(object_mask);

		if(info == false) {

			var max_width = Math.round(jQuery(window).width() - 250);
			var max_height = Math.round(jQuery(window).height() - 180);
			var scaling_factor = Math.min((max_width / width), (max_height / height));

			var w = Math.round(width * scaling_factor);
			var h = Math.round(height * scaling_factor);

			if(object_type == "image") {

				(pk_images_up_scale == false && (w >= pk_image_width || h >= pk_image_height)) ? obj.css({"width" : pk_image_width + "px", "height" : pk_image_height + "px" }) : obj.css({"width" : w + "px", "height" : h + "px" });

			} else {
				
				(pk_videos_up_scale == false && (w >= pk_video_width || h >= pk_video_height)) ? obj.css({"width" : pk_video_width + "px", "height" : pk_video_height + "px" }) : obj.css({"width" : w + "px", "height" : h + "px" });
			}

			mask.css({"width" : obj.width() + "px", "height" : obj.height() + "px"});

		} else {

			var max_width = 910;
			var max_height = Math.round(jQuery(window).height() - 180);

			(max_height >= pk_info_max_height) ? obj.css({ "width" : max_width + "px", "height" : pk_info_max_height + "px" }) : obj.css({ "width" : max_width + "px", "height" : max_height + "px" });

		}

	}


/**
   * PK Position Object
*/

	function pkPositionObject(object) {

		var obj = jQuery(object);

		var pk_stage_width = jQuery(window).width();
		var pk_stage_height = jQuery(window).height();

		obj.css({"position" : "absolute", "left" : (pk_stage_width / 2) - (obj.width() / 2), "top" : (pk_stage_height / 2) - (obj.height() / 2) });

	}


/**
   * PK Update Counter
*/

	function pkUpDateCounter(current, total) {

		var current_number = ((current + 1) <= 9) ? "0" + (current + 1) : (current + 1);
		var total_number = (total <= 9) ? "0" + total : total;

		jQuery("#pk_count").text(current_number + "/" + total_number);

	}
