//Enclosing and passing (jQuery) to avoid conflicts
;(function($) {

    /*////// [ EVENTS ] ////////*/
    KVIK.Events = {

        /* Dependencies for KVIK.Events	
        jquery-1.4.2.min.js
        jquery.libs.js
        lib.js
        */
        init: function() {
            KVIK.Events.onReady();
        },
		loaded: function() {
            KVIK.Events.onLoad();
        },
        onLoad: function() {
			//Init deals page
            //
			KVIK.Events.deals.init();
		},
		onReady: function() {
            
            /*///// [GLOBALS] /////*/
            var IE6 = (navigator.appVersion.indexOf("MSIE 6.") == -1) ? false : true;
            
            /*////// [ HANDLERS ] ////////*/

            // JS Style
            KVIK.DynamicStyle.overlay();
            KVIK.DynamicStyle.teaserLink();  
            KVIK.DynamicStyle.productPrice();
            KVIK.DynamicStyle.footerHeading();
            KVIK.DynamicStyle.storeInfoBoxes();
            KVIK.DynamicStyle.alignWeekday($('.timeopen .weekday'));
            KVIK.DynamicStyle.alignEmployees($('.employees ul li'));
            KVIK.DynamicStyle.replaceFont();

            //append nearest store in bottom of productpage
             if($('.productPage').is(':visible')){
                    $('#header .storeListContent').appendTo('.lightboxInner:last');
                    $('#header .overlayNearestStore, #header .lightboxNearestStore').remove();                
                }  
			

			
			// Change store
            $(".changeStoreLink").attr("href", "#");
            $(".changeStoreLink").click(KVIK.Events.NearestStore.changeStore);

            // Get stores from Kvik base
            if($('#nearestStore').length > 0){
                KVIK.Events.NearestStore.updateNearesStoreInfo();
            };

            // Language selector cookie
            $('.languageSelectorItem').click(function(){
                var cookieValue = $(this).attr('href');
                setCookie("languageSelector",cookieValue, 365);
            });

            //Show YouTube Video in popup
            $(".youTubeLink").live('click', KVIK.ProductDetails.initYoutubeVideo);
			
			
			$(".inspiration-slider .ui-slider").slider({
				aniTime : 1000,
				autoTimer : 5000,
				onChange : function($Ul, page, totalPages){
					var movToY = -91 * page;					
					$("#header .info .heading-list ul").stop(true).animate({
						'top': movToY
					}, {
						duration: 1000,
						queue: false,
						easing: "easeInOutExpo"
					});
				}
			});
			
            

            // Show Lightbox on flyLinks
            $(".flyLinks:not(.pageLinks) a, a.booking:not('.lightbox a.booking'), div.store a").click(KVIK.Lightbox.show);

            // Show Lightbox of Demo images
            $(".demoSales .number").click(KVIK.Lightbox.getDealInfo);

            // Close Lightbox
            $(".lightbox span.close").live("click", KVIK.Lightbox.close);
            $(document).keydown(function(e) { if (e.keyCode == 27) $(".lightbox .close").click(); });

            // Select product thumbnail in gallery
            $(".productDetails .thumbnails li").live("click", KVIK.ProductDetails.selectThumbnail);
            
            


            // Form validation
            KVIK.Validation.init();
            KVIK.Validation.checkInput();

            // Move productlink on frontpage to header section
            $('#header .productLink').appendTo('#header .wrapper:first');
            
            //Functions for preview mode in SiteCore
             if(KVIK.Utils.query('sc_mode') == 'preview'){
                // Get x and y coordinates in editmode
                var navHeight = $('#header').innerHeight();
                $('#nav').height(navHeight);
                $('#header .wrapper:first').click(KVIK.Events.SCMode.GetCoordinates);
            }

            // Set cookie when click on my favorite store on storepage
            $("#uiBtnMyFavoriteStore").click(KVIK.Events.NearestStore.myFavoriteStore);

            // Select filter type
            $("span[name='filterOption']").click(KVIK.Events.Filter.Change);
        }
    }


    /*////// [ Dynamic Styles ] ////////*/

    KVIK.DynamicStyle = {
        // overlay
        overlay: function() {
            $(".overlay").css("opacity", 0.5);
        },
        teaserLink: function() {
            $(".teaserBox li:not('.productTeaser')").each(function() {
                var campaign = $(this).find("a").attr("href");
                $(this).css("cursor", "pointer").click(function() {
                    window.location = campaign;
                });
            });
        },
        // align weekdays
        alignWeekday: function(e){
            var $src = e;

            var max = 0;
            $src.each(function(){
                if ($(this).width() > max)
                    max = $(this).width();   
            });
            $src.width(max);
        },
        alignEmployees: function(e){
            var $src = e;

             var max = 0;
            $src.each(function(){
                if ($(this).height() > max)
                    max = $(this).height();   
            });
            $src.height(max);

        },
        productPrice: function(){
            $(".productCategory ul").each(function(){
                var tempHeight = 0;
                $(this).find(".categoryDescription h3").each(function(){
                    if($(this).height() > tempHeight)
                        tempHeight = $(this).height();
                });
                $(this).find(".categoryDescription h3").each(function(){
                    $(this).height(tempHeight);
                });

                var tempHeight = 0;
                $(this).find(".categoryDescription p").each(function(){
                    if($(this).height() > tempHeight)
                        tempHeight = $(this).height();
                });
                $(this).find(".categoryDescription p").each(function(){
                    $(this).height(tempHeight);
                });
            });
            $(".demoSales li.hr").each(function(){
                var tempHeight = 0;
                $(this).prevAll("li").each(function(){
                    if($(this).hasClass("hr")) 
                        return false;
                    if($(this).find("h3").height() > tempHeight)
                        tempHeight = $(this).find("h3").height();
                });
                $(this).prevAll("li").each(function(){
                    if($(this).hasClass("hr")) 
                            return false;
                    $(this).find("h3").height(tempHeight);
                });

                var tempHeight = 0;
                $(this).prevAll("li").each(function(){
                    if($(this).hasClass("hr")) 
                        return false;
                    if($(this).find("p:not('.price')").height() > tempHeight)
                        tempHeight = $(this).find("p:not('.price')").height();
                });
                $(this).prevAll("li").each(function(){
                    if($(this).hasClass("hr")) 
                        return false;
                    $(this).find("p:not('.price')").height(tempHeight);
                });
            });
        },
        footerHeading: function(){
            var tempHeight = 0;
            $("#footer dl dt").each(function(){
                if($(this).height() > tempHeight)
                    tempHeight = $(this).height();
            });
            $("#footer dl dt").each(function(){
                if(tempHeight > 0)
                    $(this).height(tempHeight);
            });
        },
        storeInfoBoxes: function(){
            var tempHeight = 0;
            if(jQuery(".storeInfo").length) {
                if(jQuery(".storeInfo").height() > jQuery(".butikContact").height())
                    jQuery(".butikContact").height(jQuery(".storeInfo").height());
                else jQuery(".storeInfo").height(jQuery(".butikContact").height());
            }
        },
        itemInfo: function(){
            if(jQuery("div.productDetails").length) {
                jQuery(".productDetails").each(function(){
                    var obj = jQuery(this);
                    var presentationHeight = obj.find(".presentation").height();
                    var detailHeight = obj.find(".details").height() + obj.find('.thumbnails').height();
                    if(detailHeight > presentationHeight)
                        obj.find(".presentation .graybox").height(detailHeight);
                });
            }
        },
        replaceFont: function(){
             $('#nav ul.main a').hover(function(){
                    $(this).addClass('hover');
                    if (KVIK.CurrentContext.lang != 'th-th') {
                    Cufon.replace(' #nav ul.main a.hover', { fontFamily: 'Avenir' });
                    }
                  }, 
                  function () {
                    $(this).removeClass('hover');
                     $(this).addClass('normal');
                    if (KVIK.CurrentContext.lang != 'th-th') {
                        Cufon.replace(' #nav ul.main a.normal', { fontFamily: 'Avenir' });
                    }
                  }
                ); 
        },
        showVideo: function(content){
            $('.youTubeLink').trigger('click');
            var target = $('#'+content).find('td');
            $('#fancybox-wrap').appendTo(target);
        }
    }

    /*///// [ Nearest store ] /////*/
    KVIK.Events.NearestStore = {
        changeStore: function(event){
            event.preventDefault();
            var $srcElem = $(this);
            var storeId = $srcElem.attr("data-storeId");
            setCookie("sckvikneareststoreid", storeId, 365);
            KVIK.Events.NearestStore.updateNearesStoreInfo();
            KVIK.Lightbox.close();
        },
        updateNearesStoreInfo: function() {
            var $tarElem = $('#nearestStore');
            KVIK.Utils.ajax({
                type: "GET",
                cache: false,
                url: "/HttpHandlers/kvik/NearestStoreProvider.ashx?rootStoreItemId=" + KVIK.CurrentContext.rootStoreItemId + "&settingsItemId=" + KVIK.CurrentContext.settingsItemId + "",
                success: function (nearestStore) {
                    if (nearestStore == null) {
                        return;
                    }
                    KVIK.Events.NearestStore.showNearestStoreInfo(nearestStore);
                },
                serverError: function (error) {
                    // Update target element with server error message
                    $tarElem.html(error);
                }
            });
        },
        showNearestStoreInfo: function(nearestStore) {
            // Update UI with nearest store
            var storeId = nearestStore["Id"];

            var storeTitle = nearestStore["Title"];
            $("#storeTitle").html(storeTitle);
            $("#storeTitle").attr("alt", storeTitle);
            $("#storeTitle").attr("title", storeTitle);

            var storeTitleLink = nearestStore["Link"];
            $("#storeTitle").attr("href", storeTitleLink);

            var storemanagerName = nearestStore["ManagerName"];
            $("#storeManagerName").html(storemanagerName);

            var storemanagerLabel = nearestStore["ManagerLabel"];
            $("#storeManagerLabel").html(storemanagerLabel);

            var storeBookMeetingLabel = nearestStore["BookMeetingLabel"];
            $("#storeBookMeetingLabel").html(storeBookMeetingLabel);
            $("#storeBookMeetingLinkLabel").attr("alt", storeBookMeetingLabel);
            $("#storeBookMeetingLinkLabel").attr("title", storeBookMeetingLabel);

            var storeChangeStoreLabel = nearestStore["ChangeStoreLabel"];
            $("#storeChangeStoreLabel").html(storeChangeStoreLabel);
            $("#storeChangeStoreLinkLabel").attr("alt", storeChangeStoreLabel);
            $("#storeChangeStoreLinkLabel").attr("title", storeChangeStoreLabel);

            var storeManagerPictureUrl = nearestStore["ManagerPictureUrl"];
            $("#storeManagerPicture").attr("src", storeManagerPictureUrl);
            $("#storeManagerPicture").attr("alt", storemanagerName);
            $("#storeManagerPicture").attr("title", storemanagerName);

            $("#nearestStore").show();
        },
        myFavoriteStore: function(e){
            e.preventDefault();
            setCookie("sckvikneareststoreid", KVIK.CurrentContext.favoriteStoreId, 365);
            $("#myFavoriteStoreButton").fadeOut('fast',function(){
                $("#myFavoriteStoreLabel").fadeIn('fast');
            });
            
        }

    }

    /*///// [ Product Details ] /////*/
    KVIK.ProductDetails = {
        selectThumbnail: function(e) {
            //Dom elements
            var $trigger = $(this),
                $allContainers = $trigger.parent().children(),
                imgSrc = jQuery(this).find("img").attr("src"),
                videoSrc = $(this).find('img.videoThumb').attr('rel'),
                content = $trigger.parents('.popupContent').attr('id'),
                elementsIndex = $allContainers.index($trigger),
                $richcontentItems;

            e.preventDefault();
            
            $allContainers.removeClass("selected");
            $trigger.addClass("selected");
            
            
            if ($trigger.find('img').hasClass('videoThumb')) {
                $('.youTubeLink').attr('href',videoSrc);
                $trigger.parents('.productDetails').find('.presentationInner img').hide();
                KVIK.DynamicStyle.showVideo(content);
            }
            else if($(this).parents(".popupContent").find(".presentationInner").hasClass("rich-content")){
                $richcontentItems = $(this).parents(".popupContent").find(".rich-content li");
                $richcontentItems.hide();
                $richcontentItems.eq(elementsIndex).show();
            }
            else{
                $.fancybox.close();
                $('#fancybox-wrap').hide();
                $trigger.parents('.productDetails').find('.presentation img').attr("src", imgSrc).show();     
            }  
        },
        initYoutubeVideo: function(){
            var href = $(this).attr('href');
            $.fancybox({
			      'padding'             : 0,
                  'overlayShow'         : false,
                  'autoScale'           : false,
                  'transitionIn'        : 'none',
                  'transitionOut'       : 'none',
                  'width'               : 370,
                  'height'              : 270,
                  'href'                : href = href.replace(new RegExp("watch\\?v=", "i"), 'v/') + '&autoplay=1',
                  'type'                : 'swf',    // <--add a comma here
                  'swf'                 : {'allowfullscreen':'false'} // <-- flashvars here
                  });
	            return false;
        },
        generateThumbnail: function(youtubeSrc,id,number){
                 var thumbnailUrl = $.jYoutube(youtubeSrc, 'small');
                 $('#'+id+' .thumbnails ul li:eq('+number+') img').attr('src', thumbnailUrl).attr('rel',youtubeSrc);
                                   
        }
    }

    /*///// [ Lightbox ] /////*/
    KVIK.Lightbox = {
        show: function(e) {
            // Dom elements
            e.preventDefault();
            var $trigger = $(this);
            KVIK.Lightbox.showThis($trigger);
        },
        showThis: function(obj){
            var $lightbox = $('.lightbox'),
                $overlay = $('.overlay'),
                content = obj.attr('data-popup');
        
                KVIK.DatePicker.init();
                
                $overlay.fadeIn(function() {
                   $('#'+content).show().css("visibility", "visible");
                    var lightboxWidth = $lightbox.width() / 2;
                    $lightbox.css({ "marginLeft": (-lightboxWidth) + "px", "marginTop": $(document).scrollTop()-150 + "px" }).append("<span class='close'/>").show().fadeIn();
                    //Insert video if on productpage
                   
                    if($('#'+content).find('.thumbnails li:first img').hasClass('videoThumb')){
                        KVIK.DynamicStyle.showVideo(content);
                    }
                    KVIK.DynamicStyle.itemInfo();
                    $('#'+content).find('.thumbnails li:first').trigger('click');
                });
            return false;
        },
        close: function() {
                if($('#fancybox-wrap').is(':visible')){
                    $.fancybox.close();

                    
                   
                    setTimeout('KVIK.Lightbox.lightboxFadeOut()',500)
                }
                
                else{
                    KVIK.Lightbox.lightboxFadeOut();
                }
                
           
        },
        lightboxFadeOut: function(){
              // Dom elements
            var $lightbox = $('.lightbox'),
                $overlay = $('.overlay'),
                $popupContent = $lightbox.find('.popupContent');
             $lightbox.fadeOut(function() {
                $(this).hide();
               
                $overlay.fadeOut();
                $popupContent.hide().css("visibility", "hidden");
                $popupContent.find('.thumbnails ul li:first').trigger('click');
                $(this).find('.close').remove();
                
            });
        },
        getDealInfo: function(e) {
            e.preventDefault();
            var $trigger = $(this);
            var dealInfo = $trigger.attr('data-dealInfo');

            $.ajax({
                type: "GET",
                url: "/HttpHandlers/kvik/DealLightboxProvider.ashx?dealInfo=" + dealInfo,
                dataType: 'json',
                cache: false,
                success: function (lighboxInfo) {
                    if (lighboxInfo == null) {
                        return;
                    }

                    var headline = lighboxInfo["Headline"];
                    var description = lighboxInfo["Description"];

                    $("#dealLightboxHeadline").html(headline);
                    $("#dealLightboxDescription").html(description);

                    var storeLinkTitle = lighboxInfo["StoreTitle"];
                    $("#dealLightboxStoreLink").attr("href", lighboxInfo["StoreLink"]);
                    $("#dealLightboxStoreLink").html(storeLinkTitle);
                    $("#dealLightboxStoreLink").attr("alt",storeLinkTitle);
                    $("#dealLightboxStoreLink").attr("title", storeLinkTitle);

                    $("#dealLightboxGuidancePrice").html(lighboxInfo["GuidancePrice"]);
                    $("#dealLightboxPrice").html(lighboxInfo["Price"]);
                    Cufon.replace("#dealLightboxGuidancePrice, #dealLightboxPrice", { fontFamily: 'Avenir' });

                    $("#dealLightboxPopupImage").hide();
                    $("#dealLightboxPopupImages").html("");

                    for (var i=0; i < lighboxInfo["ImageIds"].length; i++)
                    {
                        var itemClass = "";

                        if (i == 0)
                        {
                            var srcImage = "/HttpHandlers/kvik/DealImage.ashx?dealImageId=" + lighboxInfo["ImageIds"][i] + "&width=490&height=340";
                            $("#dealLightboxPopupImage").attr("src", srcImage);
                            $("#dealLightboxPopupImage").attr("alt", headline);
                            $("#dealLightboxPopupImage").attr("title", headline);
                            $("#dealLightboxPopupImage").show();
                            itemClass = "selected";
                        }

                        var srcImage = "/HttpHandlers/kvik/DealImage.ashx?dealImageId=" + lighboxInfo["ImageIds"][i] + "&width=490&height=340";

                        $("#dealLightboxPopupImages").append('<li class="' + itemClass + '"><a href="javascript:void(0);"><img src="' + srcImage + '" alt="' + headline + '" title="' + headline + '" /></a></li>');
                    }

                    $("#dealLightbox").find(".thumbnails").hide();
                    if(lighboxInfo["ImageIds"].length != 0)
                    {
                        $("#dealLightbox").find(".thumbnails").show();
                    }
                    
                    KVIK.Lightbox.showThis($trigger);
                }
            });
        }
    }

    /*///// [ Date Picker ] /////*/
    KVIK.DatePicker = {
        init: function() {
            // Dom elements
            var $trigger = $(".datePickerField");
            jQuery($trigger).datepicker({
                minDate: 0,
                showOn: "both",
                buttonImage: 'css/gfx/icons/date-selector.gif',
                buttonText: '',
                buttonImageOnly: true
            });
        }
    }

    /*///// [ IE6 Popup ] /////*/
    KVIK.IE6Notify = {
        showPopup: function(e) {
            // Dom elements
            var $popup = '<div class="lightbox ie6popup"><div class="lightboxInner"><h1 class="lightboxHeader">MS IE6 Notification</h1><div class="container">You use Microsoft Internet Explorer, version 6.<br />You should upgrade your browser to upper version.</div></div><span class="close" /></div>';

            if(!jQuery(".overlay").length) {
                jQuery("body").append('<div class="overlay" />')
            }
            jQuery(".overlay").addClass("ie6overlay").css("opacity", 0.75);
            jQuery("body").append($popup);
        }
    }

    /*///// [ Validation ] /////*/
    KVIK.Validation = {
        init: function(){ 
            // Objects to validate
            var $trigger = jQuery("#form1");
            $trigger.validate();
        },
        checkInput: function(){
            $(".butikContact input:text, .butikContact textarea").each(function(){
                var handler = $(this);
                var obj = handler.parent("dd").prev("dt");

                if(handler.val() != "") obj.hide();
            });
            $(".butikContact input:text, .butikContact textarea").focus(function(){
                var handler = $(this);
                var obj = handler.parent("dd").prev("dt");

                obj.hide();
            });
            $(".butikContact input:text, .butikContact textarea").blur(function(){
                var handler = $(this);
                var obj = handler.parent("dd").prev("dt");

                if(handler.val() == "") obj.show();
            });
            $(".butikContact dt").click(function(){
                $(this).next().find("input, textarea").focus();
            });
        }

    }

    /*///// [ Editmode functions ] /////*/
    KVIK.Events.SCMode = {
        GetCoordinates: function(e){ 
           
            $('.coordinates').remove();
           
               
                var x = e.pageX - this.offsetLeft,
                    y = e.pageY - this.offsetTop,
                    $triggerHeight =$(this).height(),
                    newy = ($triggerHeight - y) + 35,
                    newx = x - 15,
                    data = "<h1 class='coordinates'>Left: " + newx + " Top: " + newy +"</h1>";
                 
                $(data).prependTo('#header .wrapper:first');

            
           
            
        }

    }

    /*///// [ Deal pafe filter ] /////*/
    KVIK.Events.Filter = {
        Change: function(){
            $trigger = $(this);

            $("."+$trigger.attr("name")).hide();
            $("#"+$trigger.attr("class")).show();
        }
           
    }

   






/* . . . . . . . . . . . . . . . . . . . . . . . . 
 deals 
* * * * * * * * * * * * * * * * * * * * * * * * */
KVIK.Events.deals = {
	init : function(){
		$(".dealPage").each(function(){
			var $TableElement = $(".table-element", this),
				$Finder = $(".dealFilter", this),
				$Region = $Finder.find("a.region"),
				queryData, 
				selection, 
				timeOut = 0,
				params = 0, 
				queryString = window.location.href.split("#")[0].split("?")[1],
				deepLink = (queryString) ? $.unparam(queryString) : null;
		
				_setSelection = function(){
					queryData = {};
					selection = [];					
					$Finder.find(".radio-list").map(function(){
						var $SelectList = $(this);
						if($SelectList.data("value").length){
							queryData[$SelectList.attr("id")] = $SelectList.data("value");
						}
					});
					if($("#dealLocation").attr("data-id")){
						queryData[$("#dealLocation").attr("data-type")] = $("#dealLocation").attr("data-id");
					}
					_updateTable();
				}, 
				
				_updateTable = function(){
					clearTimeout(timeOut);
					timeOut = setTimeout(function(){
						$TableElement.triggerHandler('update', [queryData]);
					}, 50);
				},
				_styleboxes = function($Container){
					/* Set gallery lightbox link*/
					$Container.find(".productImg a").click(function(event){
						var $Link = $(this),
							id = $Link.attr("data-popup"),
							$LightBoxInner = $(".lightbox .lightboxInner"),
							$Img = $Container.find(".productImg img");
					
						if($LightBoxInner.find("#"+id).length == 0){
							
							if($Link.parents("li.deal").data("tmplItem")){
								$LightBoxInner.append($.tmpl($TableElement.data("template").popup, $Link.parents("li.deal").data("tmplItem").data));
							} else {
								$LightBoxInner.append($.tmpl($TableElement.data("template").popup, {
									"title": $Container.find(".productText h2").text(),
									"id" : id,
									"image1": $Img.attr("data-img1"),
									"image2": $Img.attr("data-img2"),
									"image3": $Img.attr("data-img3"),
									"image4": $Img.attr("data-img4")
								}));
							}
							
							
							
						}
						KVIK.Lightbox.showThis($Link);
                        return false;					
					})
					/* Cufon */
					Cufon.replace($Container.find(".price .priceAmount, .productText h2").get(), { fontFamily: 'Avenir' });
					
					/* read more link */
					$Container.find("a.more").click(function(){
						$(this).parents("li.deal").addClass("open");						
						return false;
					});
					/* read more link */
					$Container.find("a.less").click(function(){
						$(this).parents("li.deal").removeClass("open");						
						return false;
					});
					
					/* Set sharing */
					if(typeof addthis !== "undefined") {
						$Container.find(".social").map(function(){
							addthis.toolbox(this, {}, {
								url_transforms: {
									add: {
										bargainid: $(this).attr("data-id")
									}
								}
							});
						});
					}
				};
			
			$(".dealBox ul li.deal", this).map(function(){
				_styleboxes($(this))
			});
			
			$TableElement.dataTable({
				init : false,
				perPage: 3,
				styleElements : _styleboxes
			});
							
			$Finder.find(".radio-list").radioList().bind("change", function(){
				_setSelection();
			}).bind("update", function(){
				Cufon.replace($("li a > span", this).get());
			});
			
			$Finder.find(".dealStores a").click(KVIK.Lightbox.show);

			$("#dealStoresLightbox a").bind("click", function(e){			
				var $link = $(this),
					data = $link.data(),
					key;
				
				$("#dealLocation").attr({
					"data-type" : data.type,
					"data-id" : data.id
				}).text($link.text().split("(")[0]);
				
				$("#storeManagerLabel").text(($link.data("managerLabel")) ? $link.data("managerLabel") + " : " : "");
				$("#storeManagerName").text(($link.data("managerName")) ? $link.data("managerName") : "");
				
				for(key in data){
					if($("#category a."+key).length){
						$("#category a."+key+" small span").text(data[key])
					}
				}
				
				KVIK.Lightbox.close();
				_setSelection();
			});
		
			if(deepLink){
				for(var f in deepLink){
					$Finder.find("#"+f).map(function(){
						var $List = $(this);
						$List.find(".active").removeClass("active");
						$List.find("a[name='"+deepLink[f]+"']").addClass("active");
						$List.triggerHandler("update");
					});
				}	
			}

			_setSelection();

		});
	}
};
	
	
	
	
	
	



		

		

	








    $(document).ready(KVIK.Events.init);
	$(window).load(KVIK.Events.loaded);

})(jQuery);


