/*default.js*/
var MAG = Object.extend({}, MAG || {}); var radioHeight = "25"; MAG.Custom = { Init: function(options) { this.options = {}; Object.extend(this.options, options || {}); var inputs = document.getElementsByTagName("input"), span = Array(), textnode, option, active; for (a = 0; a < inputs.length; a++) { if (inputs[a].type == "radio") { span[a] = document.createElement("span"); span[a].className = inputs[a].type; span[a].id = "rad_" + inputs[a].id; if (inputs[a].checked == true) { position = "0 -" + (radioHeight * 2) + "px"; span[a].style.backgroundPosition = position } inputs[a].parentNode.insertBefore(span[a], inputs[a]); inputs[a].onchange = MAG.Custom.clear; span[a].onmousedown = MAG.Custom.pushed; span[a].onmouseup = MAG.Custom.check; document.onmouseup = MAG.Custom.clear } } }, pushed: function() { element = this.nextSibling; if (element.checked == true && element.type == "radio") { this.style.backgroundPosition = "0 -" + radioHeight * 3 + "px" } else { this.style.backgroundPosition = "0 -" + radioHeight + "px" } }, check: function() { element = this.nextSibling; if (element.type == "checkbox") { this.style.backgroundPosition = "0 -" + checkboxHeight * 2 + "px" } else { this.style.backgroundPosition = "0 -" + radioHeight * 2 + "px"; group = this.nextSibling.name; inputs = document.getElementsByTagName("input"); for (a = 0; a < inputs.length; a++) { if (inputs[a].name == group && inputs[a] != this.nextSibling) { inputs[a].previousSibling.style.backgroundPosition = "0 0" } } } element.checked = true; if (Object.isFunction(element.onclick)) element.onclick.bind(element).call() }, clear: function() { var inputs = document.getElementsByTagName("input"); for (var b = 0; b < inputs.length; b++) { if (inputs[b].type == "radio" && inputs[b].checked == true) { inputs[b].previousSibling.style.backgroundPosition = "0 -" + radioHeight * 2 + "px" } else if (inputs[b].type == "radio") { inputs[b].previousSibling.style.backgroundPosition = "0 0" } } } }; function submit_form(e) { Event.stop(e); var btc_form = (e.element().className == 'sumbmit_button') ? e.element().parentNode.parentNode : e.element(); var systems = btc_form['system']; var post_url = ''; if (systems[1].checked) { post_url = systems[1].value; $$('.username_input input')[0].setAttribute('name', 'user') } else { post_url = systems[0].value; $$('.username_input input')[0].setAttribute('name', 'username') } btc_form.setAttribute('action', post_url); btc_form.submit() } function process_adsl_quick_check_form() { var adsl_form_area_code_value = translated_texts.enter_area_code; var adsl_form_phone_number_value = translated_texts.enter_phone_number; var adsl_form_area_code_input = $('adsl_form_area_code'); var adsl_form_phone_number_input = $('adsl_form_phone_number'); if (adsl_form_area_code_input && adsl_form_phone_number_input) { adsl_form_area_code_input.observe('focus', function() { if (adsl_form_area_code_input.value.strip() == adsl_form_area_code_value) adsl_form_area_code_input.value = '' }); adsl_form_area_code_input.observe('blur', function() { if (adsl_form_area_code_input.value.blank()) adsl_form_area_code_input.value = adsl_form_area_code_value }); adsl_form_phone_number_input.observe('focus', function() { if (adsl_form_phone_number_input.value.strip() == adsl_form_phone_number_value) adsl_form_phone_number_input.value = '' }); adsl_form_phone_number_input.observe('blur', function() { if (adsl_form_phone_number_input.value.blank()) adsl_form_phone_number_input.value = adsl_form_phone_number_value }) } subm_but = $('adsl_form_submit'); subm_but.observe('click', function() { if (adsl_form_area_code_input.value.strip() == adsl_form_area_code_value) { alert(translated_texts.missing_area_code); adsl_form_area_code_input.focus(); return } else if (adsl_form_phone_number_input.value.strip() == adsl_form_phone_number_value) { alert(translated_texts.missing_phone_number); adsl_form_phone_number_input.focus(); return } else { setTimeout(function() { $('adsl_quick_checker').submit() }, 0) } }) } document.observe('dom:loaded', function() { if ($('adsl_quick_checker')) { process_adsl_quick_check_form() } var search_input_id = $$('#quick_menu input[type=text]')[0]; if (search_input_id) { var search_input_value = translated_texts.quick_search; search_input_id.observe('focus', function() { if (search_input_id.value.strip() == search_input_value) search_input_id.value = '' }); search_input_id.observe('blur', function() { if (search_input_id.value.blank()) search_input_id.value = search_input_value }); var quick_search_submit_but = $('quick_search_submit_but'); if (quick_search_submit_but) { $(quick_search_submit_but).observe('click', function() { setTimeout(function() { $('quick_search_submit_form').submit() }, 0) }) } } $$('*[name=button_for_go]').each(function(but) { $(but.form).observe('submit', function(e) { Event.stop(e) }); but.observe('click', function(event) { var element = $(this); var page = parseInt(element.previous().value); if (!isNaN(page)) { var meurl = self.location.toString().replace(/&?page=[0-9]+/, ""); meurl += meurl.indexOf('?') > -1 ? '&' : '?'; meurl += 'page=' + page; setTimeout(function() { window.location.href = meurl }, 0) } }) }); new Tooltip() }); function getDimensions() { var myWidth = 0, myHeight = 0; if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight } else if (typeof (window.innerWidth) == 'number') { myWidth = window.innerWidth; myHeight = window.innerHeight } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) { myWidth = document.body.clientWidth; myHeight = document.body.clientHeight } return { width: myWidth, height: myHeight} } function getPageSize() { var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = window.innerWidth + window.scrollMaxX; yScroll = window.innerHeight + window.scrollMaxY } else if (document.body.scrollHeight > document.body.offsetHeight) { xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight } else { xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight } var windowWidth, windowHeight; if (self.innerHeight) { if (document.documentElement.clientWidth) { windowWidth = document.documentElement.clientWidth } else { windowWidth = self.innerWidth } windowHeight = self.innerHeight } else if (document.documentElement && document.documentElement.clientHeight) { windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight } else if (document.body) { windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight } if (yScroll < windowHeight) { pageHeight = windowHeight } else { pageHeight = yScroll } if (xScroll < windowWidth) { pageWidth = xScroll } else { pageWidth = windowWidth } return [pageWidth, pageHeight] } function scroll_offset() { var scrOfX = 0, scrOfY = 0; if (typeof (window.pageYOffset) == 'number') { scrOfY = window.pageYOffset; scrOfX = window.pageXOffset } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) { scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) { scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft } return { left: scrOfX, top: scrOfY} };
/*tooltip.js*/
Tooltip = Class.create({
    initialize: function(options) {
        this.options = { show_on: 'mouseenter', hide_on: 'mouseleave', offset_x: -160, offset_y: -2, position_x: 'right', position_y: 'top', appear_on_mouse_pos: true };
     
        Object.extend(this.options, options || {});
        $$('.tooltip').each(function(elem) {
            this.prepare_tooltip(elem);
            elem.observe(this.options.show_on, this.show_tooltip.bind(this, elem));
            elem.observe(this.options.hide_on, this.hide_tooltip.bind(this, elem))
        } .bind(this))
    },
    prepare_tooltip: function(elem) {
        if (elem.hasAttribute('title')) {
            var loc_content = elem.readAttribute('title');

            if (loc_content.substr(0, 1) == "@") {
                obj = new Object();
                obj.title = '';
                obj.link = '';
                obj.content = $(loc_content.substr(1)).innerHTML;
                $(loc_content.substr(1)).remove();
            }
            else {
                obj = elem.readAttribute('title').evalJSON()
            }

        }
        else {
            obj = null
        }
        elem.removeAttribute('title');
        if (obj) {
            var content = (new Element('span')).update(obj.content + '<br />');
            content.addClassName('tooltip_content');
            if (obj.title) {
                content.insert({ top: new Element('strong').update(obj.title) })
            }
            if (obj.link) {
                var a = new Element('a', { href: obj.link, target: obj.target ? obj.target : '_self' });
                a.addClassName('read_more');
                content.insert(a.update(translated_texts.read_more))
            }

            var outer_container = (new Element('span')).update(content);
            outer_container.addClassName('tooltip_wrapper');
            elem.insert(outer_container)
        }
    },
    show_tooltip: function(elem, evt) {
        if (this.options.appear_on_mouse_pos) {
            this.options.pos_x_evt = Event.pointerX(evt);
            this.options.pos_y_evt = Event.pointerY(evt)
        }
        elem.style.position = 'relative';
        this.last_tooltip_container = $(elem).select('span').first();
        this.set_tooltip_position(elem);
        if (this.last_tooltip_container) {
            this.last_tooltip_container.setStyle({ display: 'block' })
        }
    },
    hide_tooltip: function() {
        if (this.last_tooltip_container) {
            $(this.last_tooltip_container.parentNode).style.position = 'static';
            this.last_tooltip_container.setStyle({ display: 'none' });
            if (Prototype.Browser.Opera) $('outer_wrapper').style.overflowX = 'auto'
        }
    },
    set_tooltip_position: function(parent) {
        if (this.options.appear_on_mouse_pos) {
            var additional_offset_left = 0, additional_offset_top = 0;
            //            if (Prototype.Browser.Opera) {
            //                $('outer_wrapper').style.overflowX = 'hidden';
            //                parent.offsetHeight > 15 ? additional_offset_left = -parent.offsetHeight - 15 : null;
            //                additional_offset_top = parent.cumulativeScrollOffset().top
            //            }
            this.last_tooltip_container.setStyle({ left: this.options.pos_x_evt - parent.cumulativeOffset().left + this.options.offset_x + additional_offset_left + 'px', top: this.options.pos_y_evt - parent.cumulativeOffset().top - this.last_tooltip_container.getHeight() + additional_offset_top + 'px' })
        }
        else {
            switch (this.options.position_x) {
                case 'left': this.last_tooltip_container.setStyle({ left: this.options.offset_x + 'px' });
                    break;
                case 'center': this.last_tooltip_container.setStyle({ left: parseInt(elem.getWidth() / 2) + this.options.offset_x + 'px' });
                    break;
                case 'right': this.last_tooltip_container.setStyle({ left: elem.getWidth() + this.options.offset_x + 'px' });
                    break
            }
            switch (this.options.position_y) {
                case 'top': this.last_tooltip_container.setStyle({ bottom: parent.getHeight() + this.options.offset_y + 'px' });
                    break;
                case 'middle': this.last_tooltip_container.setStyle({ top: '-' + (-parseInt(parent.getHeight() / 2) + parseInt(this.last_tooltip_container.getHeight() / 2) + this.options.offset_y) + 'px' });
                    break;
                case 'bottom': this.last_tooltip_container.setStyle({ top: parent.getHeight() + this.options.offset_y + 'px' }); break
            }
        }
    }
});
