var HOST_CORE='http://core.turtella'; if (typeof String.prototype.startsWith != 'function') { // see below for better implementation! String.prototype.startsWith = function (str){ return this.indexOf(str) == 0; }; } if (typeof String.prototype.endsWith != 'function') { String.prototype.endsWith = function (str){ return this.slice(-str.length) == str; }; } var divClick = function(e) { var a = $(this).find('a'); if (e.ctrlKey) { window.open(a.attr('href'), a.attr('href')+Math.random()); } else { if (a.attr('target')!=undefined) { window.open(a.attr('href'), a.attr('href')+Math.random()); } else { window.location=a.attr('href'); } } e.preventDefault(); }; function isValidUrl(url){ var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/; if(RegExp.test(url)){ return true; }else{ return false; } } var bPop = {opacity: 0.6, speed: 10, zIndex: 100}; var ajx = { request: function(params) { jQuery.ajax({ data: params.data, error: function(data, status, request) { if (params.error!=undefined) { params.error(data, status, request); } else { ajx.defaultError(data, status, request); } }, success: function(data, status, request) { if (data.length>=4 && data.substring(0,4)=='err:') { ajx.displayErrorMessage(data.substring(4)); } else { params.success(data, status, request); } }, type: 'POST', url: params.url }); }, requestS: function(params) { var data = $.ajax({ data: params.data, type: "POST", async: false, url: params.url }).responseText; return data; }, defaultError: function(data, status, request) { // alert('СиÑ�темнаÑ� ошибка'); }, displayErrorMessage: function(msg) { // alert(msg); } } $(document).keydown(function(event){ if (event == null) { // ie keycode = window.event.keyCode; } else { // mozilla keycode = event.which; } if(keycode == 27){ // escape, close box, esc ttl.unpop(); } }); var ttl = new Object(); ttl.getAdminEmail = function() { $('#link_email').html('turtella.links'+ '@' + 'gmail.' + 'com'); }; ttl.init = function() { var searchStr = "Поиск по всему сайту..."; $('body') .on('submit', '#searchForm', function(evt) { var val = $(searchControl).val(); if (val=='' || val==searchStr) { evt.preventDefault(); }}) .on('focus', '#searchControl', function() { var el = $(this); if (el.val()==searchStr) { el.val(''); };}) .on('blur', '#searchControl', function() { var el = $(this); if (el.val()=='') { el.val(searchStr); };}) .on('mouseover', '#lMnuBlock .item, #lMnuBlock .subitem', function() {$(this).addClass('selected')}) .on('mouseout', '#lMnuBlock .item, #lMnuBlock .subitem', function() {$(this).removeClass('selected')}) .on('click', '#lMnuBlock .item, #lMnuBlock .subitem', divClick) .on('click', '#lMnuBlock #allSubMenuItems', function() {var block = $(this).closest('.items'); block.find('.subPopular').hide(); block.find('.subAll').show()}) .on('click', '#vk-icon', ttl.loginVk) .on('click', '#ok-icon', ttl.loginOk) .on('click', '#mm-icon', ttl.loginMM) .on('click', '#fb-icon', ttl.loginFB) .on('click', '#srchButton', function() {$('#searchForm').submit();}) .on('click', '#uEnter', ttl.enter) .on('click', '#uRegistration', ttl.openRegistration); $(window).scroll(function(){ var el = $('#fixedAd'); if (el.length) { var objectTop = $('#scrollLimit').position().top; var windowScrollTop = $(window).scrollTop(); if (windowScrollTop > objectTop) { if (!el.hasClass('rightAd')) el.addClass('rightAd'); } else { if (el.hasClass('rightAd')) el.removeClass('rightAd'); } } }); var h = $('#container').height(); $('#left-panel').height(h); $('#right-panel').height(h); if (typeof initPage !='undefined') initPage(); $('#tourRequestAdv').click(divClick); setTimeout(ttl.showHExtra, 400); setTimeout(ttl.showVExtra, 600); }; ttl.showVExtra = function() { if ($('#extraV').length) { var exclude = false; if ($('#exOriginal').length) return; var ch = $('#mTable').height(); var rh = $('#rightBlock').height(); var height = ch-rh; if (height>200) { var url = "/alt/v/turtella/ttl-v/"+height+"/"+$('#extraV').attr('location')+"/?callback=?" $.getJSON(url, function(json){ $('#extraV').replaceWith(json.content); }); } } } ttl.showHExtra = function() { if ($('#extraHz').length) { var height = $('#extraHz').height(); if (height==0) { var url = "/alt/h/turtella/ttl-h/?callback=?" $.getJSON(url, function(json){ $('#extraHz').replaceWith(json.content); }); } } } ttl.moveRightAd= function(eventTime) { ttl.adMoveInProgress = 1; setTimeout(function(){ ttl.rightAdv.animate({top: ttl.window.scrollTop() + "px"}, 1000, 'swing'); ttl.adMoveInProgress = 0; }, 500); }; ttl.showAllPlaces=function() { $('#popularPlaces').hide(); $('#allPlaces').show(); } ttl.showPopularPlaces=function() { $('#allPlaces').hide(); $('#popularPlaces').show(); } $.blockUI.defaults.applyPlatformOpacityRules = false; ttl.popAllowed = true; ttl.unpopAllowed = false; ttl.popMain = undefined; ttl.popContent = undefined; ttl.pop = function (id) { if (ttl.popAllowed) { ttl.popAllowed = false; if (ttl.popMain == undefined) ttl.popMain = $('#popMain'); var popupWnd = $('#'+id); ttl.popContent = popupWnd; // put content into popup window $('#popContainer').append(ttl.popContent); ttl.popMain.remove().appendTo("body"); var w = ttl.popMain.width(); var h = ttl.popMain.height(); var scrollTop = $(window).scrollTop(); $.blockUI({message: ttl.popMain, css: { top: scrollTop+($(window).height()-h)/2+'px', left: ($(window).width()-w)/2+'px', width: w+'px', height: h+'px', border: 0, cursor: 'default'} ,centerY: ($.browser.msie && parseInt($.browser.version) === 6) ? false : true ? false : true, fadeIn: 0 }); $('.blockUI.blockPage').css('position','absolute'); ttl.unpopAllowed = true; } } ttl.popUpdate = function (id) { ttl.popContent.remove().appendTo("#hiddenPanel"); ttl.popContent = $('#'+id); // put content into popup window $('#popContainer').append(ttl.popContent); var w = ttl.popMain.width(); var h = ttl.popMain.height(); var scrollTop = $(window).scrollTop(); ttl.popMain.css('top', scrollTop+($(window).height()-h)/2+'px').css('left',($(window).width()-w)/2+'px').css('width',w+'px').css('height',h+'px'); } ttl.unpop = function(doAfter) { if (ttl.unpopAllowed) { ttl.unpopAllowed = false; ttl.popContent.attr('src',''); $.unblockUI({ onUnblock: function(){ if (ttl.popContent != undefined) { ttl.popContent.remove().appendTo("#hiddenPanel"); } ttl.popMain.remove().appendTo("#hiddenPanel"); ttl.popAllowed = true; if (doAfter!=undefined) doAfter(); }, fadeOut: 0 }); } } ttl.ID = 0; ttl.nextNumber = function() { ttl.ID++; return ttl.ID; } ttl.checkEmail = function(val) { if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(val)) { return true; } else { return false; } } ttl.checkDate = function(val) { if (/^[0|1|2|3]\d\/[0|1]\d\/[1|2][9|0]\d\d$/.test(val)) { return true; } else { return false; } } ttl.updateSecondLevel = function() { var id = $('#level1').val(); $("select[id$=level2] > option").each(function(index) { if ($(this).val()!=0) $(this).remove(); }); if (id != 0) { ajx.request({ data: {parent: id}, success: function(data, status, request) { var options = $.parseJSON(data); var d = $("#level2"); $.each(options, function() { d.append($("