window.google_key = ''; window.months = ['Janúar', 'Febrúar', 'Mars', 'Apríl', 'Maí', 'Júní', 'Júlí', 'Ágúst', 'September', 'Október', 'Nóvember', 'Desember'] function recordOutboundLink(link, success) { try { $.ajax({ url: '/index.php?option=com_n-editor&do=track&no_html=1&link='+escape(link.href), success: success }) if(window.google_key) { var pageTracker=_gat._getTracker(window.google_key); pageTracker._trackEvent('/Banners/'+escape(link.href),'Click'); } }catch(err){} } function trim(stringToTrim) { return stringToTrim.replace(/^\s+|\s+$/g,""); } function ltrim(stringToTrim) { return stringToTrim.replace(/^\s+/,""); } function rtrim(stringToTrim) { return stringToTrim.replace(/\s+$/,""); } function jsdate() { if(arguments[0]) { var date = new Date(arguments[0]); } else { var date = new Date(); } var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); return [d, m, y] } function icedate(d) { return d[0]+". "+window.months[d[1]]+" "+d[2] } function mceClean() { $('.mceEditor').each(function(i, ta) { var id = $(ta).attr('id'); try { tinyMCE.removeMCEControl(id) } catch(e) { } }) } function getUrl(strUrl) { var strReturn = ""; jQuery.ajax({ url:strUrl, success:function(html){strReturn = html;}, async:false }); return strReturn; } Object.size = function(obj) { var size = 0, key; for (key in obj) { if (obj.hasOwnProperty(key)) size++; } return size; }; $.fn.highlight = function(ms, color) { ms = ms ? ms : 700; color = color ? color : "#9b9"; //$(this).css('backgroundColor', "#afa") $(this).animate({'backgroundColor': color, 'color' : '#000'}, ms, function() { //$(this).css({'backgroundColor': '', 'color' : ''}); $(this).removeAttr('style') }) } $.fn.loading = function(ms) { var item = this $(this).addClass('n_loading') var end = function() { $(item).removeClass('n_loading') } if(ms>0) { window.setTimeout(end, ms); } else { return end } /*$(this).css('backgroundColor', "#afa") $(this).animate({'backgroundColor': '#9b9', 'color' : '#000'}, ms, function() { $(this).css({'backgroundColor': '', 'color' : ''}); })*/ } $(document).ready(function() { //Síðan er loaduð en t.d. myndir enn að loadast $('a.lightbox, a[rel=lightbox], a[rel=gallery], a.fancybox').live('click', function() { $('a.lightbox, a[rel=lightbox], a[rel=gallery], a.fancybox').fancybox({ centerOnScroll: false }) $(this).click(); return false; }) $('.hover').hover(function() { $(this).addClass('hoverSel') }, function() { $(this).removeClass('hoverSel') }) $.fn.vAlign = function() { return this.each(function(i){ var ah = $(this).height(); var ph = $(this).parent().height(); var mh = (ph - ah) / 2; //$('#opnunartimi2').html(ah + " " + ph) if(ph>0) { $(this).css('margin-top', mh); } }); }; /*$('h1').hashchange(function (e, newHash) { $(this).prepend('

New hash: "' + newHash + '"

'); });*/ $.hash.init('/js/includes/index.html'); }) $(window).load(function() { //Síðan alveg loaduð, m.a. myndir //$('.v_center').vAlign(); }) window._timeout = null; $.fn.timeout = function(time, success) { if($(this).is('div') || $(this).is('tr')) { var items = $(this).find('input, textarea, select'); } else { var items = $(this); } $.each(items, function(i, item) { var time = $(item).attr('timeout') ? $(item).attr('timeout') : time; time = typeof(time)=="undefined" ? 300 : time if(success) { $(item).bind('hasChanged', function() { success.call(this) }) } $(item).unbind('keydown').keydown(function(e) { //$(this).attr('oldval', $(this).val() ? $(this).val() : $(this).text()) //$("h3").text($(this).val()) }) $(item).unbind('keyup').keyup(function(e) { //console.log(e.keyCode); /*if($(this).changed()) { $(this).trigger('hasChanged') }*/ //var ov = $(item).attr('oldval') var val = $(item).val() ? $(item).val() : $(item).text() if(_timeout) { clearTimeout(_timeout); _timeout = null; } _timeout = setTimeout(function() { if($(item).changed()) { $(item).trigger('hasChanged');$(item).attr('lastsaved', val);} }, time) }) if($(item).attr('type')=="checkbox" || $(item).is("select") || $(item).is("radio")) { $(item).unbind('change').bind('change', function() { $(item).trigger('hasChanged') }) return; } else { $(item).unbind('blur').blur(function() { //console.log('blur') //var val =$(this).val() ? $(this).val() : $(this).text() //$(item).trigger('hasChanged') if($(this).changed()) { $(this).trigger('hasChanged') } //if( $(this).attr('oldval') && $(this).attr('oldval')!=val ) { $(item).trigger('hasChanged') } }); } }) } $.fn.changed = function() { var lastsaved = $(this).attr('lastsaved') || false; var val =$(this).val() ? $(this).val() : $(this).text() if(!val || val!=lastsaved) { return true; } else { return false; } } var timeout_return = function() { var timeout; var obj = this var objs = $(this).find('input, textarea, select, radio').andSelf() var time = $(obj).attr('timeout') ? $(obj).attr('timeout') : 500; //console.log(objs); objs.each(function(i, item) { $(item).timeout(time); }) return false; } //$.fn.timeout = timeout_return; var ajax_return = function() { var rel = $(this).attr('rel'); rel = rel ? rel : $(this) var url = $(this).attr('href'); var target = $(this).attr('target'); var is_input = $(rel).is('input, textbox, select, option') var value = is_input ? $(rel).val() : $(rel).text(); var item = this $.ajax({ url: url, data: {'val': value}, success: function(data) { $(rel).trigger('ajax', [data]) $(item).trigger('ajax', [data]) if(target) { $(target).append(data) $(target).trigger('ajax', [data]) } if(is_input) { $(item).highlight() } } }) return false; } $(function() { $(document).pngFix(); $('a.out').live('mouseup', function(e) { var link = this success = function() { }; /*var success = function() { document.location = link.href }*/ if(e.button==1 || e.ctrlKey) { success = function() { }; } if(e.button==2) { return; } recordOutboundLink(this, success) }) $(document).click(function(e) { var t = $(e.target) if(!t.hasClass('noclick') && !t.closest('.noclick').length) { if(window._uploading) { return; } var hideble = t.closest('.hideble') $('.hideble').not(hideble).not('.nohide').hide().trigger('cancel'); } }) $(document).keydown(function(e) { var targ; if (!e) var e = window.event; if (e.target) { targ = e.target; } else if (e.srcElement) { targ = e.srcElement } var t = $(targ); if(!t.hasClass('keyboard') && t.closest('.keyboard').length) { t = t.closest('.keyboard'); } if(window.hasOwnProperty('_keyEvent')) { window._keyEvent.call(t, e); } if(t.hasClass('keyboard') || t.closest('.hideble').length ) { $(t).trigger('keyboard', e.keyCode, e) switch(e.keyCode) { case 27: t.closest('.hideble').length ? t.closest('.hideble').hide() : t.hide(); break; case 13: //console.log("bla"); t.find('.save').click(); break; } } }) $('.hide').live('click', function() { $(this).closest('.hideble').hide().trigger('hide'); }) $('.lookup').live('click',function() { $(this).parent().find('input').trigger('lookup') }) $('.lookup_field').live('keyup',function(e) { if(e.keyCode==13) { $(this).trigger('lookup') } }) $('.del').live('click',function() { var obj = $(this); var r = $(this).attr('del'); var rel = $(this).attr('rel'); var url = $(this).attr('href') ? $(this).attr('href') : $(r).attr('href'); if(!url) { return } var value = $(r).is('input, textbox, select, option') ? $(r).val() : $(r).text(); if($(this).hasClass('confirm')) { if(!confirm('Ertu viss?')) { return false } } $.ajax({ url: url, data: { val : value, 'sqlid':$(rel).attr('sqlid') }, success: function(data) { if($(r).length || obj.attr('del')=="false") { $(r).remove(); $(rel).trigger('delete', [data]) } else { $(rel).remove(); } } }) return false; }) $('a.submit').live('click', function() { $(this).closest('form').submit(); //alert($(this).closest('form').html()); }) /* Öll input eða textarea undir hlut með classan "timeout" fær eventið "hasChanged" 500 ms eftir að seinasta breyting er gerð */ $('.timeout').livequery(timeout_return) //timeout_return.call() $('.timeout select').live('change', function() { $(this).trigger('hasChanged'); }) /*$("#ajax-loading").ajaxStart(function(){ $(this).show(); }); $("#ajax-loading").ajaxStop(function(){ $(this).hide(); }); */ $('.ajax_changed').live('hasChanged', ajax_return) $('.ajax').live('click', ajax_return) $('.dateselect').livequery(function() { //console.log($.datepicker.regional); var opt = { clearText: 'Hreinsa', clearStatus: '', closeText: 'Loka', closeStatus: '', prevText: '< Fyrri', prevStatus: '', prevBigText: '<<', prevBigStatus: '', nextText: 'Næsti >', nextStatus: '', nextBigText: '>>', nextBigStatus: '', currentText: 'Í dag', currentStatus: '', monthNames: ['Janúar','Febrúar','Mars','Apríl','Maí','Júní', 'Júlí','Ágúst','September','Október','Nóvember','Desember'], monthNamesShort: ['Jan','Feb','Mar','Apr','Maí','Jún', 'Júl','Ágú','Sep','Okt','Nóv','Des'], monthStatus: '', yearStatus: '', weekHeader: 'Vika', weekStatus: '', dayNames: ['Sunnudagur','Mánudagur','Þriðjudagur','Miðvikudagur','Fimmtudagur','Föstudagur','Laugardagur'], dayNamesShort: ['Sun','Mán','Þri','Mið','Fim','Fös','Lau'], dayNamesMin: ['Su','Má','Þr','Mi','Fi','Fö','La'], dayStatus: 'DD', dateStatus: 'D, M d', dateFormat: 'dd/mm/yy', firstDay: 0, initStatus: '', isRTL: false } var opt = {} opt.onSelect = function(text, inst) { $(this).trigger('hasChanged', [text, inst]) } $(this).datepicker(opt); }) }) function format_price(nStr) { nStr = Math.round(nStr+0.0001); nStr += ''; x = nStr.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + '.' + '$2'); } return x1 + x2; } function stripice(s) { var isl = "á é í ú ó þ æ ð ö" var eng = "a e i u o th ae d o" var i = isl.split(" "); var e = eng.split(" "); for(var c=0;c