var notRequired = Array("address", "city", "zip", "country"); var error_missing = "Selle välja täitmine on kohustuslik."; var error_mail = "See ei ole kehtiv meiliaadress."; var maxHeight = 400; $(document).ready(function(){ $("#nav").addClass("sf-menu").supersubs().superfish({ onBeforeShow: function() { // http://css-tricks.com/long-dropdowns-solution/ var parent = this.closest("li"), dropdown = this, height = dropdown.height() * 1.1, multiplier = height / maxHeight; parent.data("origHeight", parent.height()); this.css({ top: parent.data("origHeight") }); if (multiplier > 1) { // dropdown // .css({ // paddingTop: parent.data("origHeight"), // marginTop: - parent.data("origHeight") // }); parent .mousemove(function(e) { var offset = parent.offset(); var relativeY = ((e.pageY - offset.top) * multiplier) - (parent.data("origHeight") * multiplier); if (relativeY > parent.data("origHeight")) { dropdown.css("top", - relativeY + (2 *parent.data("origHeight"))); }; }); } }, onHide: function() { this .css({ top: 0, marginTop: 0 }); } }).each(function() { $(this).css({ width: "auto" }); $(this).css({ marginLeft: "-" + (parseInt($(this).width()) / 2) + "px" }); }); $("#nav_wrap").each(function() { $(this).css({ height: $(this).find("#nav").outerHeight() }); $(this).prev("div").css({ paddingTop: $(this).outerHeight() - 6 }); }); $("#come_ok").click(function(){ var v = ($(this).attr("checked")) ? "1" : "0"; if (v == 1) { $("#present_ok").removeAttr("checked"); $("#present li").removeClass("required"); for (i = 0; i < notRequired.length; i++) { $("#buy ." + notRequired[i]).removeClass("required"); } } else { for (i = 0; i < notRequired.length; i++) { $("#buy ." + notRequired[i]).addClass("required"); } } }); $("#present_ok").click(function(){ var v = ($(this).attr("checked")) ? "1" : "0"; if (v == 1) { $("#come_ok").removeAttr("checked"); $("#present li").addClass("required"); for (i = 0; i < notRequired.length; i++) { $("#buy ." + notRequired[i]).removeClass("required"); } } else { $("#present li").removeClass("required"); for (i = 0; i < notRequired.length; i++) { $("#buy ." + notRequired[i]).addClass("required"); } } }); $("#customer_info").submit(function(e) { var ok = 1; $("strong.error").remove(); $(".error").removeClass("error"); $("li.required input").each(function() { if ($(this).val() == "") { $(this).addClass("error").after("" + error_missing + ""); ok = 0; } }); $("input[name='email']").each(function() { if (!checkEmail($(this).val())) { $(this).addClass("error").after("" + error_mail + ""); ok = 0; } }); if (ok == 0) e.preventDefault(); }); $("#text, .box, #samalt dt dd ul, #samast_sarjast dl dd ul,#samast_sarjast dl dd ul,#jobb,#justIlmunud").append("
"); $("#comment_foot li").children("input, div").prev("label").append(":"); $("#comment_foot li").children("textarea").prev("label").append(":"); $("#comment_foot li .balra").prev("input").addClass("inputBalra"); $(".kohustuslik").prepend("* "); $(".tarnike").parent("label").css({ paddingTop: "0" }); $("#comment_foot legend").prepend("(").append(")"); $("#ostukorv .kokku").append(":"); $("#ostukorv input[type=submit]").addClass("ostukorvSubmit"); $("input[type=submit]").addClass("submit"); $("input[type=text]").addClass("textInput"); $("input[type=checkbox]").addClass("checkbox"); $(".checkbox").add(":radio").next("label").addClass("balra"); $("#tellimus label").not(".balra").append(":"); $(".autor_raamatust").prepend("(").append(")"); // $(".character").next(".stage").before(""); $("h3 .stitle").prev(".title").append(" "); $("#arvustused a").addClass("out"); $(".meedia #text dd a").addClass("out"); $("dt.year").next("dd").children(":first-child").css({ marginTop: "-1em" }); $("#footer li:first").addClass("dekaart"); // $("#arvustused").prev("h4").append(" (" + $("#arvustused ul li").size() + ")"); var nr = $("#kommentaarid #comment_body li dl").size(); if (nr == "") { nr = 0; } $("#kommentaarid").prev("h4").append(" (" + nr + ")"); // $("h4").next("div").addClass("peida"); // $("#uudised div").removeClass("peida"); // $(".peida").hide(); // $(".peida").prev("h4").prepend("").wrap(""); // $(".loe").click(function(event) // { // $(this).next(".peida").toggle("fast"); // $(this).toggleClass("loe"); $(this).toggleClass("smallPadding"); // $(this).parents(".block").toggleClass("bigpadding"); // return false; }); $(".kiri").each(function() { var c = ($(this)).attr("class"); c = c.split(" "); var n = (c[1] != undefined) ? c[1] : "info"; $(this).html("" + n + "@petroneprint.ee"); }); $("#kontakt dd").next("dt").addClass("dt"); $("#pp, #uudised").equalizeCols(); // $("#myyk, #kontakt").equalizeCols(); $("#search input").hide(); $("#search .textInput").each(function() { if ($(this).val() != "") { $(this).addClass("focus"); } }).focus(function() { $(this).addClass("focus"); }).blur(function() { $(this).removeClass("focus"); }); $("#search form").submit(function() { if ($("#search .textInput").val() == "") { return false; } }); $("#map li").each(function() { var li = $(this); var div = li.find("div"); var img = li.find("img"); var a = div.find("a"); var imgMaxSize = 35; var imgOrigSize = img.width(); var diff = img.width() - imgMaxSize; var liPadding = parseInt(li.css("paddingLeft")); if (parseInt(li.css("left")) > 500) { li.addClass("left"); } else { li.addClass("right"); var right = true; } li.hoverIntent(function() { li.addClass("show"); var imgMaxSize = 35; if (right) { img.animate({ width: imgMaxSize + "px" }, function() { div.addClass("show"); var divMarginLeft = parseInt(img.width()) + liPadding + "px"; div.css({ marginLeft: divMarginLeft, height: li.height() }); li.css({ width: img.outerWidth() + div.outerWidth(), height: "auto" }); }); } else { img.animate({ width: imgMaxSize + "px", marginLeft: diff + "px" }, function() { div.addClass("show"); var divMarginLeft = "-" + (parseInt(div.outerWidth()) + liPadding - diff) + "px"; div.css({ marginLeft: divMarginLeft, height: li.height() }); li.css({ width: img.outerWidth() + diff, marginLeft: "-" + (div.outerWidth() - diff) + "px", paddingLeft: div.outerWidth() - diff, height: "auto" }); }); } }, function() { li.removeClass("show"); if (right) { div.removeClass("show"); li.css({ width: "auto" }); } else { li.css({ paddingLeft: liPadding, marginLeft: 0 }); div.removeClass("show"); li.css({ width: "auto" }); } img.animate({ width: imgOrigSize + "px", marginLeft: 0 }, function() { }); }).click(function() { location.href = a.attr("href"); }).css({ cursor: "pointer" }); }); }); function checkEmail(email) { var email = email.replace(/^\s+|\s+$/g, ''); var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/; if (!filter.test(email)) { return false; } else { return true; } }