�����JFIF��XX����������    $.' ",#(7),01444'9=82<.342  2!!22222222222222222222222222222222222222222222222222�����"����4���������������������������� ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������,�PG"Z_�4�˷����kjز�Z�,F+��_z�,�© �����zh6�٨�ic�fu������������������������������������#ډb���_�N��?�����������wQ���5-�~�I���8���������������������������������TK<5o�Iv-������������������k�_U_������������������������������~b�M��d��������Ӝ�U�Hh��?]��E�w��Q���k�{��_}qFW7HTՑ��Y��F�����?_�'ϔ��_�Ջt������������������������=||I �����6�έ"�����D���/[�k�9����Y�8������ds|\���Ҿp6�Ҵ���]��.����6���z<�v��@]�i%������������������������$j��~����g��J>��no����pM[me�i$[�����������s�o�ᘨ�˸ nɜG-�ĨU�ycP���3.DB�li�;���������������������hj���x����7Z^�N�h��������N3u{�:j�����x�힞��#M��&��jL P@��_���� P�������������������&��o8��������9������@Sz���6�t7#O�ߋ �����s}Yf�T������lmr����Z)'N��k�۞p�����w\�T���������������ȯ?�8`���O��i{wﭹW�[�r�� ��Q4F�׊������3m&L�=��h3�������z~��#����\�l :�F,j@�� ʱ�wQT����8�"kJO����6�֚l������������������}����R�>ډK���]��y����&����p�}b������;N�1�m�r$����|��7�>e�@���B�TM*-i�H��g�D�)� E�m�|�ؘbҗ�a���Ҿ����������������t4�����o���G��*oCN�rP���Q��@z,|?W[0���������:�n,j���WiE��W������$~/�hp\��?��{(�0���+�Y8rΟ�+����>S-S���������������VN;���}�s?.����� w��9��˟<���Mq4�Wv'������{)0�1mB����V����W[��������8�/<� �%���wT^�5���b��)iM� p�g�N�&ݝ������������VO~��q���u���9��� ����!��J27�����$����O-���! �:���%H��� ـ�������y�ΠM=t{!S�� �oK8�������t<����è��������:a��������[������ա�H���~��w��Qz`�p����o�^ ������Q��n����� �,uu�C��$ ^���,�������8�#��:�6��e�|~�����������!�3��3.�\0�����q��o�4`.|� ����y�Q�`~;�d�ׯ,��O�Zw�������`73�v�܋�<�����Ȏ�� ـ4k��5�K�a�u�=9Yd��$>x�A�&�� j0� ���vF��� Y���|�y��� ~�6�@c��1vOp��������Ig�����4��l�OD�����L����� R���c���j�_�uX�6��3?nk��Wy�f;^*B� ��@���~a�`��Eu�������+�����6�L��.ü>��}y���}_�O�6�͐�:�Yr���G�X��kG������l^w����������~㒶sy���Iu�!���� W ��X��N�7BV��O��!X�2����wvG�R�f�T#�����t�/?���%8�^�W�aT����G�cL�M���I��(J����1~�8�?aT ���]����AS�E��(��*E}� 2������#I/�׍qz��^t�̔���������b�Yz4x����t�){ OH�����+(E��A&�N�������XT��o��"�XC����'���)}�J�z�p� ����~5�}�^����+�6����w��c��Q�|�Lp�d�H��}�(�.|����k��c4^�����"�����Z?ȕ ��a<�������L�!0�39C� �Eu�����C�F�Ew�ç ;�n?�*o���B�8�bʝ���'#Rqf����M}7����]�������s2tcS{�\icTx;�\��7K���P������ʇ Z O-��~�������c>"��?��������P�����E��O�8��@�8��G��Q�g�a�Վ���󁶠��䧘��_%#r�>�����1�z�a���eb��qcP��ѵ��n���#L��� =��׀t� L�7�`�����V����A{�C:�g���e@�����w1 Xp�3�c3�ġ�������p��M"'-�@n4���fG���B3�DJ�8[Jo�ߐ���gK)ƛ��$���� �������8�3�����+���� �����6�ʻ���� ���S�kI�*KZlT _`�������?��K�����QK�d���������B`�s}�>���`������*�>��,*@J�d�oF*�����弝��O}�k��s��]��y�ߘ�������c1G�V���<=�7��7����6��q�PT��tXԀ�!9*4�4Tހ���3XΛex�46�������Y��D ����� ����BdemDa����\�_l,����G�/���֌7���Y�](�xTt^%�GE�����4�}bT����ڹ�����;��Y)���B�Q��u��>J/J ���⮶.�XԄ��j�ݳ������+E��d ���r�5�_D�����1 ���o�� �B�x�΢�#����<��W�����8���R6�@���g�M�.��� dr�D��>(otU��@�x=��~v���2� ӣ�d�oBd�����3�eO�6�㣷����������ݜ�6��6Y��Qz`����S��{���\P��~z m5{J/L��1������<�e�ͅPu���b�]�ϔ��������'�������f�b� Zpw��c`"��i���BD@:)ִ�:�]��h���v�E��w���T�l�������P����"Ju�}��وV ��J��G6��. J/�Qgl߭�e�����@�z�Zev2u����)]կ���������7x�������s�M�-<ɯ�c��r��v�����@��$�ޮ}lk���a����'����>x��O\�Z������Fu>������ck#��&:��`�$��ai�>2Δ����l���oF[h�������lE�ܺ�Π���k:)���`������� $[6�����9�����kOw�\|�����8}������ބ:��񶐕��������I�A1/���=�2[�,�!��.}gN#�u����b���� ~���������݊��}34q�����d�E��L��������c��$���"�[q�U�硬g^��%B ��z���r�p�������J�ru%v\h�����1Y�ne`������ǥ:g����pQM~�^��Xi� ��`S�:V2������9.�P���V������?B�k�� ��������AEvw%�_�9C�Q����wKekP�ؠ�\������;Io d�{ ߞo�c1eP�����\� `����E=���@K<�Y��������eڼ�J����w����{av�F�'�M�@��������������/J��+9p����|]���������Iw &`���8���&�M�hg���[�{�������Xj���%��Ӓ�������������������$��(�����ʹN�������<>�I���RY�����K2�NPlL�ɀ�)��&e��������B+ь����(������������������� � �JTx����_?EZ� }@���� 6�U���뙢ط�z��dWI��n` D����噥�[��uV��"�G&�����Ú����2�g�}&m���������������������?ċ���"����Om#�������������������������� ��{���������������������ON��"S�X���Ne��ysQ���@�������������Fn��Vg�����dX�~nj����������������������]J�<�K]:����FW���b�������62����������=��5f����JKw����bf�X������������������������55��~J �%^�������:�-�QIE��P��v�nZum� z � ~ə ���� ���ة����;�f��\v�������g�8�1��f2�������������������������4;�V���ǔ�)�������������������9���1\������������������������������c��v�/'Ƞ�w������������������$�4�R-��t����������������������������������� e�6�/�ġ �̕Ecy�J���u�B���<�W�ַ~�w[B1L۲�-JS΂�{���΃�������������������������������������������A��20�c#���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������@���� 0!1@AP"#2Q`$3V�%45a6�FRUq����� ������^7ׅ,$n��������+��F�`��2X'��0vM��p�L=�������5��8������u�p~���.�`r�����\����O��,ư�0oS ��_�M�����l���4�kv\JSd���x���SW�<��Ae�IX����������$I���w�:S���y���›R��9�Q[���,�5�;�@]�%���u�@ *ro�lbI �� ��+���%m:�͇ZV�����u�̉����θau<�fc�.����{�4Ա� �Q����*�Sm��8\ujqs]{kN���)qO�y�_*dJ�b�7���yQqI&9�ԌK!�M}�R�;�������S�T���1���i[U�ɵz�]��U)V�S6���3$K{��ߊ<�(� E]Զ[ǼENg�����'�\?#)Dkf��J���o��v���'�%ƞ�&K�u��!��b�35LX�Ϸ��63$K�a�;�9>,R��W��3�3� d�JeTYE.Mϧ��-�o�j3+y��y^�c�������VO�9NV\nd�1 ��!͕_)a�v;����թ�M�lWR1��)El��P;��yوÏ�u 3�k�5Pr6<�⒲l�!˞*��u־�n�!�l:����UNW ��%��Chx8vL'��X�@��*��)���̮��ˍ��� ����D-M�+J�U�kvK����+�x8��cY������?�Ԡ��~3mo��|�u@[XeY�C�\Kp�x8�oC�C�&����N�~3-H���� ��MX�s�u<`���~"WL��$8ξ��3���a�)|:@�m�\���^�`�@ҷ)�5p+��6���p�%i)P M���ngc�����#0Aruz���RL+xSS?���ʮ}()#�t��mˇ!��0}}y����<�e� �-ή�Ԩ��X������ MF���ԙ~l L.3���}�V뽺�v������멬��Nl�)�2����^�Iq��a��M��qG��T�����c3#������3U�Ǎ���}��לS�|qa��ڃ�+���-��2�f����/��bz��ڐ�� �ݼ[2�ç����k�X�2�* �Z�d���J�G����M*9W���s{��w���T��x��y,�in�O�v��]���n����P�$��JB@=4�OTI�n��e�22a\����q�d���%�$��(���:���: /*�K[PR�fr\nڙdN���F�n�$�4��[�� U�zƶ����� �mʋ���,�ao�u 3�z� �x��Kn����\[��VFmbE;�_U��&V�Gg�]L�۪&#n%�$ɯ��dG���D�TI=�%+AB�Ru#��b4�1�»x�cs�YzڙJG��f��Il���d�eF'T� iA��T���uC�$����Y��H?����[!G`}���ͪ� �纤Hv\������j�Ex�K���!���OiƸ�Yj�+u-<���'q����uN�*�r\��+�]���<�wOZ.fp�ێ��,-*)V?j-kÊ#�`�r��dV����(�ݽBk�����G�ƛk�QmUڗe��Z���f}|����8�8��a���i��3'J�����~G_�^���d�8w������ R�`(�~�.��u���l�s+g�bv���W���lGc}��u���afE~1�Ue������Z�0�8�=e�� f@/�jqEKQQ�J���oN��J���W5~M>$6�Lt�;$ʳ{���^��6�{����v6���ķܰg�V�cnn �~z�x�«�,2�u�?cE+Ș�H؎�%�Za�)���X>uW�Tz�Nyo����s���FQƤ��$��*�&�LLXL)�1�" L��eO��ɟ�9=���:t��Z���c��Ž���Y?�ӭV�wv�~,Y��r�ۗ�|�y��GaF�����C�����.�+� ���v1���fήJ�����]�S��T��B��n5sW}y�$��~z�'�c ��8 ��� ,! �p��VN�S��N�N�q��y8z˱�A��4��*��'������2n<�s���^ǧ˭P�Jޮɏ�U�G�L�J�*#��<�V��t7�8����TĜ>��i}K%,���)[��z�21z ?�N�i�n1?T�I�R#��m-�����������������1����lA�`��fT5+��ܐ�c�q՝��ʐ��,���3�f2U�եmab��#ŠdQ�y>\��)�SLY����w#��.���ʑ�f��� ,"+�w�~�N�'�c�O�3F�������N<���)j��&��,-� �љ���֊�_�zS���TǦ����w�>��?�������n��U仆�V���e�����0���$�C�d���rP �m�׈e�Xm�Vu� �L��.�bֹ��� �[Դaզ���*��\y�8�Է:�Ez\�0�Kq�C b��̘��cө���Q��=0Y��s�N��S.����3.���O�o:���#���v7�[#߫ ��5�܎�L���Er4���9n��COWlG�^��0k�%<���ZB���aB_���������'=��{i�v�l�$�uC���mƎҝ{�c㱼�y]���W�i ��ߧc��m�H� m�"�"�����;Y�ߝ�Z�Ǔ�����:S#��|}�y�,/k�Ld� TA�(�AI$+I3��;Y*���Z��}|��ӧO��d�v��..#:n��f>�>���ȶI�TX��� 8��y����"d�R�|�)0���=���n4��6ⲑ�+��r<�O�܂~zh�z����7ܓ�HH�Ga롏���nCo�>������a ���~]���R���̲c?�6(�q�;5%� |�uj�~z8R�=X��I�V=�|{v�Gj\gc��q����z�؋%M�ߍ����1y��#��@f^���^�>N������#x#۹��6�Y~�?�dfPO��{��P�4��V��u1E1J �*|���%����JN��`eWu�zk M6���q t[�� ��g�G���v��WIG��u_ft����5�j�"�Y�:T��ɐ���*�;� e5���4����q$C��2d�}���� _S�L#m�Yp��O�.�C�;��c����Hi#֩%+) �Ӎ��ƲV���SYź��g |���tj��3�8���r|���V��1#;.SQ�A[���S������#���`n�+���$��$�I �P\[�@�s��(�ED�z���P��])8�G#��0B��[ى��X�II�q<��9�~[Z멜�Z�⊔IWU&A>�P~�#��dp<�?����7���c��'~���5 ��+$���lx@�M�dm��n<=e�dyX��?{�|Aef ,|n3�<~z�ƃ�uۧ�����P��Y,�ӥQ�*g�#먙R�\���;T��i,��[9Qi歉����c>]9�� ��"�c��P�� �Md?٥��If�ت�u��k��/����F��9�c*9��Ǎ:�ØF���z�n*�@|I�ށ9����N3{'��[�'ͬ�Ҳ4��#}��!�V� Fu��,�,mTIk���v C�7v���B�6k�T9��1�*l� '~��ƞF��lU��'�M ����][ΩũJ_�{�i�I�n��$����L�� j��O�dx�����kza۪��#�E��Cl����x˘�o�����V���ɞ�ljr��)�/,�߬h�L��#��^��L�ф�,íMƁe�̩�NB�L�����iL����q�}��(��q��6IçJ$�W�E$��:������=#����(�K�B����zђ <��K(�N�۫K�w��^O{!����)��H���>x�������lx�?>Պ�+�>�W���,Ly!_�D���Ō�l���Q�!�[ �S����J��1��Ɛ�Y}��b,+�Lo�x�ɓ)����=�y�oh�@�꥟/��I��ѭ=��P�y9��� �ۍYӘ�e+�p�Jnϱ?V\SO%�(�t� ���=?MR�[Ș�����d�/ ��n�l��B�7j� ��!�;ӥ�/�[-���A�>��dN�sLj ��,ɪv��=1c�.SQ�O3�U���ƀ�ܽ�E����������̻��9G�ϷD�7(�}��Ävӌ\��y�_0[w ���<΍>����a_��[0+�L��F.�޺��f�>oN�T����q;���y\��bՃ��y�jH�<|q-eɏ�_?_9+P���Hp$�����[ux�K w�Mw��N�ی'$Y2�=��q���KB��P��~�������Yul:�[<����F1�2�O���5=d����]Y�sw:���Ϯ���E��j,_Q��X��z`H1,#II ��d�wr��P˂@�ZJV����y$�\y�{}��^~���[:N����ߌ�U�������O��d�����ؾe��${p>G��3c���Ė�lʌ�� ת��[��`ϱ�-W����dg�I��ig2��� ��}s ��ؤ(%#sS@���~���3�X�nRG�~\jc3�v��ӍL��M[JB�T��s3}��j�Nʖ��W����;7���ç?=X�F=-�=����q�ߚ���#���='�c��7���ڑW�I(O+=:uxq�������������e2�zi+�kuG�R��������0�&e�n���iT^J����~\jy���p'dtG��s����O��3����9* �b#Ɋ�� p������[Bws�T�>d4�ۧs���nv�n���U���_�~,�v����ƜJ1��s�� �QIz���)�(lv8M���U=�;����56��G���s#�K���MP�=��LvyGd��}�VwWBF�'�à �?MH�U�g2�� ����!�p�7Q��j��ڴ����=��j�u��� Jn�A s���uM������e��Ɔ�Ҕ�!)�'��8Ϣ�ٔ���ޝ(��Vp���צ֖d=�IC�J�Ǡ{q������kԭ�߸���i��@K����u�|�p=..�*+����x�����z[Aqġ#s2a�Ɗ���RR�)*HRsi�~�a &f��M��P����-K�L@��Z��Xy�'x�{}��Zm+���:�)�) IJ�-i�u���� ���ܒH��'��L(7�y�GӜq���� j��� 6ߌg1�g�o���,kر���tY�?W,���p���e���f�OQS��!K�۟cҒA�|ս�j�>��=⬒��˧L[�� �߿2JaB~R��u�:��Q�] �0H~���]�7��Ƽ�I���(�}��cq '�ήET���q�?f�ab���ӥvr� �)o��-Q��_'����ᴎo��K������;��V���o��%���~OK ����*��b�f:���-ťIR��`B�5!RB@���ï�� �u �̯e\�_U�_������� g�ES��3��������QT��a�����x����U<~�c?�*�#]�MW,[8O�a�x��]�1bC|踤�P��lw5V%�)�{t�<��d��5���0i�XSU��m:��Z�┵�i�"��1�^B�-��P�hJ��&)O��*�D��c�W��vM��)����}���P��ܗ-q����\mmζZ-l@�}��a��E�6��F�@��&Sg@���ݚ�M����� ȹ 4����#p�\H����dYDo�H���"��\��..R�B�H�z_�/5˘����6��KhJR��P�mƶi�m���3��,#c�co��q�a)*P�t����R�m�k�7x�D�E�\Y�閣_X�<���~�)���c[[�BP����6�Yq���S��0����%_����;��Àv�~�| VS؇ ��'O0��F0��\���U�-�d@�����7�SJ*z��3n��y��P����O����������m�~�P�3|Y��ʉr#�C�<�G~�.,! ���bqx���h~0=��!ǫ�jy����l��O,�[B��~��|9��ٱ����Xly�#�i�B��g%�S��������tˋ���e���ې��\[d�t)��.+u�|1 ������#�~Oj����hS�%��i.�~X���I�H�m��0n���c�1uE�q��cF�RF�o���7� �O�ꮧ� ���ۛ{��ʛi5�rw?׌#Qn�TW��~?y$��m\�\o����%W� ?=>S�N@�� �Ʈ���R����N�)�r"C�:��:����� �����#��qb��Y�. �6[��2K����2u�Ǧ�HYR��Q�MV��� �G�$��Q+.>�����nNH��q�^��� ����q��mM��V��D�+�-�#*�U�̒ ���p욳��u:�������IB���m����PV@O���r[b= �� ��1U�E��_Nm�yKbN�O���U�}�the�`�|6֮P>�\2�P�V���I�D�i�P�O;�9�r�mAHG�W�S]��J*�_�G��+kP�2����Ka�Z���H�'K�x�W�MZ%�O�YD�Rc+o��?�q��Ghm��d�S�oh�\�D�|:W������UA�Qc yT�q��������~^�H��/��#p�CZ���T�I�1�ӏT����4��"�ČZ�����}��`w�#�*,ʹ�� ��0�i��課�Om�*�da��^gJ݅{���l�e9uF#T�ֲ��̲�ٞC"�q���ߍ ոޑ�o#�XZTp����@ o�8��(jd��xw�]�,f���`~��|,s��^����f�1���t��|��m�򸄭/ctr��5s��7�9Q�4�H1꠲BB@�l9@���C�����+�wp�xu�£Yc�9��?`@#�o�mH�s2��)�=��2�.�l����jg�9$�Y�S�%*L������R�Y������7Z���,*=�䷘$�������arm�o�ϰ���UW.|�r�uf����IGw�t����Zwo��~5 ��YյhO+=8fF�)�W�7�L9lM�̘·Y���֘YLf�큹�pRF���99.A �"wz��=E\Z���'a� 2��Ǚ�#;�'}�G���*��l��^"q��+2FQ� hj��kŦ��${���ޮ-�T�٭cf�|�3#~�RJ����t��$b�(R��(����r���dx� >U b�&9,>���%E\� Ά�e�$��'�q't��*�א���ެ�b��-|d���SB�O�O��$�R+�H�)�܎�K��1m`;�J�2�Y~9��O�g8=vqD`K[�F)k�[���1m޼c��n���]s�k�z$@��)!I �x՝"v��9=�ZA=`Ɠi �:�E��)`�7��vI��}d�YI�_ �o�:ob���o ���3Q��&D&�2=�� �Ά��;>�h����y.*ⅥS������Ӭ�+q&����j|UƧ�����}���J0��WW< ۋS�)jQR�j���Ư��rN)�Gű�4Ѷ(�S)Ǣ�8��i��W52���No˓� ۍ%�5brOn�L�;�n��\G����=�^U�dI���8$�&���h��'���+�(������cȁ߫k�l��S^���cƗjԌE�ꭔ��gF���Ȓ��@���}O���*;e�v�WV���YJ\�]X'5��ղ�k�F��b 6R�o՜m��i N�i�����>J����?��lPm�U��}>_Z&�KK��q�r��I�D�Չ~�q�3fL�:S�e>���E���-G���{L�6p�e,8��������QI��h��a�Xa��U�A'���ʂ���s�+טIjP�-��y�8ۈZ?J$��W�P� ��R�s�]��|�l(�ԓ��sƊi��o(��S0���Y� 8�T97.�����WiL��c�~�dxc�E|�2!�X�K�Ƙਫ਼�$((�6�~|d9u+�qd�^3�89��Y�6L�.I�����?���iI�q���9�)O/뚅����O���X��X�V��ZF[�یgQ�L��K1���RҖr@v�#��X�l��F���Нy�S�8�7�kF!A��sM���^rkp�jP�DyS$N���q���nxҍ!U�f�!eh�i�2�m����`�Y�I�9r�6� �TF���C}/�y�^���Η���5d�'��9A-��J��>{�_l+�`��A���[�'��յ�ϛ#w:݅�%��X�}�&�PSt�Q�"�-��\縵�/����$Ɨh�Xb�*�y��BS����;W�ջ_mc�����vt?2}1�;qS�d�d~u:2k5�2�R�~�z+|HE!)�Ǟl��7`��0�<�,�2*���Hl-��x�^����'_TV�gZA�'j� ^�2Ϊ��N7t�����?w�� �x1��f��Iz�C-Ȗ��K�^q�;���-W�DvT�7��8�Z�������� hK�(P:��Q- �8�n�Z���܃e貾�<�1�YT<�,�����"�6{�/ �?�͟��|1�:�#g��W�>$����d��J��d�B���=��jf[��%rE^��il:��B���x���Sּ�1հ��,�=��*�7 fcG��#q� �eh?��2�7�����,�!7x��6�n�LC�4x��},Geǝ�tC.��vS �F�43��zz\��;QYC,6����~;RYS/6���|2���5���v��T��i����������mlv��������&� �nRh^ejR�LG�f���? �ۉҬܦƩ��|��Ȱ����>3����!v��i�ʯ�>�v��オ�X3e���_1z�Kȗ\<������!�8���V��]��?b�k41�Re��T�q��mz��TiOʦ�Z��Xq���L������q"+���2ۨ��8}�&N7XU7Ap�d�X��~�׿��&4e�o�F��� �H�����O���č�c�� 懴�6���͉��+)��v;j��ݷ�� �UV�� i��� j���Y9GdÒJ1��詞�����V?h��l�����l�cGs�ځ�������y�Ac������\V3�? �� ܙg�>qH�S,�E�W�[�㺨�uch�⍸�O�}���a��>�q�6�n6�����N6�q��������N� ���! 1AQaq�0@����"2BRb�#Pr���3C`��Scst���$4D���%Td���� ?�����N����a��3��m���C���w��������xA�m�q�m����m������$����4n淿t'��C"w��zU=D�\R+w�p+Y�T�&�պ@��ƃ��3ޯ?�Aﶂ��aŘ���@-�����Q�=���9D��ռ�ѻ@��M�V��P��܅�G5�f�Y<�u=,EC)�<�Fy'�"�&�չ�X~f��l�KԆV��?�� �W�N����=(� �;���{�r����ٌ�Y���h{�١������jW����P���Tc�����X�K�r��}���w�R��%��?���E��m�� �Y�q|����\lEE4����r���}�lsI�Y������f�$�=�d�yO����p�����yBj8jU�o�/�S��?�U��*������ˍ�0�������u�q�m [�?f����a�� )Q�>����6#������� ?����0UQ����,IX���(6ڵ[�DI�MNލ�c&���υ�j\��X�R|,4��� j������T�hA�e��^���d���b<����n�� �즇�=!���3�^�`j�h�ȓr��jẕ�c�,ٞX����-����a�ﶔ���#�$��]w�O��Ӫ�1y%��L�Y<�wg#�ǝ�̗`�x�xa�t�w��»1���o7o5��>�m뭛C���Uƃߜ}�C���y1Xνm�F8�jI���]����H���ۺиE@I�i;r�8ӭ�����V�F�Շ| ��&?�3|x�B�MuS�Ge�=Ӕ�#BE5G������Y!z��_e��q�р/W>|-�Ci߇�t�1ޯќd�R3�u��g�=0 5��[?�#͏��q�cf���H��{ ?u�=?�?ǯ���}Z��z���hmΔ�BFTW�����<�q��(v� ��!��z���iW]*�J�V�z��gX֧A�q�&��/w���u�gYӘa���; �i=����g:��?2�dž6�ى�k�4�>�Pxs����}������G�9���3 ���)gG�R<>r h�$��'nc�h�P��Bj��J�ҧH� -��N1���N��?��~��}-q!=��_2hc�M��l�vY%UE�@|�v����M2�.Y[|y�"Eï��K�ZF,�ɯ?,q�?v�M 80jx�"�;�9vk�����+ ֧�� �ȺU��?�%�vcV��mA�6��Qg^M�����A}�3�nl� QRN�l8�kkn�'�����(��M�7m9و�q���%ޟ���*h$Zk"��$�9��: �?U8�Sl��,,|ɒ��xH(ѷ����Gn�/Q�4�P��G�%��Ա8�N��!� �&�7�;���eKM7�4��9R/%����l�c>�x;������>��C�:�����t��h?aKX�bhe�ᜋ^�$�Iհ �hr7%F$�E��Fd���t��5���+�(M6�t����Ü�UU|zW�=a�Ts�Tg������dqP�Q����b'�m���1{|Y����X�N��b �P~��F^F:����k6�"�j!�� �I�r�`��1&�-$�Bevk:y���#y�w��I0��x��=D�4��tU���P�ZH��ڠ底taP��6����b>�xa�����Q�#� WeF��ŮNj�p�J* mQ�N�����*I�-*�ȩ�F�g�3 �5��V�ʊ�ɮ�a��5F���O@{���NX��?����H�]3��1�Ri_u��������ѕ�� ����0��� F��~��:60�p�͈�S��qX#a�5>���`�o&+�<2�D����: �������ڝ�$�nP���*)�N�|y�Ej�F�5ټ�e���ihy�Z �>���k�bH�a�v��h�-#���!�Po=@k̆IEN��@��}Ll?j�O������߭�ʞ���Q|A07x���wt!xf���I2?Z��<ץ�T���cU�j��]���陎Ltl �}5�ϓ��$�,��O�mˊ�;�@O��jE��j(�ا,��LX���LO���Ц�90�O �.����a��nA���7������j4 ��W��_ٓ���zW�jcB������y՗+EM�)d���N�g6�y1_x��p�$Lv�:��9�"z��p���ʙ$��^��JԼ*�ϭ����o���=x�Lj�6�J��u82�A�H�3$�ٕ@�=Vv�]�'�qEz�;I˼��)��=��ɯ���x �/�W(V���p�����$ �m�������u�����񶤑Oqˎ�T����r��㠚x�sr�GC��byp�G��1ߠ�w e�8�$⿄����/�M{*}��W�]˷.�CK\�ުx���/$�WP�w���r� |i���&�}�{�X� �>��$-��l���?-z���g����lΆ���(F���h�vS*���b���߲ڡn,|)mrH[���a�3�ר�[1��3o_�U�3�TC�$��(�=�)0�kgP���� ��u�^=��4 �WYCҸ:��vQ�ר�X�à��tk�m,�t*��^�,�}D*�� �"(�I��9R����>`�`��[~Q]�#af��i6l��8���6�:,s�s�N6�j"�A4���IuQ��6E,�GnH��zS�HO�uk�5$�I�4��ؤ�Q9�@��C����wp��BGv[]�u�Ov����0I4���\��y�����Q�Ѹ��~>Z��8�T��a��q�ޣ;z��a���/��S��I:�ܫ_�|������>=Z����8:�S��U�I�J��"IY���8%b8���H��:�QO�6�;7�I�S��J��ҌAά3��>c���E+&jf$eC+�z�;��V����� �r���ʺ������my�e���aQ�f&��6�ND���.:��NT�vm�<- u���ǝ\MvZY�N�NT��-A�>jr!S��n�O 1�3�Ns�%�3D@���`������ܟ 1�^c<���� �a�ɽ�̲�Xë#�w�|y�cW�=�9I*H8�p�^(4���՗�k��arOcW�tO�\�ƍR��8����'�K���I�Q�����?5�>[�}��yU�ײ -h��=��% q�ThG�2�)���"ו3]�!kB��*p�FDl�A���,�eEi�H�f�Ps�����5�H:�Փ~�H�0Dت�D�I����h�F3�������c��2���E��9�H��5�zԑ�ʚ�i�X�=:m�xg�hd(�v����׊�9iS��O��d@0ڽ���:�p�5�h-��t�&���X�q�ӕ,��ie�|���7A�2���O%P��E��htj��Y1��w�Ѓ!����  ���� ࢽ��My�7�\�a�@�ţ�J ��4�Ȼ�F�@o�̒?4�wx��)��]�P��~�����u�����5�����7X ��9��^ܩ�U;Iꭆ 5 �������eK2�7(�{|��Y׎ �V��\"���Z�1� Z�����}��(�Ǝ"�1S���_�vE30>���p;� ΝD��%x�W�?W?v����o�^V�i�d��r[��/&>�~`�9Wh��y�;���R���� ;;ɮT��?����r$�g1�K����A��C��c��K��l:�'��3 c�ﳯ*"t8�~l��)���m��+U,z��`(��>yJ�?����h>��]��v��ЍG*�{`��;y]��I�T� ;c��NU�fo¾h���/$���|NS���1�S�"�H��V���T���4��uhǜ�]�v;���5�͠x��'C\�SBpl���h}�N����� A�Bx���%��ޭ�l��/����T��w�ʽ]D�=����K���ž�r㻠l4�S�O?=�k �M:� ��c�C�a�#ha���)�ѐxc�s���gP�iG���{+���x���Q���I= �� z��ԫ+ �8"�k�ñ�j=|����c ��y��CF��/���*9ж�h{ �?4�o� ��k�m�Q�N�x��;�Y��4膚�a�w?�6�>�e]�����Q�r�:����g�,i"�����ԩA��*M�<�G��b�if��l^M��5�� �Ҩ�{����6J��ZJ�����P�*�����Y���ݛu�_4�9�I8�7���������,^ToR���m4�H��?�N�S�ѕw��/S��甍�@�9H�S�T��t�ƻ���ʒU��*{Xs�@����f������֒Li�K{H�w^���������Ϥm�tq���s� ���ք��f:��o~s��g�r��ט� �S�ѱC�e]�x���a��) ���(b-$(�j>�7q�B?ӕ�F��hV25r[7 Y� }L�R��}����*sg+��x�r�2�U=�*'WS��ZDW]�WǞ�<��叓���{�$�9Ou4��y�90-�1�'*D`�c�^o?(�9��u���ݐ��'PI&� f�Jݮ�������:wS����jfP1F:X �H�9dԯ����˝[�_54 �}*;@�ܨ�� ð�yn�T���?�ןd�#���4rG�ͨ��H�1�|-#���Mr�S3��G�3�����)�.᧏3v�z֑��r����$G"�`j �1t��x0<Ɔ�Wh6�y�6��,œ�Ga��gA����y��b��)���h�D��ß�_�m��ü �gG;��e�v��ݝ�nQ� ��C����-�*��o���y�a��M��I�>�<���]obD��"�:���G�A��-\%LT�8���c�)��+y76���o�Q�#*{�(F�⽕�y����=���rW�\p���۩�c���A���^e6��K������ʐ�cVf5$�'->���ՉN"���F�"�UQ@�f��Gb~��#�&�M=��8�ט�JNu9��D��[̤�s�o�~������� G��9T�tW^g5y$b��Y'��س�Ǵ�=��U-2 #�MC�t(�i� �lj�@Q 5�̣i�*�O����s�x�K�f��}\��M{E�V�{�υ��Ƈ�����);�H����I��fe�Lȣr�2��>��W��I�Ȃ6������i��k�� �5�YOxȺ����>��Y�f5'��|��H+��98pj�n�.O�y�������jY��~��i�w'������l�;�s�2��Y��:'lg�ꥴ)o#'Sa�a�K��Z� �m��}�`169�n���"���x��I ��*+� }F<��cГ���F�P�������ֹ*�PqX�x۩��,� ��N�� �4<-����%����:��7����W���u�`����� $�?�I��&����o��o��`v�>��P��"��l���4��5'�Z�gE���8���?��[�X�7(��.Q�-��*���ތL@̲����v��.5���[��=�t\+�CNܛ��,g�SQnH����}*F�G16���&:�t��4ُ"A��̣��$�b �|����#rs��a�����T�� ]�<�j��B�S�('$�ɻ� �wP;�/�n��?�ݜ��x�F��yUn�~mL*-�������Xf�wd^�a�}��f�,=t�׵i�.2/wpN�Ep8�OР���•��R�FJ� 55TZ��T �ɭ�<��]��/�0�r�@�f��V��V����Nz�G��^���7hZi����k��3�,kN�e|�vg�1{9]_i��X5y7� 8e]�U����'�-2,���e"����]ot�I��Y_��n�(JҼ��1�O ]bXc���Nu�No��pS���Q_���_�?i�~�x h5d'�(qw52] ��'ޤ�q��o1�R!���`ywy�A4u���h<קy���\[~�4�\ X�Wt/� 6�����n�F�a8��f���z �3$�t(���q��q�x��^�XWeN'p<-v�!�{�(>ӽDP7��ո0�y)�e$ٕv�Ih'Q�EA�m*�H��RI��=:��� ���4牢) �%_iN�ݧ�l]� �Nt���G��H�L��� ɱ�g<���1V�,�J~�ٹ�"K��Q�� 9�HS�9�?@��k����r�;we݁�]I�!{ �@�G�[�"��`���J:�n]�{�cA�E����V��ʆ���#��U9�6����j�#Y�m\��q�e4h�B�7��C�������d<�?J����1g:ٳ���=Y���D�p�ц� ׈ǔ��1�]26؜oS�'��9�V�FVu�P�h�9�xc�oq�X��p�o�5��Ա5$�9W�V(�[Ak�aY錎qf;�'�[�|���b�6�Ck��)��#a#a˙��8���=äh�4��2��C��4tm^ �n'c����]GQ$[Wҿ��i���vN�{Fu ��1�gx��1┷���N�m��{j-,��x�� Ūm�ЧS�[�s���Gna���䑴�� x�p 8<������97�Q���ϴ�v�aϚG��Rt�Һ׈�f^\r��WH�JU�7Z���y)�vg=����n��4�_)y��D'y�6�]�c�5̪��\� �PF�k����&�c;��cq�$~T�7j ���nç]�<�g ":�to�t}�159�<�/�8������m�b�K#g'I'.W������6��I/��>v��\�MN��g���m�A�yQL�4u�Lj�j9��#44�t��l^�}L����n��R��!��t��±]��r��h6ٍ>�yҏ�N��fU�� ���� Fm@�8}�/u��jb9������he:A�y�ծw��GpΧh�5����l}�3p468��)U��d��c����;Us/�֔�YX�1�O2��uq�s��`hwg�r~�{ R��mhN��؎*q 42�*th��>�#���E����#��Hv�O����q�}������6�e��\�,Wk�#���X��b>��p}�դ��3���T5��†��6��[��@��P�y*n��|'f�֧>�lư΂�̺����SU�'*�q�p�_S�����M�� '��c�6������m�� ySʨ;M��r���Ƌ�m�Kxo,���Gm�P��A�G�:��i��w�9�}M(�^�V��$ǒ�ѽ�9���|���� �a����J�SQ�a���r�B;����}���ٻ֢�2�%U���c�#�g���N�a�ݕ�'�v�[�OY'��3L�3�;,p�]@�S��{ls��X�'���c�jw��k'a�.��}�}&�� �dP�*�bK=ɍ!����;3n�gΊU�ߴmt�'*{,=SzfD� A��ko~�G�aoq�_mi}#�m�������P�Xhύ�����mxǍ�΂���巿zf��Q���c���|kc�����?���W��Y�$���_Lv����l߶��c���`?����l�j�ݲˏ!V��6����U�Ђ(A���4y)H���p�Z_�x��>���e���R��$�/�`^'3qˏ�-&Q�=?��CFVR �D�fV�9��{�8g�������n�h�(P"��6�[�D���< E�����~0<@�`�G�6����Hг�cc�� �c�K.5��D��d�B���`?�XQ��2��ٿyqo&+�1^� DW�0�ꊩ���G�#��Q�nL3��c���������/��x ��1�1�[y�x�პCW��C�c�UĨ80�m�e�4.{�m��u���I=��f�����0QRls9���f���������9���~f�����Ǩ��a�"@�8���ȁ�Q����#c�ic������G��$���G���r/$W�(��W���V�"��m�7�[m�A�m����bo��D� j����۳� l���^�k�h׽����� ��#� iXn�v��eT�k�a�^Y�4�BN���ĕ���0������� !01@Q"2AaPq3BR�������?�����@4�Q�����T3,���㺠�W�[=JK�Ϟ���2�r^7��vc�:�9 �E�ߴ�w�S#d���Ix��u��:��Hp��9E!�� V 2;73|F��9Y���*ʬ�F��D����u&���y؟��^EA��A��(ɩ���^��GV:ݜDy�`��Jr29ܾ�㝉��[���E;Fzx��YG��U�e�Y�C���� ����v-tx����I�sם�Ę�q��Eb�+P\ :>�i�C'�;�����k|z�رn�y]�#ǿb��Q��������w�����(�r|ӹs��[�D��2v-%��@;�8<a���[\o[ϧw��I!��*0�krs)�[�J9^��ʜ��p1)� "��/_>��o��<1����A�E�y^�C��`�x1'ܣn�p��s`l���fQ��):�l����b>�Me�jH^?�kl3(�z:���1ŠK&?Q�~�{�ٺ�h�y���/�[��V�|6��}�KbX����mn[-��7�5q�94�������dm���c^���h� X��5��<�eޘ>G���-�}�دB�ޟ� ��|�rt�M��V+�]�c?�-#ڛ��^ǂ}���Lkr���O��u�>�-D�ry� D?:ޞ�U��ǜ�7�V��?瓮�"�#���r��չģVR;�n���/_� ؉v�ݶe5d�b9��/O��009�G���5n�W����JpA�*�r9�>�1��.[t���s�F���nQ� V 77R�]�ɫ8����_0<՜�IF�u(v��4��F�k�3��E)��N:��yڮe��P�`�1}�$WS��J�SQ�N�j��ٺ��޵�#l���ј(�5=��5�lǏmoW�v-�1����v,W�mn��߀$x�<����v�j(����c]��@#��1������Ǔ���o'��u+����;G�#�޸��v-lη��/(`i⣍Pm^����ԯ̾9Z��F��������n��1��� ��]�[��)�'�������:�֪�W��FC����� �B9،!?���]��V��A�Վ�M��b�w��G F>_DȬ0¤�#�QR�[V��kz���m�w�"��9ZG�7'[��=�Q����j8R?�zf�\a�=��O�U����*oB�A�|G���2�54 �p��.w7� �� ���&������ξxGHp� B%��$g�����t�Џ򤵍z���HN�u�Я�-�'4��0���;_���3������� !01"@AQa2Pq#3BR�������?����ʩca��en��^��8���<�u#��m*08r��y�N"�<�Ѳ0��@\�p��� �����Kv�D��J8�Fҽ� �f�Y��-m�ybX�NP����}�!*8t(�OqѢ��Q�wW�K��ZD��Δ^e��!� ��B�K��p~�����e*l}z#9ң�k���q#�Ft�o��S�R����-�w�!�S���Ӥß|M�l޶V��!eˈ�8Y���c�ЮM2��tk���� ������J�fS����Ö*i/2�����n]�k�\���|4yX�8��U�P.���Ы[���l��@"�t�<������5�lF���vU�����W��W��;�b�cД^6[#7@vU�xgZv��F�6��Q,K�v��� �+Ъ��n��Ǣ��Ft���8��0��c�@�!�Zq s�v�t�;#](B��-�nῃ~���3g������5�J�%���O������n�kB�ĺ�.r��+���#�N$?�q�/�s�6��p��a����a��J/��M�8��6�ܰ"�*������ɗud"\w���aT(����[��F��U՛����RT�b���n�*��6���O��SJ�.�ij<�v�MT��R\c��5l�sZB>F��<7�;EA��{��E���Ö��1U/�#��d1�a�n.1ě����0�ʾR�h��|�R��Ao�3�m3 ��%�� ���28Q�� ��y��φ���H�To�7�lW>����#i`�q���c����a��� �m,B�-j����݋�'mR1Ήt�>��V��p���s�0IbI�C.���1R�ea�����]H�6�����������4B>��o��](��$B���m�����a�!=���?�B� K�Ǿ+�Ծ"�n���K��*��+��[T#�{�E�J�S����Q�����s�5�:�U�\wĐ�f�3����܆&�)�����I���Ԇw��E T�lrTf6Q|R�h:��[K�� �z��c֧�G�C��%\��_�a��84��HcO�bi��ؖV��7H �)*ģK~Xhչ0��4?�0��� �E<���}3���#���u�?�� ��|g�S�6ꊤ�|�I#Hڛ� �ա��w�X��9��7���Ŀ%�SL��y6č��|�F�a 8���b���$�sק�h���b9RAu7�˨p�Č�_\*w��묦��F ����4D~�f����|(�"m���NK��i�S�>�$d7SlA��/�²����SL��|6N�}���S�˯���g��]6��; �#�.��<���q'Q�1|KQ$�����񛩶"�$r�b:���N8�w@��8$�� �AjfG|~�9F ���Y��ʺ��Bwؒ������M:I岎�G��`s�YV5����6��A �b:�W���G�q%l�����F��H���7�������Fsv7���k�� 403WebShell
403Webshell
Server IP : 103.30.72.248  /  Your IP : 216.73.216.144
Web Server : Microsoft-IIS/10.0
System : Windows NT WIN-CARKG80MF9A 10.0 build 17763 (Windows Server 2019) AMD64
User : IUSR ( 0)
PHP Version : 8.2.7
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Websites/sanjaymotels.com/wp-content/plugins/photo-gallery/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Websites/sanjaymotels.com/wp-content/plugins/photo-gallery/js/bwg_frontendac45.js
var bwg_param;
var bwg = 0;

var isMobile = (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()));
var bwg_click = isMobile ? 'touchend' : 'click';

/* Slideshow params */
var bwg_params = [];
/* Image browser params */
var bwg_params_ib = [];
/* Carousel params */
var bwg_params_carousel = [];

jQuery.fn.extend({
  hideShow: function (callback) {
    this.checkForVisiblilityChange(callback);
    return this;
  },
  checkForVisiblilityChange: function (callback) {
    if (!(this.length >>> 0)) {
      return undefined;
    }
    var elem, i = 0;
    while ((elem = this[i++])) {
      var curValue = jQuery(elem).is(":visible");
      (elem.lastVisibility === undefined) && (elem.lastVisibility = curValue);
      (curValue !== elem.lastVisibility) && (
        elem.lastVisibility = curValue,
        (typeof callback === "function") && (
          callback.apply(this, [new jQuery.Event('visibilityChanged'), curValue ? "shown" : "hidden"])
        ),
          (function (elem, curValue) {
            setTimeout(function () {
              jQuery(elem).trigger('visibilityChanged', [curValue ? "shown" : "hidden"])
            }, 10)
          })(elem, curValue)
      )
    }
    (function (that, a) {
      setTimeout(function () {
        that.checkForVisiblilityChange.apply(that, a);
      }, 10)
    })(this, arguments)
  }
});

/* Execute on ajax complete.*/
jQuery(document).ajaxComplete(function () {
  setTimeout(function () {
    bwg_main_ready();
  });
});

jQuery(document).ready(function () {
  document.addEventListener("visibilitychange", function() {
    var bwg_error = false;
    /* If there is error (empty gallery).*/
    jQuery(".bwg_container").each(function () {
      if ( jQuery(this).find(".wd_error").length > 0 ) {
        bwg_error = true;
      }
    });
    if ( !bwg_error ) {
      if (document.visibilityState == 'visible') {
        bwg_slideshow_focus();
      }
      if (document.visibilityState == 'hidden') {
        bwg_slideshow_blur();
      }
    }
  });
  /* To bind only visible containers.*/
  bwg_main_ready();
  jQuery(this).hideShow(function(event, visibility) {
    if ( visibility == 'shown' ) {
      bwg_main_ready();
    }
  });
});

function bwg_main_ready() {
  /* If there is error (empty gallery).*/
  jQuery(".bwg_container").each(function () {
    if ( jQuery(this).find(".wd_error").length > 0 ) {
      var bwg = jQuery(this).data("bwg");
      bwg_container_loaded(bwg);
    }
  });
  bwg_document_ready();
  jQuery(".bwg-thumbnails, .bwg-masonry-thumbnails, .bwg-album-thumbnails").each(function () {
    bwg_all_thumnails_loaded(this);
  });

  jQuery(".bwg-mosaic-thumbnails").each(function () {
    bwg_thumbnail_mosaic(this);
  });
  bwg_slideshow_ready();
  bwg_carousel_ready();
  bwg_carousel_onload();
  bwg_image_browser_ready();
}

function bwg_resize_search_line() {
  jQuery('.search_line').each(function() {
    var element = jQuery(this);
    if (element.width() < 410) {
      element.addClass('bwg-search-line-responsive');
    }
    else {
      element.removeClass('bwg-search-line-responsive');
    }
  });
}

jQuery(window).on("resize", function () {
  var bwg_error = false;
  /* If there is error (empty gallery).*/
  jQuery(".bwg_container").each(function () {
    if ( jQuery(this).find(".wd_error").length > 0 ) {
      bwg_error = true;
    }
  });
  if ( !bwg_error ) {
    jQuery(".bwg-thumbnails, .bwg-masonry-thumbnails, .bwg-album-thumbnails").each(function () {
      bwg_all_thumnails_loaded(this);
    });
    bwg_slideshow_resize();
    bwg_image_browser_resize();
    bwg_carousel_resize();
    bwg_blog_style_resize();
    jQuery(".bwg-mosaic-thumbnails").each(function () {
      bwg_thumbnail_mosaic(this);
    });
  }
  bwg_resize_search_line();
});

jQuery(window).on("load", function () {
  var bwg_error = false;
  /* If there is error (empty gallery).*/
  jQuery(".bwg_container").each(function () {
    if ( jQuery(this).find(".wd_error").length > 0 ) {
      bwg_error = true;
    }
  });
  if ( !bwg_error ) {
    bwg_blog_style_onload();
    jQuery(".bwg-mosaic-thumbnails").each(function () {
      bwg_thumbnail_mosaic(this);
    });
  }
});

jQuery(".bwg-masonry-thumb-span img, .bwg-mosaic-thumb-span img").on("error", function() {
  jQuery(this).height(100);
  jQuery(this).width(100);
});

function bwg_slideshow_resize() {
  jQuery(".bwg_slideshow").each(function () {
    bwg = jQuery(this).attr('data-bwg');
    if ( jQuery("#bwg_slideshow_image_container_" + bwg).length ) {
      bwg_params[bwg] = JSON.parse(jQuery("#bwg_slideshow_image_container_" + bwg).attr("data-params"));
      bwg_params[bwg]['event_stack'] = [];
      bwg_popup_resize(bwg);
    }
  });
}

function bwg_blog_style_resize() {
  jQuery(".bwg_blog_style").each(function () {
    bwg = jQuery(this).attr('data-bwg');
    jQuery('.bwg_embed_frame_16x9_'+bwg).each(function (e) {
      jQuery(this).width(jQuery(this).parent().width());
      jQuery(this).height(jQuery(this).width() * 0.5625);
    });
    jQuery('.bwg_embed_frame_instapost_'+bwg).each(function (e) {
      jQuery(this).width(jQuery(this).parent().width());
      jQuery(this).height((jQuery(this).width() - 16) * jQuery(this).attr('data-height') / jQuery(this).attr('data-width') + 96);
    });
  })
}

function bwg_blog_style_onload() {
  jQuery(".bwg_blog_style").each(function () {
    bwg = jQuery(this).attr('data-bwg');
	var data_right_click = jQuery("#bwg_blog_style_"+bwg);
    jQuery('.bwg_embed_frame_16x9_'+bwg).each(function (e) {
		/* Conflict with Sydney Theme */
		if ( jQuery('.bwg_blog_style_image_' + bwg).find('.fluid-width-video-wrapper').length ) {
			jQuery('.fluid-width-video-wrapper').removeAttr('style');
			var content = jQuery(this).parents('.bwg_blog_style_image_' + bwg).find('.fluid-width-video-wrapper').contents();
			jQuery(this).parents('.fluid-width-video-wrapper').replaceWith(content);
		}
		jQuery(this).width(jQuery(this).parents('.bwg_blog_style_image_' + bwg).width());
		jQuery(this).height(jQuery(this).width() * 0.5625);
    });

    jQuery('.bwg_embed_frame_instapost_'+bwg).each(function (e) {
      jQuery(this).width(jQuery(this).parents('.bwg_blog_style_image_' + bwg).width());
      /* 16 is 2*padding inside iframe */
      /* 96 is 2*padding(top) + 1*padding(bottom) + 40(footer) + 32(header) */
      jQuery(this).height((jQuery(this).width() - 16) * jQuery(this).attr('data-height') / jQuery(this).attr('data-width') + 96);
    });

    bwg_container_loaded(bwg);
  });
}

function bwg_blog_style_ready() {
  jQuery(".bwg_blog_style").each(function () {
    var bwg = jQuery(this).attr('data-bwg');
    bwg_container_loaded( bwg );

    var bwg_touch_flag = false;
    jQuery(this).find('.bwg_lightbox_' + bwg).on('click', function () {
	  var image_id = jQuery(this).attr('data-image-id');
	  jQuery('#bwg_blog_style_share_buttons_' + image_id ).removeAttr('data-open-comment');
      if ( !bwg_touch_flag ) {
        bwg_touch_flag = true;
        setTimeout( function(){ bwg_touch_flag = false; }, 100 );
		bwg_gallery_box(image_id, jQuery(this).closest('.bwg_container'));
        return false;
      }
    });
    jQuery(".bwg_lightbox_" + bwg + " .bwg_ecommerce").on("click", function (event) {
      event.stopPropagation();
      if (!bwg_touch_flag) {
        bwg_touch_flag = true;
        setTimeout(function(){ bwg_touch_flag = false; }, 100);
        bwg_gallery_box(jQuery(this).attr( "data-image-id" ), jQuery(this).closest( '.bwg_container' ), true);
        return false;
      }
    });

    jQuery( 'div[id^="bwg_container"]' ).each( function () {
      var bwg_container = jQuery(this);
      var search_tags = bwg_container.find('.search_tags');
      if (search_tags.length) {
        search_tags.SumoSelect({
          triggerChangeCombined: true,
          placeholder: bwg_objectsL10n.bwg_select_tag,
          search: 1,
          searchText: bwg_objectsL10n.bwg_search,
          forceCustomRendering: true,
          noMatch: bwg_objectsL10n.bwg_tag_no_match,
          captionFormatAllSelected: bwg_objectsL10n.bwg_all_tags_selected,
          captionFormat: '{0} ' + bwg_objectsL10n.bwg_tags_selected,
        });
      }
      var bwg_order = bwg_container.find('.bwg_order');
      if (bwg_order.length) {
        bwg_order.SumoSelect({
          triggerChangeCombined: true,
          forceCustomRendering: true,
        });
      }
    });
    var bwg_hash = window.location.hash.substring(1);
    if (bwg_hash) {
      if (bwg_hash.indexOf("bwg") != "-1") {
        bwg_hash_array = bwg_hash.replace("bwg", "").split("/");
        if(bwg_hash_array[0] == "<?php echo $params_array['gallery_id']; ?>"){
          bwg_gallery_box(bwg_hash_array[1]);
        }
      }
    }
  });
}

function bwg_slideshow_focus() {
  jQuery(".bwg_slideshow").each(function () {
    bwg = jQuery(this).attr('data-bwg');
    if ( jQuery("#bwg_slideshow_image_container_" + bwg).length ) {
      bwg_params[bwg] = JSON.parse(jQuery("#bwg_slideshow_image_container_" + bwg).attr("data-params"));
      bwg_params[bwg]['event_stack'] = [];
      window.clearInterval(window['bwg_playInterval' + bwg]);
      if (!jQuery(".bwg_ctrl_btn_" + bwg).hasClass("fa-play")) {
        bwg_play(bwg_params[bwg]['data'], bwg);
      }
    }
  });
}

function bwg_slideshow_blur() {
  jQuery(".bwg_slideshow").each(function () {
    bwg = jQuery(this).attr('data-bwg');
    if ( jQuery("#bwg_slideshow_image_container_" + bwg).length ) {
      bwg_params[bwg] = JSON.parse(jQuery("#bwg_slideshow_image_container_" + bwg).attr("data-params"));
      bwg_params[bwg]['event_stack'] = [];
      window.clearInterval(window['bwg_playInterval' + bwg]);
    }
  });
}

function bwg_carousel_ready() {
  jQuery(".bwg-carousel").each(function () {
    var bwg = jQuery(this).data("bwg");
    bwg_params_carousel[bwg] = [];
    bwg_params_carousel[bwg]['bwg_currentCenterNum'] = 1;
    bwg_params_carousel[bwg]['bwg_currentlyMoving'] = false;
    bwg_params_carousel[bwg]['data'] = [];

    jQuery("#spider_carousel_left-ico_" + bwg).on("click", function () {
      bwg_params_carousel[bwg]['carousel'].prev();
    });
    jQuery("#spider_carousel_right-ico_" + bwg).on("click", function () {
      bwg_params_carousel[bwg]['carousel'].next();
    });
    if ( parseInt(bwg_params_carousel[bwg]['carousel_enable_autoplay']) ) {
      jQuery(".bwg_carousel_play_pause_" + bwg).attr("title", bwg_objectsL10n.pause);
      jQuery(".bwg_carousel_play_pause_" + bwg).attr("class", "bwg_ctrl_btn_" + bwg + " bwg_carousel_play_pause_" + bwg + " fa fa-pause");
    }
    jQuery(".bwg_carousel_play_pause_" + bwg).on(bwg_click, function () {
      if (jQuery(".bwg_ctrl_btn_" + bwg).hasClass("fa-play") ) {
        /*play*/
        jQuery(".bwg_carousel_play_pause_" + bwg).attr("title", bwg_objectsL10n.pause);
        jQuery(".bwg_carousel_play_pause_" + bwg).attr("class", "bwg_ctrl_btn_" + bwg + " bwg_carousel_play_pause_" + bwg + " fa fa-pause");
        bwg_params_carousel[bwg]['carousel'].start();
      }
      else {
        /* Pause.*/
        jQuery(".bwg_carousel_play_pause_" + bwg).attr("title", bwg_objectsL10n.play);
        jQuery(".bwg_carousel_play_pause_" + bwg).attr("class", "bwg_ctrl_btn_" + bwg + " bwg_carousel_play_pause_" + bwg + " fa fa-play");
        bwg_params_carousel[bwg]['carousel'].pause();
      }
    });
    if (typeof jQuery().swiperight !== 'undefined') {
      if (jQuery.isFunction(jQuery().swiperight)) {
        jQuery("#bwg_container1_" + bwg).swiperight(function () {
          bwg_params_carousel[bwg]['carousel'].prev();
        });
      }
    }
    if (typeof jQuery().swipeleft !== 'undefined') {
      if (jQuery.isFunction(jQuery().swipeleft)) {
        jQuery("#bwg_container1_" + bwg).swipeleft(function () {
          bwg_params_carousel[bwg]['carousel'].next();
        });
      }
    }
  });
}

function bwg_carousel_resize() {
  jQuery(".bwg-carousel").each(function () {
    var bwg = jQuery(this).data("bwg");
    bwg_carousel_params(bwg);
    bwg_params_carousel[bwg]['carousel'].pause();
    bwg_carousel_watermark(bwg);
    if ( !jQuery(".bwg_ctrl_btn_" + bwg).hasClass("fa-play") ) {
      bwg_params_carousel[bwg]['carousel'].start();
    }
  });
}

function bwg_carousel_onload() {
  jQuery(".bwg-carousel").each(function () {
    var bwg = jQuery(this).data("bwg");

    bwg_params_carousel[bwg] = jQuery(this).data("params");
    bwg_carousel_watermark(bwg);
    bwg_carousel_params(bwg);
    bwg_container_loaded(bwg);
  });
}

function bwg_carousel_params(bwg) {
  var parent_width = jQuery("#bwg_container1_" + bwg).parent().width();
  var par = 1;
  if ( parent_width < bwg_params_carousel[bwg]['carousel_r_width'] ) {
    par = parent_width / bwg_params_carousel[bwg]['carousel_r_width'];
  }
  else {
    parent_width = bwg_params_carousel[bwg]['carousel_r_width'];
  }
  if ( bwg_params_carousel[bwg]['carousel_image_column_number'] > bwg_params_carousel[bwg]['count'] ) {
    bwg_params_carousel[bwg]['carousel_image_column_number'] = bwg_params_carousel[bwg]['count'];
  }

  jQuery( ".bwg_carousel_play_pause_" + bwg).css({display: (!parseInt(bwg_params_carousel[bwg]['carousel_play_pause_butt']) ? 'none': '') });

  if ( !parseInt(bwg_params_carousel[bwg]['carousel_prev_next_butt']) ) {
    jQuery("#bwg_carousel-left" + bwg).css({display:'none' });
    jQuery("#bwg_carousel-right" + bwg).css({display:'none' });
  }
  else {
    jQuery("#bwg_carousel-right" + bwg).css({display:'' });
    jQuery("#bwg_carousel-left" + bwg).css({display:'' });
  }

  jQuery(".inner_instagram_iframe_bwg_embed_frame_" + bwg).each(function () {
    /* 16 is 2*padding inside iframe */
    /* 96 is 2*padding(top) + 1*padding(bottom) + 40(footer) + 32(header) */
    var parent_container = jQuery(this).parent();
    if ( bwg_params_carousel[bwg]['image_height'] / (parseInt(parent_container.attr('data-height')) + 96) < bwg_params_carousel[bwg]['image_width'] / parseInt(parent_container.attr('data-width')) ) {
      parent_container.height(bwg_params_carousel[bwg]['image_height'] * par);
      parent_container.width((parent_container.height() - 96) * parent_container.attr('data-width') / parent_container.attr('data-height') + 16);
    }
    else {
      parent_container.width(bwg_params_carousel[bwg]['image_width'] * par);
      parent_container.height((parent_container.width() - 16) * parent_container.attr('data-height') / parent_container.attr('data-width') + 96);
    }
  });

  jQuery(".bwg_carousel_image_container_" + bwg).css({width: bwg_params_carousel[bwg]['image_width'] * par,height: bwg_params_carousel[bwg]['image_height'] * par });
  jQuery(".bwg_carousel_watermark_text_" + bwg + ", .bwg_carousel_watermark_text_" + bwg + ":hover").css({fontSize: ((parent_width) * (bwg_params_carousel[bwg]['watermark_font_size'] / bwg_params_carousel[bwg]['image_width']) * par)});
  jQuery(".bwg_carousel-image " + bwg).css({width: bwg_params_carousel[bwg]['image_width'] * par, height: bwg_params_carousel[bwg]['image_height'] * par });
  jQuery(".bwg_carousel_watermark_container_" + bwg).css({width: bwg_params_carousel[bwg]['image_width'] * par, height: bwg_params_carousel[bwg]['image_height'] * par });
  jQuery(".bwg_carousel_embed_video_" + bwg).css({width: bwg_params_carousel[bwg]['image_width'] * par, height: bwg_params_carousel[bwg]['image_height'] * par });
  jQuery(".bwg_carousel_watermark_spun_" + bwg).css({width: bwg_params_carousel[bwg]['image_width'] * par, height: bwg_params_carousel[bwg]['image_height'] * par  });
  jQuery(".bwg_carousel-container" + bwg).css({width:  parent_width, height: bwg_params_carousel[bwg]['image_height'] * par  });
  jQuery(".bwg_video_hide" + bwg).css({width: bwg_params_carousel[bwg]['image_width'] * par, height: bwg_params_carousel[bwg]['image_height'] * par });

  bwg_params_carousel[bwg]['carousel'] = jQuery("#bwg_carousel" + bwg).featureCarousel({
    containerWidth:       parent_width * par,
    containerHeight:      bwg_params_carousel[bwg]['image_height'] * par,
    fit_containerWidth:   bwg_params_carousel[bwg]['carousel_fit_containerWidth'],
    largeFeatureWidth:    bwg_params_carousel[bwg]['image_width'] * par,
    largeFeatureHeight:   bwg_params_carousel[bwg]['image_height'] * par,
    smallFeaturePar:      bwg_params_carousel[bwg]['carousel_image_par'],
    currentlyMoving:      false,
    startingFeature:      bwg_params_carousel[bwg]['bwg_currentCenterNum'],
    featuresArray:        [],
    timeoutVar:           null,
    rotationsRemaining:   0,
    autoPlay:             bwg_params_carousel[bwg]['car_inter'] * 1000,
    interval:             bwg_params_carousel[bwg]['carousel_interval'] * 1000,
    imagecount:           bwg_params_carousel[bwg]['carousel_image_column_number'],
    bwg_number:           bwg,
    enable_image_title:   bwg_params_carousel[bwg]['enable_image_title'],
    borderWidth:		      0
  });
}

function bwg_carousel_watermark(bwg) {
  var par = 1;
  var parent_width = jQuery("#bwg_container1_" + bwg).parent().width();
  if ( parent_width < bwg_params_carousel[bwg]['carousel_r_width'] ) {
    par = parent_width / bwg_params_carousel[bwg]['carousel_r_width'];
  }
  if ( parent_width >= bwg_params_carousel[bwg]['image_width'] ) {
    /* Set watermark container size.*/
    bwg_carousel_change_watermark_container(bwg);
    jQuery("#bwg_carousel_play_pause-ico_" + bwg).css({fontSize: bwg_params_carousel[bwg]['carousel_play_pause_btn_size']});
    jQuery(".bwg_carousel_watermark_image_" + bwg).css({maxWidth: bwg_params_carousel[bwg]['watermark_width'] * par, maxHeight: bwg_params_carousel[bwg]['watermark_height'] * par});
    jQuery(".bwg_carousel_watermark_text_" + bwg + ", .bwg_carousel_watermark_text_" + bwg + ":hover").css({fontSize: par * bwg_params_carousel[bwg]['watermark_font_size']});
  }
  else {
    /* Set watermark container size.*/
    var img_width = bwg_params_carousel[bwg]['image_width'] / par;
    bwg_carousel_change_watermark_container(bwg);
    jQuery("#bwg_carousel_play_pause-ico_" + bwg).css({fontSize: (parent_width * bwg_params_carousel[bwg]['carousel_play_pause_btn_size'] / img_width )});
    jQuery(".bwg_carousel_watermark_image_" + bwg).css({maxWidth: ( parent_width * bwg_params_carousel[bwg]['watermark_width'] / img_width), maxHeight: (parent_width * bwg_params_carousel[bwg]['watermark_height'] / img_width)});
    jQuery(".bwg_carousel_watermark_text_" + bwg + ", .bwg_carousel_watermark_text_" + bwg + ":hover").css({fontSize:  (parent_width * bwg_params_carousel[bwg]['watermark_font_size'] / img_width )});
  }
}

function bwg_carousel_change_watermark_container(bwg) {
  jQuery(".bwg_carousel" + bwg).children().each(function() {
    if (jQuery(this).css("zIndex") == 2) {
      var bwg_current_image_span = jQuery(this).find("img");
      if (!bwg_current_image_span.length) {
        bwg_current_image_span = jQuery(this).find("iframe");
      }
      var width = bwg_current_image_span.width();
      var height = bwg_current_image_span.height();
      jQuery(".bwg_carousel_watermark_spun_" + bwg).width(width);
      jQuery(".bwg_carousel_watermark_spun_" + bwg).height(height);
      jQuery(".bwg_carousel_title_spun_" + bwg).width(width);
      jQuery(".bwg_carouel_title_spun_" + bwg).height(height);
      jQuery(".bwg_carousel_watermark_" + bwg).css({display: 'none'});
    }
  });
}

/* Change hidden carousel items to visiblle */
function bwg_carousel_preload( bwg, right ) {
  var preload_images_count = 1;

  var selector = jQuery(".bwg_carousel_preload").get();
  if ( !right ) {
    selector.reverse();
  }
  var i = 0;
  jQuery(selector).each(function () {
    if ( ++i > preload_images_count ) {
      return false;
    }
    if ( jQuery(this).parent().hasClass('bwg_carousel_embed_video_' + bwg)
      || jQuery(this).parent().hasClass('bwg_embed_frame_' + bwg)
      || jQuery(this).parent().hasClass('bwg_carousel_video') ) {
      /* Embed. */
      jQuery(this).attr('src', jQuery(this).attr('data-src'));
      jQuery(this).on("load", function () {
        jQuery(this).removeClass('bwg_carousel_preload');
      });
      /* Load video after changing source. */
      if ( jQuery(this).parent().hasClass('bwg_carousel_video') ) {
        jQuery(".bwg_carousel_video")[0].load();
        jQuery(this).parent().parent().removeClass('bwg_carousel_preload');
      }
      jQuery(this).removeAttr('data-src');
    }
    else {
      /* Image. */
      jQuery(this).css({
        'background-image': "url('" + jQuery(this).attr('data-background') + "')",
        'height': '100%',
      });
      jQuery(this).removeClass('bwg_carousel_preload');
      jQuery(this).removeAttr('data-background');
    }
  });
}

function bwg_slideshow_ready() {
  jQuery(".bwg_slideshow").each(function () {
    var bwg = jQuery(this).data("bwg");
    if ( jQuery("#bwg_slideshow_image_container_" + bwg).length ) {
      bwg_params[bwg] = JSON.parse(jQuery("#bwg_slideshow_image_container_" + bwg).attr("data-params"));
      bwg_params[bwg]['event_stack'] = [];
      bwg_container_loaded(bwg);
      var data = bwg_params[bwg]['data'];
      if (typeof jQuery().swiperight !== 'undefined') {
        if (jQuery.isFunction(jQuery().swiperight)) {
          jQuery("#bwg_container1_" + bwg).swiperight(function () {
            bwg_change_image(parseInt(jQuery("#bwg_current_image_key_" + bwg).val()), (parseInt(jQuery("#bwg_current_image_key_" + bwg).val()) - bwg_iterator(bwg)) >= 0 ? (parseInt(jQuery("#bwg_current_image_key_" + bwg).val()) - bwg_iterator(bwg)) % data.length : data.length - 1, data, '', bwg);
            return false;
          });
        }
      }
      if (typeof jQuery().swipeleft !== 'undefined') {
        if (jQuery.isFunction(jQuery().swipeleft)) {
          jQuery("#bwg_container1_" + bwg).swipeleft(function () {
            bwg_change_image(parseInt(jQuery("#bwg_current_image_key_" + bwg).val()), (parseInt(jQuery("#bwg_current_image_key_" + bwg).val()) + bwg_iterator(bwg) % data.length), data, '', bwg);
            return false;
          });
        }
      }
      var isMobile = (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()));
      var bwg_click = isMobile ? 'touchend' : 'click';
      bwg_popup_resize(bwg);
      jQuery(".bwg_slideshow_watermark_" + bwg).css({display: 'none'});
      jQuery(".bwg_slideshow_title_text_" + bwg).css({display: 'none'});
      jQuery(".bwg_slideshow_description_text_" + bwg).css({display: 'none'});
      setTimeout(function () {
        bwg_change_watermark_container(bwg);
      }, 500);
      /* Set image container height.*/
      if (bwg_params[bwg]['filmstrip_direction'] == 'horizontal') {
        jQuery(".bwg_slideshow_image_container_" + bwg).height(jQuery(".bwg_slideshow_image_wrap_" + bwg).height() - bwg_params[bwg]['slideshow_filmstrip_height']);
      }
      else {
        jQuery(".bwg_slideshow_image_container_" + bwg).width(jQuery(".bwg_slideshow_image_wrap_" + bwg).width() - bwg_params[bwg]['slideshow_filmstrip_width']);
      }
      var mousewheelevt = (/Firefox/i.test(navigator.userAgent)) ? "DOMMouseScroll" : "mousewheel";
      /* FF doesn't recognize mousewheel as of FF3.x */
      jQuery(".bwg_slideshow_filmstrip_" + bwg).bind(mousewheelevt, function (e) {
        var evt = window.event || e;
        /* Equalize event object.*/
        evt = evt.originalEvent ? evt.originalEvent : evt;
        /* Convert to originalEvent if possible.*/
        var delta = evt.detail ? evt.detail * (-40) : evt.wheelDelta;
        /* Check for detail first, because it is used by Opera and FF.*/
        if (delta > 0) {
          /* Scroll up.*/
          jQuery(".bwg_slideshow_filmstrip_left_" + bwg).trigger("click");
        }
        else {
          /* Scroll down.*/
          jQuery(".bwg_slideshow_filmstrip_right_" + bwg).trigger("click");
        }
        return false;
      });
      jQuery(".bwg_slideshow_filmstrip_right_" + bwg).on(bwg_click, function () {
        jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).stop(true, false);
        if (bwg_params[bwg]['left_or_top'] == 'left') { /* For left, width */
          if (bwg_params[bwg]['width_or_height'] == 'width') {
            if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left >= -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).width() - jQuery(".bwg_slideshow_filmstrip_" + bwg).width())) {
              jQuery(".bwg_slideshow_filmstrip_left_" + bwg).css({opacity: 1, filter: "Alpha(opacity=100)"});
              if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left < -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).width() - jQuery(".bwg_slideshow_filmstrip_" + bwg).width() - (bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width']))) {
                jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({left: -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).width() - jQuery(".bwg_slideshow_filmstrip_" + bwg).width())}, 500, 'linear');
              }
              else {
                jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({left: (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left - (bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width']))}, 500, 'linear');
              }
            }
            /* Disable right arrow.*/
            window.setTimeout(function () {
              if ((jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left) == -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).width() - jQuery(".bwg_slideshow_filmstrip_" + bwg).width())) {
                jQuery(".bwg_slideshow_filmstrip_right_" + bwg).css({opacity: 0.3, filter: "Alpha(opacity=30)"});
              }
            }, 500);
          }
          else { /* For left, height */
            if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left >= -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).height() - jQuery(".bwg_slideshow_filmstrip_" + bwg).height())) {
              jQuery(".bwg_slideshow_filmstrip_left_" + bwg).css({opacity: 1, filter: "Alpha(opacity=100)"});
              if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left < -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).height() - jQuery(".bwg_slideshow_filmstrip_" + bwg).height() - (bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width']))) {
                jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({left: -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).height() - jQuery(".bwg_slideshow_filmstrip_" + bwg).width())}, 500, 'linear');
              }
              else {
                jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({left: (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left - (bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width']))}, 500, 'linear');
              }
            }
            /* Disable right arrow.*/
            window.setTimeout(function () {
              if ((jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left) == -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).height() - jQuery(".bwg_slideshow_filmstrip_" + bwg).height())) {
                jQuery(".bwg_slideshow_filmstrip_right_" + bwg).css({opacity: 0.3, filter: "Alpha(opacity=30)"});
              }
            }, 500);
          }
        }
        else {
          if (bwg_params[bwg]['width_or_height'] == 'width') { /* For top, width */
            if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top >= -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).width() - jQuery(".bwg_slideshow_filmstrip_" + bwg).width())) {
              jQuery(".bwg_slideshow_filmstrip_left_" + bwg).css({opacity: 1, filter: "Alpha(opacity=100)"});
              if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top < -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).width() - jQuery(".bwg_slideshow_filmstrip_" + bwg).width() - bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width'])) {
                jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({top: -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).width() - jQuery(".bwg_slideshow_filmstrip_" + bwg).width())}, 500, 'linear');
              }
              else {
                jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({top: (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top - bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width'])}, 500, 'linear');
              }
            }
            /* Disable right arrow.*/
            window.setTimeout(function () {
              if ((jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top) == -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).width() - jQuery(".bwg_slideshow_filmstrip_" + bwg).width())) {
                jQuery(".bwg_slideshow_filmstrip_right_" + bwg).css({opacity: 0.3, filter: "Alpha(opacity=30)"});
              }
            }, 500);
          }
          else { /* For top, height */
            if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top >= -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).height() - jQuery(".bwg_slideshow_filmstrip_" + bwg).height())) {
              jQuery(".bwg_slideshow_filmstrip_left_" + bwg).css({opacity: 1, filter: "Alpha(opacity=100)"});
              if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top < -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).height() - jQuery(".bwg_slideshow_filmstrip_" + bwg).height() - (bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width']))) {
                jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({top: -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).height() - jQuery(".bwg_slideshow_filmstrip_" + bwg).width())}, 500, 'linear');
              }
              else {
                jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({top: (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top - (bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width']))}, 500, 'linear');
              }
            }
            /* Disable right arrow.*/
            window.setTimeout(function () {
              if ((jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top) == -(jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).height() - jQuery(".bwg_slideshow_filmstrip_" + bwg).height())) {
                jQuery(".bwg_slideshow_filmstrip_right_" + bwg).css({opacity: 0.3, filter: "Alpha(opacity=30)"});
              }
            }, 500);
          }
        }
      });
      jQuery(".bwg_slideshow_filmstrip_left_" + bwg).on(bwg_click, function () {
        jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).stop(true, false);
        if (bwg_params[bwg]['left_or_top'] == 'left') {
          if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left < 0) {
            jQuery(".bwg_slideshow_filmstrip_right_" + bwg).css({opacity: 1, filter: "Alpha(opacity=100)"});
            if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left > -bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width']) {
              jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({left: 0}, 500, 'linear');
            }
            else {
              jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({left: (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left + bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width'])}, 500, 'linear');
            }
          }
          /* Disable left arrow.*/
          window.setTimeout(function () {
            if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().left == 0) {
              jQuery(".bwg_slideshow_filmstrip_left_" + bwg).css({opacity: 0.3, filter: "Alpha(opacity=30)"});
            }
          }, 500);
        }
        else {
          if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top < 0) {
            jQuery(".bwg_slideshow_filmstrip_right_" + bwg).css({opacity: 1, filter: "Alpha(opacity=100)"});
            if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top > -bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width']) {
              jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({top: 0}, 500, 'linear');
            }
            else {
              jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).animate({top: (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top + bwg_params[bwg]['filmstrip_thumb_margin_hor'] + bwg_params[bwg]['slideshow_filmstrip_width'])}, 500, 'linear');
            }
          }
          /* Disable top arrow.*/
          window.setTimeout(function () {
            if (jQuery(".bwg_slideshow_filmstrip_thumbnails_" + bwg).position().top == 0) {
              jQuery(".bwg_slideshow_filmstrip_left_" + bwg).css({opacity: 0.3, filter: "Alpha(opacity=30)"});
            }
          }, 500);
        }
      });
      if (bwg_params[bwg]['width_or_height'] == 'width') {
        /* Set filmstrip initial position.*/
        bwg_set_filmstrip_pos(jQuery(".bwg_slideshow_filmstrip_" + bwg).width(), bwg);
      }
      else {
        /* Set filmstrip initial position.*/
        bwg_set_filmstrip_pos(jQuery(".bwg_slideshow_filmstrip_" + bwg).height(), bwg);
      }
      /* Play/pause.*/
      jQuery("#bwg_slideshow_play_pause_" + bwg).off(bwg_click).on(bwg_click, function () {
        if (jQuery(".bwg_ctrl_btn_" + bwg).hasClass("fa-play")) {
          bwg_play(bwg_params[bwg]['data'], bwg);
          jQuery(".bwg_slideshow_play_pause_" + bwg).attr("title", bwg_objectsL10n.pause);
          jQuery(".bwg_slideshow_play_pause_" + bwg).attr("class", "bwg_ctrl_btn_" + bwg + " bwg_slideshow_play_pause_" + bwg + " fa fa-pause");
          if (bwg_params[bwg]['enable_slideshow_music'] == 1) {
            document.getElementById("bwg_audio_" + bwg).play();
          }
        }
        else {
          /* Pause.*/
          window.clearInterval(window['bwg_playInterval' + bwg]);
          jQuery(".bwg_slideshow_play_pause_" + bwg).attr("title", "Play");
          jQuery(".bwg_slideshow_play_pause_" + bwg).attr("class", "bwg_ctrl_btn_" + bwg + " bwg_slideshow_play_pause_" + bwg + " fa fa-play");
          if (bwg_params[bwg]['enable_slideshow_music'] == 1) {
            document.getElementById("bwg_audio_" + bwg).pause();
          }
        }
      });
      if (bwg_params[bwg]['enable_slideshow_autoplay'] != 0) {
        bwg_play(bwg_params[bwg]['data'], bwg);
        jQuery(".bwg_slideshow_play_pause_" + bwg).attr("title", bwg_objectsL10n.pause);
        jQuery(".bwg_slideshow_play_pause_" + bwg).attr("class", "bwg_ctrl_btn_" + bwg + " bwg_slideshow_play_pause_" + bwg + " fa fa-pause");
        if (bwg_params[bwg]['enable_slideshow_music'] == 1 && jQuery("#bwg_audio_" + bwg).length) {
          document.getElementById("bwg_audio_" + bwg).play();
        }
      }
      if (bwg_params[bwg]['preload_images']) {
        bwg_preload_images(parseInt(jQuery("#bwg_current_image_key_".$bwg).val()), bwg);
      }
      jQuery(".bwg_slideshow_image_" + bwg).removeAttr("width");
      jQuery(".bwg_slideshow_image_" + bwg).removeAttr("height");
    }
  });
}

function bwg_image_browser_resize() {
  jQuery(".bwg_image_browser").each(function () {
    var bwg = jQuery(this).attr('data-bwg');
    if (jQuery('.image_browser_images_conteiner_' + bwg).length) {
      bwg_params_ib[bwg] = JSON.parse(jQuery('#bwg_container1_' + bwg + ' .image_browser_images_conteiner_' + bwg ).attr('data-params'));
      bwg_image_browser( bwg );
    }
  });
}

function bwg_image_browser_ready() {
  /* For ImageBrowser */
  jQuery(".bwg_image_browser").each(function () {
    var bwg = jQuery(this).attr('data-bwg');
    bwg_container_loaded( bwg );
    if (jQuery('.image_browser_images_conteiner_' + bwg).length) {
      bwg_params_ib[bwg] = JSON.parse(jQuery('.image_browser_images_conteiner_' + bwg).attr('data-params'));
      setTimeout(function () {
        bwg_image_browser(bwg);
      }, 3);
    }
  });
}

/* hide search_placeholder_title class container */
function bwg_search_focus(that) {
  jQuery(that).parent().find('.bwg_search_input').focus();
  jQuery(that).hide();
}

/* show search and reset icons */
function bwg_key_press(that) {
  jQuery(that).parent().find('.bwg_search_reset_container').removeClass("hidden");
  jQuery(that).parent().find('.bwg_search_loupe_container1').removeClass("hidden");
}

function bwg_all_thumnails_loaded(that) {
  var thumbnails_count = 0;
  var thumbnails_loaded = jQuery(that).find("img").length;
  if (0 == thumbnails_loaded) {
    bwg_all_thumbnails_loaded_callback(that);
  }
  else {
    jQuery( that ).find( "img" ).each( function () {
      var fakeSrc = jQuery( this ).attr( "src" );
      jQuery( "<img/>" ).attr( "src", fakeSrc ).on( "load error", function () {
        if ( ++thumbnails_count >= thumbnails_loaded ) {
          bwg_all_thumbnails_loaded_callback( that );
        }
      });
    });
  }

  return thumbnails_loaded == 0;
}

function bwg_all_thumbnails_loaded_callback(that) {
  if (jQuery(that).hasClass('bwg-thumbnails')) {
    bwg_thumbnail( that );
  }
  if (jQuery(that).hasClass('bwg-masonry-thumbnails')) {
    bwg_thumbnail_masonry( that );
  }
  if (jQuery(that).hasClass('bwg-album-extended')) {
    bwg_album_extended( that );
  }
}

function bwg_container_loaded(bwg) {
  jQuery('#gal_front_form_' + bwg).removeClass('bwg-hidden');
  jQuery('#ajax_loading_' + bwg).addClass('bwg-hidden');
}

function bwg_album_thumbnail(that) {
  bwg_container_loaded(jQuery(that).data('bwg'));
}

function bwg_album_extended(that) {
  var container_width = jQuery(that).width();
  var thumb_width = jQuery(that).data("thumbnail-width");
  var spacing = jQuery(that).data("spacing");
  var max_count = jQuery(that).data("max-count");
  var column_count = parseInt(container_width / (2 * thumb_width));
  if ( column_count < 1 ) {
    column_count = 1;
  }
  if (column_count > max_count) {
    column_count = max_count;
  }
  var min_width = 100 / column_count;
  var bwg_item = jQuery(that).find(".bwg-extended-item");
  var margin_left = parseInt(bwg_item.css("margin-left"));
  var margin_right = parseInt(bwg_item.css("margin-right"));
  bwg_item.css({
    width: "calc(" + min_width + "% - " + (margin_left + margin_right) + "px)"
  });
  if ( bwg_item.width() < thumb_width ) {
    bwg_item.find(".bwg-extended-item0, .bwg-extended-item1").css({
      width: 'calc(100% - ' + spacing + 'px)'
    });
  }
  else if ( bwg_item.width() > 2 * thumb_width ) {
    bwg_item.find(".bwg-extended-item0").css({
      width: 'calc(50% - ' + spacing + 'px)'
    });
    bwg_item.find(".bwg-extended-item1").css({
      width: 'calc(100% - ' + (thumb_width + spacing * 2) + 'px)'
    });
  }
  else {
    bwg_item.find(".bwg-extended-item0, .bwg-extended-item1").css({
      width: 'calc(50% - ' + spacing + 'px)'
    });
  }

  jQuery(that).children(".bwg-extended-item").each(function () {
    var image = jQuery(this).find("img");
    var item0 = jQuery(this).find(".bwg-item0");
    var item2 = jQuery(this).find(".bwg-item2");
    if ( (item2.width() / item2.height()) > (image.width() / image.height()) ) {
      if ( item2.width() > image.width() ) {
        image.css({width: "100%"});
      }
      else {
        image.css({maxWidth: "100%"});
      }
    }
    else {
      if ( item2.height() > image.height() ) {
        image.css({height: "100%"});
      }
      else {
        image.css({maxHeight: "100%"});
      }
    }
    jQuery(this).find(".bwg-item2").css({
      marginLeft: (item0.width() - image.width()) / 2,
      marginTop: (item0.height() - image.height()) / 2
    });
  });
  bwg_container_loaded(jQuery(that).data('bwg'));
}

function bwg_thumbnail(that) {
  var container_width = jQuery(that).width();
  var thumb_width = jQuery(that).data("thumbnail-width");
  var max_count = jQuery(that).data("max-count");
  var column_count = parseInt(container_width / thumb_width) + 1;
  if (column_count > max_count) {
    column_count = max_count;
  }
  /*var flex = 1 / column_count;*/
  var min_width = 100 / column_count;
  var bwg_item = jQuery(that).find(".bwg-item");
  bwg_item.css({
    /*flexGrow: flex,*/
    width: min_width + "%"
  });
  jQuery(that).children(".bwg-item").each(function () {
    var image = jQuery(this).find("img");
    var item2 = jQuery(this).find(".bwg-item2");
    if ( (item2.width() / item2.height()) > (image.width() / image.height()) ) {
      if ( item2.width() > image.width() ) {
        image.css({width: "100%"});
      }
      else {
        image.css({maxWidth: "100%"});
      }
    }
    else {
      if ( item2.height() > image.height() ) {
        image.css({height: "100%"});
      }
      else {
        image.css({maxHeight: "100%"});
      }
    }
    jQuery(this).find(".bwg-item2").css({
      marginLeft: (item2.width() - image.width()) / 2,
      marginTop: (item2.height() - image.height()) / 2
    });
  });
  bwg_container_loaded(jQuery(that).data('bwg'));
}

function bwg_thumbnail_masonry(that) {
  var container = jQuery(that);
  container.find('.bwg-empty-item').remove();
  var masonry_type = container.data("masonry-type");
  if ('horizontal' == masonry_type) {
    var thumb_height = container.data( "thumbnail-height" );
    var max_count = container.data( "max-count" );
    var column_widths = [];
    for ( i = 0; i < max_count; i++ ) {
      column_widths.push( 0 );
    }
    container.find( ".bwg-item" ).each( function () {
      var order = column_widths.indexOf( Math.min.apply( Math, column_widths ) );
      jQuery( this ).css( { height: thumb_height, order: order + 1 } );
      /* Use getBoundingClientRect instead of jQuery.width() to avoid rounding. */
      column_widths[order] += jQuery( this )[0].getBoundingClientRect().width;
    } );
    var container_width = Math.max.apply( Math, column_widths );
    container.width( container_width );

    /* Equalize all rows. */
    for ( i = 0; i < max_count; i++ ) {
      if ( column_widths[i] < container_width ) {
        container.append( jQuery( '<div class="bwg-item bwg-empty-item"></div>' ).css( {
          height: thumb_height,
          order: i + 1,
          width: container_width - column_widths[i]
        } ) );
      }
    }
  }
  else {
    container.removeAttr('style');
    var container_width = container.width();
    var thumb_width = container.data( "thumbnail-width" );
    var max_count = container.data( "max-count" );
    var column_count = parseInt( container_width / thumb_width ) + (container.data('resizable-thumbnails') == '0' ? 0 : 1);
    if ( column_count > max_count ) {
      column_count = max_count;
    }
    var thumb_count = container.find( ".bwg-item" ).length;
    if ( thumb_count < column_count ) {
      column_count = thumb_count;
    }
    var min_width = 100 / column_count;
    var column_heights = [];
    for ( i = 0; i < column_count; i++ ) {
      column_heights.push( 0 );
    }
    container.find( ".bwg-item" ).each( function () {
      var order = column_heights.indexOf( Math.min.apply( Math, column_heights ) );
      jQuery( this ).css( { width: min_width + "%", order: order + 1 } );
      /* Use getBoundingClientRect instead of jQuery.height() to avoid rounding. */
      column_heights[order] += jQuery( this )[0].getBoundingClientRect().height;
    } );

    var container_height = Math.max.apply( Math, column_heights );
    /* Equalize all columns. */
    for ( i = 0; i < column_count; i++ ) {
      if ( column_heights[i] < container_height ) {
        container.append( jQuery( '<div class="bwg-item bwg-empty-item"></div>' ).css( {
          width: min_width + "%",
          order: i + 1,
          height: container_height - column_heights[i]
        } ) );
      }
    }

    container.outerWidth( column_count * thumb_width );
    container.height( container_height );
  }
  bwg_container_loaded(container.data('bwg'));
}

function bwg_thumbnail_mosaic(that) {
  var container = jQuery(that);
  var bwg = container.attr('data-bwg');
  var block_id = container.attr('data-block-id');
  var padding_px = parseInt(container.attr('data-thumb-padding')) / 2;
  var border_px = parseInt(container.attr('data-thumb-border'));
  var border_and_padding = border_px + padding_px;
  if (container.attr('data-mosaic-direction') == 'horizontal') {
    var thumb_height = parseInt(container.attr('data-height'));
    /*resizable mosaic*/
    if (container.attr('data-resizable') == '1') {
      if (jQuery(window).width() >= 1920) {
        var thumbnail_height = (1+jQuery(window).width()/1920)*thumb_height;
      }
      else if (jQuery(window).width() <= 640) {
        var thumbnail_height = jQuery(window).width()/640*thumb_height;
      }
      else {
        var thumbnail_height = thumb_height;
      }
    }
    else {
      var thumbnail_height = thumb_height;
    }
    /* initialize */
    var mosaic_pics = jQuery(".bwg_mosaic_thumb_" + bwg);
    mosaic_pics.each(function (index) {
      var thumb_w = mosaic_pics.get(index).naturalWidth;
      var thumb_h = mosaic_pics.get(index).naturalHeight;
      thumb_w = thumb_w * thumbnail_height / thumb_h;
      mosaic_pics.eq(index).height(thumbnail_height);
      mosaic_pics.eq(index).width(thumb_w);
    });
    /* resize */
    var divwidth = jQuery("#bwg_mosaic_thumbnails_div_" + bwg).width() / 100 * parseInt(container.attr('data-total-width'));
    /*set absolute mosaic width*/
    jQuery("#" + block_id).width(divwidth);
    var row_height = thumbnail_height + 2 * border_and_padding;
    var row_number = 0;
    var row_of_img = [];
    /* row of the current image*/
    row_of_img[0] = 0;
    var imgs_by_rows = [];
    /* number of images in each row */
    imgs_by_rows[0] = 0;
    var row_cum_width = 0;
    /* width of the current row */
    /* create masonry horizontal */
    mosaic_pics.each(function (index) {
      row_cum_width2 = row_cum_width + mosaic_pics.eq(index).width() + 2 * border_and_padding;
      if (row_cum_width2 - divwidth < 0) { /* add the image to the row */
        row_cum_width = row_cum_width2;
        row_of_img[index] = row_number;
        imgs_by_rows[row_number]++;
      }
      else {
        if (index !== mosaic_pics.length - 1) { /* if not last element */
          if ((Math.abs(row_cum_width - divwidth) > Math.abs(row_cum_width2 - divwidth)) || !(!(Math.abs(row_cum_width - divwidth) <= Math.abs(row_cum_width2 - divwidth)) || !(imgs_by_rows[row_number] == 0))) {
            if (index !== mosaic_pics.length - 2) { /* add and shrink if not the second */
              row_cum_width = row_cum_width2;
              row_of_img[index] = row_number;
              imgs_by_rows[row_number]++;
              row_number++;
              imgs_by_rows[row_number] = 0;
              row_cum_width = 0;
            }
            else { /* add second but NOT shrink and not change row */
              row_cum_width = row_cum_width2;
              row_of_img[index] = row_number;
              imgs_by_rows[row_number]++;
            }
          }
          else { /* add to new row and  stretch prev row (or shrink if even one pic is big) */
            row_number++;
            imgs_by_rows[row_number] = 1;
            row_of_img[index] = row_number;
            row_cum_width = row_cum_width2 - row_cum_width;
          }
        }
        else { /* if the last element, add and shrink */
          row_cum_width = row_cum_width2;
          row_of_img[index] = row_number;
          imgs_by_rows[row_number]++;
        }
      }
    });
    /* create mosaics */
    var stretch = [];
    /* stretch[row] factors */
    var row_new_height = [];
    /* array to store height of every column */
    for (var row = 0; row <= row_number; row++) {
      stretch[row] = 1;
      row_new_height[row] = row_height;
    }
    /* find stretch factors */
    for (var row = 0; row <= row_number; row++) {
      row_cum_width = 0;
      mosaic_pics.each(function (index) {
        if (row_of_img[index] == row) {
          row_cum_width += mosaic_pics.eq(index).width();
        }
      });
      stretch[row] = x = (divwidth - imgs_by_rows[row] * 2 * border_and_padding) / row_cum_width;
      row_new_height[row] = (row_height - 2 * border_and_padding) * stretch[row] + 2 * border_and_padding;
    }
    /* stretch and shift to create mosaic horizontal */
    var last_img_index = [];
    /* last image in row */
    last_img_index[0] = 0;
    /* zero points */
    var img_left = [];
    var row_top = [];
    img_left[0] = 0;
    row_top[0] = 0;
    for (var row = 1; row <= row_number; row++) {
      img_left[row] = img_left[0];
      row_top[row] = row_top[row - 1] + row_new_height[row - 1];
    }
    mosaic_pics.each(function (index) {
      var thumb_w = mosaic_pics.eq(index).width();
      var thumb_h = mosaic_pics.eq(index).height();
      mosaic_pics.eq(index).width(thumb_w * stretch[row_of_img[index]]);
      mosaic_pics.eq(index).height(thumb_h * stretch[row_of_img[index]]);
      mosaic_pics.eq(index).parent().css({
        top: row_top[row_of_img[index]],
        left: img_left[row_of_img[index]]
      });
      img_left[row_of_img[index]] += thumb_w * stretch[row_of_img[index]] + 2 * border_and_padding;
      last_img_index[row_of_img[index]] = index;
    });
    jQuery("#" + block_id).height(row_top[row_number] + row_new_height[row_number] - row_top[0]);
  }
  else {
    var thumb_width = parseInt(container.attr('data-width'));
    /* Resizable mosaic.*/
    if (container.attr('data-resizable') == '1') {
      if (jQuery(window).width() >= 1920) {
        var thumbnail_width = (1 + jQuery(window).width() / 1920) * thumb_width;
      }
      else if (jQuery(window).width() <= 640) {
        var thumbnail_width = jQuery(window).width() / 640 * thumb_width;
      }
      else {
        var thumbnail_width = thumb_width;
      }
    }
    else {
      var thumbnail_width = thumb_width;
    }
    /* Initialize.*/
    var mosaic_pics = jQuery(".bwg_mosaic_thumb_" + bwg);
    mosaic_pics.each(function (index) {
      var thumb_w = mosaic_pics.get(index).naturalWidth;
      var thumb_h = mosaic_pics.get(index).naturalHeight;
      mosaic_pics.eq(index).height(thumb_h * thumbnail_width / thumb_w);
      mosaic_pics.eq(index).width(thumbnail_width);
    });
    /* Resize.*/
    var divwidth = jQuery("#bwg_mosaic_thumbnails_div_" + bwg).width() / 100 * parseInt(container.attr('data-total-width'));
    /* Set absolute width of mosaic.*/
    jQuery('#' + block_id).width(divwidth);
    var col_width = thumbnail_width + 2 * border_and_padding < divwidth ? thumbnail_width : divwidth - 2 * border_and_padding;
    var col_number = Math.floor(divwidth / (col_width + 2 * border_and_padding));
    var col_of_img = [];
    /*column of the current image*/
    col_of_img[0] = 0;
    var imgs_by_cols = [];
    /*number of images in each column*/
    /*zero points*/
    var min_top = [];
    for (var x = 0; x < col_number; x++) {
      min_top[x] = 0;
      imgs_by_cols[x] = 0;
    }
    var img_wrap_left = 0;
    /*create masonry vertical*/
    mosaic_pics.each(function (index) {
      var col = 0;
      var min = min_top[0];
      for (var x = 0; x < col_number; x++) {
        if (min > min_top[x]) {
          min = min_top[x];
          col = x;
        }
      }
      col_of_img[index] = col;
      /*store in which col is arranged*/
      imgs_by_cols[col]++;
      img_container_top = min;
      img_container_left = img_wrap_left + col * (col_width + 2 * border_and_padding);
      mosaic_pics.eq(index).parent().css({top: img_container_top, left: img_container_left});
      min_top[col] += mosaic_pics.eq(index).height() + 2 * border_and_padding;
    });
    /*create mosaics*/
    var stretch = [];
    stretch[0] = 1;
    var sum_col_width = 0;
    var sum_col_height = [];
    /*array to store height of every column*/
    /*solve equations to calculate stretch[col] factors*/
    var axbx = 0;
    var axpxbx = 0;
    for (var x = 0; x < col_number; x++) {
      sum_col_width += col_width;
      sum_col_height[x] = 0;
      mosaic_pics.each(function (index) {
        if (col_of_img[index] == x) {
          sum_col_height[x] += mosaic_pics.eq(index).height();
        }
      });
      if (sum_col_height[x] != 0) {
        axbx += col_width / sum_col_height[x];
        axpxbx += col_width * imgs_by_cols[x] * 2 * border_and_padding / sum_col_height[x];
      }
    }
    var common_height = 0;
    if (axbx != 0) {
      common_height = (sum_col_width + axpxbx) / axbx;
    }
    for (var x = 0; x < col_number; x++) {
      if (sum_col_height[x] != 0) {
        stretch[x] = (common_height - imgs_by_cols[x] * 2 * border_and_padding) / sum_col_height[x];
      }
    }
    var img_container_left = [];
    /*position.left of every column*/
    img_container_left[0] = img_wrap_left;
    for (var x = 1; x <= col_number; x++) {
      img_container_left[x] = img_container_left[x - 1] + col_width * stretch[x - 1] + 2 * border_and_padding;
    }
    /*reset min_top array to the position.top of #wrap container*/
    var img_container_top = [];
    for (var x = 0; x < col_number; x++) {
      img_container_top[x] = 0;
    }
    /*stretch and shift to create mosaic verical*/
    var last_img_index = [];
    /* last image in column*/
    last_img_index[0] = 0;
    mosaic_pics.each(function (index) {
      var thumb_w = mosaic_pics.eq(index).width();
      var thumb_h = mosaic_pics.eq(index).height();
      mosaic_pics.eq(index).width(thumb_w * stretch[col_of_img[index]]);
      mosaic_pics.eq(index).height(thumb_h * stretch[col_of_img[index]]);
      mosaic_pics.eq(index).parent().css({
        top: img_container_top[col_of_img[index]],
        left: img_container_left[col_of_img[index]]
      });
      img_container_top[col_of_img[index]] += thumb_h * stretch[col_of_img[index]] + 2 * border_and_padding;
      last_img_index[col_of_img[index]] = index;
    });
    jQuery("#" + block_id).width(img_container_left[col_number]).height(img_container_top[0]);
  }
  /*IMPORTANT!*/
  jQuery(".bwg_mosaic_thumbnails_" + bwg).css({visibility: 'visible'});
  jQuery(".tablenav-pages_" + bwg).css({visibility: 'visible'});
  bwg_container_loaded(bwg);
  jQuery(".bwg_mosaic_thumb_"+bwg).removeClass("bwg-hidden");
  jQuery("#bwg_mosaic_thumbnails_div_"+bwg).removeClass("bwg-hidden");

  bwg_mosaic_mosaic_play_icons(bwg, container, border_and_padding);
  if (container.attr('data-image-title') == 'hover') {
    bwg_mosaic_title_on_hover(bwg, container, border_and_padding)
  }
  if (container.attr('data-ecommerce-icon') == 'hover') {
    jQuery(".bwg_mosaic_thumb_spun_" + bwg).on("mouseenter", function() {
      var img_w = jQuery(this).parents(".bwg-mosaic-thumb-span").children(".bwg_mosaic_thumb_" + bwg).width();
      var img_h = jQuery(this).parents(".bwg-mosaic-thumb-span").children(".bwg_mosaic_thumb_" + bwg).height();
      jQuery(this).children(".bwg_ecommerce_spun1_" + bwg).width(img_w);
      var title_w = jQuery(this).children(".bwg_ecommerce_spun1_" + bwg).width();
      var title_h = jQuery(this).children(".bwg_ecommerce_spun1_" + bwg).height();
      jQuery(this).children(".bwg_ecommerce_spun1_" + bwg).css({
        top: border_and_padding + 0.5 * img_h - 0.5 * title_h,
        left: border_and_padding +  0.5 * img_w - 0.5 * title_w,
        'opacity': 1,
        'filter': 'Alpha(opacity=100)'
      });
    });
    jQuery(".bwg_mosaic_thumb_spun_" + bwg).on("mouseleave", function() {
      jQuery(this).children(".bwg_ecommerce_spun1_" + bwg).css({ top: 0, left: -10000,'opacity': 0,
        'filter': 'Alpha(opacity=0)','padding': container.attr('data-title-margin')});
    });
  }
}

function bwg_mosaic_title_on_hover(bwg, container, border_and_padding) {
  jQuery(".bwg-mosaic-thumb-span").on("mouseenter", function() {
      var img_w = jQuery(this).children(".bwg_mosaic_thumb_" + bwg).width();
      var img_h = jQuery(this).children(".bwg_mosaic_thumb_" + bwg).height();
      jQuery(this).find(".bwg_mosaic_title_spun1_" + bwg).width(img_w);
      var title_w = jQuery(this).find(".bwg_mosaic_title_spun1_" + bwg).width();
      var title_h = jQuery(this).find(".bwg_mosaic_title_spun1_" + bwg).height();
      jQuery(this).find(".bwg_mosaic_title_spun1_" + bwg).css({
        top: ( (border_and_padding + 0.5 * img_h - 0.5 * title_h) < 0 ) ? border_and_padding : border_and_padding + 0.5 * img_h - 0.5 * title_h,
        left: border_and_padding +  0.5 * img_w - 0.5 * title_w,
        'opacity': 1,
        'filter': 'Alpha(opacity=100)',
        'max-height' : 'calc(100% - ' + 2 * border_and_padding + 'px)',
        'overflow' : 'hidden'
      });
    });
    jQuery(".bwg-mosaic-thumb-span").on("mouseleave", function() {
      jQuery(this).find(".bwg_mosaic_title_spun1_" + bwg).css({
        top : 0,
        left : -10000,
        'opacity' : 0,
        'filter' : 'Alpha(opacity=0)',
        'padding' : container.attr('data-title-margin'),
        'max-height' : 'calc(100% - ' + 2 * border_and_padding + 'px)',
        'overflow' : 'hidden'
      });
    });
}

function bwg_mosaic_mosaic_play_icons(bwg, container, border_and_padding) {
 if ( container.attr('data-play-icon') == '1' ) {
    jQuery(".bwg_mosaic_play_icon_spun_" + bwg).each(function() {
      var img_w = jQuery(this).parent().children(".bwg_mosaic_thumb_" + bwg).width();
      var img_h = jQuery(this).parent().children(".bwg_mosaic_thumb_" + bwg).height();
      jQuery(this).css({
        top: border_and_padding + 0.5 * img_h -0.5 *  jQuery(this).height(),
        left: border_and_padding +  0.5 * img_w - 0.5 *  jQuery(this).width(),
        'opacity': 1,
        'filter': 'Alpha(opacity=100)'
      });
    });
  }
}

function bwg_mosaic_ajax(bwg, tot_cccount_mosaic_ajax) {
  var cccount_mosaic_ajax = 0;
  jQuery(".bwg_mosaic_thumb_spun_" + bwg + " img").on("load", function() {
    if (++cccount_mosaic_ajax >= tot_cccount_mosaic_ajax) {
      bwg_thumbnail_mosaic(jQuery('.bwg-mosaic-thumbnails[data-bwg=' + bwg + ']'));
    }
  });
  jQuery(".bwg_mosaic_thumb_spun_" + bwg + " img").on("error", function() {
    jQuery(this).height(100);
    jQuery(this).width(100);
    if (++cccount_mosaic_ajax >= tot_cccount_mosaic_ajax) {
      bwg_thumbnail_mosaic(jQuery('.bwg-mosaic-thumbnails[data-bwg=' + bwg + ']'));
    }
  });
}

function bwg_add_album() {
  var bwg_touch_flag = false;
  jQuery( ".bwg-album" ).off("click").on("click", function () {
    if ( !bwg_touch_flag ) {
      var bwg = jQuery(this).attr("data-bwg");
      bwg_touch_flag = true;
      setTimeout(function () {
        bwg_touch_flag = false;
      }, 100);
      bwg_ajax('gal_front_form_' + bwg, bwg, jQuery(this).attr("data-container_id"), jQuery(this).attr("data-alb_gal_id"), jQuery(this).attr("data-album_gallery_id"), jQuery(this).attr("data-def_type"), '', jQuery(this).attr("data-title"));
      return false;
    }
  });

  /* Add description more button event.*/
  jQuery( ".bwg_description_more" ).on("click", function () {
    if ( jQuery(this).hasClass("bwg_more") ) {
      jQuery(this).parent().find(".bwg_description_full").show();
      jQuery(this).addClass("bwg_hide").removeClass("bwg_more");
      jQuery(this).html(jQuery(this).data("hide-msg"));
    }
    else {
      jQuery(this).parent().find(".bwg_description_full").hide();
      jQuery(this).addClass("bwg_more").removeClass("bwg_hide");
      jQuery(this).html(jQuery(this).data("more-msg"));
    }
  });
}

function bwg_add_lightbox() {
  var bwg_touch_flag = false;
  jQuery( ".bwg_lightbox .bwg-item0, .bwg_lightbox .bwg_slide, .bwg_lightbox .bwg-carousel-image" ).on("click", function ( event ) {
    event.stopPropagation();
    event.preventDefault();
    var that = jQuery(this).parent();
    if ( !bwg_touch_flag ) {
      bwg_touch_flag = true;
      setTimeout( function () {
        bwg_touch_flag = false;
      }, 100 );
      bwg_gallery_box( jQuery( that ).attr( "data-image-id" ), jQuery( that ).closest( '.bwg_container' ) );
      return false;
    }
  });

  jQuery( ".bwg_lightbox .bwg_ecommerce" ).on("click", function ( event ) {
    event.stopPropagation();
    if ( !bwg_touch_flag ) {
      bwg_touch_flag = true;
      setTimeout( function () {
        bwg_touch_flag = false;
      }, 100 );
      var image_id = jQuery( this ).closest( ".bwg_lightbox" ).attr( "data-image-id" );
      bwg_gallery_box( image_id, jQuery( this ).closest( '.bwg_container' ), true );
      return false;
    }
  });
}

function bwg_document_ready() {
  bwg_add_lightbox();
  jQuery( 'div[id^="bwg_container"]' ).each( function () {
    var bwg_container = jQuery( this );
    if ( bwg_container.data( 'right-click-protection' ) ) {
		bwg_disable_right_click( bwg_container );
    }

    /*  Add dashicon  to select container */
    jQuery(".SumoSelect > .CaptionCont > label > i").addClass("fa fa-angle-down closed");

    var search_tags = bwg_container.find('.search_tags');
    if (search_tags.length) {
      search_tags.SumoSelect({
        triggerChangeCombined:true,
        placeholder: bwg_objectsL10n.bwg_select_tag,
        search: 1,
        searchText : bwg_objectsL10n.bwg_search,
        forceCustomRendering: true,
        noMatch: bwg_objectsL10n.bwg_tag_no_match,
        captionFormatAllSelected : bwg_objectsL10n.bwg_all_tags_selected,
        captionFormat: '{0} '+ bwg_objectsL10n. bwg_tags_selected,
      } );
    }

    var bwg_order = bwg_container.find('.bwg_order');
    if (bwg_order.length) {
      bwg_order.SumoSelect({
          triggerChangeCombined:true,
          forceCustomRendering: true,
      } );
    }

    /* Show/Hide search_placeholder_title class container */
    if (jQuery(this).find('.bwg_search_input').val() == '') {
      jQuery(this).find('search_placeholder_title').show();
    }
    else {
      jQuery(this).find('search_placeholder_title').hide();
    }

    /* Show search_placeholder_title class container on focusout and hide reset, search icons*/
    jQuery(".bwg_thumbnail .bwg_search_container_2").focusout(function (e) {
      if (jQuery(this).find('.bwg_search_input').val() == '') {
         jQuery(this).find('.search_placeholder_title').show();
         jQuery(this).find('.bwg_search_loupe_container1').addClass("hidden");
         jQuery(this).find('.bwg_search_reset_container').addClass("hidden");
      }
    });
  });

  var currentTags;

  /* Show No tags text if tags empty */
  jQuery('.search_tags').on('sumo:opened',function(event){
    currentTags = jQuery(this).parent().find('.CaptionCont').attr('title');
    if( jQuery(this).parent().find('ul li').length == 0 ) {
      jQuery(".no-match").html(bwg_objectsL10n.bwg_tag_no_match);
      jQuery(".no-match").show();
    }
  });

  /* Run function of tag filters if select box closed and there are difference between new/old selection */
  jQuery('.bwg_thumbnail .search_tags').on('sumo:closed',function(event){
    var newTags = '';
    var curCont = jQuery(this).parent().parent();
    var current_view = curCont.find('.current_view').val();
    var form_id = curCont.find('.form_id').val();
    var cur_gal_id = curCont.find('.cur_gal_id').val();
    var album_gallery_id = curCont.find('.album_gallery_id').val();
    var type = curCont.find('.type').val();

    jQuery(this).parent().find('.opt.selected').each( function () {
      newTags = newTags + jQuery(this).text() + ',';
    });
    newTags = newTags.slice(0, -1);
    if ( newTags == '' ) {
      newTags = bwg_objectsL10n.bwg_select_tag;
    }
    jQuery(this).parent().find('.CaptionCont').attr('title',newTags);
    jQuery(this).parent().find('.CaptionCont .placeholder').html(newTags);
    /* Run function if selected */
    if ( currentTags != newTags ) {
      jQuery('#bwg_tag_id_' + current_view).val(jQuery('#bwg_tag_id_' + cur_gal_id).val());
      bwg_select_tag(current_view, form_id, cur_gal_id, album_gallery_id, type, false);
    }
  });

  /* Change dashicon from up arrow to down arrow when select box is close */
  jQuery('.bwg_thumbnail .SumoSelect').on('sumo:closed', function(){
    jQuery(this).find('label i').removeClass('opened fa fa-angle-up');
    jQuery(this).find('label i').addClass("fa fa-angle-down closed");
  });

  /* Change dashicon from down arrow to up arrow when select box is open */
  jQuery('.bwg_thumbnail .SumoSelect').on('sumo:opened', function() {
    jQuery(this).find('label i').removeClass('closed fa fa-angle-down');
    jQuery(this).find('label i').addClass("fa fa-angle-up opened");
  });

  bwg_add_album();

  var bwg_hash = window.location.hash.substring( 1 );
  if ( bwg_hash ) {
    if ( bwg_hash.indexOf( "bwg" ) != "-1" ) {
      bwg_hash_array = bwg_hash.replace( "bwg", "" ).split( "/" );
      var bwg_container = jQuery( '.bwg_container' );

      if ( bwg_container ) {
        bwg_gallery_box( bwg_hash_array[1], bwg_container, false, bwg_hash_array[0] );
      }
    }
  }

  bwg_blog_style_ready();
  bwg_image_browser_ready();
  bwg_resize_search_line();
}

function bwg_clear_search_input (current_view) {
  jQuery("#bwg_search_input_" + current_view).val('');
  jQuery("#bwg_search_container_1_" + current_view + " .bwg_search_loupe_container1").addClass("hidden");
  jQuery("#bwg_search_container_1_" + current_view + " .bwg_search_reset_container").addClass("hidden");
}

function bwg_check_search_input_enter(that, e) {
  var key_code = e.which || e.keyCode;
  if (key_code == 13) {
    jQuery(that).closest('.bwg_search_container_1').find('.bwg_search').trigger('click');
    return false;
  }
  return true;
}

/* Ajax call for filters and pagination.*/
function bwg_ajax(form_id, current_view, id, album_gallery_id, cur_album_id, type, srch_btn, title, sortByParam, load_more, description) {
  /* Show loading.*/
  jQuery("#ajax_loading_" + current_view).removeClass('bwg-hidden');

  /* Disable scroll to prevent bugs with load more.*/
  if (typeof bwg_scroll_load_action === "function") {
    jQuery(window).off("scroll", bwg_scroll_load_action);
  }

  /* To prevent bugs with filters.*/
  jQuery(".bwg_thumbnail .search_tags").off("sumo:closed");

  var ajax_url = jQuery('#' + form_id).data("ajax-url");

  var masonry_loaded = 0;
  var mosaic_loaded = 0;
  if (typeof load_more == "undefined") {
    var load_more = false;
  }
  var page_number = jQuery("#page_number_" + current_view).val();

  var post_data = {};

  var breadcrumb_str = jQuery('#bwg_album_breadcrumb_' + current_view).val();
  if ( breadcrumb_str && load_more !== true ) { /* For album views.*/
    var breadcrumb = JSON.parse(breadcrumb_str);
    if (album_gallery_id == 'back') {
      /* Remove last element of array.*/
      breadcrumb.splice(-1, 1);
      var last_el = breadcrumb.slice(-1)[0];
      album_gallery_id = last_el["id"];
      page_number = last_el["page"];
      post_data["action_" + current_view] = 'back';
    }
    else if ( load_more === 'numeric' || srch_btn ) {/* From numeric pagination.*/
      breadcrumb.splice(-1, 1);
      breadcrumb.push({id: album_gallery_id, page: page_number});
    }
    else {
      breadcrumb.push({id: album_gallery_id, page: 1});
      page_number = 1;
    }
    post_data["bwg_album_breadcrumb_" + current_view] = JSON.stringify(breadcrumb);
  }

  /** Set values for elementor widget.*/
  post_data['gallery_type'] = jQuery('#' + form_id).data("gallery-type");
  post_data['gallery_id'] = jQuery('#' + form_id).data("gallery-id");
  post_data['tag'] = jQuery('#' + form_id).data("tag");
  post_data['album_id'] = jQuery('#' + form_id).data("album-id");
  post_data['theme_id'] = jQuery('#' + form_id).data("theme-id");

  post_data['shortcode_id'] = jQuery('#' + form_id).data("shortcode-id");
  post_data['bwg'] = current_view;

  if ( srch_btn ) { /* Start search. */
    page_number = 1;
  }
  if (typeof title == "undefined" || title == '') {
    var title = "";
  }
  if (typeof description == "undefined" || description == '') {
    var description = "";
  }
  if (typeof sortByParam == "undefined" || sortByParam == '') {
    var sortByParam = jQuery(".bwg_order_" + current_view).val();
  }

  post_data["page_number_" + current_view] = page_number;
  post_data["bwg_load_more_" + current_view] = jQuery("#bwg_load_more_" + current_view).val();
  post_data["album_gallery_id_" + current_view] = album_gallery_id;
  post_data["type_" + current_view] = type;
  post_data["title_" + current_view] = title;
  post_data["description_" + current_view] = description;
  post_data["sortImagesByValue_" + current_view] = sortByParam;
  if (jQuery("#bwg_search_input_" + current_view).length > 0) { /* Search box exists.*/
    post_data["bwg_search_" + current_view] = jQuery("#bwg_search_input_" + current_view).val();
  }
  post_data["bwg_tag_id_" + id] = jQuery("#bwg_tag_id_" + id).val();
  /* Loading.*/
  jQuery('#gal_front_form_' + current_view).addClass('bwg-hidden');
  jQuery("#ajax_loading_" + current_view).removeClass('bwg-hidden');

  jQuery.ajax({
    type: "POST",
    url: ajax_url,
    data: post_data,
    success: function (data) {
      masonry_loaded = jQuery(data).find(".bwg_masonry_thumb_spun_" + current_view + " img").length;
      mosaic_loaded = jQuery(data).find(".bwg_mosaic_thumb_spun_" + current_view + " img").length;

      if ( load_more === true ) {
        /* Add next page images after current ones instead of change all container.*/
        if ( id == "bwg_thumbnails_mosaic_" + current_view ) {
          /* ToDo: Remove after changing mosaic view.*/
          jQuery('#' + id).append(jQuery(data).closest(".bwg-container-" + current_view).find("#" + id).html());
        }
        else if ( id == "bwg_album_compact_" + current_view ) {
          jQuery('#' + id).append(jQuery(data).closest(".bwg-album-thumbnails").html());
        }
        else {
          jQuery('#' + id).append(jQuery(data).closest(".bwg-container-" + current_view).html());
        }
        /* Change load more button container withe new one.*/
        jQuery('.bwg_nav_cont_' + current_view).html(jQuery(data).closest('.bwg_nav_cont_' + current_view).html());
      }
      else {
        /* Change all container with new data.*/
        jQuery('#bwg_container3_' + current_view).html(data);
      }
    },
    complete: function() {
      /* To prevent conflict with lazy load.*/
      jQuery("div[id^='bwg_container1_'] img").each(function () {
        if (jQuery(this).attr("data-lazy-src") != undefined && jQuery(this).attr("data-lazy-src") != '') {
          jQuery(this).attr("src", jQuery(this).attr("data-lazy-src"));
        }
        else if (jQuery(this).attr("data-src") != undefined && jQuery(this).attr("data-src") != '') {
          jQuery(this).attr("src", jQuery(this).attr("data-src"));
        }
      });
      jQuery(".blog_style_image_buttons_conteiner_" + current_view).find(jQuery(".bwg_blog_style_img_" + current_view)).on("load", function() {
        jQuery(".bwg_blog_style_img_" + current_view).closest(jQuery(".blog_style_image_buttons_conteiner_" + current_view)).show();
      });
      jQuery("#bwg_tags_id_" + id).val(jQuery("#bwg_tag_id_" + id).val());

      if ( jQuery(".pagination-links_" + current_view).length ) {
        jQuery("html, body").animate({scrollTop: jQuery('#' + form_id).offset().top - 150}, 500);
      }
      /* For all views. */
      bwg_document_ready();
      bwg_mosaic_ajax(current_view, mosaic_loaded);
      var no_data = bwg_all_thumnails_loaded(".bwg-container-" + current_view);
      if ( no_data ) {
        /* If there where no data after after ajax request.*/
        bwg_container_loaded(current_view);
      }
      /* For Blog style view.*/
      jQuery(".blog_style_images_conteiner_" + current_view + " .bwg_embed_frame_16x9_" + current_view).each(function (e) {
        jQuery(this).width(jQuery(this).parent().width());
        jQuery(this).height(jQuery(this).width() * 0.5625);
      });
      jQuery(".blog_style_images_conteiner_" + current_view + " .bwg_embed_frame_instapost_" + current_view).each(function (e) {
        jQuery(this).width(jQuery(this).parent().width());
        /* 16 is 2*padding inside iframe */
        /* 96 is 2*padding(top) + 1*padding(bottom) + 40(footer) + 32(header) */
        jQuery(this).height((jQuery(this).width() - 16) * jQuery(this).attr('data-height') / jQuery(this).attr('data-width') + 96);
      });
      /* For Image browser view.*/
      jQuery('#bwg_embed_frame_16x9_' + current_view).width(jQuery('#bwg_embed_frame_16x9_' + current_view).parent().width());
      jQuery('#bwg_embed_frame_16x9_' + current_view).height(jQuery('#bwg_embed_frame_16x9_' + current_view).width() * 0.5625);
      jQuery('#bwg_embed_frame_instapost_' + current_view).width(jQuery('#bwg_embed_frame_16x9_' + current_view).parent().width());
      /* 16 is 2*padding inside iframe */
      /* 96 is 2*padding(top) + 1*padding(bottom) + 40(footer) + 32(header) */
      jQuery('.bwg_embed_frame_instapost_' + current_view).height((jQuery('.bwg_embed_frame_instapost_' + current_view).width() - 16) * jQuery('.bwg_embed_frame_instapost_' + current_view).attr('data-height') / jQuery('.bwg_embed_frame_instapost_' + current_view).attr('data-width') + 96);

      /* return value to search input field */
      jQuery("#bwg_search_input_" + current_view).val(post_data["bwg_search_" + current_view]);

      if ( jQuery("#bwg_search_input_" + current_view).val() != '' ) {
        jQuery("#bwg_search_input_" + current_view).parent().find('.search_placeholder_title').hide();
        jQuery("#bwg_search_input_" + current_view).parent().parent().find('.bwg_search_reset_container').show();
        jQuery("#bwg_search_input_" + current_view).parent().parent().find('.bwg_search_loupe_container1').show();
      } else {
        jQuery("#bwg_search_input_" + current_view).parent().find('.search_placeholder_title').show();
      }
      var cur_gal_id = jQuery("#bwg_container2_"+current_view+" .cur_gal_id").val();
      jQuery('#bwg_tag_id_' + current_view).val(jQuery('#bwg_tag_id_'+cur_gal_id).val());
    }
  });

  return false;
}

function bwg_select_tag(current_view, form_id, cur_gal_id, album_gallery_id, type, reset) {
  if ( reset ) {
    jQuery("#bwg_tag_id_" + cur_gal_id).val('');
  }

  bwg_ajax(form_id, current_view, cur_gal_id, album_gallery_id, '', type, 1, '');
}

function bwg_preload_images_lightbox( key ) {
  var count_all = data.length;
  var preloadCount = ( bwg_param['preload_images_count'] == 0 || bwg_param['preload_images_count'] >= count_all ) ? count_all : bwg_param['preload_images_count'];
  var indexedImgCount = 0;
  for ( var i = 1; indexedImgCount < preloadCount; i++ ) {
    var sign = 1;
    do {
      var index = ( key + i * sign + count_all ) % count_all;
      if ( typeof data[index] != "undefined" ) {
        var is_embed = data[index]['filetype'].indexOf( "EMBED_" ) > -1 ? true : false;
        if ( !is_embed ) {
          jQuery( "<img/>" ).attr( "src", bwg_param['site_url'] + jQuery( '<span style="display: block;" />' ).html( data[index]["image_url"] ).text() );
        }
      }
      sign *= -1;
      indexedImgCount++;
    }
    while ( sign != 1 );
  }
}

function bwg_cube(tz, ntx, nty, nrx, nry, wrx, wry, current_image_class, next_image_class, direction, bwg) {
  var type_slideshow = false;
  var bwg_prefix = "";
  var bwg_transition_dur;
  if ( typeof bwg != 'undefined' ) {
    type_slideshow = true;
    bwg_params[bwg]['bwg_trans_in_progress'] = true;
    bwg_prefix = "_"+bwg;
    bwg_transition_dur = bwg_params[bwg]['bwg_transition_duration'];
    var event_stack = bwg_params[bwg]['event_stack']
  } else {
    bwg_transition_dur = bwg_transition_duration;
  }
  /* If browser does not support 3d transforms/CSS transitions.*/
  if (!bwg_testBrowser_cssTransitions( bwg )) {
    return bwg_fallback(current_image_class, next_image_class, direction, bwg);
  }
  if (!bwg_testBrowser_cssTransforms3d( bwg )) {
    return bwg_fallback3d(current_image_class, next_image_class, direction, bwg);
  }
  if( !type_slideshow) { /* from lightbox */
      bwg_param['bwg_trans_in_progress'] = true;
      /* Set active thumbnail.*/
      jQuery(".bwg_filmstrip_thumbnail").removeClass("bwg_thumb_active").addClass("bwg_thumb_deactive");
      jQuery("#bwg_filmstrip_thumbnail_" + bwg_param['bwg_current_key']).removeClass("bwg_thumb_deactive").addClass("bwg_thumb_active");
      jQuery(".bwg_slide_bg").css('perspective', 1000);
  } else { /* from slideshow */
      /* Set active thumbnail.*/
      jQuery(".bwg_slideshow_filmstrip_thumbnail_"+bwg).removeClass("bwg_slideshow_thumb_active_"+bwg).addClass("bwg_slideshow_thumb_deactive_"+bwg);
      jQuery("#bwg_filmstrip_thumbnail_" + bwg_params[bwg]['bwg_current_key']+ "_"+bwg).removeClass("bwg_slideshow_thumb_deactive_"+bwg).addClass("bwg_slideshow_thumb_active_"+bwg);
      jQuery(".bwg_slideshow_dots_"+bwg).removeClass("bwg_slideshow_dots_active_"+bwg).addClass("bwg_slideshow_dots_deactive_"+bwg);
      jQuery("#bwg_dots_" + bwg_params[bwg]['bwg_current_key'] + "_" + bwg).removeClass("bwg_slideshow_dots_deactive_"+bwg).addClass("bwg_slideshow_dots_active_"+bwg);
      jQuery(".bwg_slide_bg_"+bwg).css('perspective', 1000);
  }
  jQuery(current_image_class).css({
    transform : 'translateZ(' + tz + 'px)',
    backfaceVisibility : 'hidden'
  });
  jQuery(next_image_class).css({
    opacity : 1,
    filter: 'Alpha(opacity=100)',
    backfaceVisibility : 'hidden',
    transform : 'translateY(' + nty + 'px) translateX(' + ntx + 'px) rotateY('+ nry +'deg) rotateX('+ nrx +'deg)'
  });
  jQuery(".bwg_slider"+bwg_prefix).css({
    transform: 'translateZ(-' + tz + 'px)',
    transformStyle: 'preserve-3d'
  });
  /* Execution steps.*/
  setTimeout(function () {
    jQuery(".bwg_slider"+bwg_prefix).css({
      transition: 'all ' + bwg_transition_dur + 'ms ease-in-out',
      transform: 'translateZ(-' + tz + 'px) rotateX('+ wrx +'deg) rotateY('+ wry +'deg)'
    });
  }, 20);
  /* After transition.*/
  jQuery(".bwg_slider"+bwg_prefix).one('webkitTransitionEnd transitionend otransitionend oTransitionEnd mstransitionend', jQuery.proxy(bwg_after_trans));
  function bwg_after_trans() {
    jQuery(current_image_class).removeAttr('style');
    jQuery(next_image_class).removeAttr('style');
    jQuery(".bwg_slider"+bwg_prefix).removeAttr('style');
    jQuery(current_image_class).css({'opacity' : 0, filter: 'Alpha(opacity=0)', 'z-index': 1});
    jQuery(next_image_class).css({'opacity' : 1, filter: 'Alpha(opacity=100)', 'z-index' : 2});
    jQuery(".bwg_image_info").show();

    jQuery(current_image_class).html('');

    if ( type_slideshow ) {  /*check if cube works from slideshow*/
      bwg_change_watermark_container( bwg );
      bwg_params[bwg]['bwg_trans_in_progress'] = false;
      var data = bwg_params[bwg]['data'];
      var event_stack = bwg_params[bwg]['event_stack'];
    } else {
      bwg_param['bwg_trans_in_progress'] = false;
      var event_stack = bwg_param['event_stack'];
    }
    if (typeof event_stack !== 'undefined') {
      if (event_stack.length > 0) {
        key = event_stack[0].split("-");
        event_stack.shift();
        bwg_change_image(key[0], key[1], data, true, bwg);
      }
    }
    bwg_change_watermark_container();
  }
  if (bwg_transition_dur == 0) {
    bwg_after_trans();
  }
}

function bwg_fade(current_image_class, next_image_class, direction, bwg) {
  var type_slideshow = false;
  var bwg_transition_dur;
  if( typeof bwg != 'undefined' ) {
      type_slideshow = true;
      bwg_params[bwg]['bwg_trans_in_progress'] = true;
      bwg_transition_dur = bwg_params[bwg]['bwg_transition_duration'];
  } else {
      bwg_param['bwg_trans_in_progress'] = true;
      bwg_transition_dur = bwg_param['bwg_transition_duration'];
  }

  if(type_slideshow) {
      /* Set active thumbnail.*/
      jQuery(".bwg_slideshow_filmstrip_thumbnail_"+bwg).removeClass("bwg_slideshow_thumb_active_"+bwg).addClass("bwg_slideshow_thumb_deactive_"+bwg);
      jQuery("#bwg_filmstrip_thumbnail_" + bwg_params[bwg]['bwg_current_key'] + "_"+bwg).removeClass("bwg_slideshow_thumb_deactive_"+bwg).addClass("bwg_slideshow_thumb_active_"+bwg);
      jQuery(".bwg_slideshow_dots_"+bwg).removeClass("bwg_slideshow_dots_active_"+bwg).addClass("bwg_slideshow_dots_deactive_"+bwg);
      jQuery("#bwg_dots_" + bwg_params[bwg]['bwg_current_key'] + "_"+bwg).removeClass("bwg_slideshow_dots_deactive_"+bwg).addClass("bwg_slideshow_dots_active_"+bwg);
  } else {
      /* Set active thumbnail.*/
      jQuery(".bwg_filmstrip_thumbnail").removeClass("bwg_thumb_active").addClass("bwg_thumb_deactive");
      jQuery("#bwg_filmstrip_thumbnail_" + bwg_param['bwg_current_key']).removeClass("bwg_thumb_deactive").addClass("bwg_thumb_active");
  }
    function bwg_after_trans() {
        jQuery(".bwg_image_info").show();
        bwg_change_watermark_container( bwg );
        if( type_slideshow ) {
          bwg_params[bwg]['bwg_trans_in_progress'] = false;
        } else {
          bwg_param['bwg_trans_in_progress'] = false;
        }
    }
    if (bwg_testBrowser_cssTransitions()) {
        jQuery(next_image_class).css('transition', 'opacity ' + bwg_transition_dur + 'ms linear');
        jQuery(current_image_class).css({'opacity' : 0, 'z-index': 1});
        jQuery(next_image_class).css({'opacity' : 1, 'z-index' : 2});
        jQuery(next_image_class).one('webkitTransitionEnd transitionend otransitionend oTransitionEnd mstransitionend', jQuery.proxy(bwg_after_trans));
    }
    else {
        jQuery(current_image_class).animate({'opacity' : 0, 'z-index' : 1}, bwg_transition_dur);
        jQuery(next_image_class).animate({
            'opacity' : 1,
            'z-index': 2
        }, {
            duration: bwg_transition_dur,
            complete: function () {
              if( type_slideshow ) {
                bwg_params[bwg]['bwg_trans_in_progress'] = false;
              } else {
                bwg_param['bwg_trans_in_progress'] = false;
              }
              jQuery(current_image_class).html('');
                bwg_after_trans()
            }
        });
        /* For IE.*/
        jQuery(current_image_class).fadeTo(bwg_transition_dur, 0);
        jQuery(next_image_class).fadeTo(bwg_transition_dur, 1);
    }
    if (bwg_transition_dur == 0) {
        bwg_after_trans();
    }
}

/* Set watermark container size.*/
function bwg_change_watermark_container( bwg ) {
  var defix = ( typeof bwg != 'undefined' ) ? '_'+bwg : '';
  jQuery(".bwg_slider"+defix).children().each(function() {
    if (jQuery(this).css("zIndex") == 2) {
      /* For images.*/
      var bwg_current_image_span = jQuery(this).find("img");
      if (bwg_current_image_span.length) {
        if (bwg_current_image_span.prop('complete')) {
          var width = bwg_current_image_span.width();
          var height = bwg_current_image_span.height();
          bwg_change_each_watermark_container(width, height, bwg);
        }
        else {
          bwg_current_image_span.on("load", function () {
            var width = bwg_current_image_span.width();
            var height = bwg_current_image_span.height();
            bwg_change_each_watermark_container(width, height, bwg);
          });
        }
      }
      else {
        /* For embeds and videos.*/
        bwg_current_image_span = jQuery(this).find("iframe");
        if (!bwg_current_image_span.length) {
          bwg_current_image_span = jQuery(this).find("video");
        }
        var width = bwg_current_image_span.width();
        var height = bwg_current_image_span.height();
        bwg_change_each_watermark_container(width, height, bwg);
      }
    }
  });
}

/* Set each watermark container size.*/
function bwg_change_each_watermark_container(width, height, bwg) {

  var defix = ( typeof bwg != 'undefined' ) ? '_'+bwg : '';
  var source = ( typeof bwg != 'undefined' ) ? '_slideshow' : '';

  jQuery(".bwg"+source+"_watermark_spun" + defix).width(width);
  jQuery(".bwg"+source+"_watermark_spun" + defix).height(height);
  jQuery(".bwg"+source+"_watermark" + defix).css({display: ''});

  if( typeof bwg == 'undefined' ) {
      /* Set watermark image size.*/
      var comment_container_width = 0;
      if (jQuery(".bwg_comment_container").hasClass("bwg_open") || jQuery(".bwg_ecommerce_container").hasClass("bwg_open")) {
        comment_container_width = bwg_param['lightbox_comment_width'];
      }
      if (width <= (jQuery(window).width() - comment_container_width)) {
        jQuery(".bwg_watermark_image").css({
          width: ((jQuery(".spider_popup_wrap").width() - comment_container_width) * bwg_param['watermark_font_size'] / bwg_param['image_width'])
        });
        jQuery(".bwg_watermark_text, .bwg_watermark_text:hover").css({
          fontSize: ((jQuery(".spider_popup_wrap").width() - comment_container_width) * bwg_param['watermark_font_size'] / bwg_param['image_width'])
        });
      }
  } else {
    jQuery(".bwg" + source + "_title_spun" + defix).width(width);
    jQuery(".bwg" + source + "_title_spun" + defix).height(height);
    jQuery(".bwg" + source + "_description_spun" + defix).width(width);
    jQuery(".bwg" + source + "_description_spun" + defix).height(height);
  }
  if (jQuery.trim(jQuery(".bwg"+source+"_title_text" + defix).text())) {
    jQuery(".bwg_slideshow_title_text" + defix).css({display: ''});
  }
  if (jQuery.trim(jQuery(".bwg"+source+"_description_text" + defix).text())) {
    jQuery(".bwg"+source+"_description_text" + defix).css({display: ''});
  }

}

/* Set filmstrip initial position.*/
function bwg_set_filmstrip_pos( filmStripWidth, bwg ) {
  var defix = ( typeof bwg != 'undefined' ) ? '_'+bwg : '';
  var source = ( typeof bwg != 'undefined' ) ? '_slideshow' : '';
  var left_or_top = ( typeof bwg != 'undefined' ) ?  bwg_params[bwg]['left_or_top'] : bwg_param['left_or_top'];
  var top_bottom_space = parseInt(jQuery(".bwg_filmstrip_thumbnails").attr('data-all-images-top-bottom-space'));
  var right_left_space = parseInt(jQuery(".bwg_filmstrip_thumbnails").attr('data-all-images-right-left-space'));
  if( typeof bwg == 'undefined' ) {  /* for lightbox */
      if ( bwg_param['outerWidth_or_outerHeight'] == 'outerWidth' ) {
        var selectedImagePos = -bwg_current_filmstrip_pos - (jQuery(".bwg_filmstrip_thumbnail").outerWidth(true)) / 2;
      } else if ( bwg_param['outerWidth_or_outerHeight'] == 'outerHeight' ) {
        var selectedImagePos = -bwg_current_filmstrip_pos - (jQuery(".bwg_filmstrip_thumbnail").outerHeight(true)) / 2;
      }
      if ( bwg_param['width_or_height'] == 'width' ) {
        var imagesContainerLeft = Math.min(0, Math.max(filmStripWidth - jQuery(".bwg_filmstrip_thumbnails").width(), selectedImagePos + filmStripWidth / 2));
      } else if (bwg_param['width_or_height'] == 'height') {
        var imagesContainerLeft = Math.min(0, Math.max(filmStripWidth - jQuery(".bwg_filmstrip_thumbnails").height(), selectedImagePos + filmStripWidth / 2));
      }
  } else { /* for slideshow */
      if (bwg_params[bwg]['width_or_height'] == 'width') {
        var selectedImagePos = -bwg_params[bwg]['bwg_current_filmstrip_pos'] - (jQuery(".bwg_slideshow_filmstrip_thumbnail" + defix).width() + bwg_params[bwg]['filmstrip_thumb_margin_hor']) / 2;
        var imagesContainerLeft = Math.min(0, Math.max(filmStripWidth - jQuery(".bwg_slideshow_filmstrip_thumbnails" + defix).width(), selectedImagePos + filmStripWidth / 2));
      }
      else {
        var selectedImagePos = -bwg_params[bwg]['bwg_current_filmstrip_pos'] - (jQuery(".bwg_slideshow_filmstrip_thumbnail" + defix).height() + bwg_params[bwg]['filmstrip_thumb_margin_hor']) / 2;
        var imagesContainerLeft = Math.min(0, Math.max(filmStripWidth - jQuery(".bwg_slideshow_filmstrip_thumbnails" + defix).height(), selectedImagePos + filmStripWidth / 2));
      }
  }

	if ( imagesContainerLeft + right_left_space > 0 ) {
		right_left_space = 0;
	}
	if ( imagesContainerLeft + top_bottom_space > 0 ) {
		top_bottom_space = 0;
	}

  if( left_or_top == 'left' ) {
    jQuery(".bwg"+source+"_filmstrip_thumbnails" + defix).animate({
      left: imagesContainerLeft + right_left_space
    }, {
      duration: 500,
      complete: function () { bwg_filmstrip_arrows( bwg ); }
    });
  } else {
    jQuery(".bwg"+source+"_filmstrip_thumbnails" + defix).animate({
      top: imagesContainerLeft + top_bottom_space
    }, {
      duration: 500,
      complete: function () { bwg_filmstrip_arrows( bwg ); }
    });
  }
}

/* Show/hide filmstrip arrows.*/
function bwg_filmstrip_arrows( bwg ) {

  var defix = ( typeof bwg != 'undefined' ) ? '_'+bwg : '';
  var source = ( typeof bwg != 'undefined' ) ? '_slideshow' : '';
  var width_or_height = ( typeof bwg != 'undefined' ) ? bwg_params[bwg]['width_or_heigh'] : bwg_param['width_or_height'];

  if ( width_or_height == 'width' ){
    var condition1 = jQuery(".bwg"+source+"_filmstrip_thumbnails"+defix).width();
    var condition2 = jQuery(".bwg"+source+"_filmstrip"+defix).width()
  } else {
    var condition1 = jQuery(".bwg"+source+"_filmstrip_thumbnails"+defix).height();
    var condition2 = jQuery(".bwg"+source+"_filmstrip"+defix).height()
  }
  if (condition1 < condition2) {
    jQuery(".bwg"+source+"_filmstrip_left" + defix).hide();
    jQuery(".bwg"+source+"_filmstrip_right" + defix).hide();
  }
  else {
    jQuery(".bwg"+source+"_filmstrip_left" + defix).show();
    jQuery(".bwg"+source+"_filmstrip_right" + defix).show();
  }
}

function bwg_move_filmstrip( bwg ) {
  var bwg_filmstrip_width;
  var bwg_filmstrip_thumbnails_width;
  var image_left;
  var image_right;
  var long_filmstrip_cont_left;
  var long_filmstrip_cont_right;

  var defix = ( typeof bwg != 'undefined' ) ? '_'+bwg : '';
  var source = ( typeof bwg != 'undefined' ) ? '_slideshow' : '';
  var outerWidth_or_outerHeight = ( typeof bwg != 'undefined' ) ? bwg_params[bwg]['outerWidth_or_outerHeight'] : bwg_param['outerWidth_or_outerHeight'];
  var left_or_top = ( typeof bwg != 'undefined' ) ? bwg_params[bwg]['left_or_top'] : bwg_param['left_or_top'];

  if(outerWidth_or_outerHeight == 'outerWidth') {
    bwg_filmstrip_width = jQuery(".bwg" + source + "_filmstrip" + defix).outerWidth(true);
    bwg_filmstrip_thumbnails_width = jQuery(".bwg" + source + "_filmstrip_thumbnails" + defix).outerWidth(true);
  } else {
    bwg_filmstrip_width = jQuery(".bwg" + source + "_filmstrip" + defix).outerHeight(true);
    bwg_filmstrip_thumbnails_width = jQuery(".bwg" + source + "_filmstrip_thumbnails" + defix).outerHeight(true);
  }
  if( left_or_top == 'left' ) {
    image_left = jQuery(".bwg" + source + "_thumb_active" + defix).position().left;
    if( outerWidth_or_outerHeight == 'outerWidth' ) {
      image_right = jQuery(".bwg" + source + "_thumb_active" + defix).position().left + jQuery(".bwg" + source + "_thumb_active" + defix).outerWidth(true);
    } else {
      image_right = jQuery(".bwg" + source + "_thumb_active" + defix).position().left + jQuery(".bwg" + source + "_thumb_active" + defix).outerHeight(true);
    }
    long_filmstrip_cont_left = jQuery(".bwg" + source + "_filmstrip_thumbnails" + defix).position().left;
    long_filmstrip_cont_right = Math.abs(jQuery(".bwg" + source + "_filmstrip_thumbnails" + defix).position().left) + bwg_filmstrip_width;
  } else {
    image_left = jQuery(".bwg" + source + "_thumb_active" + defix).position().top;
    if( outerWidth_or_outerHeight == 'outerWidth' ) {
      image_right = jQuery(".bwg" + source + "_thumb_active" + defix).position().top + jQuery(".bwg" + source + "_thumb_active" + defix).outerWidth(true);
    } else {
      image_right = jQuery(".bwg" + source + "_thumb_active" + defix).position().top + jQuery(".bwg" + source + "_thumb_active" + defix).outerHeight(true);
    }
    long_filmstrip_cont_left = jQuery(".bwg" + source + "_filmstrip_thumbnails" + defix).position().top;
    long_filmstrip_cont_right = Math.abs(jQuery(".bwg" + source + "_filmstrip_thumbnails" + defix).position().top) + bwg_filmstrip_width;
  }
  if (bwg_filmstrip_width > bwg_filmstrip_thumbnails_width) {
    return;
  }
  if (image_left < Math.abs(long_filmstrip_cont_left)) {
    if ( left_or_top == 'left' ) {
      jQuery(".bwg" + source + "_filmstrip_thumbnails" + defix).animate({
        left: -image_left
      }, {
        duration: 500,
        complete: function () { bwg_filmstrip_arrows( bwg ); }
      });
    } else {
      jQuery(".bwg" + source + "_filmstrip_thumbnails" + defix).animate({
        top: -image_left
      }, {
        duration: 500,
        complete: function () { bwg_filmstrip_arrows( bwg ); }
      });
    }
  }
  else if (image_right > long_filmstrip_cont_right) {
    if ( left_or_top == 'left' ) {
      jQuery(".bwg" + source + "_filmstrip_thumbnails" + defix).animate({
        left: -(image_right - bwg_filmstrip_width)
      }, {
        duration: 500,
        complete: function () {
          bwg_filmstrip_arrows(bwg);
        }
      });
    } else {
      jQuery(".bwg" + source + "_filmstrip_thumbnails" + defix).animate({
        top: -(image_right - bwg_filmstrip_width)
      }, {
        duration: 500,
        complete: function () {
          bwg_filmstrip_arrows(bwg);
        }
      });
    }
  }
}

function bwg_move_dots( bwg ) {
  var image_left = jQuery(".bwg_slideshow_dots_active_" + bwg).position().left;
  var image_right = jQuery(".bwg_slideshow_dots_active_" + bwg).position().left + jQuery(".bwg_slideshow_dots_active_" + bwg).outerWidth(true);
  var bwg_dots_width = jQuery(".bwg_slideshow_dots_container_" + bwg).outerWidth(true);
  var bwg_dots_thumbnails_width = jQuery(".bwg_slideshow_dots_thumbnails_" + bwg).outerWidth(false);
  var long_filmstrip_cont_left = jQuery(".bwg_slideshow_dots_thumbnails_" + bwg).position().left;
  var long_filmstrip_cont_right = Math.abs(jQuery(".bwg_slideshow_dots_thumbnails_" + bwg).position().left) + bwg_dots_width;
  if (bwg_dots_width > bwg_dots_thumbnails_width) {
    return;
  }
  if (image_left < Math.abs(long_filmstrip_cont_left)) {
    jQuery(".bwg_slideshow_dots_thumbnails_" + bwg).animate({
      left: -image_left
    }, {
      duration: 500,
      complete: function () {  }
    });
  }
  else if (image_right > long_filmstrip_cont_right) {
    jQuery(".bwg_slideshow_dots_thumbnails_" + bwg).animate({
      left: -(image_right - bwg_dots_width)
    }, {
      duration: 500,
      complete: function () {  }
    });
  }
}

function bwg_testBrowser_cssTransitions( bwg ) {
  return bwg_testDom('Transition', bwg);
}

function bwg_testBrowser_cssTransforms3d( bwg ) {
  return bwg_testDom('Perspective', bwg);
}

function bwg_testDom(prop, bwg) {
  /* Browser vendor CSS prefixes.*/
  var browserVendors = ['', '-webkit-', '-moz-', '-ms-', '-o-', '-khtml-'];
  /* Browser vendor DOM prefixes.*/
  var domPrefixes = ['', 'Webkit', 'Moz', 'ms', 'O', 'Khtml'];
  var i = domPrefixes.length;
  while (i--) {
    if (typeof document.body.style[domPrefixes[i] + prop] !== 'undefined') {
      return true;
    }
  }
  return false;
}

/* For browsers that does not support transitions.*/
function bwg_fallback(current_image_class, next_image_class, direction, bwg) {
  bwg_fade(current_image_class, next_image_class, direction, bwg);
}

/* For browsers that support transitions, but not 3d transforms (only used if primary transition makes use of 3d-transforms).*/
function bwg_fallback3d(current_image_class, next_image_class, direction, bwg) {
  bwg_sliceV(current_image_class, next_image_class, direction, bwg);
}

function bwg_none(current_image_class, next_image_class, direction, bwg) {

  var defix = ( typeof bwg != 'undefined' ) ? '_'+bwg : '';

  jQuery(current_image_class).css({'opacity' : 0, 'z-index': 1});
  jQuery(next_image_class).css({'opacity' : 1, 'z-index' : 2});

  if ( typeof bwg != 'undefined' ) {
    var bwg_current_key = bwg_params[bwg]['bwg_current_key'];
    bwg_change_watermark_container(bwg);
    /* Set active thumbnail.*/
    jQuery(".bwg_slideshow_filmstrip_thumbnail" + defix).removeClass("bwg_slideshow_thumb_active" + defix).addClass("bwg_slideshow_thumb_deactive" + defix);
    jQuery("#bwg_filmstrip_thumbnail_" + bwg_current_key + defix).removeClass("bwg_slideshow_thumb_deactive" + defix).addClass("bwg_slideshow_thumb_active" + defix);
    jQuery(".bwg_slideshow_dots" + defix).removeClass("bwg_slideshow_dots_active" + defix).addClass("bwg_slideshow_dots_deactive" + defix);
    jQuery("#bwg_dots_" + bwg_current_key + defix).removeClass("bwg_slideshow_dots_deactive" + defix).addClass("bwg_slideshow_dots_active" + defix);
  } else {
    /* Lightbox */
    jQuery(".bwg_image_info").show();
    bwg_param['bwg_trans_in_progress'] = false;
    jQuery(current_image_class).html('');
    bwg_change_watermark_container();
  }


}

function bwg_iterator( bwg ) {
  var iterator = 1;
  if ( typeof bwg != 'undefined' && typeof bwg_params[bwg] != 'undefined' && bwg_params[bwg]['enable_slideshow_shuffle'] == 1 ) {
    iterator = Math.floor((bwg_params[bwg]['data'].length - 1) * Math.random() + 1);
  }
  return iterator;
}

function bwg_change_image_slideshow(current_key, key, data, from_effect, bwg) {
  var data = bwg_params[bwg]['data'];
  /* Pause videos.*/
  jQuery("#bwg_slideshow_image_container_" + bwg).find("iframe").each(function () {
    jQuery(this)[0].contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
    jQuery(this)[0].contentWindow.postMessage('{ "method": "pause" }', "*");
    jQuery(this)[0].contentWindow.postMessage('pause', '*');
  });
  /* Pause videos facebook video.*/
  jQuery('#image_id_' +bwg + '_' + data[current_key]["id"]).find('.bwg_fb_video').each(function () {
    jQuery(this).attr('src', jQuery(this).attr('src'));
  });
  if (data[key]) {
    if (jQuery('.bwg_ctrl_btn_' + bwg).hasClass('fa-pause')) {
      bwg_play( bwg_params[bwg]['data'], bwg );
    }

    if (!from_effect) {
      /* Change image key.*/
      jQuery("#bwg_current_image_key_" + bwg).val(key);
      if (current_key == '-1') { /* Filmstrip.*/
        current_key = jQuery(".bwg_slideshow_thumb_active_" + bwg).children("img").attr("image_key");
      }
      else if (current_key == '-2') { /* Dots.*/
        current_key = jQuery(".bwg_slideshow_dots_active_" + bwg).attr("image_key");
      }
    }
    if ( bwg_params[bwg]['bwg_trans_in_progress'] ) {
      bwg_params[bwg]['event_stack'].push(current_key + '-' + key);
      return;
    }
    var direction = 'right';
    if (current_key > key) {
      var direction = 'left';
    } else if (current_key == key) {
      return;
    }

    jQuery(".bwg_slideshow_watermark_" + bwg).css({display: 'none'});
    jQuery(".bwg_slideshow_title_text_" + bwg).css({display: 'none'});
    jQuery(".bwg_slideshow_description_text_" + bwg).css({display: 'none'});
    /* Set active thumbnail position.*/
    if ( bwg_params[bwg]['width_or_height'] == 'width' ) {
      bwg_params[bwg]['bwg_current_filmstrip_pos'] = key * (jQuery(".bwg_slideshow_filmstrip_thumbnail_" + bwg).width() + 2 + 2 * bwg_params[bwg]['lightbox_filmstrip_thumb_border_width']);
    } else {
      bwg_params[bwg]['bwg_current_filmstrip_pos'] = key * (jQuery(".bwg_slideshow_filmstrip_thumbnail_" + bwg).height() + 2 + 2 * bwg_params[bwg]['lightbox_filmstrip_thumb_border_width']);
    }

    current_key = key;
    bwg_params[bwg]['bwg_current_key'] = current_key;
    /* Change image id, title, description.*/
    jQuery("#bwg_slideshow_image_" + bwg).attr('image_id', data[key]["id"]);
    jQuery(".bwg_slideshow_title_text_" + bwg).html(jQuery('<span style="display: block;" />').html(data[key]["alt"]).text());
    jQuery(".bwg_slideshow_description_text_" + bwg).html(jQuery('<span style="display: block;" />').html(data[key]["description"]).text());
    var current_image_class = jQuery(".bwg_slideshow_image_spun_" + bwg).css("zIndex") == 2 ? ".bwg_slideshow_image_spun_" + bwg : ".bwg_slideshow_image_second_spun_" + bwg;
    var next_image_class = current_image_class == ".bwg_slideshow_image_second_spun_" + bwg ? ".bwg_slideshow_image_spun_" + bwg : ".bwg_slideshow_image_second_spun_" + bwg;
    var is_embed = data[key]['filetype'].indexOf("EMBED_") > -1 ? true : false;
    var is_embed_instagram_post = data[key]['filetype'].indexOf('INSTAGRAM_POST') > -1 ? true :false;
    var is_embed_instagram_video = data[key]['filetype'].indexOf('INSTAGRAM_VIDEO') > -1 ? true :false;
    var cur_height = jQuery(current_image_class).height();
    var cur_width = jQuery(current_image_class).width();
    var innhtml = '<span class="bwg_slideshow_image_spun1_' + bwg +'" style="display:  ' + (!is_embed ? 'table' : 'block') + ' ;width: inherit; height: inherit;"><span class="bwg_slideshow_image_spun2_' + bwg + '" style="display: ' + (!is_embed ? 'table-cell' : 'block') + '; vertical-align: middle; text-align: center; ">';
    if (!is_embed) {
      if (bwg_params[bwg]['thumb_click_action'] != 'do_nothing' ) {
        var argument = '';
        if (bwg_params[bwg]['thumb_click_action'] == 'open_lightbox')
        {
          argument += ' class="bwg_lightbox" data-image-id="' + data[key]["id"] + '"';
        } else {
          if ( bwg_params[bwg]["thumb_click_action"] == "redirect_to_url" && data[key]["redirect_url"] ) {
            argument += 'href="' + data[key]["redirect_url"] + '"' + ( (bwg_params[bwg]['thumb_link_target'] && bwg_params[bwg]['thumb_link_target'] == 1) ? ' target="_blank"' : '' );
          }
        }
        innhtml += '<a ' + argument + '>';
      }
      innhtml += '<img style="max-height: ' + cur_height + 'px !important; max-width: ' + cur_width + 'px !important; display:inline-block;" ';
      innhtml +=   ' class="bwg_slide bwg_slideshow_image_'+bwg+'" ';
      innhtml +=   ' id="bwg_slideshow_image_' + bwg + '" ';
      innhtml +=   ' src="' + bwg_params[bwg]['upload_url'] + jQuery("<span style=\'display: block;\' />").html(data[key]["image_url"]).text() + '" alt="' + data[key]["alt"] + '" image_id="' + data[key]["id"] + '" /></a>';
    } else { /*is_embed*/
      innhtml += '<span style="height: ' + cur_height + 'px; width: ' + cur_width + 'px;" class="bwg_popup_embed bwg_popup_watermark">';
      if (is_embed_instagram_video ) {
        innhtml += '<span class="bwg_inst_play_btn_cont" onclick="bwg_play_instagram_video(this)"><span class="bwg_inst_play"></span></span>';
      }
      if (is_embed_instagram_post) {
        var post_width = 0;
        var post_height = 0;
        if (cur_height < cur_width + 88) {
          post_height = cur_height;
          post_width = post_height - 88;
        }
        else {
          post_width = cur_width;
          post_height = post_width + 88;
        }
        innhtml += spider_display_embed(data[key]['filetype'], data[key]['image_url'], data[key]['filename'], {class:"bwg_embed_frame", 'data-width': data[key]['image_width'], 'data-height': data[key]['image_height'], frameborder: "0", allowfullscreen: "allowfullscreen", style: "width:" + post_width + "px; height:" + post_height + "px; vertical-align:middle; display:inline-block; position:relative;"});
      } else {
        innhtml += spider_display_embed(data[key]['filetype'], data[key]['image_url'], data[key]['filename'], {class:"bwg_embed_frame", frameborder:"0", allowfullscreen:"allowfullscreen", style:"width:inherit; height:inherit; vertical-align:middle; display:table-cell;" });
      }
      innhtml += "</span>";
    }
    innhtml += '</span></span>';
    jQuery(next_image_class).html(innhtml);
    if (bwg_params[bwg]['preload_images']) {
      bwg_preload_images(key, bwg);
    }
    window["bwg_" + bwg_params[bwg]['slideshow_effect']](current_image_class, next_image_class, direction, bwg);
    if ( bwg_params[bwg]['enable_slideshow_filmstrip'] > 0 ) {
      bwg_move_filmstrip( bwg );
    }
    else {
      bwg_move_dots( bwg);
    }
    if (data[key]["is_embed_video"]) {
      jQuery("#bwg_slideshow_play_pause_" + bwg).css({display: 'none'});
    }
    else {
      jQuery("#bwg_slideshow_play_pause_" + bwg).css({display: ''});
    }
  }
  bwg_add_lightbox();
}

function bwg_preload_images_slideshow( key, bwg ) {
  var data = bwg_params[bwg]['data'];
  count = bwg_params[bwg]['preload_images_count'] / 2;
  var count_all = data.length;
  if (count_all < bwg_params[bwg]['preload_images_count']) {
    count = 0;
  }
  if (count != 0) {
    for (var i = key - count; i < key + count; i++) {
      var index = parseInt((i + count_all) % count_all);
      var is_embed = data[index]['filetype'].indexOf("EMBED_") > -1 ? true : false;
      if (typeof data[index] != "undefined") {
        if (!is_embed) {
          jQuery("<img/>").attr("src", bwg_params[bwg]['upload_url'] + jQuery('<span style="display: block;" />').html(data[index]["image_url"]).text());
        }
      }
    }
  } else {
    for (var i = 0; i < data.length; i++) {
      var is_embed = data[i]['filetype'].indexOf("EMBED_") > -1 ? true : false;
      if (typeof data[i] != "undefined") {
        if (!is_embed) {
          jQuery("<img/>").attr("src", bwg_params[bwg]['upload_url'] + jQuery('<span style="display: block;" />').html(data[i]["image_url"]).text());
        }
      }
    }
  }
}

function bwg_preload_images( key, bwg ) {
  if ( typeof bwg != 'undefined' ) { /* SLIDESHOW */
    bwg_preload_images_slideshow( key, bwg );
  } else {  /* LIGHTBOX */
    bwg_preload_images_lightbox( key );
  }
}

function bwg_popup_resize_slidshow( bwg ) {
  var parent_width = jQuery(".bwg_slideshow_image_wrap_" + bwg).parent().width();
  var data = bwg_params[bwg]['data'];
  if (parent_width >= bwg_params[bwg]['image_width']) {
    jQuery(".bwg_slideshow_image_wrap_"+bwg).css({width: bwg_params[bwg]['image_width']});
    jQuery(".bwg_slideshow_image_wrap_"+bwg).css({height: bwg_params[bwg]['image_height']});
    jQuery(".bwg_slideshow_image_container_"+bwg).css({width: (bwg_params[bwg]['filmstrip_direction'] == 'horizontal') ? bwg_params[bwg]['image_width'] : (bwg_params[bwg]['image_width'] - bwg_params[bwg]['slideshow_filmstrip_width']) });
    jQuery(".bwg_slideshow_image_container_"+bwg).css({height: (bwg_params[bwg]['filmstrip_direction'] == 'horizontal') ? bwg_params[bwg]['image_height'] - bwg_params[bwg]['slideshow_filmstrip_height'] : bwg_params[bwg]['image_height'] });
    jQuery(".bwg_slideshow_image_"+bwg).css({
      cssText: "max-width: " + (bwg_params[bwg]['filmstrip_direction'] == 'horizontal ') ? bwg_params[bwg]['image_width'] : (bwg_params[bwg]['image_width'] - bwg_params[bwg]['slideshow_filmstrip_width'])+"px !important; max-height: " + (bwg_params[bwg]['filmstrip_direction'] == 'horizontal') ? (bwg_params[bwg]['image_height'] - bwg_params[bwg]['slideshow_filmstrip_height']) : bwg_params[bwg]['image_height']+"px !important;"
    });
    jQuery(".bwg_slideshow_embed_"+bwg).css({
      cssText: "width: "+(bwg_params[bwg]['filmstrip_direction'] == 'horizontal') ? bwg_params[bwg]['image_width'] : (bwg_params[bwg]['image_width'] - bwg_params[bwg]['slideshow_filmstrip_width'])+"px !important; height:"+ (bwg_params[bwg]['filmstrip_direction'] == 'horizontal') ? (bwg_params[bwg]['image_height'] - bwg_params[bwg]['slideshow_filmstrip_height']) : bwg_params[bwg]['image_height']+"px !important;"
    });
    bwg_resize_instagram_post( bwg );
    /* Set watermark container size. */
    bwg_change_watermark_container( bwg );
    var filmstrip_container_css = (bwg_params[bwg]['filmstrip_direction'] == 'horizontal')  ? 'width: ' + bwg_params[bwg]['image_width'] : 'height: ' + bwg_params[bwg]['image_height'];
    var filmstrip_css = (bwg_params[bwg]['filmstrip_direction'] == 'horizontal') ? 'width: ' + (bwg_params[bwg]['image_width'] - 40) : 'height: ' + (bwg_params[bwg]['image_height'] - 40);
    jQuery(".bwg_slideshow_filmstrip_container_" + bwg).css({ cssText: filmstrip_container_css });
    jQuery(".bwg_slideshow_filmstrip_"+bwg).css({ cssText: filmstrip_css });
    jQuery(".bwg_slideshow_dots_container_"+bwg).css({width: bwg_params[bwg]['image_width'] });
    jQuery("#bwg_slideshow_play_pause-ico_"+bwg).css({fontSize: (bwg_params[bwg]['slideshow_play_pause_btn_size'])});
    if ( bwg_params[bwg]['watermark_type'] == 'image') {
      jQuery(".bwg_slideshow_watermark_image_" + bwg).css({
        maxWidth: bwg_params[bwg]['watermark_width'],
        maxHeight: bwg_params[bwg]['watermark_height']
      });
    }
    if ( bwg_params[bwg]['watermark_type'] == 'text') {
      jQuery(".bwg_slideshow_watermark_text_" + bwg + ", .bwg_slideshow_watermark_text_" + bwg + " : hover").css({
        fontSize: (bwg_params[bwg]['watermark_font_size'])
      });
    }
    jQuery(".bwg_slideshow_title_text_"+bwg).css({fontSize: ( bwg_params[bwg]['slideshow_title_font_size'] * 2 )});
    jQuery(".bwg_slideshow_description_text_"+bwg).css({fontSize: (bwg_params[bwg]['slideshow_description_font_size'] * 2)});
  }
  else {
    jQuery(".bwg_slideshow_image_wrap_"+bwg).css({width: (parent_width)});
    jQuery(".bwg_slideshow_image_wrap_"+bwg).css({ height: ((parent_width) * bwg_params[bwg]['image_height'] / bwg_params[bwg]['image_width'] )});
    jQuery(".bwg_slideshow_image_container_"+bwg).css({width: (parent_width - (bwg_params[bwg]['filmstrip_direction'] == 'horizontal' ? 0 : bwg_params[bwg]['slideshow_filmstrip_width']))});
    jQuery(".bwg_slideshow_image_container_"+bwg).css({height: ((parent_width) * bwg_params[bwg]['image_height'] / bwg_params[bwg]['image_width'] - (bwg_params[bwg]['filmstrip_direction'] == 'horizontal' ? bwg_params[bwg]['slideshow_filmstrip_height'] : 0))});
    jQuery(".bwg_slideshow_image_"+bwg).css({
      cssText: "max-width: " + (parent_width - (bwg_params[bwg]['filmstrip_direction'] == 'horizontal' ? 0 : bwg_params[bwg]['slideshow_filmstrip_width'])) + "px !important; max-height: " + (parent_width * (bwg_params[bwg]['image_height'] / bwg_params[bwg]['image_width']) - (bwg_params[bwg]['filmstrip_direction'] == 'horizontal' ? bwg_params[bwg]['slideshow_filmstrip_height'] : 0) - 1) + "px !important;"
      });
    jQuery(".bwg_slideshow_embed_"+bwg).css({
      cssText: "width: " + (parent_width - (bwg_params[bwg]['filmstrip_direction'] == 'horizontal' ? 0 : bwg_params[bwg]['slideshow_filmstrip_width']) ) + "px !important; height: " + (parent_width * (bwg_params[bwg]['image_height'] / bwg_params[bwg]['image_width']) - (bwg_params[bwg]['filmstrip_direction'] == 'horizontal' ? bwg_params[bwg]['slideshow_filmstrip_height'] : 0) - 1) + "px !important;"
      });
    bwg_resize_instagram_post( bwg );
    /* Set watermark container size.*/
    bwg_change_watermark_container( bwg );
    if (bwg_params[bwg]['filmstrip_direction'] == 'horizontal') {
      jQuery(".bwg_slideshow_filmstrip_container_"+bwg).css({width: (parent_width)});
      jQuery(".bwg_slideshow_filmstrip_"+bwg).css({width: (parent_width - 40)});
    } else {
      jQuery(".bwg_slideshow_filmstrip_container_"+bwg).css({height: (parent_width * bwg_params[bwg]['image_height'] / bwg_params[bwg]['image_width'])});
      jQuery(".bwg_slideshow_filmstrip_"+bwg).css({height: (parent_width * bwg_params[bwg]['image_height'] / bwg_params[bwg]['image_width'] - 40)});
    }
  jQuery(".bwg_slideshow_dots_container_"+bwg).css({width: (parent_width)});
  jQuery("#bwg_slideshow_play_pause-ico_"+bwg).css({fontSize: ((parent_width) * bwg_params[bwg]['slideshow_play_pause_btn_size'] / bwg_params[bwg]['image_width'])});
  jQuery(".bwg_slideshow_watermark_image_"+bwg).css({maxWidth: ((parent_width) * bwg_params[bwg]['watermark_width'] / bwg_params[bwg]['image_width']), maxHeight: ((parent_width) * bwg_params[bwg]['watermark_height'] / bwg_params[bwg]['image_width'])});
  jQuery(".bwg_slideshow_watermark_text_"+bwg+", .bwg_slideshow_watermark_text_"+bwg+":hover").css({fontSize: ((parent_width) * bwg_params[bwg]['watermark_font_size'] / bwg_params[bwg]['image_width'])});
  jQuery(".bwg_slideshow_title_text_"+bwg).css({fontSize: ((parent_width) * 2 * bwg_params[bwg]['slideshow_title_font_size'] / bwg_params[bwg]['image_width'])});
  jQuery(".bwg_slideshow_description_text_"+bwg).css({fontSize: ((parent_width) * 2 * bwg_params[bwg]['slideshow_description_font_size'] / bwg_params[bwg]['image_width'])});
  jQuery(".bwg_slideshow_image_"+bwg).css({'display':'inline-block'});
  }
  if (data[parseInt(jQuery("#bwg_current_image_key_"+bwg).val())]["is_embed_video"]) {
            jQuery("#bwg_slideshow_play_pause_"+bwg).css({display: 'none'});
  }
  else {
    jQuery("#bwg_slideshow_play_pause_"+bwg).css({display: ''});
  }
}

function bwg_popup_resize( bwg ) {
  if ( typeof bwg != 'undefined' ) { /* SLIDESHOW */
    bwg_popup_resize_slidshow( bwg );
  } else {  /* LIGHTBOX */
    bwg_popup_resize_lightbox();
  }
}

function bwg_change_image(current_key, key, data, from_effect, bwg) {
  if ( typeof bwg != 'undefined' ) { /* SLIDESHOW */
    bwg_change_image_slideshow(current_key, key, data, from_effect, bwg);
  } else {  /* LIGHTBOX */
    bwg_change_image_lightbox(current_key, key, data, from_effect);
  }
}

function bwg_resize_instagram_post( bwg ) {
  if ( typeof bwg != 'undefined' ) { /* SLIDESHOW */
      if (jQuery(".inner_instagram_iframe_bwg_embed_frame_"+bwg).length) {
        var post_width = jQuery(".bwg_slideshow_embed_"+bwg).width();
        var post_height = jQuery(".bwg_slideshow_embed_").height();
        jQuery(".inner_instagram_iframe_bwg_embed_frame_"+bwg).each(function() {
          var parent_container = jQuery(this).parent();
          if (post_height / (parseInt(parent_container.attr('data-height')) + 96) < post_width / parseInt(parent_container.attr('data-width'))) {
            parent_container.height(post_height);
            parent_container.width((parent_container.height() - 96) * parent_container.attr('data-width') / parent_container.attr('data-height') + 16);
          }
          else {
            parent_container.width(post_width);
            parent_container.height((parent_container.width() - 16) * parent_container.attr('data-height') / parent_container.attr('data-width') + 96);
          }
        });
        bwg_change_watermark_container( bwg );
      }
  } else { /* LIGHTBOX */
      if (jQuery('.inner_instagram_iframe_bwg_embed_frame').length) {
        var post_width = jQuery(".bwg_image_container").width();
        var post_height = jQuery(".bwg_image_container").height();
        var FeedbackSocialProofHeight = 132;
        jQuery('.inner_instagram_iframe_bwg_embed_frame').each(function() {
          var parent_container = jQuery(this).parent();
          if (post_height / (parseInt(parent_container.attr('data-height')) + FeedbackSocialProofHeight) < post_width / parseInt(parent_container.attr('data-width'))) {
            parent_container.height(post_height);
            parent_container.width((parent_container.height() - FeedbackSocialProofHeight) * parent_container.attr('data-width') / parent_container.attr('data-height') + 16);
          }
          else {
            parent_container.width(post_width);
            parent_container.height((parent_container.width() - 16) * parent_container.attr('data-height') / parent_container.attr('data-width') + 96);
          }
          parent_container.css({top: 0.5 * (post_height - parent_container.height())});
        });
        bwg_change_watermark_container();
      }
  }
}

function bwg_play( data, bwg  ) {
  if ( typeof bwg != 'undefined' ) {
    var data = bwg_params[bwg]['data'];
  }

  /* Play.*/
  if ( typeof bwg != 'undefined' ) { /* SLIDESHOW */
    window.clearInterval(window['bwg_playInterval' + bwg]);
    window['bwg_playInterval' + bwg] = setInterval(function () {
      var iterator = 1;
      if (bwg_params[bwg]['enable_slideshow_shuffle'] == 1) {
        iterator = Math.floor((data.length - 1) * Math.random() + 1);
      }
      bwg_change_image( parseInt(jQuery("#bwg_current_image_key_"+bwg).val()), (parseInt(jQuery("#bwg_current_image_key_"+bwg).val()) + iterator) % data.length, data, '', bwg )
    }, bwg_params[bwg]['slideshow_interval'] * 1000);
  } else {
      window.clearInterval(bwg_param['bwg_playInterval']);
      bwg_param['bwg_playInterval'] = setInterval(function () {
        /* Stop play of lightbox if comment was opened*/
        if ( jQuery(".bwg_comment_container").hasClass("bwg_open") || (jQuery(".bwg_play_pause").length && jQuery(".bwg_play_pause").hasClass("fa-play"))) {
          return;
        }

        if (typeof data != 'undefined' && typeof data[(parseInt(jQuery('#bwg_current_image_key').val()) + 1)] == 'undefined') {
            if (bwg_param['enable_loop'] == 1) {
              /* Wrap around.*/
              bwg_change_image(parseInt(jQuery('#bwg_current_image_key').val()), 0, data);
            }
            return;
        }
        bwg_change_image(parseInt(jQuery('#bwg_current_image_key').val()), parseInt(jQuery('#bwg_current_image_key').val()) + 1, data)
      }, bwg_param['slideshow_interval'] * 1000);
  }
}

/*------------------ Image Browser Functions ---------------------------*/
function bwg_image_browser( bwg ) {
  jQuery('#bwg_embed_frame_16x9_' + bwg).width(jQuery('#bwg_embed_frame_16x9_' + bwg).parents('.image_browser_image_buttons_' + bwg).width());
  jQuery('#bwg_embed_frame_16x9_' + bwg).height(jQuery('#bwg_embed_frame_16x9_' + bwg).width() * 0.5625);
  jQuery('#bwg_embed_frame_instapost_' + bwg).width(jQuery('#bwg_embed_frame_16x9_' + bwg).parents('.image_browser_image_buttons_' + bwg).width());
  /* Conflict with Sydney Theme */
  if ( jQuery('.image_browser_images_conteiner_' + bwg).find('.fluid-width-video-wrapper').length ) {
	var content = jQuery('.image_browser_images_conteiner_' + bwg).find('.fluid-width-video-wrapper').contents();
	jQuery('.image_browser_images_conteiner_' + bwg).find('.fluid-width-video-wrapper').replaceWith(content);
  }
  /* 16 is 2*padding inside iframe */
  /* 96 is 2*padding(top) + 1*padding(bottom) + 40(footer) + 32(header) */
  jQuery('.bwg_embed_frame_instapost_' + bwg).height((jQuery('.bwg_embed_frame_instapost_' + bwg).width() - 16) * jQuery('.bwg_embed_frame_instapost_' + bwg).attr('data-height') / jQuery('.bwg_embed_frame_instapost_' + bwg).attr('data-width') + 96);

  var bwg_image_browser_width = jQuery('.image_browser_images_' + bwg).width();
  if (bwg_image_browser_width <= 108) {
    jQuery('.paging-input_' + bwg).css('display', 'none');
  }
  else if (bwg_image_browser_width <= 200) {
    jQuery('.paging-input_' + bwg).css('margin', '0% 0% 0% 0%');
    jQuery('.paging-input_' + bwg).css('display', 'inline');
    jQuery('.tablenav-pages_' + bwg + ' .next-page').css('margin', '0% 0% 0% 0%');
    jQuery('.tablenav-pages_' + bwg + ' .prev-page').css('margin', '0% 0% 0% 0%');
  }
  else if (bwg_image_browser_width <= 580) {
    jQuery('.paging-input_' + bwg).css('display', 'inline');
    jQuery('.tablenav-pages_' + bwg + ' a').css('font-size', '13px');
    jQuery('.paging-input_' + bwg).css('margin', '0% 7% 0% 7%');
    jQuery('.tablenav-pages_' + bwg + ' .next-page').css('margin', '0% 0% 0% 0%');
    jQuery('.tablenav-pages_' + bwg + ' .prev-page').css('margin', '0% 0% 0% 0%');
  }
  else {
    jQuery('.tablenav-pages_' + bwg + ' a').css('font-size', '15px');
    jQuery('.paging-input_' + bwg).css('margin', '0%  14% 0%  14%');
    jQuery('.paging-input_' + bwg).css('display', 'inline');
    jQuery('.tablenav-pages_' + bwg + ' .next-page').css('margin', '0% 0% 0% 0%');
    jQuery('.tablenav-pages_' + bwg + ' .prev-page').css('margin', '0% 0% 0% 0%');
  }
}

/**
 * Disable right click.
 *
 * @param container
 */
function bwg_disable_right_click( container ) {
  container.bind( "contextmenu", function () {
	return false;
  });
  container.css( 'webkitTouchCallout', 'none' );
}

Youez - 2016 - github.com/yon3zu
LinuXploit