// Creates new window from link // Parameters: // Link - link to show in window // Effect: // Opens a window with name "Additional" and shows needed link in it. function linkWindow(linkURL) { if (window.event) { event.cancelBubble = true; event.returnValue = false; } var width = Math.ceil(screen.width/2); var height = Math.ceil(screen.height*0.6); if (width < 600) width = 600; if (height < 400) height = 400; var left = Math.ceil(screen.width/4); var top = Math.ceil(screen.height*0.1); var oTarget = window.open(linkURL, "Additional", "height="+height+",width="+width+",scrollbars=1,left="+left+",top="+top); oTarget.focus(); return false; } // Function to check all checkboxes of the form with predefined name function checkAll(elm, name) { for (i = 0; i < elm.form.elements.length; i++) { if (elm.form.elements[i].type == "checkbox" && elm.form.elements[i].name == name) { elm.form.elements[i].checked = elm.checked; } } } function getAbsolutePos(el) { var SL = 0, ST = 0; var is_div = /^div$/i.test(el.tagName); if (is_div && el.scrollLeft) SL = el.scrollLeft; if (is_div && el.scrollTop) ST = el.scrollTop; var r = { x: el.offsetLeft - SL, y: el.offsetTop - ST }; if (el.offsetParent) { var tmp = getAbsolutePos(el.offsetParent); r.x += tmp.x; r.y += tmp.y; } return r; } function createFCK(name, toolbarSet, width, height) { // Create instance of FCKeditor var oFCKeditor = new FCKeditor(name); // Path to FCKeditor oFCKeditor.BasePath = '/include/fckeditor/'; oFCKeditor.Width = width || '100%'; oFCKeditor.Height = height || '500'; // Custom configuration oFCKeditor.Config['CustomConfigurationsPath'] = '/website/maze/fckconfig/fckconfig.js'; oFCKeditor.Config['EditorAreaCSS'] = '/website/maze/fckconfig/fck_editorarea.css'; // Set language oFCKeditor.Config['AutoDetectLanguage'] = false; oFCKeditor.Config['DefaultLanguage'] = 'en'; oFCKeditor.Config['LanguagePath'] = '/admin/language/en/fckeditor/'; // Use site manager toolbar oFCKeditor.ToolbarSet = toolbarSet || 'SiteManager'; // Show FCKeditor oFCKeditor.ReplaceTextarea(); return oFCKeditor; } function createEmailFCK(name, toolbarSet, width, height) { // Create instance of FCKeditor var oFCKeditor = new FCKeditor(name); // Path to FCKeditor oFCKeditor.BasePath = '/include/fckeditor/'; oFCKeditor.Width = width || '100%'; oFCKeditor.Height = height || '500'; // Custom configuration oFCKeditor.Config['CustomConfigurationsPath'] = '/website/maze/fckconfig/fckconfigemail.js'; oFCKeditor.Config['EditorAreaCSS'] = '/website/maze/fckconfig/fck_editorarea.css'; // Set language oFCKeditor.Config['AutoDetectLanguage'] = false; oFCKeditor.Config['DefaultLanguage'] = 'en'; oFCKeditor.Config['LanguagePath'] = '/admin/language/en/fckeditor/'; // Use site manager toolbar oFCKeditor.ToolbarSet = toolbarSet || 'SiteManager'; // Show FCKeditor oFCKeditor.ReplaceTextarea(); return oFCKeditor; } var CustomSelect = Class.create(); CustomSelect.prototype = { initialize: function(name) { if (!($(name))) return; this.name = name; Event.observe(document, 'click', this.toggle.bindAsEventListener(this)); Event.observe(document, 'keyup', this.close.bindAsEventListener(this)); }, toggle: function(event) { var target = Event.element(event); if (target.id == this.name+'Control') { event.stop(); if ($(this.name).getStyle('display') == 'block') $(this.name).setStyle({display: 'none'}); else $(this.name).setStyle({display: 'block'}); } else { $(this.name).setStyle({display: 'none'}); } }, close: function(event) { if (event.keyCode == 27) $(this.name).setStyle({display: 'none'}); } } document.observe('dom:loaded', function() { new CustomSelect('WebsiteList'); new CustomSelect('LanguageList'); }); function preventSelection(element) { var preventSelection = false; function addHandler(element, event, handler) { if (element.attachEvent) element.attachEvent('on' + event, handler); else if (element.addEventListener) element.addEventListener(event, handler, false); } function removeSelection() { if (window.getSelection) window.getSelection().removeAllRanges(); else if (document.selection && document.selection.clear) document.selection.clear(); // or empty? } function killCtrlA(event) { var event = event || window.event; var sender = event.target || event.srcElement; if (sender.tagName.match(/INPUT|TEXTAREA/i)) return; var key = event.keyCode || event.which; if (event.ctrlKey && key == 'A'.charCodeAt(0)) { removeSelection(); if (event.preventDefault) event.preventDefault(); else event.returnValue = false; } } // Do not allow to select text with mouse addHandler(element, 'mousemove', function() { if (preventSelection) removeSelection(); }); addHandler(element, 'mousedown', function(event) { var event = event || window.event; var sender = event.target || event.srcElement; preventSelection = !sender.tagName.match(/INPUT|TEXTAREA/i); }); // avoid dblckick addHandler(element, 'mouseup', function() { if (preventSelection) removeSelection(); preventSelection = false; }); // avoid CTRL+A addHandler(element, 'keydown', killCtrlA); addHandler(element, 'keyup', killCtrlA); } function getPageSize() { var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = document.body.scrollWidth; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight) { // Explorer 6 strict mode xScroll = document.documentElement.scrollWidth; yScroll = document.documentElement.scrollHeight; } else { // Explorer Mac...would also work in Mozilla and Safari xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } var windowWidth, windowHeight; if (self.innerHeight) { // all except Explorer windowWidth = self.innerWidth; windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } // for small pages with total height less then height of the viewport if (yScroll < windowHeight) { pageHeight = windowHeight; } else { pageHeight = yScroll; } // for small pages with total width less then width of the viewport if (xScroll < windowWidth) { if (yScroll > windowHeight) pageWidth = windowWidth - 16; else pageWidth = windowWidth; } else { pageWidth = xScroll; } return [pageWidth, pageHeight, windowWidth, windowHeight]; } function getScrollTop() { var scrollTop = 0; if (window.pageYOffset) scrollTop = window.pageYOffset; else if (document.documentElement.scrollTop) scrollTop = document.documentElement.scrollTop; else if (document.body.scrollTop) scrollTop = document.body.scrollTop; return scrollTop; } function numberFormat(number, decimals, dec_point, thousands_sep) { // Formats a number with grouped thousands // // version: 1102.614 // discuss at: http://phpjs.org/functions/number_format // + original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com) // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + bugfix by: Michael White (http://getsprink.com) // + bugfix by: Benjamin Lupton // + bugfix by: Allan Jensen (http://www.winternet.no) // + revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com) // + bugfix by: Howard Yeend // + revised by: Luke Smith (http://lucassmith.name) // + bugfix by: Diogo Resende // + bugfix by: Rival // + input by: Kheang Hok Chin (http://www.distantia.ca/) // + improved by: davook // + improved by: Brett Zamir (http://brett-zamir.me) // + input by: Jay Klehr // + improved by: Brett Zamir (http://brett-zamir.me) // + input by: Amir Habibi (http://www.residence-mixte.com/) // + bugfix by: Brett Zamir (http://brett-zamir.me) // + improved by: Theriault // + input by: Amirouche // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // * example 1: number_format(1234.56); // * returns 1: '1,235' // * example 2: number_format(1234.56, 2, ',', ' '); // * returns 2: '1 234,56' // * example 3: number_format(1234.5678, 2, '.', ''); // * returns 3: '1234.57' // * example 4: number_format(67, 2, ',', '.'); // * returns 4: '67,00' // * example 5: number_format(1000); // * returns 5: '1,000' // * example 6: number_format(67.311, 2); // * returns 6: '67.31' // * example 7: number_format(1000.55, 1); // * returns 7: '1,000.6' // * example 8: number_format(67000, 5, ',', '.'); // * returns 8: '67.000,00000' // * example 9: number_format(0.9, 0); // * returns 9: '1' // * example 10: number_format('1.20', 2); // * returns 10: '1.20' // * example 11: number_format('1.20', 4); // * returns 11: '1.2000' // * example 12: number_format('1.2000', 3); // * returns 12: '1.200' // * example 13: number_format('1 000,50', 2, '.', ' '); // * returns 13: '100 050.00' number = (number + '').replace(',', '').replace(' ', ''); var n = !isFinite(+number) ? 0 : +number, prec = !isFinite(+decimals) ? 0 : Math.abs(decimals), sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep, dec = (typeof dec_point === 'undefined') ? '.' : dec_point, s = '', toFixedFix = function (n, prec) { var k = Math.pow(10, prec); return '' + Math.round(n * k) / k; }; // Fix for IE parseFloat(0.55).toFixed(0) = 0; s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.'); if (s[0].length > 3) { s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep); } if ((s[1] || '').length < prec) { s[1] = s[1] || ''; s[1] += new Array(prec - s[1].length + 1).join('0'); } return s.join(dec); } function switchTabOf(tab, total) { if(tab>2){ jQuery('.buttons').hide(); }else{ jQuery('.buttons').show(); } for(var i=1; i<=total; i++) { $('content-'+i).hide(); } for(var i=1; i<=total; i++) { if(i == 1) { $('tab-'+i).className = 'first'; } else if(i == total) { $('tab-'+i).className = 'last'; } else { $('tab-'+i).className = ''; } if(i == tab) { if(i == total) { $('tab-'+i).className = 'active-last'; } else { $('tab-'+i).className = 'active'; } } else if(i == tab+1) { if(i == total) { $('tab-'+i).className = 'past-active-last'; } else { $('tab-'+i).className = 'past-active'; } } } $('content-'+tab).show(); }