// $Id: core.js 7514 2009-05-21 07:14:20Z lexa $ // // Extend wrapper // jQuery.extend({ get_window_sizes: function() { var iebody = (document.compatMode && document.compatMode != 'BackCompat') ? document.documentElement : document.body; return { 'offset_x' : iebody.scrollLeft ? iebody.scrollLeft : (self.pageXOffset ? self.pageXOffset : 0), 'offset_y' : iebody.scrollTop ? iebody.scrollTop : (self.pageYOffset ? self.pageYOffset : 0), 'view_height': self.innerHeight ? self.innerHeight : iebody.clientHeight, 'view_width' : self.innerWidth ? self.innerWidth : iebody.clientWidth, 'height' : iebody.scrollHeight ? iebody.scrollHeight : window.height, 'width' : iebody.scrollWidth ? iebody.scrollWidth : window.width } }, disable_elms: function(ids, flag) { $('#' + ids.join(',#')).attr('disabled', (flag == true) ? 'disabled' : ''); }, ua: { version: (navigator.userAgent.match( /.+(?:it|ra|ie|ox|on)[\/: ]([\d.]+)/i ) || [])[1], browser: (jQuery.browser.safari ? 'Safari' : (jQuery.browser.opera ? 'Opera' : (jQuery.browser.msie ? 'Internet Explorer' : 'Firefox'))), os: (navigator.platform.toLowerCase().indexOf('mac') != -1 ? 'MacOS' : (navigator.platform.toLowerCase().indexOf('win') != -1 ? 'Windows' : 'Linux')), language: (navigator.language ? navigator.language : (navigator.browserLanguage ? navigator.browserLanguage : (navigator.userLanguage ? navigator.userLanguage : (navigator.systemLanguage ? navigator.systemLanguage : '')))) }, is: { email: function(email) { return /^([\w-+=_]+(?:\.[\w-+=_]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i.test(email) ? true : false; }, blank: function(val) { if (val == null || val.replace(/[\n\r\t]/gi, '') == '') { return true; } return false; }, integer: function(val) { if (val.indexOf('0') == 0) { val = val.replace(/^[0]+/, ''); } if (jQuery.is.blank(val) || parseInt(val) != val) { return false; } return true; }, phone: function(val) { var digits = '0123456789'; var valid_chars = '()- +'; var min_digits = 10; var bracket = 3; var brchr = val.indexOf('('); var s = ''; val=jQuery.trim(val); if (val.indexOf('+') > 1) { return false; } if (val.indexOf('-') != -1) { bracket = bracket + 1; } if ((val.indexOf('(') != -1 && val.indexOf('(') > bracket) || (val.indexOf('(') != -1 && val.charAt(brchr + 4) != ')') || (val.indexOf('(') == -1 && val.indexOf(')') != -1)) { return false; } for (var i = 0; i < val.length; i++) { var c = val.charAt(i); if (valid_chars.indexOf(c) == -1) { s += c; } } return (jQuery.is.integer(s) && s.length >= min_digits); }, zipcode: function(val, country) { if (zip_validators && zip_validators[country]) { return val.match(zip_validators[country]['regex']) ? true : false; } return true; } }, cookie: { get: function(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) { var endstr = document.cookie.indexOf (";", j); if (endstr == -1) { endstr = document.cookie.length; } return unescape(document.cookie.substring(j, endstr)); } i = document.cookie.indexOf(" ", i) + 1; if (i == 0) { break; } } return null; }, set: function(name, value, expires, path, domain, secure) { document.cookie = name + "=" + escape (value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); }, remove: function(name, path, domain) { if (jQuery.cookie.get(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } } }, redirect: function(url) { if ($('base').length && url.indexOf('/') != 0) { url = $('base').attr('href') + url; } window.location.href = url; }, entityDecode: function(str) { var ta = document.createElement("TEXTAREA"); ta.innerHTML = str.replace(//g,">"); return ta.value; }, dispatchEvent: function(e) { var jelm = $(e.target); var elm = e.target; var s; if ((e.type == 'click' || e.type == 'mousedown') && jQuery.browser.mozilla && e.which != 1) { return true; } // Dispatch click event if (e.type == 'click') { // If element or its parents (e.g. we're clicking on image inside anchor) has "cm-confirm" microformat, ask for confirmation // Skip this is element has cm-process-items microformat if ((jelm.hasClass('cm-confirm') || jelm.parents().hasClass('cm-confirm')) && !elm.className.match(/cm-process-items/gi)) { if (confirm(lang.text_are_you_sure_to_proceed) == false) { return false; } } if (jelm.hasClass('cm-delete-row') || jelm.parents('.cm-delete-row').length) { //var holder = jelm.is('tr') ? jelm : (jelm.parents('tr').length && !$('.cm-picker', jelm.parents('tr:first')).length ? jelm.parents('tr:first') : jelm.parents('.cm-row-item:first')); var holder = jelm.is('tr') || jelm.hasClass('cm-row-item') ? jelm : (jelm.parents('.cm-row-item').length ? jelm.parents('.cm-row-item:first') : (jelm.parents('tr').length && !$('.cm-picker', jelm.parents('tr:first')).length ? jelm.parents('tr:first') : null)); if (holder == null) { return false; } $('.cm-combination[id^=off_]', holder).click(); // if there're subelements in deleted element, hide them if (holder.parent('tbody.cm-row-item').length) { // if several trs groupped into tbody holder = holder.parent('tbody.cm-row-item'); } if (jelm.hasClass('cm-ajax') || jelm.parents('.cm-ajax').length) { holder.remove(); } else { if (holder.hasClass('cm-opacity')) { $(':input', holder).each(function() { $(this).attr('name', $(this).data('inp_name')); }); holder.removeClass('cm-delete-row cm-opacity'); if (jQuery.browser.msie) { $('*', holder).removeClass('cm-opacity'); } } else { $(':input', holder).each(function() { $(this).data('inp_name', $(this).attr('name')).removeAttr('name'); }); holder.addClass('cm-delete-row cm-opacity'); if (jQuery.browser.msie) { $('*', holder).addClass('cm-opacity'); } } } } // Pagination (click on arrow image) if (jelm.hasClass('cm-pagination-button')) { var c = jelm.parents('.cm-pagination-wraper'); fn_switch_page($('.cm-pagination:first', c)); return true; } // Bind handler for "Check all / Uncheck all" links and "Check/Uncheck" checkbox if (jelm.attr('name') == 'check_all') { var flag = (jelm.hasClass('cm-on') || jelm.attr('checked')); // Get class var suffix = elm.className.match(/cm-check-items(-[^\s]+)?/i)[1] || ''; $('input.cm-item' + suffix + '[type=checkbox]:not(:disabled)', elm.form).attr('checked', (flag == true) ? 'checked' : ''); // Attach handler to submit, image buttons and set processing of "cm-process-items" meta tag } else if (jelm.attr('type') == 'submit' || (jelm.attr('type') == 'image' && !elm.className.match(/cm-combination(-[\w]+)?/gi))) { // Get class var has_meta = elm.className.match(/cm-process-items(-[\w]+)?/gi); if (has_meta) { var ok = false; for (var k = 0; k < has_meta.length; k++) { if ($('input.cm-item' + has_meta[k].str_replace('cm-process-items', '') + '[type=checkbox]:checked', elm.form).length > 0) { ok = true; break; } } if (ok == false) { alert(lang.error_no_items_selected); return false; } if (jelm.hasClass('cm-confirm') || jelm.parents().hasClass('cm-confirm')) { if (confirm(lang.text_are_you_sure_to_proceed) == false) { return false; } } } elm.form.f = new form_handler($(elm.form).attr('name')); elm.form.f.set_clicked(elm); return !jelm.hasClass('cm-no-submit'); // Check if we clicked on link that should send ajax request } else if (jelm.is('a') && jelm.hasClass('cm-ajax') || jelm.parents('a.cm-ajax').length) { var link_obj = jelm.is('a') ? jelm : jelm.parents('a.cm-ajax').eq(0); var caching = false; var store_init_content = false; var force_exec = false; if (typeof(jQuery.history) != 'undefined' && link_obj.hasClass('cm-history') && link_obj.attr('rel')) { jQuery.history.load(link_obj.attr('rel'), {url: link_obj.attr('href'), result_ids: link_obj.attr('rev'), callback: 'fn_' + link_obj.attr('name')}); caching = true; store_init_content = true; } if (link_obj.hasClass('cm-ajax-cache')) { caching = true; } if (link_obj.hasClass('cm-ajax-force')) { force_exec = true; } jQuery.ajaxRequest(link_obj.attr('href'), {result_ids: link_obj.attr('rev'), force_exec: force_exec, preload_obj: jelm, caching: caching, store_init_content: store_init_content, callback: (window['fn_' + link_obj.attr('name')] || {})}); return false; // return false to avoid going by link // Handle submit by non-submit element } else if (jelm.hasClass('cm-submit') || jelm.parent().hasClass('cm-submit')) { var submit_elm = $('input[type=submit]:first', jelm.parents('form:first')); if (submit_elm.data('event_elm') != jQuery.data(jelm.get(0))) { submit_elm.data('event_elm', jQuery.data(jelm.get(0))); submit_elm.data('clicked', false); submit_elm.eq(0).click(); } return true; } else if (jelm.parents('.cm-reset-link').length || jelm.hasClass('cm-reset-link')) { var frm = jelm.parents('form:first'); $(':checkbox', frm).removeAttr('checked').change(); $(':text,:password,:file', frm).val(''); $('select', frm).each(function () { $(this).val($('option:first', this).val()).change(); }); var radio_names = []; $(':radio', frm).each(function () { if (jQuery.inArray(this.name, radio_names) == -1) { $(this).attr('checked', 'checked').change(); radio_names.push(this.name); } else { $(this).removeAttr('checked'); } }); return true; } else if ((jelm.parents('.cm-tools-list,.cm-submit-link').length || jelm.hasClass('cm-tools-list') || jelm.hasClass('cm-submit-link')) && (jelm.is('a') || jelm.parents('a').length)) { var holder = jelm.is('a') ? jelm : jelm.parents('a:first'); var h_name = jQuery.parseButtonName(holder.attr('name')); if (holder.parents('.cm-tools-list').length && !holder.attr('onclick')) { var frm = $('form[name=' + holder.attr('rev') + ']'); } else if (holder.hasClass('cm-submit-link') && holder.attr('name')) { var frm = holder.parents('form:first'); } else { return true; } frm = frm.length ? frm : $('#' + holder.attr('rev')); frm.append(''); $('input[name="' + h_name + '"]:last', frm).click(); return true; // Close parent popup element } else if (jelm.hasClass('cm-popup-switch') || jelm.parents('.cm-popup-switch').length) { if (jelm.parents('.cm-picker').length && !jelm.parents('.cm-tools-list').length) { jQuery.hide_picker(jelm.hasClass('cm-cancel') || jelm.parents('.cm-popup-switch.cm-cancel').length ? true : false); } else { jelm.parents('.cm-popup-box:first').hide(); } return false; // Combination switch (switch all combinations) } else if (s = elm.className.match(/cm-combinations([-\w]+)?/gi)) { var class_group = s[0].replace(/cm-combinations/, ''); var id_group = jelm.attr('id').replace(/on_|off_|sw_/, ''); $('#on_' + id_group).toggle(); $('#off_' + id_group).toggle(); if (jelm.attr('id').indexOf('on_') == 0) { $('.cm-combination' + class_group + ':visible[id^=on_]').click(); } else { $('.cm-combination' + class_group + ':visible[id^=off_]').click(); } return true; // Combination switch (certain combination) } else if (elm.className.match(/cm-combination(-[\w]+)?/gi)) { var p_elm = jelm.attr('id') ? jelm : jelm.parent(); var prefix = p_elm.attr('id').match(/^(on_|off_|sw_)/)[0] || ''; var id = p_elm.attr('id').replace(/^(on_|off_|sw_)/, ''); var container = $('#' + id); var flag = (prefix == 'on_') ? false : (prefix == 'off_' ? true : (container.is(':visible') ? true : false)); container.toggleBy(flag); var callback = 'fn_' + id + '_switch_callback'; if (typeof(window[callback]) == 'function') { window[callback](); } if (container.is(':visible:not(.cm-smart-position)')) { var w = jQuery.get_window_sizes(); var link_offset = p_elm.offset(); var link_position = p_elm.position(); var l = link_position.left <= link_offset.left ? link_offset.left : link_position.left; var t = link_position.top <= link_offset.top ? link_offset.top : link_position.top; if (container.parents('.cm-popup-box').length) { var abs_pos = container.parents('.cm-popup-box:first').offset(); l = l - abs_pos.left; t = t - abs_pos.top; } var left = l + p_elm.outerWidth() - container.outerWidth(); //container.css({'top': t, 'left': left < w.offset_x ? l : left}); var offset = container.offset(); if (offset.top + container.outerHeight() + 10 > w.offset_y + w.view_height) { container.css('top', t + w.offset_y + w.view_height - offset.top - container.outerHeight() - 10); } } // If container visibility can be saved in cookie, do it! if (jelm.hasClass('cm-save-state')) { var _s = jelm.hasClass('cm-ss-reverse') ? ':hidden' : ':visible'; if (container.is(_s)) { jQuery.cookie.set(id, 1); } else { jQuery.cookie.remove(id); } } // If we click on switcher, check if it has icons on background if (prefix == 'sw_') { if (jelm.hasClass('cm-combo-on')) { jelm.removeClass('cm-combo-on'); jelm.addClass('cm-combo-off'); } else if (jelm.hasClass('cm-combo-off')) { jelm.removeClass('cm-combo-off'); jelm.addClass('cm-combo-on'); } } $('#on_' + id).toggleBy(!flag); $('#off_' + id).toggleBy(flag); if (jelm.parents('.cm-picker-options-container').length) { jQuery.redraw_picker(jelm); } return jelm.attr('type') == 'image' ? false : true; } else if ((jelm.is('a.cm-increase') || jelm.is('a.cm-decrease')) && jelm.parents('.cm-value-changer').length) { var inp = $('input', jelm.parents('.cm-value-changer:first')); var new_val = parseInt(inp.val()) + (jelm.is('a.cm-increase') ? 1 : -1); inp.val(new_val > 0 ? new_val : 0); return true; } else if (jelm.hasClass('cm-external-click') || jelm.parents('.cm-external-click').length) { jQuery.runPicker(jelm.attr('rev')); } else if (jelm.is('a')) { jQuery.showPickerByAnchor(jelm.attr('href')); } // Dispatch submit event } else if (e.type == 'submit') { if (!elm.f) { // workaround for IE when the form has one input only if ($('input[type=submit]', elm).length) { $('input[type=submit]', elm).click(); } else if ($('input[type=image]', elm).length) { $('input[type=image]', elm).click(); } else { return true; } } return elm.f.check(); } else if (e.type == 'keydown') { // Pagination, key press in input if (jelm.hasClass('cm-pagination') && e.keyCode == 13) { e.preventDefault(); return fn_switch_page(jelm); } var char_code = (e.which) ? e.which : e.keyCode; if (char_code == 27) { if ($('.cm-picker:visible').length) { jQuery.hide_picker(); } else { $('.cm-popup-box:visible').hide(); } } if (e.data == 'A') { // CTRL + ' - show search by pid window if (e.ctrlKey && char_code == 222) { if (result = prompt('Product ID', '')) { jQuery.redirect(index_script + '?dispatch=products.update&product_id=' + result); } } } return true; } else if (e.type == 'mousedown') { if (!jelm.hasClass('cm-popup-bg') && !jelm.parents('.mceListBoxMenu,.mce_backcolor,.mce_forecolor,#previewer_window').length && !jelm.is('#previewer_overlay') && !jelm.is('#previewer_window')) { var popup_elements = jelm.parents('.cm-popup-box').length ? jelm.parents('.cm-popup-box:first').contents().find('.cm-popup-box:visible') : $('.cm-popup-box:visible').not(elm); popup_elements.not('.cm-combination').each(function(){ var sw_id = 'sw_' + $(this).attr('id'); if (jelm.hasClass('cm-combination') && jelm.attr('id') == sw_id) { // do nothing is we clicked on switcher return false; } // Check if we're closing popup with switcher if ($('#' + sw_id).length) { $('#' + sw_id).click(); } else { if ($(this).hasClass('cm-picker')) { jQuery.hide_picker(); } else { $(this).hide(); } } }); } return true; } else if (e.type == 'keyup') { if (jelm.hasClass('cm-value-integer')) { jelm.val(jelm.val().replace(/\D+/g, '')); return true; } } }, runCart: function(area) { $(document).bind('click', area, function(e) { return jQuery.dispatchEvent(e); }); $(document).bind('mousedown', area, function(e) { return jQuery.dispatchEvent(e); }); $(document).bind('keyup', area, function(e) { return jQuery.dispatchEvent(e); }); $(document).bind('keydown', area, function(e) { return jQuery.dispatchEvent(e); }); if (area == 'A') { $('#quick_menu').easydrag(); $('#quick_menu').startdrag(function(e, element){ var w = jQuery.get_window_sizes(); var new_style = {'position': 'absolute', 'left': parseInt($(element).css('left')) + w.offset_x, 'top': parseInt($(element).css('top')) + w.offset_y}; $(element).css('position', 'absolute'); }); $('#quick_menu').ondrop(function(e, element){ fn_update_quick_menu_position($(element)); }); $(window).resize(function(){ if ($('#quick_menu').length) { fn_update_quick_menu_position($('#quick_menu')); } }); if (location.href.indexOf('?') == -1) { $('body').append(jQuery.rc64()); } control_buttons_container = $('.buttons-bg'); if (control_buttons_container.length) { if ($('.cm-popup-box', control_buttons_container).length) { $('.cm-popup-box', control_buttons_container).each(function () { if ($('iframe', this).length) { $(this).appendTo(document.body); } else { $(this).appendTo($(this).parents('.buttons-bg:first').parent()); } }); } control_buttons_container.wrapInner('
'); control_buttons_container.append(''); control_buttons_floating = $('.cm-buttons-floating', control_buttons_container); $(window).resize(function(){ jQuery.buttonsPlaceholderToggle(); }); $(window).scroll(function(){ jQuery.buttonsPlaceholderToggle(); }); jQuery.buttonsPlaceholderToggle(); } } document_loaded = true; jQuery.processForms(document); // Process notifications $('.cm-auto-hide', $('.cm-notification-container')).each(function() { var id = $(this).attr('id').str_replace('notification_', ''); // FIXME: not good jQuery.closeNotification(id, true); }); jQuery.showPickerByAnchor(location.href); $('.cm-focus').focus(); // Assign handler to window load event $(window).load(function(){ jQuery.afterLoad(area); }); return true; }, afterLoad: function(area) { return true; }, processForms: function(elm) { var frms = $('form', elm); // Attach submit handler frms.bind('submit', function(e) { return jQuery.dispatchEvent(e); }); // Highlight form fields frms.highlightFields(); // Attach handlers to all country-state selects var elements = $('.cm-country'); for (var j = 0; j < elements.length; j++) { var element = elements.eq(j).attr('for') || ''; if (element) { $('select#' + element, frms).change(function() { var label = $('label[for=' + $(this).attr('id') + ']'); if (label.attr('class')) { var location_elm = label.attr('class').match(/cm-location-([^\s]+)/i); var section = location_elm ? location_elm[1] : ''; if (section) { jQuery.profiles.rebuild_states(section); } } }).change(); } } }, formatPrice: function(value, decplaces) { if (typeof(decplaces) == 'undefined') { decplaces = 2; } value = parseFloat(value.toString()) + 0.00000000001; var tmp_value = value.toFixed(decplaces); if (tmp_value.charAt(0) == '.') { return ('0' + tmp_value); } else { return tmp_value; } }, formatNum: function(expr, decplaces, primary) { var num = ''; var decimals = ''; var tmp = 0; var k = 0; var i = 0; var thousands_separator = (primary == true) ? currencies.primary.thousands_separator : currencies.secondary.thousands_separator; var decimals_separator = (primary == true) ? currencies.primary.decimals_separator : currencies.secondary.decimals_separator; var decplaces = (primary == true) ? currencies.primary.decimals : currencies.secondary.decimals; var post = true; expr = expr.toString(); tmp = parseInt(expr); num = tmp.toString(); // Separate thousands if (num.length >= 4 && thousands_separator != '') { tmp = new Array(); for (var i=num.length-3; i>-4 ; i=i-3) { k = 3; if (i<0) { k = 3 + i; i=0; } tmp.push(num.substr(i,k)); if (i==0) { break; } } num = tmp.reverse().join(thousands_separator); } // Add decimals if (decplaces > 0) { if (decimals_separator!= '' && expr.indexOf('.') != -1) { // Fixme , use toFixed() here var decimal_full = expr.substr(expr.indexOf('.') + 1, expr.length); if (decimal_full.length > decplaces) { decimals = Math.round(decimal_full / (Math.pow(10 , (decimal_full.length - decplaces)))).toString(); post = false; } else { decimals = expr.substr(expr.indexOf('.') + 1, decplaces); } } else { decimals = '0'; } if (decimals.length < decplaces) { tmp = decimals.length; for (i=0; i' + this.errors[id].join('
') + '
'; }; }; // // Utility functions // // // str_replace wrapper // String.prototype.str_replace = function(src, dst) { return this.toString().split(src).join(dst); }; // // Print variable contents // function fn_print_r(value) { alert(fn_print_array(value)); }; // Helper function fn_print_array(arr, level) { var dumped_text = ""; if(!level) { level = 0; } //The padding given at the beginning of the line. var level_padding = ""; for(var j=0; j < level+1; j++) { level_padding += " "; } if(typeof(arr) == 'object') { //Array/Hashes/Objects for(var item in arr) { var value = arr[item]; if(typeof(value) == 'object') { //If it is an array, dumped_text += level_padding + "'" + item + "' ...\n"; dumped_text += fn_print_array(value,level+1); } else { dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n"; } } } else { //Stings/Chars/Numbers etc. dumped_text = arr+" ("+typeof(arr)+")"; } return dumped_text; }; // // Raise event on defined hook // function fn_set_hook(hook, data) { for (var k in window['_HOOKS']) { if (jQuery.isFunction(window[k])) { window[k].apply(window[k], data); } } }; // // Register hooks // function fn_register_hooks(addon, hooks) { if (!window['_HOOKS']) { window['_HOOKS'] = {}; } var data = {}; for (var i = 0; i < hooks.length ; i++) { window['_HOOKS']['fn_' + addon + '_' + hooks[i]] = true; } }; function fn_update_quick_menu_position(elm) { var w = jQuery.get_window_sizes(); var new_x = parseInt(elm.css('left')) - w.offset_x; var new_y = parseInt(elm.css('top')) - w.offset_y; new_x = new_x > 0 ? (new_x < w.offset_x + w.view_width - elm.width() ? new_x : w.offset_x + w.view_width - elm.width()) : 0; new_y = new_y > 0 ? (new_y < w.offset_y + w.view_height - elm.height() ? new_y : w.offset_y + w.view_height - elm.height()) : 0; elm.css({'position': 'fixed', 'left': new_x, 'top': new_y}); jQuery.cookie.set('quick_menu_offset', 'left: ' + new_x + 'px; top:' + new_y + 'px;'); } function fn_switch_page(elm) { var c = elm.parents('.cm-pagination-wraper'); var l = $('a[name=pagination][href]:first', c); // get link to retrieve parameters from it var page_num = elm.val() < 1 ? 1 : elm.val(); var url = l.attr('href').replace(/page=(\d+)$/i, 'page=' + page_num); if (l.hasClass('cm-ajax')) { if (typeof(jQuery.history) != 'undefined' && l.hasClass('cm-history') && l.attr('rel')) { jQuery.history.load(page_num, {url: url, result_ids: l.attr('rev'), callback: 'fn_' + l.attr('name')}); } $.ajaxRequest(url, { result_ids: l.attr('rev'), caching: true, callback: fn_pagination, store_init_content: true }); } else { jQuery.redirect(url); } return true; } function fn_pagination() { var c = $('.cm-pagination-wraper:first'); var w = jQuery.get_window_sizes(); if (w.offset_y > c.offset().top) { jQuery.scrollToElm(c); } } function fn_history_callback(data) { if (data) { jQuery.ajaxRequest(data.url, {result_ids: data.result_ids, caching: true, callback: (window[data.callback] || {}), store_init_content: true}); } else if (jQuery.ajax_cache.init_content && jQuery.history._init_page) { if (jQuery.ajax_cache[jQuery.last_hash]) { for (var id in jQuery.ajax_cache[jQuery.last_hash].data.html) { jQuery.ajax_cache[jQuery.last_hash].data.html[id] = $('#' + id).html(); } } jQuery.last_hash = 'init_content'; jQuery.ajaxResponse(jQuery.ajax_cache.init_content, {callback: (window['fn_pagination'] || {})}); } } function fn_unserialize(s) { var r = {}; if (!s) { return r; } var pp = s.split('&'); for (var i in pp) { var p = pp[i].split('='); r[decodeURIComponent(p[0])] = decodeURIComponent(p[1]); } return r; } function fn_serialize(obj) { var str = ''; for (var i in obj) { str += (str ? '&' : '') + i + '=' + encodeURIComponent(obj[i]); } return str; } function fn_to_source(obj) { if (typeof(obj) == 'string') { return '"' + obj + '"'; } else if (typeof(obj) == 'number') { return obj; } else if (typeof(obj) == 'boolean') { return obj ? 'true' : 'false'; } else if (typeof(obj) == 'object') { var res = ''; if (obj.length >= 0) { for (var i = 0; i