$(document).ready(function(){ // load background $('#header').addClass('transparent'); // infopage related $("a.more").click(function(event){ var parentblock = $(this).parents(".infohtmlblock"); $(".short", parentblock).hide(); $(".full", parentblock).show(); event.preventDefault(); }) $("a.less").click(function(event){ var parentblock = $(this).parents(".infohtmlblock"); $(".short", parentblock).show(); $(".full", parentblock).hide(); event.preventDefault(); }) $("#btn_rate").click(function(event){ var rate = 0; $(".ipgrating").each(function(event){ if ($(this).attr("checked")) { rate = $(this).val(); } }) if (!rate) { alert('Выберите нужную оценку'); } else { $.post("/imones/vertinti/"+current_infopage_abnr, { rate: rate }, function(result){ if (result) { $(".rateinput").slideUp("fast"); $(".rateaccepted").slideDown("fast"); updateRating(); } }, "json" ); } }) $(".comment_input").focus(function(event){ if ($(this).attr("name") == "comment_author" && $(this).val() == "Ваше имя") { $(this).val(''); } if ($(this).attr("name") == "comment_text" && $(this).val() == "Ваш отзыв") { $(this).val(''); } $(this).addClass("input_activated"); }) $(".comment_input").blur(function(event){ var input_valid = true; if ($(this).attr("name") == "comment_author" && $(this).val() == "") { $(this).val('Ваше имя'); $(this).removeClass("input_activated"); } if ($(this).attr("name") == "comment_text" && $(this).val() == "") { $(this).val('Ваш отзыв'); $(this).removeClass("input_activated"); } }) $(".comment_input").keyup(function(event){ if (!commentInputValid()) { $(".comment_button").removeClass("input_activated"); $(".comment_button").attr("disabled", true); } else { $(".comment_button").addClass("input_activated"); $(".comment_button").attr("disabled", false); } }); $("#btn_submit_comment").click(function(event){ if (!commentInputValid()) { alert("Пожалуйста, заполните все поля отзыва"); } $("#comment_loading").show(); $.ajax({ type: "POST", url: "/ru/imones/atsiliepimai/"+current_infopage_abnr, data: ({ author: $("#comment_author").val(), text: $("#comment_text").val() }), dataType: "json", success: function (data, textStatus) { if (data.status == 'ok') { $(".comment_form").slideUp("fast"); $(".comment_accepted").slideDown("fast"); } else if (data.text) { alert(data.text); } else { alert('Извините, произошла ошибка. Ваш комментарий не был сохранен.'); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert('Извините, произошла ошибка. Ваш комментарий не был сохранен.'); }, complete: function (XMLHttpRequest, textStatus) { this; // the options for this ajax request $("#comment_loading").hide(); } }); }); if (jQuery().lightBox) { $('a[rel=lightbox]').lightBox({ imageLoading: 'http://www.viskasturizmui.lt/cimg/lightbox-ico-loading.gif', imageBtnClose: 'http://www.viskasturizmui.lt/cimg/lightbox-btn-close.gif', imageBtnPrev: 'http://www.viskasturizmui.lt/cimg/previous.png', imageBtnNext: 'http://www.viskasturizmui.lt/cimg/next.png', txtImage: 'Фото', txtOf: 'из' }); } buildPhotosImagesOffsetsMap(); }) var months = new Array(12); months[1] = 'января'; months[2] = 'февраля'; months[3] = 'марта'; months[4] = 'апреля'; months[5] = 'мая'; months[6] = 'июня'; months[7] = 'июля'; months[8] = 'августа'; months[9] = 'сентября'; months[10] = 'октября'; months[11] = 'ноября'; months[12] = 'декабря'; function showDate () { curdate = new Date(); document.write(months[curdate.getMonth()+1]); document.write(' '); document.write(curdate.getDate()); return true; } function setAsHomepage (url) { if (document.all && document.getElementById) { // IE eniroHomePage.setHomePage(url); } else { // Other alert('Установьте "http://www.viskasturizmui.lt/"домашней страницой в настройках своего браузера'); } } function addToFavorites () { if (document.all && document.getElementById) { // IE window.external.AddFavorite(location.href, document.title); } else { // Other alert('Нажмите Ctrl-D или Ctrl-Y, если хотите добавить www.viskasturizmui.lt в список любимых ссылок'); } } function openPop (url) { window.open('http://www.viskasturizmui.lt'+url, 'eniro_pop', 'dependent=yes,height=490,width=670,location=no,menubar=no,personalbar=no,resizable=no,scrollbars=auto,status=no,toolbar=no'); } function mover (tr) { tr.className = 'cursorHand'; } function mout (tr) { tr.className = ''; } var servertime = false; /* video.js */ function openVideo (video) { window.open('/imones/video/?video='+video, 'eniro_video', 'dependent=yes,height=300,width=340,location=no,menubar=no,personalbar=no,resizable=no,scrollbars=auto,status=no,toolbar=no'); } var vidDuration = 100; var vidStep = 10; var vidK = vidDuration / vidStep; function expandVideo () { var cw = parseInt(document.getElementById('vidobj').width); var ch = parseInt(document.getElementById('vidobj').height); if (cw < 320) { document.getElementById('vidobj').width = cw + (160 / vidK); document.getElementById('vidobj').height = ch + (130 / vidK); var pos = cw - 160 + (160 / vidK); document.getElementById('video').style.left = "-" + pos + "px"; setTimeout("expandVideo()", vidStep); } } function collapseVideo () { var cw = parseInt(document.getElementById('vidobj').width); var ch = parseInt(document.getElementById('vidobj').height); if (cw > 160) { document.getElementById('vidobj').width = cw - (160 / vidK); document.getElementById('vidobj').height = ch - (130 / vidK); var pos = cw - 160 - (160 / vidK); document.getElementById('video').style.left = "-" + pos + "px"; setTimeout("collapseVideo()", vidStep); } } /* banners.js */ var topbannertimeout = 5000; var topbannerlocktimeout = 100; var topbanneractive = false; var topbannershown = false; var topbannerlocked = false; $(document).ready(function(){ if (isFirstVisitToday()) { activateTopBanner(); setTimeout('deactivateTopBanner()', topbannertimeout); } $("#topbanner .collapsed").hover( function() { topbanneractive = true; setTimeout('drawTopBanner()', topbannerlocktimeout); }, function() { topbanneractive = false; setTimeout('drawTopBanner()', topbannerlocktimeout); } ); $("#topbanner .expanded").hover( function() { topbanneractive = true; setTimeout('drawTopBanner()', topbannerlocktimeout); }, function() { topbanneractive = false; setTimeout('drawTopBanner()', topbannerlocktimeout); } ); }) function drawTopBanner() { if (topbannerlocked) { setTimeout('drawTopBanner()', topbannerlocktimeout); return false; } if (topbanneractive && !topbannershown) { activateTopBanner(); } else if (!topbanneractive && topbannershown) { deactivateTopBanner(); } } function unlockTopBanner() { topbannerlocked = false; } function activateTopBanner() { if (!topbannershown) { topbannershown = true; expandTopBanner(); topbannerlocked = true; setTimeout('unlockTopBanner()', topbannerlocktimeout); } } function deactivateTopBanner() { if (topbannershown) { topbannershown = false; collapseTopBanner(); topbannerlocked = true; setTimeout('unlockTopBanner()', topbannerlocktimeout); } } function expandTopBanner() { $("#topbanner .collapsed").slideUp("fast"); $("#topbanner .expanded").slideDown("fast"); } function collapseTopBanner() { $("#topbanner .expanded").slideUp("fast"); $("#topbanner .collapsed").slideDown("fast"); } function isFirstVisitToday() { var d = new Date(); var now = d.toDateString(); // get cookie var lastvisit = getCookie("viskasturizmui_visitdate"); // set cookie setCookie("viskasturizmui_visitdate", now, 7); return lastvisit != now; } function setCookie(c_name,value,expiredays) { var exdate=new Date(); exdate.setDate(exdate.getDate()+expiredays); document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toUTCString()); } function getCookie(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + "="); if (c_start!=-1) { c_start=c_start + c_name.length+1; c_end=document.cookie.indexOf(";",c_start); if (c_end==-1) c_end=document.cookie.length; return unescape(document.cookie.substring(c_start,c_end)); } } return ""; } /* infopage */ function commentInputValid() { var comment_author = $("#comment_author").val().replace(/^\s+|\s+$/g, ''); var comment_text = $("#comment_text").val().replace(/^\s+|\s+$/g, ''); return (comment_author != '') && (comment_author != 'Ваше имя') && (comment_text != '') && (comment_text != 'Ваш отзыв'); } function updateRating() { $.getJSON( "/imones/vertinti/"+current_infopage_abnr, function(data){ if (data) { var h = 41 - Math.round(data * 41 / 5); $(".rating_slider_fill").css("height", h); $(".rating_value").html(data); } } ); } function showAllComments(adv_code, page) { $(".infopage_comments_newest").hide("fast"); $(".infopage_comments_all").show("fast"); $(".infopage_comments_all .comments_body").hide(); $(".infopage_comments_all .loading").show(); if (!page) { page = 1; } $.getJSON("/ru/imones/atsiliepimai/ajax/"+current_infopage_adv_code+"/"+page, function(data){ $(".infopage_comments_all .comments_body").html(''); $(".infopage_comments_all .loading").hide(); $.each(data.items, function(i,item){ html = "
"; html += "
"+item.comment_author+" / "+item.comment_on_formatted+" / IP: "+item.ip_address+"
"; html += "
"+item.comment_text+"
"; html += "
"; $(".infopage_comments_all .comments_body").append(html); }); $(".infopage_comments_all .comments_body").show(); // paging if (data.pages > 1) { html = "Страницы: "; for (var i = 1; i <= data.pages; i++) { if (page == i) { html += ""+i+" "; } else { html += ""+i+" "; } } } else { html = ''; } $(".infopage_comments_all .paging").html(html); } ); return true; } var photos_images_offsets = {}; function buildPhotosImagesOffsetsMap() { var prev_offset = 0; $('.photos .image').each(function(){ var offset = prev_offset; prev_offset += $(this).outerWidth(true); photos_images_offsets[$(this).attr('id')] = offset; }) } var currphoto = 1; function scrollToPhoto(num) { var cnt_photos = $('.photos .image').length; if (num < 1 || num > cnt_photos || !$('#image_'+num).length) num = 1; scrollPhotosTo(photos_images_offsets[$('#image_'+num).attr('id')]); currphoto = num; } function scrollPhotosTo(offset) { $('.photos .scroller').animate({ scrollLeft: offset }, 'slow'); } function scrollToNextPhoto() { currphoto++; scrollToPhoto(currphoto); } function scrollToPrevPhoto() { currphoto--; scrollToPhoto(currphoto); } /* other */ function pupFlash(message) { var id = 'pupdebugflash' + Math.round(Math.random()*10000); $('body').append('
'+message+'
'); var top = 15; $('.pupdebugflash').each(function(){ var pos = $(this).position(); if (pos.top >= top) { top = pos.top + $(this).height() + 40; } }) $('#'+id).css('top', top); $('#'+id).fadeIn('fast'); setTimeout(function(){$('#'+id).fadeOut('fast', function(){$('#'+id).remove();});}, 3000); }