/** * Cookie plugin * * Copyright (c) 2006 Klaus Hartl (stilbuero.de) * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * */ jQuery.cookie=function(name,value,options) {if(typeof value!="undefined") {options=options||{};if(value===null) {value="";options.expires=-1}var expires="";if(options.expires&&(typeof options.expires=="number"||options.expires.toUTCString)) {var date;if(typeof options.expires=="number") {date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000))}else{date=options.expires}expires="; expires="+date.toUTCString()}var path=options.path?"; path="+(options.path):"";var domain=options.domain?"; domain="+(options.domain):"";var secure=options.secure?"; secure":"";document.cookie=[name,"=",encodeURIComponent(value),expires,path,domain,secure].join("")}else{var cookieValue=null;if(document.cookie&&document.cookie!="") {var cookies=document.cookie.split(";");for(var i=0;i 0) || (parseInt(jQuery(a).css("margin-right")) > 0)); }, marginy: function(a) { return ((parseInt(jQuery(a).css("margin-bottom")) > 0) || (parseInt(jQuery(a).css("margin-top")) > 0)); }, margin: function(a) { return ((parseInt(jQuery(a).css("margin-left")) > 0) || (parseInt(jQuery(a).css("margin-right")) > 0) || (parseInt(jQuery(a).css("margin-bottom")) > 0) || (parseInt(jQuery(a).css("margin-top")) > 0)); } }); $('.input-datepicker').datePicker({startDate:'01.01.1900'}); /*--- poll ---*/ jQuery("form#poll-form").submit(function() { var responseData = ''; var lng = jQuery('#pollLng').val(); if (jQuery('#multi-answers').val() != '1') // one answer responseData = jQuery("form#poll-form input:checked").val(); else { // multiple answers jQuery("form#poll-form input:checked").each(function () { responseData += this.value + ' '; }); } jQuery.post("/util/ajaxresponse.php?lng="+lng,{ func: "poll", response: responseData }, function(html) { showPoll(html); }); return false; }); function showPoll(htmlResponse) { jQuery("#poll-container").html(htmlResponse); jQuery("#poll-container img").each(function() { var tmp = jQuery(this).attr("class"); var aVals = tmp.match(/[0-9]+$/); // get number at the end of the string var val = aVals[0]; jQuery(this).animate({ width: val+"px" }, 1000 ); }); } /*--- FAQ ---*/ if ($("div#faq-form-section").length) { $("p#faq-form-toggle").slideDown(); $("p#faq-form-toggle").click(function() { $("p#faq-form-toggle").slideUp(500); $("div#faq-form-section").slideToggle(500); }); } if ($("div#faq-list").length) { $("div#faq-list h2").click(function() { $(this).next("dl.faq-list").slideToggle(500); $(this).next("dl.faq-list").toggleClass('open'); $(this).toggleClass('open'); }); } /* --- main menu --- */ $("#main-menu a[href != '#']").each(function() { // consider the id in the url when comparing if($(this).attr("class") == "m-m-useid") { // find matching url var urlDir = urlDirFull; var aHref = $(this).attr("href"); // trim IDs from url (example. "123758363528/") // ignore the id in the url when comparing } else { // find matching url var urlDir = urlDirFull.replace(/all\/|[_\d]+\/.*/g, ''); // trim IDs from url (.../all/34235435234623/313/123123/...) var aHref = $(this).attr("href").replace(/all\/|[_\d]+\/.*/g, ''); // trim IDs from url (.../all/34235435234623/313/123123/...) } // the page url is the same (or contains) as the menu link, so open the menu if (urlDir.indexOf(aHref) != -1) { $(this).parents("li").each(function() { var tmp = $(this).attr('class'); var aLevels = tmp.match(/[0-9]+/); // get number at the end of the string //if (aLevels != undefined) { var level = aLevels[aLevels.length-1]; $(this).addClass("menu-level"+level+"-open"); //} }); $(this).parents("ul").show(); $(this).next("ul").show(); } }); $("#main-menu span").click(function(e) { var liEl = $(this).parents("li:first"); // li element var liSibl = liEl.siblings(); // sibling li elements // find out li level var tmp = liEl.attr('class'); var aLevels = tmp.match(/[0-9]+/); var tgtlevel = aLevels[aLevels.length-1]; // tgt level liSibl.find("ul").slideUp('fast'); // hide all of the siblings' uls liEl.find("ul ul").slideUp('fast'); // hide child uls liEl.find("ul:first").slideToggle('fast'); // toggle the current submenu liSibl.removeClass("menu-level"+tgtlevel+"-open"); // remove the 'm-m-levelX-open' class from all the siblings of the clicked li liSibl.find('li').each(function() { var tmp = jQuery(this).attr('class'); var aLevels = tmp.match(/[0-9]+/); // get number at the end of the string var level = aLevels[aLevels.length-1]; jQuery(this).removeClass("menu-level"+level+"-open"); // remove the 'm-m-levelX-open' class from all the children of the siblings of the clicked li }); liEl.find('li').each(function() { var tmp = jQuery(this).attr('class'); var aLevels = tmp.match(/[0-9]+/); // get number at the end of the string var level = aLevels[aLevels.length-1]; jQuery(this).removeClass("menu-level"+level+"-open"); // remove the 'm-m-levelX-open' class from all the children of the clicked li }); liEl.toggleClass("menu-level"+tgtlevel+"-open"); // toggle class 'm-m-levelX-open' of the clicked li // prevent jumping to the top of the page for invalid (#) links if (liEl.find("a").attr("href") == '#') { e.preventDefault(); } }); /* --- anchor click scrolling --- */ $('a[href^="#"]').click(function(e) { // scroll to anchor if there is actually more after the # sign in the link if ($(this).attr('href').length > 1) { scrollToElementName = $(this).attr('href').substr($(this).attr('href').indexOf("#")+1); scrollTo = $("a[name="+scrollToElementName+"]").offset().top; $('html, body').animate({scrollTop: scrollTo}, 500); e.preventDefault(); } }); /* --- populate text fields and clear them on focus --- */ jQuery.fn.textBoxHint = function () { return this.each(function () { var t = jQuery(this); // get jQuery version of 'this' var title = t.attr('title'); // get it once since it won't change // only apply logic if the element has the attribute if (title) { // on blur, set value to title attr if text is blank t.blur(function () { if (t.val() == '') { t.val(title); t.addClass('blur'); } }); // on focus, set value to blank if current value // matches title attr t.focus(function () { if (t.val() == title) { t.val(''); t.removeClass('blur'); } }); // clear the pre-defined text when form is submitted t.parents('form:first').submit(function() { if (t.val() == title) { t.val(''); t.removeClass('blur'); } }); t.blur(); // now change all inputs to title } }); } /* --- table zebra striping --- */ jQuery.fn.zebraStripeIt = function() { jQuery("tr:odd", this).addClass("odd"); // set class to every odd row in a table } /* --- External links --- */ $.fn.markExternalLinks = function() { $(this).filter(function() { return this.hostname && this.hostname !== location.hostname && ($(this).children('img').size() == 0); }).addClass("external"); } /* --- Calendar --- */ function initCalendar() { // advance a month var strId = $('#calendar-response').attr('class'); if (strId) { // Get language var aLng = strId.split('_'); var lng = aLng[1]; // Load next month $("#cal-next-month").click(function(e) { var cName = $("#cal-next-month").attr("class"); var y = cName.substr(6,4); var m = cName.substr(10,2); $("#calendar-response").load("/util/ajaxresponse.php?lng="+lng, { 'func': 'outputCalendar', 'y': y, 'm': m, 'eventsStrId':strId }, function() { initCalendar(); }); e.preventDefault(); }); // backtrack a month $("#cal-prev-month").click(function(e) { var cName = $("#cal-prev-month").attr("class"); var y = cName.substr(6,4); var m = cName.substr(10,2); $("#calendar-response").load("/util/ajaxresponse.php", { 'func': 'outputCalendar', 'y': y, 'm': m, 'eventsStrId':strId}, function() { initCalendar(); }); e.preventDefault(); }); } } /* --- Photogallery --- */ function initPhotogallery() { if (jQuery("#photo-gallery-container").length) { var galleryWidth = jQuery("div#photo-gallery-container").width(); var galleryItemWidth = jQuery("div#photo-gallery-container .photo-gallery-item:first").width(); var itemsPerRow = Math.floor(galleryWidth / galleryItemWidth); var cnt = 1; var cntItems = 0; var maxHeight = 0; var aHighest = new Array(); var nItems = jQuery("div#photo-gallery-container .photo-gallery-item").length; jQuery("div#photo-gallery-container .photo-gallery-item").each(function() { cntItems++; if (cnt > itemsPerRow) { cnt = 1; maxHeight = 0; } //var totalHeight = if (jQuery(this).height() > maxHeight) { maxHeight = jQuery(this).height(); } if (cnt == itemsPerRow || cntItems == nItems) { aHighest.push(maxHeight); } cnt++; }); cnt = 1; cnt2 = 0; jQuery("div#photo-gallery-container .photo-gallery-item").each(function() { if (cnt > itemsPerRow) { cnt = 1; cnt2++; } jQuery(this).height(aHighest[cnt2]); // check for thumbs which are too wide and remove the height attribute / add width if (jQuery(this).width() <= jQuery("img", this).width()) { jQuery("img", this).removeAttr("height"); jQuery("img", this).width(jQuery(this).width()); } cnt++; }); } } /* --- Photolist --- */ // resize the photolist widths for non-standard width photos function resizePhotolist() { if (jQuery("dl.photo-list").length) { var imgWidth = jQuery("dl.photo-list img:first").width(); var dlWidth = jQuery("dl.photo-list").width(); jQuery("dl.photo-list dt, dl.photo-list dd.summary").width(dlWidth - imgWidth - 10 + "px"); } } /* --- Equal element heights --- */ // make all given objects the same height $.fn.equalHeightColumns = function() { var tallest = 0; $(this).each(function() { if ($(this).outerHeight(true) > tallest) { tallest = $(this).outerHeight(true); } }); $(this).each(function() { var diff = 0; diff = tallest - $(this).outerHeight(true); $(this).height($(this).height() + diff); }); }; // remove any previously set equal heights $.fn.removeEqualHeights = function() { $(this).each(function() { $(this).css('height', ''); }); }; /* --- cart ajax --- */ function addCart() { jQuery(".btnCart").click(function(e) { var idValue = $(this).attr("id"); var aId = idValue.split('-'); var id = aId[1]; var quantity = $(this).prevAll('p').find("input[name=quantity]").val(); var price = $(this).prevAll("input[name=price]").val(); var lng = $(this).prevAll("input[name=lng]").val(); jQuery($("#cart-wrapper")).load("/util/ajaxresponse.php", {'act':'addCart','lng':lng, 'quantity':quantity, 'price':price, 'articleId': id }, function() { removeCart(); }); e.preventDefault(); }); } function removeCart() { jQuery(".imgCartEdit").click(function(e) { var idValue = $(this).attr("id"); var id = idValue.substring(8); var lng = idValue.substr(4,3); jQuery($("#cart-wrapper")).load("/util/ajaxresponse.php", {'act':'removeCart','lng':lng, 'articleId': id }, function() { removeCart(); }); jQuery($("#editCart")).load("/util/ajaxresponse.php", {'act':'updateShopCart','lng':lng, 'articleId': id }, function() { removeCart(); updateCart(); }); e.preventDefault(); }); } function updateCart() { jQuery(".quantity-num").keypress(function(e) { if(e.which == 13) { var idValue = $(this).attr("id"); var id = idValue.substring(8); var lng = idValue.substr(4,3); var quantity = $(this).val(); jQuery($("#cart-wrapper")).load("/util/ajaxresponse.php", {'act':'updateCart','lng':lng, 'articleId': id, 'quantity': quantity }, function() { removeCart(); }); jQuery($("#editCart")).load("/util/ajaxresponse.php", {'act':'updateCartFrom','lng':lng, 'articleId': id, 'quantity': quantity }, function() { updateCart(); removeCart(); }); } }); } function initOurPhotos() { $('#body-content .photo-item a').click (function (e) { e.preventDefault(); var bigPhotoId = $(this).attr('data-id'); jQuery($("#content-wrapper")).load("/util/ajaxresponse.php", {'func': 'ourPhotos', 'bigPhotoId': bigPhotoId }, function() { initOurPhotos(); }); }); } function hideChildren() { var childWidthSum = 0; $('.list .student-item').each(function() { childWidthSum = $(this).width()+70 + childWidthSum; if (childWidthSum > $('#student-list.list').width()) { $(this).hide(); // $(this).nextAll().hide(); } else { $(this).show(); } }); } function studentPhotos() { //masonry $('.gallery-container .student-photos').masonry({ itemSelector: '.gallery-container .student-photos .student-photo', percentPosition: true }); } function hoveringTable() { $("td").hover( function() { var $el = $(this); $el.parent().addClass("hover"); if ($el.parent().has('td[rowspan]').length == 0) { $el.parent().prevAll('tr:has(td[rowspan]):first').find('td[rowspan]').addClass("hover"); } }, function() { $(this).parents("table").eq(0).find(".hover").removeClass("hover"); // var $el = $(this); // $el.parent().removeClass("hover").prevAll('tr:has(td[rowspan]):first').find('td[rowspan]').removeClass("hover"); } ); } //Scroll to enroll function initEnrollBtn() { $(".enroll").click(function(e) { e.preventDefault(); //generates select value var selectValue = $('h1').text()+' - '+$(this).parent('.plans-text-container').prev('h2').text(); var selectValue = selectValue.toLowerCase().replace(/\b[a-z]/g, function(letter) { return letter.toUpperCase(); }); $('select#form_2016060814055609').val(selectValue); $('html, body').animate({ scrollTop: $("#enroll-form-wrapper").offset().top }, 1000); }); } function containerHeight() { if (viewport().width > 815) { $('#our-photos, #blog').removeEqualHeights(); $('.plans-text-container').removeEqualHeights(); $('#our-photos, #blog').equalHeightColumns(); $('.plans-text-container').equalHeightColumns(); } else { $('#our-photos, #blog').removeEqualHeights(); $('.plans-text-container').removeEqualHeights(); } } $("iframe").wrap('
').addClass('embed-responsive-item'); /* --- "on load" --- */ $('input:text').textBoxHint(); // titles to input text $(".table-data").zebraStripeIt(); // alternate coloring of table rows $("article a, ul.grouped-link-list a").markExternalLinks(); // adds class to external links initCalendar(); // initialize the calendar $(".photo-group").each(function() { $(this).magnificPopup({ type: 'image', delegate: 'a.grouped ', gallery: { enabled: true, navigateByImgClick: true }, }); }); $("a[rel^='magnific']").magnificPopup({ type: 'image', closeBtnInside: false, gallery: { enabled: true, navigateByImgClick: true }, closeOnBgClick: true }); $("a[rel^='lightbox']").magnificPopup({ type: 'image', closeBtnInside: false, gallery: { enabled: true, navigateByImgClick: true }, closeOnBgClick: true }); /* Wait for the whole page to load, including images. */ $(window).load(function() { hideChildren(); //initPhotogallery(); // initialize the photogallery $('.video-item').equalHeightColumns(); $('.list .student-item').equalHeightColumns(); $('#banner-wrapper, #footer-content').equalHeightColumns(); studentPhotos(); hoveringTable(); initOurPhotos(); initEnrollBtn(); containerHeight(); }); /* --- window resizing --- */ $(window).resize(function() { hideChildren(); // resize and/or reposition elements here $('.video-item').equalHeightColumns(); $('.list .student-item').equalHeightColumns(); $('#banner-wrapper, #footer-content').equalHeightColumns(); studentPhotos(); containerHeight(); }); }); /* --- Non-jQuery functions below --- */ //check if just one checkbox is checked function isChecked(formId, message) { var form = document.getElementById(formId); for(i=0; i= 35 && n <= 126) { s += String.fromCharCode((n-3)); } else { s += enlsShow.charAt(i); } } if (insertHtml == '') { insertHtml = s; } document.write(""+insertHtml+""); } /* * function get elements by class name ... simiar to getElementsByTagName * leave container arg out, and will default to document. */ function getElementsByClassName(className, container) { if (!container) { container = document; } if (container.all) { var all = container.all; } else { var all = container.getElementsByTagName('*'); } var arr = [] ; for(var k=0;k