PageSourceSearch

https://istionclub.gr/wp-content/themes/sunway/scripts/sunway.js

js istionclub.gr collected 2026-09-27 00:52:35 UTC 59,789 bytes, 1,783 lines download raw bytes

1/*jslint browser: true*/
2/*jslint white: true */
3/*global $,jQuery,ozy_headerType,alert,ozyTypeWriterData,ozy_Animsition,TweenMax,Power1,ozy_facebookWidget*/
4
5/* Sunway WordPress Theme Main JS File */
6
7/**
8* Read cookie
9*
10* @key - Cookie key
11*/
12function getCookieValue(key) {
13	"use strict";
14    var currentcookie = document.cookie, firstidx, lastidx;
15    if (currentcookie.length > 0)
16    {
17        firstidx = currentcookie.indexOf(key + "=");
18        if (firstidx !== -1)
19        {
20            firstidx = firstidx + key.length + 1;
21            lastidx = currentcookie.indexOf(";", firstidx);
22            if (lastidx === -1)
23            {
24                lastidx = currentcookie.length;
25            }
26            return decodeURIComponent(currentcookie.substring(firstidx, lastidx));
27        }
28    }
29    return "";
30}
31
32/**
33* Cookie Notice Banner
34*/
35function ozy_cookie_notice_banner() {
36	"use strict";
37	if(getCookieValue( "sunway_cookie_banner" ) != '1') {
38		jQuery('#ozy-cookie_notice_banner').addClass('show');
39
40		jQuery('#ozy-cookie_notice_banner a.generic-button').on("click", function(e){
41			e.preventDefault();
42
43			var now = new Date();
44			now.setMonth( now.getYear() + 1 );
45			document.cookie="sunway_cookie_banner=" + "1; expires=" + now.toGMTString() + "; path=/; ";
46			jQuery('#ozy-cookie_notice_banner').removeClass('show');
47
48			return false;
49		});
50	}
51}
52
53/**
54* Offer Box
55*/
56function ozy_offer_box() {
57	"use strict";
58	if(getCookieValue( "sunway_offer_box" ) != '1') {
59		jQuery('#ozy-offer_box,.mobile-show-offer-box').addClass('show');
60
61		jQuery('#ozy-offer_box a.close').on("click", function(e){
62			e.preventDefault();
63
64			var now = new Date();
65			now.setHours( 7*24 );
66			document.cookie="sunway_offer_box=" + "1; expires=" + now.toGMTString() + "; path=/; ";
67			jQuery('#ozy-offer_box,.mobile-show-offer-box').removeClass('show show-mobile');
68
69			return false;
70		});
71
72		jQuery('.mobile-show-offer-box').on('click', function(e){
73			e.preventDefault();
74			jQuery('#ozy-offer_box').addClass('show-mobile');
75			jQuery('.mobile-show-offer-box').removeClass('show');
76			return false;
77		});
78	}
79}
80
81/**
82* Load more button handler
83*
84* @order
85* @orderby
86* @item_count
87* @category_name
88* @offset
89* @found
90* @e
91* @layout_type
92*/
93function ozy_ajax_load_more_blog(order, orderby, item_count, category_name, offset, found, e) {
94	"use strict";
95	jQuery.ajax({
96		url: ozy_headerType.$OZY_WP_AJAX_URL,
97		data: { action: 'sunway_ajax_load_more', p_order : order, p_orderby : orderby, p_item_count : item_count, p_category_name : category_name, p_offset : offset},
98		cache: false,
99		success: function(data) {
100
101			jQuery('.isotope.blog-listing-masonry, .isotope.blog-listing-mosaic').append(data);
102
103			ozy_page_template_page_blog_init();
104
105			jQuery(e).css('opacity', '1').attr('disabled', false);
106
107			if((item_count + offset) >= found) {
108				jQuery(e).hide();
109			}
110
111			var load_more_button_top_pos = e.position();
112			jQuery('html, body').animate({scrollTop: load_more_button_top_pos.top }, 'slow');
113
114		},
115		error: function(MLHttpRequest, textStatus, errorThrown){
116			alert(errorThrown);
117		}
118	});
119
120}
121
122function ozy_ajax_load_more_blog_action() {
123	"use strict";
124	jQuery(".load_more_blog").on("click", function(e) {
125
126		e.preventDefault();
127
128		jQuery(this).css('opacity', '.3').attr('disabled', 'disabled');
129
130		var order 			= jQuery(this).data("order");
131		var orderby 		= jQuery(this).data("orderby");
132		var item_count 		= jQuery(this).data("item_count");
133		var category_name 	= jQuery(this).data("category_name");
134		var offset 			= jQuery(this).data("offset");
135		var found 			= jQuery(this).data("found");
136
137		offset = offset + item_count;
138		ozy_ajax_load_more_blog(order, orderby, item_count, category_name, offset, found, jQuery(this));
139		jQuery(this).data("offset", offset);
140
141		return false;
142
143	});
144}
145
146function ozy_page_template_page_blog_init() {
147	"use strict";
148	var $container_portfolio;
149	jQuery('.isotope.blog-listing-masonry,.isotope.blog-listing-mosaic').each(function() {
150		var $that = jQuery(this);
151		$that.imagesLoaded( function() {
152			var conf_arr = {
153				filter:  '',
154				itemSelector: '.post-single-masonry',
155				layoutMode: 'masonry',
156				masonry: {}
157			};
158			conf_arr['masonry'] = {
159				columnWidth: '.grid-sizer',
160				gutter: '.gutter-sizer'
161			};
162			jQuery('.isotope.loaded-already').isotope('destroy');
163			$container_portfolio = $that.addClass('loaded-already').isotope(conf_arr);
164
165			ozy_init_waypoint();
166		});
167	});
168}
169
170/**
171* Popup window launcher
172*
173* @url - Url address for the popup window
174* @title - Popup window title
175* @w - Width of the window
176* @h - Height of the window
177*/
178function ozyPopupWindow(url, title, w, h) {
179	"use strict";
180	var left = (screen.width/2)-(w/2), top = (screen.height/2)-(h/2);
181	return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
182}
183
184function ozyIsValidURL(string) {
185    "use strict";
186    var res = string.match(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g);
187    return (res !== null)
188}
189
190/**
191* To check iOS devices and versions
192*/
193function ozyCheckIsMobile() {
194	"use strict";
195	return (/Mobi/.test(navigator.userAgent));
196}
197
198function ozyCheckIs479el() {
199	"use strict";
200	return jQuery(window).width()<=479 ? true : false;
201}
202
203function ozyCheckIs768el() {
204	"use strict";
205	return jQuery(window).width()<=768 ? true : false;
206}
207
208function ozyCheckIs1440el() {
209	"use strict";
210	return jQuery(window).width()<=1440 ? true : false;
211}
212
213function ozyCheckMac(){
214	"use strict";
215	var isMac = /(mac)/.exec( window.navigator.userAgent.toLowerCase() );
216	return ( isMac != null && isMac.length );
217}
218
219function ozyCheckFirefox() {
220	"use strict";
221	if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1){
222		 return true;
223	}
224	return false;
225}
226
227function ozyCheckChrome() {
228	"use strict";
229	var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
230	var isSafari = /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor);
231	return isChrome || isSafari;
232}
233
234/**
235* ozy_generic_element_fix
236*
237* Set sections to document height which matches with selector
238*/
239function ozy_generic_element_fix() {
240	"use strict";
241	/* Countdown Page */
242	if(jQuery('body.page-template-page-revo-full').length) {
243		jQuery('#content').height(jQuery(window).height());
244	}
245
246	/* Single Room Bottom Form */
247	jQuery('.mphb-reserve-btn-wrapper>.mphb-reserve-btn').each(function(){
248		jQuery(this).height(jQuery(this).parent().siblings('p.mphb-check-out-date-wrapper').find('input[type=text]').outerHeight(true)-16);
249	});
250}
251
252function ozy_share_button() {
253	"use strict";
254	jQuery(document).on('click', 'a.footer-share-buttons, body.single .post-submeta>a:not(.blog-like-link)', function(e) {
255		e.preventDefault();
256		ozyPopupWindow(jQuery(this).attr('href'), 'Share', 640, 440);
257	});
258}
259
260/**
261* ozy_hash_scroll_fix
262*
263* Check if there is a hash and scrolls to there, onload
264*/
265function ozy_hash_scroll_fix() {
266	"use strict";
267	setTimeout(function(){
268	if(window.location.hash) {
269		var hash = window.location.hash;
270		if(jQuery(hash).length) {
271			jQuery('html,body').animate({scrollTop: jQuery(hash).offset().top}, 1600, 'easeInOutExpo');
272		}
273	}}, 200);
274}
275
276function ozy_custom_map_mobile_full_height_fix() {
277	"use strict";
278	/* Google Map */
279	if ('undefined' !== typeof jQuery.fn.prettyMaps) {
280		if(jQuery(window).width() <= 479) {
281			jQuery('.ozy-google-map:not(.init-later)').each(function() {
282				if(jQuery(this).data('height').toString().indexOf('%') !== -1) {
283					jQuery(this).height('400px');
284				}
285			});
286		}else{
287			jQuery('.ozy-google-map:not(.init-later)').each(function() {
288				if(jQuery(this).data('height').toString().indexOf('%') !== -1) {
289					jQuery(this).height(jQuery(this).data('height'));
290				}
291			});
292		}
293	}
294}
295
296function ozy_mobile_maybe() {
297	"use strict";
298	if(jQuery(window).width() < 1280) {
299		jQuery('body').addClass('mobile-maybe');
300	}else{
301		jQuery('body').removeClass('mobile-maybe');
302	}
303}
304
305/* Resets windows scroll position if there is a hash to make it work smooth scroll*/
306var windowScrollTop = jQuery(window).scrollTop();
307window.scrollTo(0, 0);
308setTimeout(function() {
309	"use strict";
310	window.scrollTo(0, windowScrollTop);
311}
311, 1);
312
313function ozy_custom_heading_mobile_fix() {
314	"use strict";
315	if(jQuery(window).width() <= 479) {
316		jQuery('.vc_custom_heading').each(function(index, element){
317			if(parseInt(jQuery(element).css('margin-top'))> 10 ) {
318				jQuery(element).addClass('modified');
319			}
320			if(parseInt(jQuery(element).css('margin-bottom')) > 10 ) {
321				jQuery(element).addClass('modified-b');
322			}
323		});
324		jQuery('.vc_empty_space').each(function(index, element){
325			if(parseInt(jQuery(element).css('height'))> 20 ) {
326				jQuery(element).addClass('modified').data('h', jQuery(element).css('height')).css('height', '20px');
327			}
328		});
329	}else{
330		jQuery('.vc_custom_heading.modified').each(function(index, element){
331			jQuery(element).removeClass('modified').removeClass('modified-b');
332		});
333		jQuery('.vc_empty_space.modified').each(function(index, element){
334			jQuery(element).removeClass('modified').css('height', jQuery(element).data('h'));
335		});
336	}
337}
338
339function ozy_init_waypoint() {
340	"use strict";
341	if ('undefined' !== typeof jQuery.fn.waypoint) {
342		/* fading background color */
343	    jQuery('.vc_row.fading-bg-color').waypoint(function(direction) {
344			var _row_bg = jQuery(this).find('.vc_row-fading-bg-color'), _color1 = _row_bg.data('bgcolor1'), _color2 = _row_bg.data('bgcolor2');
345			if (direction === 'down') {
346				if(!_row_bg.hasClass('apply-to-body')) {
347					_row_bg.stop().animate({backgroundColor: _color2}, 700, 'easeInOutExpo');
348				}else{
349					jQuery('body').stop().animate({backgroundColor: _color2}, 700, 'easeInOutExpo');
350				}
351				if(!_row_bg.hasClass('no-affect-font-color')) {
352					jQuery(this).find('*:not(.vc_row-fading-bg-color)').stop().animate({color: _color1}, 500, 'easeInOutExpo');
353				}
354			}else{
355				if(!_row_bg.hasClass('apply-to-body')) {
356					_row_bg.stop().animate({backgroundColor: _color1}, 700, 'easeInOutExpo');
357				}else{
358					jQuery('body').stop().animate({backgroundColor: _color1}, 700, 'easeInOutExpo');
359				}
360				if(!_row_bg.hasClass('no-affect-font-color')) {
361					jQuery(this).find('*:not(.vc_row-fading-bg-color)').stop().animate({color: _color2}, 500, 'easeInOutExpo');
362				}
363			}
364		},{
365			offset: '50%'
366		});
367
368		/* generic waypoint appear effect */
369	    jQuery('.ozy-waypoint-animate').waypoint(function(direction) {
370			if (direction === 'down') {
371				jQuery(this).removeClass('hiding').addClass('ozy-start-animation');
372			}else{
373				jQuery(this).removeClass('ozy-start-animation').addClass('hiding');
374			}
375		},{
376			offset: '85%'
377		});
378	}else{
379		jQuery('.ozy-waypoint-animate').removeClass('ozy-waypoint-animate');
380	}
381}
382
383var has_body_use_transparent = false; //just in case if user try to resize window to test responsive mode
384
385function ozy_mobile_menu_header_style_check() {
386	"use strict";
387	if(jQuery(window).width() <= 768) {
388		jQuery('#wpadminbar').css('position', 'fixed');
389
390		has_body_use_transparent = jQuery('body').hasClass('use-transparent-menu');
391		jQuery('body').removeClass('use-transparent-menu').addClass('ozy-alternate-menu');
392	}else{
393		if(has_body_use_transparent) {
394			jQuery('body').addClass('use-transparent-menu');
395		}
396	}
397}
398
399jQuery(window).resize(function() {
400	"use strict";
401	ozy_generic_element_fix();
402	ozy_custom_map_mobile_full_height_fix();
403	ozy_custom_heading_mobile_fix();
404	ozy_mobile_maybe();
405	ozy_mobile_menu_header_style_check();
406});
407
408jQuery.fn.extend({
409  isLoaded: function(){
410	  "use strict";
411	  return this.prop("complete") && this.prop("naturalWidth") !== 0;
412  }
413});
414
415var revealImages = function() {
416	"use strict";
417	jQuery('.img-wrapper:not(.no-reveal) img[loading="lazy"]').parents('.img-wrapper').addClass('native-lazy');
418
419	jQuery('.img-wrapper:not(.no-reveal):not(.native-lazy):not(.img-loaded):not(.in-animation)').each(function(){
420		var el = this;
421		if(jQuery(el).offset().top < jQuery(window).scrollTop() + (jQuery(window).height() / 10)*8 ) {
422			jQuery(el).addClass('img-loaded');
423		}
424	});
425
426	jQuery('.img-wrapper:not(.no-reveal).native-lazy img').each(function(){
427		if(jQuery(this).isLoaded()) {
428			jQuery(this).attr('loading', '');
429			jQuery(this).parents('.img-wrapper').removeClass('native-lazy');
430		}
431	});
432};
433
434/* Row Reveal Slider */
435function ozy_reveal_image_animations() {
436	"use strict";
437	requestAnimationFrame(revealImages);
438	jQuery(window).on('scroll', function(){
439		requestAnimationFrame(revealImages);
440	});
441}
442
443function ozy_revealSlider() {
444	"use strict";
445	jQuery('div[id^="top-banner-background-"]').each(function(){
446		var sts = 1200,
447			std = 4000,
448			$that = jQuery(this),
449			ran = false,
450			$slider_id = '#' + jQuery(this).attr('id') + ' ';
451
452		// Add pagination wrapper
453		$that.append('<nav class="slider-nav"></nav>');
454
455		function starttopslideshow(looping) {
456			jQuery($slider_id + '.hero-background-slider>div').removeClass('active');
457
458			var total_slider_count = jQuery($slider_id + '.hero-background-slider').length,
459			current_slide = jQuery($slider_id + '.hero-background-slider>div.active'),
460			current_slide_number = 1,
461			next_slide,
462			slide_counter = 0;
463
464			for(var zindex=total_slider_count;zindex>
464=0;zindex--) {
465				jQuery($slider_id + '.hero-background-slider:nth-child('+slide_counter+')').css({'width':'100%','z-index':(zindex+1)});
466				slide_counter++;
467			}
468
469			// Pagination Link Builder
470			if(!ran) {
471				$that.find('.slider-nav').html('');slide_counter = 0;
472				for(zindex=total_slider_count-1;zindex>=0;zindex--) {
473					slide_counter++;
474					$that.find('.slider-nav').append('<a href="#'+ slide_counter +'" aria-label="Slide '+ slide_counter +'" data-index="'+ slide_counter +'" class="nav-item '+ (slide_counter===1 ? ' nav-item-current':'') +'"></a>');
475				}
476			}
477			ran = true;
478
479			$that.find('.slider-nav a').on("click", function(e){
480				e.preventDefault();
481				return false;
482			});
483
484			jQuery($slider_id + '.hero-background-slider:first-child>div').addClass('active');
485			if(!looping) { captionMaker(jQuery($slider_id + '.hero-background-slider:first-child>div')); }
486
487			function runSlide() {
488				jQuery($slider_id + '.hero-background-slider>div.active').parent('div').delay(std).animate({width:0},{
489					duration:sts,
490					start:function(){
491						current_slide = jQuery($slider_id + '.hero-background-slider>div.active');
492						next_slide = current_slide.parent('div').next($slider_id + '.hero-background-slider');
493						current_slide.parent('div').next($slider_id + '.hero-background-slider').find('div').addClass('active');
494
495						$that.find('.slider-nav a').removeClass('nav-item-current');
496						$that.find('.slider-nav a[data-index="'+ (current_slide_number+1) +'"]').addClass('nav-item-current');
497
498						captionMaker(current_slide.parent('div').next($slider_id + '.hero-background-slider').find('div'));
499
500						if(current_slide_number === total_slider_count) {
501							$that.find('.slider-nav a[data-index="1"]').addClass('nav-item-current');
502
503							jQuery($slider_id + '.hero-background-slider:first-child').css({'width':'100%','z-index':0}).find('div').addClass('active');
504							captionMaker(jQuery($slider_id + '.hero-background-slider:first-child').find('div'));
505						}
506					},
507					complete:function(){
508						current_slide_number++;
509						current_slide.removeClass('active');
510						if(current_slide_number > total_slider_count) {
511							starttopslideshow(true);
512						}else{
513							runSlide();
514						}
515					}
516				});
517			}
518			runSlide();
519		}
520
521		function captionMaker($this) {
522			var html_o = '';
523
524			$this.parents('div').find('div.reveal-slider-caption').stop().animate({opacity:'hide'}, 300, function() {
525				if(typeof $this.data('title') != 'undefined' && $this.data('title') != '') {
526					html_o += '<h2>' + $this.data('title') + '</h2>';
527				}
528				if(typeof $this.data('subtitle') != 'undefined' && $this.data('subtitle') != '') {
529					html_o += '<h3>' + $this.data('subtitle') + '</h3>';
530				}
531				if(typeof $this.data('link') != 'undefined' && $this.data('link') != '' && typeof $this.data('linktitle') != 'undefined' && $this.data('linktitle') != '') {
532					html_o += $this.find('.div_link').html();
533				}
534				if(typeof $this.data('fgcolor') != 'undefined' && $this.data('fgcolor') != '') {
535					$this.parents('div').find('div.reveal-slider-caption').css('color', $this.data('fgcolor'));
536				}
537				$this.parents('div').find('div.reveal-slider-caption').html('<span class="overlay">'+ html_o + '</span>').stop().animate({opacity: 'show'}, 600);
538
539				sunway_ozy_inline_link_handler();
540			});
541		}
542
543		jQuery(window).on('resize', function(){
544			window.resizeEvt;
545			jQuery(window).resize(function(){
546				jQuery('div[id^="top-banner-background-"]:not(.shortcode-mode)').css({'height': Math.ceil(jQuery(window).height())});
547				jQuery('div[id^="top-banner-background-"]>div').addClass('notransition');
548				clearTimeout(window.resizeEvt);
549				window.resizeEvt = setTimeout(function(){
550					//code to do after window is resized
551					jQuery('div[id^="top-banner-background-"]>div').removeClass('notransition');
552				}, 250);
553			});
554
555			jQuery('div[id^="top-banner-background-"].shortcode-mode').each(function(){
556				jQuery(this).height(jQuery(this).parents('div.vc_row').height());
557			});
558		}).resize();
559
560		starttopslideshow(false);
561	});
562}
563
564/**
565 * Fix direct reservation form on room pages
566 */
567jQuery( document ).ajaxComplete(function( event, xhr, settings ) {
568	if( event.currentTarget.activeElement.className.toString().indexOf('single-mphb_room_type') > -1 ) {	
569		const $this = jQuery('body.single-mphb_room_type .mphb-reserve-room-section');
570		const $that = $this.siblings('p.mphb-check-out-date-wrapper');
571
572		$this.height($that.height());
573
574		jQuery('body.single-mphb_room_type .button.mphb-button.mphb-confirm-reservation').val( ozy_headerType.short_confirm_button_text );
575	}
576});
577
578jQuery(window).on('load', function(){
579	"use strict";
580
581	ozy_mobile_maybe();
582
583	/* Search page */
584	if (jQuery().masonry) {
585		if(jQuery('body.search-results').length) {
586			jQuery('body.search-results .post-content>div').imagesLoaded( function(){
587				jQuery('body.search-results .post-content>div').masonry({
588					itemSelector : 'article.result',
589					gutter : 20
590				});
591			});
592		}
593	}
594
595	/* Row Kenburns Slider */
596	jQuery('.smoothslides').each(function() {
597		function kbSlideshow($this) {
598			window.setInterval(kenBurns, 7000);
599			var images = jQuery($this).find('div'),
600				numberOfImages = images.length, i = 1;
601			images.eq(0).addClass('fx1');
602			function kenBurns() {
603				if (i===numberOfImages) { i = 0; }
604				images.eq(i).addClass("fx");
605				if (i===0) { images.eq(numberOfImages-2).removeClass(); }
606				if (i===1) { images.eq(numberOfImages-1).removeClass(); }
607				if (i>1 && numberOfImages-2 > 1) {
608					images.eq(i-2).removeClass();
609				}else{
610					images.eq(i-1).removeClass();
611				}
612				i++;
613			}
614		}
615		setTimeout(kbSlideshow(this), 1);
616    });
617
618	/* Row Reveal Slider */
619	ozy_revealSlider();
620
621	/* Testimonial Slider Bullet Fix */
622	jQuery('div.flickity-carousel').find('.testimonial').each(function() {
623		jQuery(this).parents('div.flickity-carousel').find('ol.flickity-page-dots').css('bottom', '25px');
624		return;
625	});
626
627	ozy_reveal_image_animations();
628
629	/* Paroller Parallax */
630	if(!ozyCheckIs768el()) {
631		jQuery('.ozy-image_with_featured_content.paroller div[data-paroller-factor],.wpb_single_image.paroller').each(function(){
632			jQuery(this).paroller({
633				factorXl: jQuery(this).attr('data-paroller-factor'),
634				type: 'foreground'
635			});			
636		});		
637	}
638
639	/* Row Background Slider */
640	if(jQuery('.ozy-background-cycler').length>0) {
641		jQuery('.ozy-background-cycler').each(function(index, elm){
642			jQuery(elm).fadeIn(1500); //fade the background back in once all the images are loaded
643			setInterval( function(){ ozy_cycle_images(elm); }, 5000);	// run every 5s
644		});
645	}
646
647	if(jQuery('body.page-template-page-masonry-blog,body.page-template-page-mosaic-blog').length>0) {
648		ozy_page_template_page_blog_init();
649	}
650
651	/* Layz Load */
652	jQuery('div[data-bgsrc]').each(function(){
653		jQuery(this).css('background-image', 'url('+ jQuery(this).data('bgsrc') +')');
654	});
655
656	/* Hotel Booking Single Room Gallery Loading */
657	jQuery('body.single-mphb_room_type .mphb-room-type-gallery-wrapper.mphb-single-room-type-gallery-wrapper').addClass('gallery-loaded');
658
659});
660
661/**
662*
663* Original Idea: Simon Battersby @ http://goo.gl/CsWVJL
664*/
665function ozy_cycle_images(elm){
666	"use strict";
667	var $active = jQuery(elm).find('div.active');
668	var $next = (jQuery(elm).find('div.active').next().length > 0) ? jQuery(elm).find('div.active').next() : jQuery(elm).find('div:first');
669	$next.css('z-index',2);//move the next image up the pile
670	$active.fadeOut(1500,function(){//fade out the top image
671		$active.css('z-index',1).show().removeClass('active');//reset the z-index and unhide the image
672		$next.css('z-index',3).addClass('active');//make the next image the top one
673	});
674}
675
676function sunway_ozy_menu_bg_color_fixer() {
677	"use strict";
678	var do_time = 0;
679	var headerMenuFixed = false;
680	jQuery.doTimeout('scroll', do_time, function(){
681		if(jQuery('body').hasClass('use-transparent-menu')) {
682			if(jQuery(window).scrollTop() >= 150) {
683				if(!headerMenuFixed) {
684					jQuery('body').addClass('ozy-alternate-menu');
685					jQuery('#ozy-cookie_notice_banner').addClass('in-viewport');
686				}
687			} else {
688				jQuery('body').removeClass('ozy-alternate-menu');
689				headerMenuFixed = false;
690			}
691		}
692
693		/* Cookie Notice Banner Visibility */
694		if(jQuery('#ozy-cookie_notice_banner').length) {
695			if(jQuery(window).scrollTop() >= 150) {
696				jQuery('#ozy-cookie_notice_banner').addClass('in-viewport');
697			}else{
698				jQuery('#ozy-cookie_notice_banner').removeClass('in-viewport');
699			}
700		}
701	});
702}
703
704/* Inline Link Handler */
705
706function ozy_click_hash_check($this) {
707	"use strict";
708	if (location.pathname.replace(/^\//,'') == $this.pathname.replace(/^\//,'')
709		|| location.hostname == $this.hostname) {
710
711		var target = jQuery($this.hash);
712		target = target.length ? target : jQuery('[name=' + $this.hash.slice(1) +']');
713		if (target.length) {
714			jQuery('html,body').animate({
715				 scrollTop: target.offset().top - jQuery('.nav-container').height()
716			}, 1600, 'easeInOutExpo');
717
718			history.replaceState(undefined, undefined, "#" + $this.hash.slice(1));
719
720			return false;
721		}
722	}
723	return true;
724}
725
726function sunway_ozy_inline_link_handler() {
727	"use strict";
728	if( ozyCheckIs768el() ) {
729		sunway_ozy_inline_link_handler_mobile();
730	}else{
731		jQuery('.sunway-primary-nav a[href*="#"]:not(.menu-search),.reveal-slider-caption a[href*="#"], #content a.ozy-custom_button[href*="#"],#content a.vc_btn3[href*="#"],.widget ul.menu>
731li>a[href*="#"], .velo-slide__btn>a.btn-draw[href*="#"]').unbind('click').on("click", function(e) {
732			var pattern = /^((http|https|ftp):\/\/)/;
733			if (/#/.test(this.href)) {
734				e.preventDefault();
735				if(ozy_click_hash_check(this)) {
736					if(ozy_Animsition.is_active) {
737						if(pattern.test(jQuery(this).attr('href'))) {
738							jQuery('.animsition').animsition('out', jQuery(e.target), jQuery(this).attr('href'));
739						}else{
740							jQuery('.animsition').animsition('out', jQuery(e.target), ozy_headerType.$OZY_WP_HOME_URL + jQuery(this).attr('href'));
741						}
742					}else{
743						if(pattern.test(jQuery(this).attr('href'))) {
744							window.location = jQuery(this).attr('href');
745						}else{
746							window.location = ozy_headerType.$OZY_WP_HOME_URL + jQuery(this).attr('href');
747						}
748					}
749				}
750			}else if(pattern.test(this.href)) {
751				e.preventDefault();
752				if(ozy_click_hash_check(this)) {
753					if(ozy_Animsition.is_active) {
754						jQuery('.animsition').animsition('out', jQuery(e.target), ozy_headerType.$OZY_WP_HOME_URL + this.hash);
755					}else{
756						window.location = ozy_headerType.$OZY_WP_HOME_URL + this.hash;
757					}
758				}
759			}else {
760				if(ozy_Animsition.is_active) {
761					e.preventDefault();
762					jQuery('.animsition').animsition('out', jQuery(e.target), jQuery(this).attr('href'));
763				}
764			}
765		});
766	}
767}
768
769/*
770* Same as above but it doesn't unbind Click event so mobile menu can expand if parent element has anchor like #row-id
771*/
772function sunway_ozy_inline_link_handler_mobile() {
773	"use strict";
774	jQuery('.sunway-primary-nav a[href*="#"],.reveal-slider-caption a[href*="#"], #content a.ozy-custom_button[href*="#"],#content a.vc_btn3[href*="#"],.widget ul.menu>li>a[href*="#"], .velo-slide__btn>a.btn-draw[href*="#"]').on("click", function(e) {
775		var pattern = /^((http|https|ftp):\/\/)/;
776		if (/#/.test(this.href)) {
777			e.preventDefault();
778			if(ozy_click_hash_check(this)) {
779				if(ozy_Animsition.is_active) {
780					if(pattern.test(jQuery(this).attr('href'))) {
781						jQuery('.animsition').animsition('out', jQuery(e.target), jQuery(this).attr('href'));
782					}else{
783						jQuery('.animsition').animsition('out', jQuery(e.target), ozy_headerType.$OZY_WP_HOME_URL + jQuery(this).attr('href'));
784					}
785				}else{
786					if(pattern.test(jQuery(this).attr('href'))) {
787						window.location = jQuery(this).attr('href');
788					}else{
789						window.location = ozy_headerType.$OZY_WP_HOME_URL + jQuery(this).attr('href');
790					}
791				}
792			}
793		}else if(pattern.test(this.href)) {
794			e.preventDefault();
795			if(ozy_click_hash_check(this)) {
796				if(ozy_Animsition.is_active) {
797					jQuery('.animsition').animsition('out', jQuery(e.target), ozy_headerType.$OZY_WP_HOME_URL + this.hash);
798				}else{
799					window.location = ozy_headerType.$OZY_WP_HOME_URL + this.hash;
800				}
801			}
802		}else {
803			if(ozy_Animsition.is_active) {
804				e.preventDefault();
805				jQuery('.animsition').animsition('out', jQuery(e.target), jQuery(this).attr('href'));
806			}
807		}
808	});
809}
810
811jQuery(window).scroll(function() {
812	"use strict";
813	sunway_ozy_menu_bg_color_fixer();
814});
815
816jQuery(document).ready(function($) {
817	"use strict";
818
819	jQuery(window).scroll(); //init logo switch for first time
820
821	ozy_share_button();
822
823	ozy_generic_element_fix();
824
825	ozy_ajax_load_more_blog_action();
826
827	ozy_hash_scroll_fix();
828
829	ozy_custom_heading_mobile_fix();
830
831	ozy_mobile_menu_header_style_check();
832
833	ozy_cookie_notice_banner();
834
835	ozy_offer_box();
836
837	/* Primary Menu Hover Handler */
838	$(".sunway-primary-nav>li.dropdown").hoverIntent({
839		over: function(){
840			$(this).addClass('active-hover');
841		},
842		out: function(){
843			$(this).removeClass('active-hover');
844		},
845		sensitivity: 5,
846		timeout: 300
847	});
848
849	/* Mobile Menu Handler */
850	$('.sunway-primary-nav li>a.dropdown-toggle').on("click", function(e){
851		if($(window).width() < 1025) {
852			var $that = $(this).parent('li');
853			//var $that = $(this).parent('span').parent('a').parent('li');
854
855			if($that.hasClass('open')) {
856				$that.removeClass('open');
857			}else{
858				if(!$that.hasClass('dropdown-submenu')) {
859					$('ul.sunway-primary-nav li').removeClass('open');
860				}
861				$that.addClass('open');
862			}
863
864			e.preventDefault();
865			return false;
866		}
867	});
868
869	/* Fixes Attributes Table of Room Listing */
870	$('.mphb_sc_rooms-wrapper mphb-room-types.jsaction .mphb-loop-room-type-attributes>li').each(function(){
871		var tooltip_title = $(this).find('span:first-child').html().replace(':', '');
872		$(this).attr('title', tooltip_title);$(this).find('span:last-child').append(tooltip_title);
873	});
874
875	/* Switch Menu Overlay */
876	var menu_hover_alternate = false;
877	$(".nav-container").hoverIntent({
878		over: function(){
879			if(!$('body').hasClass('ozy-alternate-menu')) {
880				$('body').addClass('ozy-alternate-menu');
881				menu_hover_alternate = true;
882			}
883			if(!$('body').hasClass('mobile-maybe')) {
884				if(!$('body').hasClass('ozy-menu-jsaction')) {
885					$('body').addClass('ozy-menu-jsaction');
886				}
887			}
888		},
889		out: function(){
890			if(menu_hover_alternate) {
891				$('body').removeClass('ozy-alternate-menu');
892				menu_hover_alternate = false;
893			}
894			$('body').removeClass('ozy-menu-jsaction');
895		},
896		sensitivity: 20,
897		timeout: 300
898	});
899
900
901	/* Mobile Menu Hamburger Handler */
902	$('#responsive_menu').change(function() {
903		$('.hamburger-menu').toggleClass('animate');
904    	if ($(this).is(':checked')) {
905			$('body').addClass('ozy-menu-jsaction');
906    	} else {
907			$('body').removeClass('ozy-menu-jsaction');
908    	}
909	});
910
911
912	/* Adds CSS class name to body if there is 6 widget in footer */
913	$('.footer-widget-bar:not(#footer) .widget:nth-child(3n)').after('<hr>');
914
915	/* Primary Menu Video Button Handler */
916	$(".menu-video").on("click touchstart", function(e){
917		e.preventDefault();
918
919		var videoSrc = $(this).attr('href'),
920			videoHtml = '',
921			videoOverlayType = 'regular';
922
923		if( !ozyIsValidURL(videoSrc) ) { //if not valid URL it must be YouTube video ID
924            videoSrc = videoSrc.replace('http://', ''); videoSrc = videoSrc.replace('#video-menu', '');
925			videoHtml = '<iframe width="1024" height="768" style="max-width:78vw !important;max-height:50vh !important;" src="https://www.youtube.com/embed/'+ videoSrc +'?controls=0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>';
926			videoOverlayType = 'youtube';
927		} else {
928			videoHtml = '<video controls autoplay poster="'+ ozy_headerType.theme_url +'images/blank.gif"><source src="'+ videoSrc +'" type="video/mp4">Your browser does not support the video tag.</video>';
929		}
930
931		$('body').append('<div id="menu-video-overlay" class="video-'+ videoOverlayType +'"><div><a href="#close-video"><i class="oic-pe-icon-7-stroke-139"></i></a>'+ videoHtml +'</div></div>');
932		$('#menu-video-overlay').fadeIn(300);
933		$('#menu-video-overlay>div>a').on("click touchstart", function(e){
934			e.preventDefault();
935			$('#menu-video-overlay').fadeOut(300, function(){
936				$(this).remove();
937			});
938		});
939		
940		return false;
941	});
942
943	/* Search Availability Button Height Fix */
944	if(!ozyCheckIs768el()) {
945		$('.mphb_sc_search-submit-button-wrapper:visible').height($('.mphb_sc_search-submit-button-wrapper:visible').parents('form').outerHeight());
946	}
947
948	/* Search Availability + - buttons */
949	$('.mphb_sc_search-form p[class^="mphb_sc_search-"]>span>span:first-of-type').on("click", function(){
950		var _field = $(this).parents('p').find('input');
951		var _new_val = parseFloat(_field.val()) - 1;  var _min = parseFloat(_field.attr('min'));
952		_field.val( _new_val >= _min ? _new_val : parseFloat(_field.val()) );
953	});
954
955	$('.mphb_sc_search-form p[class^="mphb_sc_search-"]>span>span:last-of-type').on("click", function(){
956		var _field = $(this).parents('p').find('input');
957		var _new_val = parseFloat(_field.val()) + 1; var _max = parseFloat(_field.attr('max'));
958		_field.val( _new_val <= _max ?  _new_val : parseFloat(_field.val()) );
959	});
960
961	$('.mphb_sc_search-form input').on("click", function(){
962		$(this).focus(); $(this).select();
963	});
964
965	/* Animsition */
966	if(ozy_Animsition.is_active) {
967		$(".animsition").animsition({
968			inClass: 'fade-in',
969			outClass: 'fade-out',
970			inDuration: 800,
971			outDuration: 400,
972			linkElement: '.sunway-primary-nav li>a:not([target="_blank"]):not([href^="#"]), a.book-your-stay:not([target="_blank"]), a.menu-logo, .mobile-book-your-stay>a:not([target="_blank"])',
973			loading: true,
974			loadingParentElement: 'body',
975			loadingClass: 'loader-container',
976			loadingInner: (ozy_loadingScreen.loading_screen_html != '0' ? unescape(ozy_loadingScreen.loading_screen_html) : '<div id="loader-container"><div id="loader-circle"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="300px" height="300px" viewBox="0 0 300 300" enable-background="new 0 0 300 300" xml:space="preserve"><circle fill="none" cx="150" cy="149" r="124"/><g><g><path id="circlePath" fill="none" d="M35.808,147.892c0-62.967,51.043-114.012,114.012-114.012c62.967,0,114.012,51.045,114.012,114.012S212.786,261.903,149.82,261.903C86.851,261.903,35.808,210.858,35.808,147.892"/></g><text class="content-font-family content-color"><textPath xlink:href="#circlePath">LOADING - PLEASE BE PATIENT - THANK YOU FOR WAITING - </textPath></text></g></svg></div></div>'),
977			timeout: true,
978			timeoutCountdown: 3000,
979			onLoadEvent: true,
980			browser: [ 'animation-duration', '-webkit-animation-duration'],
981			overlay : false,
982			overlayClass : 'animsition-overlay-slide',
983			overlayParentElement : 'body',
984			transition: function(url){ window.location.href = url; }
985		});
986
987		$('.animsition').on('animsition.outStart', function(){
988			$('#ozy-offer_box,#ozy-cookie_notice_banner').css('opacity', 0);
989		});
990	}
991	
992	sunway_ozy_inline_link_handler();
993
994	/* Search Button & Stuff */
995	$(document).on('click', '#close-search-overlay, a.menu-search', function(e) {
996		e.preventDefault();
997		$('body').toggleClass('search-overlay-open');
998		$('#search-overlay #search').focus();
999		return false;
1000	});
1001
1002	$(document).keyup(function(e) {
1003		if (e.which === 27) {
1004			$('body').removeClass('search-overlay-open');
1005		}
1006		e.preventDefault();
1007    });
1008
1009	/* Language Switcher */
1010	$('.lang-switcher').on("click", function(e) {
1011		$('body').toggleClass('lang-switcher-open');
1012        e.preventDefault();
1013    });
1014
1015	$(document).on("click", function(e) {
1016		if($('body').hasClass('lang-switcher-open')) {
1017			var lang_switcher_div = $('.lang-switcher,.lang-switcher-dropdown');
1018			if( !ozyCheckIs768el() ) {
1019				$('.lang-switcher-dropdown').css({"top":  $('.menu-lang:visible>span>span').offset().top + $('.menu-lang:visible>span>span').outerHeight() + ( $('body').hasClass('admin-bar') ? -32 : 0 )  });
1020			}
1021			if (!lang_switcher_div.is(e.target) && !lang_switcher_div.has(e.target).length && lang_switcher_div.is(':visible') && !$(e.target).hasClass('lang-switcher-dropdown')) {
1022				$('body').toggleClass('lang-switcher-open');
1023			}
1024		}
1025	});
1026
1027	function ozy_visual_stuff() {
1028		/* Tooltip plugin init */
1029		$(function(){
1030			$('.tooltip-right').tooltipsy({className:'tooltipsy right', offset: [0, 0]});
1031			$('.tooltip-top, abbr[title],.mphb-price-period[title],.mphb-loop-room-type-attributes>li[title]').tooltipsy({className:'tooltipsy white', offset: [0, 20]});
1032			$('.tooltip').tooltipsy();
1033		});
1034
1035		/* YouTube Embed */
1036		$('.oytb-videoWrapper').each(function() {
1037			var $poster = $(this);
1038			var $wrapper = $poster.closest(this);
1039
1040			$(this).on("click", function(ev){
1041				ev.preventDefault();
1042				videoPlay($wrapper);
1043			});
1044
1045			function videoPlay($wrapper) {
1046				var $iframe = $wrapper.find('.oytb-js-videoIframe');
1047				var src = $iframe.data('src');
1048				$wrapper.addClass('oytb-videoWrapperActive');
1049				$poster.parent('div').find('.oytb-video-StopButton').show(100, 'easeInOutExpo');
1050				$iframe.attr('src',src);
1051			}
1052
1053			$('.oytb-video-StopButton').on("click", function(){
1054				videoStop($wrapper);
1055			});
1056
1057			function videoStop($wrapper) {
1058				if (!$wrapper) {
1059					var $wrapper = $('.oytb-js-videoWrapper');
1060					var $iframe = $('.oytb-js-videoIframe');
1061				} else {
1062					var $iframe = $wrapper.find('.oytb-js-videoIframe');
1063				}
1064				$wrapper.removeClass('oytb-videoWrapperActive');
1065				$poster.parent('div').find('.oytb-video-StopButton').hide(100, 'easeInOutExpo');
1066				$iframe.attr('src','');
1067			}
1068        });
1069
1070		/* Flickity See All switch button */
1071		$('.flickity-carousel-wrapper>.flickity-carousel.carousel').each(function() {
1072			var $carousel = $(this);
1073			var isFlickity = true;
1074			// toggle Flickity on/off
1075			$('.flickity-see-all').on( 'click', function() {
1076				//switch button label
1077				var button_label = $(this).toggleClass('grid-open').data('label');$(this).data('label', $(this).html());$(this).html(button_label);
1078
1079				if ( isFlickity ) {
1080					//setup isotope
1081					var conf_arr = {
1082						layoutMode: 'packery',
1083						itemSelector: '.carousel-cell'
1084					};
1085					$carousel.toggleClass('flickity-carousel-grid').flickity('destroy').isotope(conf_arr);
1086
1087					//isotope animation
1088					var anim_timing = 0.25;
1089					$carousel.find('.carousel-cell').each(function() {
1090						$(this).css({'-webkit-transform' : 'translateX(200%)', 'transform' : 'translateX(200%)', '-webkit-animation' : 'comeFromRight '+anim_timing+'s ease-in-out forwards', 'animation' : 'comeFromRight '+anim_timing+'s ease-in-out forwards'});
1091						anim_timing = anim_timing + 0.10;
1092                    });
1093
1094				} else {
1095					//init new Flickity
1096					var data_flickity_str = $carousel.attr('data-flickity');
1097					$carousel.isotope('destroy').toggleClass('flickity-carousel-grid').flickity(JSON.parse(data_flickity_str));
1098				}
1099				isFlickity = !isFlickity;
1100				return false;
1101			});
1102		});
1103
1104		/* Flickity News Carousel */
1105		$('.explore-news').each(function(index, element) {
1106			$(element).flickity({
1107				// options
1108				lazyLoad: true,
1109				contain: true,
1110				accessibility: true,
1111				imagesLoaded: true,
1112				percentPosition: false,
1113				prevNextButtons: false, //custom option used
1114				pageDots: true,
1115				groupCells: ozyCheckIs768el() ? 1 : 2,
1116				cellAlign: 'left'
1117			});
1118			//Custon Arrows
1119			var $programs = $(element).flickity({
1120				prevNextButtons: false,
1121				pageDots: false
1122			});
1123
1124			// previous
1125			$('.button--previous').on( 'click', function() {
1126				$programs.flickity('previous');
1127			});
1128			// next
1129			$('.button--next').on( 'click', function() {
1130				$programs.flickity('next');
1131			});
1132        });
1133
1134		/* Custom Buttons */
1135		$('.ozy-custom_button.ocbtn-6')
1136		.on('mouseenter', function(e) {
1137				var parentOffset = $(this).offset(),
1138				relX = e.pageX - parentOffset.left,
1139				relY = e.pageY - parentOffset.top;
1140				$(this).find('span').css({top:relY, left:relX});
1141		})
1142		.on('mouseout', function(e) {
1143				var parentOffset = $(this).offset(),
1144				relX = e.pageX - parentOffset.left,
1145				relY = e.pageY - parentOffset.top;
1146			$(this).find('span').css({top:relY, left:relX});
1147		});
1148
1149		/* Tabbed Service Slider Arrow Shape */
1150		jQuery('.carousel.tabbed_service-nav').each(function(index, element){
1151			jQuery(element).flickity({
1152				"contain" : true,
1153				"pageDots": false,
1154				"asNavFor": jQuery(element).data('asnavfor')
1155
1156			});
1157		});
1158
1159		/* Tabbed Call To Action Slider Arrow Shape */
1160		jQuery('.tabbed_call_to_action-bottom').each(function(index, element){
1161			jQuery(element).flickity({
1162				"imagesLoaded" : true,
1163				"pageDots": false,
1164				"wrapAround": true,
1165				"autoPlay": 6000,
1166				"pauseAutoPlayOnHover": true,
1167				"prevNextButtons": true
1168			});
1169		});
1170
1171		/* Mosaic Gallery */
1172		if($('ul.ozy-mosaic_gallery').length) {
1173			jQuery('ul.ozy-mosaic_gallery').each(function() {
1174				var $that = jQuery(this);
1175				$that.imagesLoaded( function() {
1176					var conf_arr = {
1177						filter:  '',
1178						itemSelector: '.gallery-item',
1179						layoutMode: 'masonry',
1180						masonry: {columnWidth: 100}
1181					};
1182					conf_arr['masonry'] = {
1183						columnWidth: '.grid-sizer',
1184						gutter: '.gutter-sizer'
1185					};
1186					$that.isotope(conf_arr);
1187				});
1188			});
1189
1190			$('ul.ozy-mosaic_gallery').photobox('a',{ time:0 });
1191		}
1192
1193		/* Page: Rooms */
1194		if ('undefined' !== typeof jQuery.fn.isotope) {
1195			if($(window).width()>1024) {
1196				var maxHeight = 0;
1197				$(".mphb_sc_rooms-wrapper.mphb-room-types .mphb-room-type").each(function(){
1198				   if ($(this).height() > maxHeight) { maxHeight = $(this).height(); }
1199				});
1200				$(".mphb_sc_rooms-wrapper.mphb-room-types .mphb-room-type").height(maxHeight);
1201			}
1202
1203			jQuery('.mphb_sc_rooms-wrapper.mphb-room-types').each(function() {
1204				var $that = jQuery(this);
1205				$that.imagesLoaded( function() {
1206					var conf_arr = {
1207						filter:  '',
1208						itemSelector: '.mphb-room-type',
1209						layoutMode: 'fitRows',
1210						fitRows: {
1211						  gutter: 20
1212						}
1213					};
1214					$that.isotope(conf_arr);
1215
1216					$that.addClass('jsaction');
1217				});
1218			});
1219		}
1220
1221		/* Regular Blog */
1222		$('body.post-template-default.single.single-post #content p:has(>img)').each(function(){
1223			$(this).addClass(($(this).find('img').hasClass('narrow-p') ? '' : 'image-p')  + ' ' + $(this).find('img').attr('class'));
1224		});
1225		$('body.post-template-default.single.single-post #content p:has(>iframe)').addClass('iframe-p');
1226
1227		/* Single Post Gallery and Image operations */
1228		if($('body').hasClass('single single-post')) {
1229			/* Blog Content Image Wrapper */
1230			$('body.single-post .post-content img:not(.no-wrap):not([class^="attachment"])').each(function(){
1231				$(this).wrap('<div class="img-wrapper '+ $(this).attr('class') + '"/>');
1232			});
1233
1234			/* Convert Gallery into flickity slider on post */
1235			$('.gallery').each(function(){
1236				var flickity_images_output = '';
1237				$(this).find('img').each(function(){
1238					flickity_images_output += '<div class="carousel-cell">' + $(this).get(0).outerHTML + '</div>';
1239				});
1240
1241				$(this).html(flickity_images_output);
1242
1243				$(this).addClass('post-classic-gallery').flickity({
1244					cellSelector: '.carousel-cell',
1245					contain: true,
1246					pageDots: true,
1247					navArrows: true,
1248					wrapAround: true,
1249					adaptiveHeight: true,
1250					setGallerySize: true,
1251					lazyLoad: false
1252				});
1253			});
1254
1255			/* Fix flickity height issue on FF and IE */
1256			jQuery(window).load( function() {
1257				window.dispatchEvent(new Event('resize'));
1258			});
1259
1260		}
1261
1262		/* Comment Form is Field Empty Check */
1263		$('#commentform input, #commentform textarea').on('blur', function(){
1264			if($(this).val() === '') {
1265				$(this).addClass('empty');$(this).removeClass('not-empty');
1266			} else {
1267				$(this).addClass('not-empty');$(this).removeClass('empty');
1268			}
1269		});
1270
1271		/* Check Free Services On Booking Confirmation Page*/
1272		$('span.mphb-price.mphb-price-free').each(function(){
1273			$(this).parents('li').find('input:checkbox').css('border', '2px solid red').attr('checked', true);
1274		});
1275
1276		/* Regular Gallery in Hotel Room Page */
1277		if($('body.single-mphb_room_type').length && $('.mphb-room-type-gallery-wrapper .gallery').length) {
1278			$('.mphb-room-type-gallery-wrapper').append($('.mphb-room-type-gallery-wrapper .gallery')[0].outerHTML).ready(function() {
1279				$('.mphb-room-type-gallery-wrapper .gallery:first-of-type').attr('id', 'gallerymain');
1280				jQuery(window).on('load', function(){
1281					jQuery('.mphb-room-type-gallery-wrapper .gallery a').unbind('click').on("click", function(e){e.preventDefault();return false;});
1282					jQuery('.mphb-room-type-gallery-wrapper .gallery:first-of-type a').unbind('click');
1283					jQuery('.mphb-room-type-gallery-wrapper .gallery:first-of-type').photobox('a',{ time:0 });
1284				});
1285
1286				$('.gallery').each(function() {
1287					$(this).flickity({
1288						cellSelector: '.gallery-item',
1289						contain: false,
1290						pageDots: false,
1291						navArrows: true,
1292						wrapAround: true,
1293						imagesLoaded: true,
1294						asNavFor: '#gallerymain'
1295					});
1296				});
1297			});
1298		}
1299
1300		$('.mphb-room-type-images>.slides:first-child').each(function() {
1301			var masterGallerySlider = 'gallerySliderMaster' + Math.floor(Math.random() * 10000) + 1;
1302			$(this).addClass('gallery').attr('id', masterGallerySlider).flickity({
1303				cellSelector: '.gallery-item',
1304				contain: false,
1305				pageDots: false,
1306				navArrows: true,
1307				wrapAround: true,
1308				imagesLoaded: true,
1309			});
1310
1311			$(this).parents('.mphb-room-type-images').find('.slides:last-child a').addClass('gallery').attr('href', 'javascript:void(0);');
1312			$(this).parents('.mphb-room-type-images').find('.slides:last-child').flickity({ "imagesLoaded": true, "wrapAround": true, "cellSelector": ".gallery-item", "asNavFor": "#"+ $(this).attr("id") , "contain": true, "pageDots": false });
1313		});
1314
1315		/* Checkout Form Details Form Additional CSS Class Name */
1316		var check_out_form_room_details = $('.mphb-reserve-rooms-details>.mphb-room-details');
1317		if(check_out_form_room_details.length>0) {
1318			check_out_form_room_details.addClass('column' + check_out_form_room_details.find('>p:not(.mphb-room-type-title)').length);
1319		}
1320	}
1321
1322	ozy_visual_stuff();
1323
1324	/* Waypoint animations */
1325	ozy_init_waypoint();
1326
1327	function ozy_vc_components() {
1328		/* OpenTable */
1329		if ('undefined' !== typeof jQuery.fn.datetimepicker) {
1330			$('input.datetimepicker').datetimepicker({
1331				timepicker:false,
1332				format:'m/d/Y',
1333				formatDate:'m/d/Y',
1334				minDate:0
1335			});
1336		}
1337
1338		/* Google Map */
1339		if ('undefined' !== typeof jQuery.fn.prettyMaps) {
1340			$('.ozy-google-map:not(.init-later)').each(function() {
1341				if($(this).data('height').toString().indexOf('%') !== -1) {
1342					$(this).parent('div.wpb_wrapper').css('height', '100%');
1343				}
1344				$(this).parent().append(
1345					$('<div class="gmaps-cover"></div>').on("click", function(){ $(this).remove(); })
1346				);
1347				var disable_ui = (typeof $(this).data('disableui') !== 'undefined' ? false:true);
1348				$(this).prettyMaps({
1349					address: $(this).data('address'),
1350					zoom: $(this).data('zoom'),
1351					panControl: disable_ui,
1352					zoomControl: disable_ui,
1353					mapTypeControl: disable_ui,
1354					scaleControl: disable_ui,
1355					streetViewControl: disable_ui,
1356					overviewMapControl: disable_ui,
1357					scrollwheel: true,
1358					image: $(this).data('icon'),
1359					hue: $(this).data('hue'),
1360					saturation: $(this).data('saturation'),
1361					lightness: $(this).data('lightness')
1362				});
1363			});
1364			ozy_custom_map_mobile_full_height_fix();
1365		}
1366
1367		/* Multi Google Map */
1368		if ('undefined' !== typeof jQuery.fn.ozyGmap) {
1369			$('.ozy-multi-google-map').each(function() {
1370				$(this).parent().append(
1371					$('<div class="gmaps-cover"></div>').on("click", function(){ $(this).remove(); })
1372				);
1373				$(this).ozyGmap({
1374					dataPath: $(this).data('path'),
1375					zoom: $(this).data('zoom'),
1376					panControl: true,
1377					zoomControl: true,
1378					mapTypeControl: true,
1379					scaleControl: true,
1380					streetViewControl: true,
1381					overviewMapControl: true,
1382					scrollwheel: true,
1383					image: $(this).data('icon'),
1384					hue: $(this).data('hue'),
1385					saturation: $(this).data('saturation'),
1386					lightness: $(this).data('lightness')
1387				});
1388			});
1389		}
1390
1391		/* Blog Hero */
1392		if(!ozyCheckIsMobile() && !ozyCheckIs768el() && !$('body.single-mphb_room_type')){
1393			(function () {
1394				$(window).scroll(function () {
1395					var s_speed = $(window).scrollTop() * 0.5; // speed of title scroll
1396					var s_speed_mod = s_speed + 100;
1397					$(".featured-thumbnail-header>img").css({"margin-top":"-" + s_speed_mod + "px"});
1398				});
1399			}.call(this));
1400		}
1401
1402		/* Typewriter */
1403		$(".typing-box").each(function() {
1404			var options = {
1405				typeSpeed : $(this).data('typespeed'),
1406				startDelay : $(this).data('startdelay'),
1407				backSpeed : $(this).data('backspeed'),
1408				backDelay : $(this).data('backdelay'),
1409				loop : $(this).data('loop'),
1410				strings : $.parseJSON(ozyTypeWriterData[$(this).data('path')])
1411			};
1412			$(this).typed(options);
1413        });
1414
1415		/* Instagram Feed */
1416		$('.ozy-instagram-gallery:not(.new)').each(function(index, element) {
1417			var accesstoken = $(this).data('accesstoken'),
1418				num_photos = $(this).data('numitems'),
1419				title = $(this).data('title'),
1420				username = $(this).data('username');
1421			$.ajax({
1422				url: 'https://api.instagram.com/v1/users/self/media/recent/?access_token='+accesstoken+'&count='+num_photos+'&callback=?',
1423				dataType: 'jsonp',
1424				type: 'GET',
1425				data: {count: num_photos, access_token: accesstoken},
1426				success: function(data2){
1427					//Join the Sunway Community
1428					$(element).append('<li><div><h3>'+ title +'</h3><p>@'+ username +'</p></div></li>');
1429					if (typeof data2.data !== "undefined"){
1430						for(var i = 0; i < data2.data.length; i++) {
1431							$(element).append('<li><a href="'+ data2.data[i].link +'" target="_blank"><img src="'+data2.data[i].images.standard_resolution.url+'"></a></li>');
1432						}
1433					}else{
1434						console.warn('Instagram Widget:', data2.meta.error_message);
1435					}
1436				},
1437				error: function(data2){
1438					$(element).append('<li>'+ data2 +'</li>');
1439				}
1440			});
1441		});
1442
1443		/* New Instagram Feed */
1444		$('.ozy-instagram-gallery.new').each(function(index, element) {
1445			var accesstoken = $(this).data('accesstoken'),
1446				userid = $(this).data('userid'),
1447				title = $(this).data('title'),
1448				num_photos = $(this).data('numitems');
1449			if(accesstoken && userid && title && num_photos) {
1450				jQuery.ajax({
1451					url: ozy_headerType.$OZY_WP_AJAX_URL,
1452					data: { action: 'sunway_ajax_instagram', request_user_id : userid, request_access_token : accesstoken, request_title : title, request_num_photos : num_photos},
1453					cache: false,
1454					success: function(data) {
1455						$(element).append(data);
1456					},
1457					error: function(MLHttpRequest, textStatus, errorThrown){
1458						alert(errorThrown);
1459					}
1460				});
1461			}
1462		});
1463
1464		/* Fancy Blog List */
1465		$('.ozy-fancyaccordion-feed tr.title').on("click", function(e){
1466			e.preventDefault();
1467			if($(this).hasClass('open')) {
1468				$(this).next('tr.excerpt').find('td>div').hide(200, function() {
1469					$(this).parent().slideUp(100);
1470				});
1471			}else{
1472				$(this).next('tr.excerpt').find('td').show(200, function() {
1473					$(this).find('div').slideDown(100);
1474				});
1475			}
1476			$(this).toggleClass('open');
1477		});
1478
1479		/* Facebook Widget */
1480		jQuery('.ozy-facebook_widget:not(.error)').each(function(index, element) {
1481			jQuery.ajax({url:"https://graph.facebook.com/"+ jQuery(element).data("username") +"/feed?access_token="+ ozy_facebookWidget.facebook_app_id +"&fields=picture,full_picture,message,created_time", success: function (r) {
1482				var html = "", item;
1483				for (var i = 0; i < jQuery(element).data('count'); i++) {
1484					item = r.data[i];
1485					html = html + '<div class="item">';
1486					var d = new Date(item.created_time);
1487					html = html + '<h3 class="content-color-alternate2 content-font-family">' + d.dateFormat(jQuery(element).data('date_format')) + '</h3>';
1488					html = html + '<p>' + item.message + '</p>';
1489					html = html + '</div>';
1490				}
1491				jQuery(element).removeClass('loading').html(jQuery(element).html() + html);
1492			},error: function(e) {
1493				console.log(e);
1494			}});
1495		});
1496
1497		/* Weather Widget */
1498		if ($('.weather-widget').length) {
1499			function titleCase(str) {
1500				return str.split(' ').map(function (word) {
1501					return word[0].toUpperCase() + word.substring(1);
1502				}).join(' ');
1503			}
1504
1505			function fullDay(str) {
1506				switch (str) {
1507					case 'Tue':
1508						return 'Tuesday';
1509					case 'Wed':
1510						return 'Wednesday';
1511					case 'Thu':
1512						return 'Thursday';
1513					case 'Sat':
1514						return 'Saturday';
1515					default:
1516						return str + 'day';
1517				}
1518			}
1519
1520			$(function () {
1521				var $wrapper = $('.weather-widget'),
1522					$request_city = $wrapper.data('city'),
1523					$request_city_id = $wrapper.data('cityid'),
1524					$request_lang = $wrapper.data('lang'),
1525					$city = $wrapper.find('#city'),
1526					$city_id = $wrapper.find('#city_id'),
1527					$loading = $wrapper.find('.loading'),
1528					$weather = $wrapper.find('.weather'),
1529					$group = $wrapper.find('.group'),
1530					$dt = $group.find('#dt'),
1531					$description = $group.find('#description'),
1532					$wind = $group.find('#wind'),
1533					$humidity = $group.find('#humidity'),
1534					$temperature = $weather.find('#temperature'),
1535					$temp = $temperature.find('#temp'),
1536					$icon = $temp.find('#condition'),
1537					$tempNumber = $temp.find('#num'),
1538					$celsius = $temp.find('#celsius'),
1539					$fahrenheit = $temp.find('#fahrenheit'),
1540					$forecast = $weather.find('#forecast');
1541
1542				function getWeather() {
1543
1544					var requestWeather = $.ajax({
1545						dataType: 'json',
1546						url: ozy_headerType.$OZY_WP_AJAX_URL,
1547						data: {
1548							action: 'sunway_ajax_weather',
1549							request_city: $request_city,
1550							request_city_id: $request_city_id,
1551							request_lang: $request_lang,
1552							request_type: '1'
1553						}
1554					});
1555
1556					var requestForecast = $.ajax({
1557						dataType: 'json',
1558						url: ozy_headerType.$OZY_WP_AJAX_URL,
1559						data: {
1560							action: 'sunway_ajax_weather',
1561							request_city: $request_city,
1562							request_city_id: $request_city_id,
1563							request_lang: $request_lang,
1564							request_type: '2'
1565						}
1566					});
1567
1568					$fahrenheit.addClass('active').removeAttr('href');
1569					$celsius.removeClass('active').attr("href", '#');
1570					$icon.removeClass();
1571
1572					requestWeather.done(function (data) {
1573						if("error" in data) { console.info(data.error);return; }
1574
1575						var dt = new Date(data.dt * 1000).toString().split(' ');
1576						var title;
1577						if (typeof data.sys.country !== "undefined"){
1578							title = data.sys.country ?
1579								data.name + ', ' + data.sys.country :
1580								data.name;
1581						}else{
1582							title = data.name;
1583						}
1584
1585						$city.html(title);
1586						$tempNumber.html(Math.round(data.main.temp));
1587						$description.html(titleCase(data.weather[0].description));
1588						$wind.html('Wind: ' + data.wind.speed + ' mph');
1589						$humidity.html('Humidity ' + data.main.humidity + '%');
1590						$dt.html(fullDay(dt[0]) + ' ' + dt[4].substring(0, 5));
1591
1592						$celsius.on('click', toCelsius).click();
1593						$fahrenheit.on('click', toFahrenheit);
1594
1595						function toCelsius() {
1596							$(this).addClass('active').removeAttr('href');
1597							$fahrenheit.removeClass('active').attr('href', '#');
1598							$tempNumber.html(Math.round((data.main.temp - 32) * (5 / 9)));
1599							$wind.html('Wind: ' + (data.wind.speed / 0.62137119223733).toFixed(2) + ' km/h');
1600						}
1601
1602						function toFahrenheit() {
1603							$(this).addClass('active').removeAttr('href');
1604							$celsius.removeClass('active').attr("href", '#');
1605							$tempNumber.html(Math.round(data.main.temp));
1606							$wind.html('Wind: ' + data.wind.speed + ' mph');
1607						}
1608
1609						switch (data.weather[0].icon) {
1610							case '01d':
1611								$icon.addClass('wi wi-day-sunny');
1612								break;
1613							case '02d':
1614								$icon.addClass('wi wi-day-sunny-overcast');
1615								break;
1616							case '01n':
1617								$icon.addClass('wi wi-night-clear');
1618								break;
1619							case '02n':
1620								$icon.addClass('wi wi-night-partly-cloudy');
1621								break;
1622						}
1623
1624						switch (data.weather[0].icon.substr(0, 2)) {
1625							case '03':
1626								$icon.addClass('wi wi-cloud');
1627								break;
1628							case '04':
1629								$icon.addClass('wi wi-cloudy');
1630								break;
1631							case '09':
1632								$icon.addClass('wi wi-showers');
1633								break;
1634							case '10':
1635								$icon.addClass('wi wi-rain');
1636								break;
1637							case '11':
1638								$icon.addClass('wi wi-thunderstorm');
1639								break;
1640							case '13':
1641								$icon.addClass('wi wi-snow');
1642								break;
1643							case '50':
1644								$icon.addClass('wi wi-fog');
1645								break;
1646						}
1647					});
1648
1649					requestForecast.done(function (data) {
1650						$loading.remove();
1651
1652						$celsius.on('click', toCelsius);
1653						$fahrenheit.on('click', toFahrenheit);
1654						if (typeof data.list !== "undefined"){
1655							var forecast = [];
1656							var length = data.list.length;
1657							for (var i = 1; i < length; i++) {
1658								forecast.push({
1659									date: new Date(data.list[i].dt * 1000).toString().split(' ')[0],
1660									fahrenheit: {
1661										high: Math.round(data.list[i].temp.max),
1662										low: Math.round(data.list[i].temp.min),
1663									},
1664									celsius: {
1665										high: Math.round((data.list[i].temp.max - 32) * (5 / 9)),
1666										low: Math.round((data.list[i].temp.min - 32) * (5 / 9))
1667									}
1668								});
1669							}
1670						}else{
1671							console.warn('Weather Widget:', data.message);
1672						}
1673
1674						function toCelsius() {
1675							doForecast('celsius');
1676						}
1677
1678						function toFahrenheit() {
1679							doForecast('fahrenheit');
1680						}
1681
1682						function doForecast(unit) {
1683							if (typeof forecast !== "undefined"){
1684								var arr = [];
1685								var length = forecast.length;
1686								for (var i = 0; i < length; i++) {
1687									arr[i] = ("<div class='block'><span class='secondary'>" + forecast[i].date + "</span><span class='high'>" + forecast[i][unit].high + "</span><span class='secondary'>" + forecast[i][unit].low + "</span></div>");
1688								}
1689								$forecast.html(arr.join(''));
1690							}
1691						}
1692
1693						doForecast('celsius');
1694					});
1695				}
1696				getWeather();
1697
1698			});
1699		}
1700	}
1701
1702	ozy_vc_components();
1703
1704	/* FancyBox initialization */
1705	$(".wp-caption>p").on('click', function(){ jQuery(this).prev('a').attr('title', jQuery(this).text()).click(); } ); //WordPress captioned image fix
1706	$(".fancybox, .wp-caption>a, .single-image-fancybox a").fancybox({
1707		beforeLoad: function() {
1708		},
1709		padding : 0,
1710		helpers		: {
1711			title	: { type : 'inside' },
1712			buttons	: {}
1713		}
1714	});
1715	$('.fancybox-media').fancybox({openEffect  : 'none',closeEffect : 'none',helpers : {title	: { type : 'inside' }, media : {}}});
1716
1717	/* Back to top button */
1718	var pxScrolled = 200;
1719	var duration = 500;
1720
1721	$(window).scroll(function() {
1722		$('.sunway-btt-container').show();
1723		if ($(this).scrollTop() > pxScrolled) {
1724			$('.sunway-btt-container').css({'bottom': '20px', 'transition': '.3s'});
1725		} else {
1726			$('.sunway-btt-container').css({'bottom': '-100px'});
1727		}
1728	});
1729
1730	$('.top').on("click", function() {
1731		$('body,html').animate({scrollTop: 0}, duration);
1732	});
1733
1734	/* Menu Card */
1735	if($('.ozy-menu-item-card[data-popimg]').length) {
1736		$('.ozy-menu-item-card[data-popimg]>div').on("click", function(e) {
1737			e.preventDefault();
1738
1739			var $this = $(this).parents('div.ozy-menu-item-card');
1740
1741			if($this.data('popimg')) {
1742				var downloadingImage = new Image();
1743				downloadingImage.onload = function(){
1744					$.fancybox({
1745						maxWidth:940,
1746						padding:0,
1747						scrolling:'no',
1748						'content' : '<div id="ozy-menu-card-popup" class="content-font"><div>' + '<img src="' + this.src + '"/>' + '<h2 class="heading-font">' + $this.find('.item-name').html() + '</h2>' + $this.find('.item-popup-content').html() + '</div></div>',
1749						afterShow: function() {
1750							if(!ozyCheckFirefox()) {
1751								$('#ozy-menu-card-popup>div').niceScroll({autohidemode:"false", cursorwidth: "5px", cursorcolor: jQuery('.menu-circle').css('border-color'), cursorborder: "none"});
1752							}else{
1753								$('#ozy-menu-card-popup>div').css('overflow-y', 'scroll');
1754							}
1755							$('#ozy-menu-card-popup>div').scrollLock();
1756						}
1757					});
1758				};
1759
1760				downloadingImage.src = $this.data('popimg');
1761			}else{
1762
1763				$.fancybox({
1764					maxWidth:940,
1765					padding:0,
1766					scrolling:'no',
1767					'content' : '<div id="ozy-menu-card-popup" class="content-font"><div><h2 class="heading-font">' + $this.find('.item-name').html() + '</h2>' + $this.find('.item-popup-content').html() + '</div></div>',
1768					afterShow: function() {
1769						if(!ozyCheckFirefox()) {
1770							$('#ozy-menu-card-popup>div').niceScroll({autohidemode:"false", cursorwidth: "5px", cursorcolor: jQuery('.menu-circle').css('border-color'), cursorborder: "none"});
1771						}else{
1772							$('#ozy-menu-card-popup>div').css('overflow-y', 'scroll');
1773						}
1774						$('#ozy-menu-card-popup>div').scrollLock();
1775					}
1776				});
1777
1778			}
1779
1780			return false;
1781		});
1782	}
1783});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.