function _click(obj1, obj2) { obj1.onclick = function(){return obj2}; return obj2; } function kl_confirm(msg) { var question = confirm(msg); if (question) { return true; } else { return false; } } function reload(link){ location.href=''+link+''; } $(window).load(function() { $('img').each(function() { var broken = false; if($.browser.msie) { if(!this.complete) broken = true; } else if($.browser.opera) { } else if(typeof this.naturalWidth != "undefined" && this.naturalWidth == 0) { broken = true; } if (broken) { // image was broken, replace with your new image $(this).attr('_src', this.src); this.src = "http://www.aegmaha.com/media/img/broken-link.png"; } }); }); $(function(){ $("form#search input[name=\"query\"]").DefaultValue("Otsi märksõna"); $("a[rel=gallery]").fancybox({ 'transitionIn' : 'none', 'transitionOut' : 'none' }); $('#get_more_comments').bind('click', function(e){ $(this).html(''); $.get("/ajax", { act: "get_comments", id: $(this).attr('rel'), action: $(this).attr('_action') }, function(data){ if (data.response=="ok") { $(data.comments).insertAfter('#ajax_block_comments'); $('#get_more_comments').remove(); } }, "json"); return false; }); $('.favourite_action').live('click', function(e){ if (kl_is_logged==0){ alert("Ainult registreeritud kasutajad saavad lemmikutesse lisada"); location.href="http://www.aegmaha.com/register"; } else { var _btn = $(this); if (_btn.val()=="remove"&&kl_is_logged==1){ if (confirm("Oled kindel, et soovid lemmikutest eemaldada?")==false){ return false; } } $.get("/ajax", { act: "process_favourites", id: _btn.attr('name')}, function(data){ if (data.response=="ok") { if (data.action=="notregistered"){ alert("Oled kindel, et soovid lemmikutest eemaldada?"); location.href="http://www.aegmaha.com/register"; } else if (data.action=="removed"){ _btn.attr("src", "http://www.aegmaha.com/media/img/btn_addtofav.gif"); _btn.val("add"); $.achtung({message: "Lemmikutest eemaldatud", timeout:3, icon: 'ui-icon-check', className: 'achtungSuccess'}); if (kl_action=="favorites"){ setTimeout(reload("http://www.aegmaha.com/favorites"), 10000); } } else if (data.action=="added"){ _btn.attr("src", "http://www.aegmaha.com/media/img/btn_fav_del.gif"); _btn.val("remove"); $.achtung({message: "Lisatud lemmikutesse", timeout:3, icon: 'ui-icon-check', className: 'achtungSuccess'}); } } }, "json"); } return false; }); }); var starImages=new Array(); function starHighlight(commentID, starNr){ c=getCookie('contentVotes') if(c) var rated=doArray(c); if(rated && in_array(commentID,rated)) { return; } for(i=1;i<6;i++) { starImages[i]=null; } for(var i=1;i<6;i++) { if(im=document.getElementById('star'+commentID+'_'+i)){ starImages[i]=im.src; im.src='http://'+kl_path_domain+'/media/img/star1'+(i<=starNr?'_b':'')+'.gif'; } } if (starNr == 1) { document.getElementById('show_vote_'+commentID).innerHTML = ' Jama'; } else if (starNr == 2) { document.getElementById('show_vote_'+commentID).innerHTML = ' Enam-vähem'; } else if (starNr == 3) { document.getElementById('show_vote_'+commentID).innerHTML = ' Normaalne'; } else if (starNr == 4) { document.getElementById('show_vote_'+commentID).innerHTML = ' Väga hea'; }else if (starNr == 5) { document.getElementById('show_vote_'+commentID).innerHTML = ' Super'; } } function restoreStarImages(commentID){ for(i=1;i<6;i++) if(starImages[i]!=null) if(im=document.getElementById('star'+commentID+'_'+i)) im.src=starImages[i]; document.getElementById('show_vote_'+commentID).innerHTML = ''; } function addRating(contentID,rate){ c=getCookie('contentVotes') document.getElementById('show_vote_'+contentID).innerHTML = ' Täname hindamise eest'; if(c){ var rated=doArray(c); } if(rated && in_array(contentID,rated)){ return; } $.get("/ajax", { act: "add_rating", id: contentID, rate: rate}, function(data){ if (data.response=="ok") { restoreStarImages(contentID); } }, "json"); } function fixDate(date) { var base = new Date(0); var skew = base.getTime(); if (skew > 0) date.setTime(date.getTime() - skew); } function getCookieVal(offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape (document.cookie.substring(offset, endstr)); } function getCookie(name) { var arg = name+"="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal(j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } function doArray(el){ return el.split(","); } function in_array(element,arr){ c=arr.length; for(i=0;i