﻿function imagelinkpairrollover(img_name, img_src, li_name, li_class) { document[img_name].src = img_src; document.getElementById(li_name).className = li_class } $(document).ready(function () { $("#AllCollectionPoints").click(function (event) { $("#allcollectionpointsselection").attr("checked", "checked") }); $("#allcollectionpointsselection").click(function (event) { var thisButton = this; var radioButtons = $(".noutopisteet input[type=radio]"); radioButtons.each(function () { if (this != thisButton) { $(this).removeAttr("checked") } }) }); $("#AllCollectionPoints").change(function (event) { var selectedCollectionPoint = this.value; __doPostBack("allCollectionPoints", selectedCollectionPoint) }); $(".greenBtn").bind("click", function () { return validateCollectionPoints() }); $(".txtsmall_trigger").bind("change", function () { $("form:first").submit() }); var areCookiesEnabled = areCookiesEnabled(); if (areCookiesEnabled == false) { $("#scriptErrorMessage").html("<div class='error-message'><span>Yliopiston Apteekin verkkopalvelun käyttö edellyttää että evästeet (cookies) ovat sallittuja.</span></div>") } handleProductBatchDropDown(); var checkupUrl; $("#btnCheckup").click(function () { checkupUrl = $(this).attr("checkupUrl"); setBlock("#layerInteractionCheckup") }); $("#continueToInteractionCheckup").click(function () { $(window.location).attr("href", checkupUrl) }); $("#cancelInteractionCheckup").click($.unblockUI); var href = $("#continueToContactInformation").attr("href"); $("#basketContinue").click(function () { var isvalid = validateMultipleCheckBoxes(); if (isvalid) { setBlock("#layerlogin") } }); $("#continueWithOutLogin").click(function () { setBlock("#layerAgeLimit") }); $("#agelimitcheckbox").click(function () { validateCheckBox() }); $("#continueToContactInformation").click(function () { validateCheckBox() }); $("#toContactInformation").click(function () { var isvalid = validateMultipleCheckBoxes(); if (isvalid) { __doPostBack("toContactInformation", true) } }); var lineItemId; $(".greyBtn").click(function () { lineItemId = $(this).attr("lineitemid"); setBlock("#layerConfirmDelete") }); $("#continueDelete").click(function (event) { __doPostBack("continueDelete", lineItemId); event.preventDefault(); var mode = document.documentMode || 0; var ie6 = $.browser.msie && /MSIE 6.0/.test(navigator.userAgent) && !mode; if (ie6) { hideBlock("#layerConfirmDelete"); location.reload(true) } }); $("#closeLayer").click($.unblockUI); $("#closeAgeLimitLayer").click($.unblockUI); $("#cancelDelete").click($.unblockUI); function validateCollectionPoints() { var isValid = false; if ($(".noutopisteet").length > 0) { var radioButtons = $(".noutopisteet input[type=radio]"); radioButtons.each(function () { if (this.checked == true) { isValid = true } }); var allSelected = $("#allcollectionpointsselection").attr("checked"); if (allSelected == true && $("#AllCollectionPoints").attr("selectedIndex") == 0) { isValid = false } if (isValid == false) { $("#validityInfo").attr({ style: "visibility:visible;display:inline-block;" }) } else { $("#validityInfo").attr({ style: "visibility:hidden;display:none;" }) } return isValid } else { return true } } function validateMultipleCheckBoxes() { var isValid = true; var checkbox = $("#productList input[type=checkbox]"); checkbox.each(function () { if (this.id != "agelimitcheckbox") { var control = $("#" + this.id); var controlID = control.attr("validateid"); if (!control.attr("checked")) { isValid = false; $("#productList span[controltovalidate=" + controlID + "]").attr({ style: "visibility:visible;display:inline-block;" }) } else { $("#productList span[controltovalidate=" + controlID + "]").attr({ style: "visibility:hidden;display:none;" }) } } if (isValid == false) { $("#validityInfo").attr({ style: "visibility:visible;display:inline-block;" }) } else { $("#validityInfo").attr({ style: "visibility:hidden;display:none;" }) } }); return isValid } function validateCheckBox() { if (!$("#agelimitcheckbox").attr("checked")) { $("#agelimitError").show(); $("#continueToContactInformation").removeAttr("href") } else { $("#agelimitError").hide(); $("#continueToContactInformation").attr("href", href) } } function setBlock(divId) { $.blockUI.defaults.css = { padding: 0, margin: 0, width: "30%", top: "20%", left: "15%", cursor: "pointer" }; $.blockUI.defaults.overlayCSS = { backgroundColor: "#FFFFFF", opacity: 0.6 }; $.blockUI({ message: $(divId) }) } function hideBlock(divId) { $.unblockUI({ message: $(divId) }) } $("#mainContent div.print a").click(function () { window.print(); return false }); function createCookie(name, value, days) { var expires; if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); expires = "; expires=" + date.toGMTString() } else { expires = "" } document.cookie = name + "=" + value + expires + "; path=/" } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(";"); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == " ") { c = c.substring(1, c.length) } if (c.indexOf(nameEQ) == 0) { return c.substring(nameEQ.length, c.length) } } return null } function eraseCookie(name) { createCookie(name, "", -1) } function areCookiesEnabled() { var r = false; createCookie("ya.cookie", "1", 1); if (readCookie("ya.cookie") != null) { r = true; eraseCookie("ya.cookie") } return r } function handleProductBatchDropDown() { $("#productbatch").hide(); $("#productbatchdropdown_link").click(function () { $("#productbatch").slideToggle(); return false }) } $(".productCarouselContainer1 img").click(function () { showSelectedProductCarouselArea(this, "productCarouselContainer1", "1") }); $(".productCarouselContainer2 img").click(function () { showSelectedProductCarouselArea(this, "productCarouselContainer2", "2") }); $(".productCarouselContainer1 span").click(function () { showSelectedProductCarouselArea(this, "productCarouselContainer1", "1") }); $(".productCarouselContainer2 span").click(function () { showSelectedProductCarouselArea(this, "productCarouselContainer2", "2") }); function showSelectedProductCarouselArea(selected, cssClass, carouselType) { $("." + cssClass + " li").attr("class", ""); var currentParent = $(selected).closest("li"); currentParent.attr("class", "selected"); var product = $(selected).attr("product"); $(".productArea" + carouselType).hide(); $("#" + product).show() } });
