//get global object
var global = (function(){
	return this;
}());
//DOM ready ÔÅÓÔ
if (typeof Event == 'undefined') Event = new Object();
var domReady = {
    add: function(fn) {
        // Already loaded?
        if (domReady.loaded) return fn();
        // Observers
        var observers = domReady.observers;
        if (!observers) observers = domReady.observers = [];
        // Array#push is not supported by Mac IE 5
        observers[observers.length] = fn;
        // domReady function
        if (domReady.callback) return;
        domReady.callback = function() {
            if (domReady.loaded) return;
            domReady.loaded = true;
            if (domReady.timer) {
                clearInterval(domReady.timer);
                domReady.timer = null;
            }
            var observers = domReady.observers;
            for (var i = 0, length = observers.length; i < length; i++) {
                var fn = observers.pop();
                fn(); // make 'this' as window
            }
            domReady.callback = domReady.observers = null;
        };
        // Emulates 'onDOMContentLoaded'
        var ie = !!(window.attachEvent && !window.opera);
        var webkit = navigator.userAgent.indexOf('AppleWebKit/') > -1;
        if (document.readyState && webkit) {
            // Apple WebKit (Safari, OmniWeb, ...)
            domReady.timer = setInterval(function() {
                var state = document.readyState;
                if (state == 'loaded' || state == 'complete') {
                    domReady.callback();
                }
            }, 50);
        } else if (document.readyState && ie) {
            // Windows IE
            var src = (window.location.protocol == 'https:') ? 'https://' : 'javascript:void(0)';
            document.write(
                    '<script type="text/javascript" defer="defer" src="' + src + '" ' +
                            'onreadystatechange="if (this.readyState == \'complete\') domReady.callback();"' +
                            '><\/script>');
        } else {
            if (window.addEventListener) {
                // for Mozilla browsers, Opera 9
                document.addEventListener("DOMContentLoaded", domReady.callback, false);
                // Fail safe
                window.addEventListener("load", domReady.callback, false);
            } else if (window.attachEvent) {
                window.attachEvent('onload', domReady.callback);
            } else {
                // Legacy browsers
                var fn = window.onload;
                window.onload = function() {
                    domReady.callback();
                    if (fn) fn();
                }
            }
        }
    }
}

var DOMUtils = DOMUtils || {};
(function(window) {
    var win = window, doc = win.document;

    /**
     *
     * @param {Object} ele
     * @return {Array} array of classes in Node.className
     */
    function getClass(ele) {
        var className = ele.className;
        return className && typeof className.split == 'function' ?
                className.split(/\s+/) : [];
    }

    /**
     * @param {Node} ele
     * @param {String} cls
     * @return {Number} last position of className or -1
     */
    function hasClass(ele, cls) {
        var arr = getClass(ele);
        return arr.inArray(cls);
    }

    /**
     *
     * @param {Object} ele
     * @param {String} cls
     * @return {Boolean} True if added False if note added and className is present
     */
    function addClass(ele, cls) {
        var arr;
        if (hasClass(ele, cls) == -1) {
            arr = getClass(ele);
            arr.push(cls);
            ele.className = arr.join(' ');
            return true;
        } else {
            return false;
        }
    }

    /**
     *
     * @param {Object} ele
     * @param {String} cls
     * @return {Boolean} True if removed False if note removed or className note present
     */
    function removeClass(ele, cls) {
        var arr, i, max;
        if (hasClass(ele, cls) != -1) {
            arr = getClass(ele);
            for (i = 0,max = arr.length; i < max; i++) {
                if (arr[i] == cls) {
                    arr.splice(i--, 1);
                }
            }
            ele.className = arr.join(' ');
            return true;
        }
        return false;
    }

    function getElementsByClass(className, opt_el) {
        var parent = opt_el || doc, elems, max, arr = [], tmp, i;
        if (parent.querySelectorAll) {
            return parent.querySelectorAll('.' + className);
        } else if (parent.getElementsByClassName) {
            return parent.getElementsByClassName(className);
        } else {
            elems = parent.getElementsByTagName('*');
            for (i = 0,max = elems.length; i < max; i++) {
                tmp = elems[i];
                if (hasClass(tmp, className) != -1) {
                    arr.push(tmp);
                }
            }
            return arr;
        }
    }

    /**
     *
     * @param {String} url
     * @param {Function} callback
     */
    function loadScript(url, callback) {
        var script = doc.createElement("script");
        script.type = "text/javascript";

        if (script.readyState) {  //IE
            script.onreadystatechange = function() {
                if (script.readyState == 'loaded' ||
                        script.readyState == 'complete') {
                    script.onreadystatechange = null;
                    callback();
                }
            };
        } else {  //Others
            script.onload = function() {
                callback();
            };
        }

        script.src = url;
        doc.getElementsByTagName('head')[0].appendChild(script);
    }

    DOMUtils.loadScript = loadScript;
    DOMUtils.getClass = getClass;
    DOMUtils.hasClass = hasClass;
    DOMUtils.addClass = addClass;
    DOMUtils.removeClass = removeClass;
    DOMUtils.getElementsByClass = getElementsByClass;
    return DOMUtils;
}
        )(window);

/**
 * @param {String|Number|Object|Function|Boolean} p_val
 * @return {Number} last position of index or -1
 */
Array.prototype.inArray = function(p_val) {
    var i,max;
    for (i = 0,max = this.length; i < max; i++) {
        if (this[i] == p_val) {
            return i;
        }
    }
    return -1;
}

/**
* @description function gets arrays and return array
* without duplicate items
* @param {Array} arr
* @return {Array}
**/
Array.prototype.union = function(arr){
  var i = 0,
      count = 0,
      max = 0,
      buffer = [];
  if(typeof arr.join !== 'function') {
    return -1;
  }
  for(i=0,max=arr.length;i<max;i+=1){
    if(this.inArray(arr[i])===-1){
      buffer.push(arr[i]);
    }
  }
  return this.concat(buffer);
}

//begin animator
writeDebug = (typeof console != 'undefined' && console.log && window.location.href.match(/debug=1/i)) ? function(sDebug) {
    // use #debug=1 etc. in URL to enable debug output for console.log()-supported shiz
    console.log(sDebug);
} : function() {
    // oh well
}

function Animator() {
    var self = this;
    var intervalRate = 20;
    this.tweenTypes = {
        'default': [1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1],
        'blast': [12,12,11,10,10,9,8,7,6,5,4,3,2,1],
        'linear': [10,10,10,10,10,10,10,10,10,10]
    }
    this.queue = [];
    this.queueHash = [];
    this.active = false;
    this.timer = null;
    this.createTween = function(start, end, type) {
        // return array of tween coordinate data (start->end)
        type = type || 'default';
        var tween = [start];
        var tmp = start;
        var diff = end - start;
        var x = self.tweenTypes[type].length;
        for (var i = 0; i < x; i++) {
            tmp += diff * self.tweenTypes[type][i] * 0.01;
            tween[i] = {};
            tween[i].data = tmp;
            tween[i].event = null;
        }
        return tween;
    }

    this.enqueue = function(o, fMethod, fOnComplete) {
        // add object and associated methods to animation queue
        writeDebug('animator.enqueue()');
        if (!fMethod) {
            writeDebug('animator.enqueue(): missing fMethod');
        }
        self.queue.push(o);
        o.active = true;
    }

    this.animate = function() {
        var active = 0;
        for (var i = 0,j = self.queue.length; i < j; i++) {
            if (self.queue[i].active) {
                self.queue[i].animate();
                active++;
            }
        }
        if (active == 0 && self.timer) {
            // all animations finished
            writeDebug('Animations complete');
            self.stop();
        } else {
            // writeDebug(active+' active');
        }
    }

    this.start = function() {
        if (self.timer || self.active) {
            writeDebug('animator.start(): already active');
            return false;
        }
        writeDebug('animator.start()'); // report only if started
        self.active = true;
        self.timer = setInterval(self.animate, intervalRate);
    }

    this.stop = function() {
        writeDebug('animator.stop()', true);
        // reset some things, clear for next batch of animations
        clearInterval(self.timer);
        self.timer = null;
        self.active = false;
        self.queue = [];
    }
}

function Animation(oParams) {
    // unique animation object
    /*
     oParams = {
     from: 200,
     to: 300,
     tweenType: 'default',
     ontween: function(value) { ... }, // method called each time
     oncomplete: function() { ... } // when finished
     }
     */
    var self = this;
    if (typeof oParams.tweenType == 'undefined') {
        oParams.tweenType = 'default';
    }
    this.ontween = (oParams.ontween || null);
    this.oncomplete = (oParams.oncomplete || null);
    this.tween = animator.createTween(oParams.from, oParams.to, oParams.tweenType);
    this.frameCount = animator.tweenTypes[oParams.tweenType].length;
    this.frame = 0;
    this.active = false;

    this.animate = function() {
        // generic animation method
        if (self.active) {
            if (self.ontween && self.tween[self.frame]) {
                self.ontween(self.tween[self.frame].data);
            }
            if (self.frame++ >= self.frameCount - 1) {
                writeDebug('animation(): end');
                self.active = false;
                self.frame = 0;
                if (self.oncomplete) {
                    self.oncomplete();
                    // self.oncomplete = null;
                }
                return false;
            }
            return true;
        }
        return false;
    }

    this.start = function() {
        // add this to the main animation queue
        animator.enqueue(self, self.animate, self.oncomplete);
        if (!animator.active) {
            animator.start();
        }
    }

    this.stop = function() {
        self.active = false;
    }
}
//end animator

function check_doc() {
    fmt = /(.jpg|.jpeg|.png|.gif|.pdf)$/i;
    return fmt.test(document.document_form.document.value);
}

function expandingWindow(anc, winwidth, winheight) {
    var imgwidth = winwidth;
    var imgheight = winheight;

    document.write('<body bgcolor="#000000" marginwidth="0" marginheight="0" topmargin="0" leftmargin="0"><table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%"><tr><td width="100%" height="100%" valign="middle" align="center"><a href="javascript:history.go(-1)"><img src="' + anc.href + '" border="0" alt="Back"><\/a><\/td><\/tr><\/table><\/body>');
}

function newDNSSubmit(dns_fill, msg) {
    var allempty = 1, i, el;
    for (i = 0; i <= dns_fill; i++) {
        el = document.getElementsByName("name_" + i)[0];
        if (el.value != "") {
            allempty = 0;
            break;
        }
        el = document.getElementsByName("ip_" + i)[0];
        if (el.value != "") {
            allempty = 0;
            break;
        }
    }
    if (allempty) {
        return confirm(msg);
    } else {
        return true;
    }
}

function _check_all(Form, cBox, checked) {
    for (var i = 0; i < Form.elements.length; i++) {
        if (Form.elements[i].name == cBox && Form.elements[i].disabled != true)
            Form.elements[i].checked = checked;
    }
}

function _uncheck_checker(Form, checker) {
    if (Form[checker].checked == true) Form[checker].checked = false;
}

function GeoDomainsSelector(geoPrices,id) {
    this.geoPrices = geoPrices;
    this.linkList = DOMUtils.getElementsByClass('geo-domain-link');
    this.tabsList = DOMUtils.getElementsByClass('geo-tabs');
    var _self = this;
    this.id = id;
    this.geoPriceView = document.getElementById('geo-price');
    this.geoSelect = DOMUtils.getElementsByClass('geo-select');
    for (var i = 0, max = this.geoSelect.length; i < max; i++) {
        addHandler(this.geoSelect[i],'change',function(e){_self.setPriceForGeo(e)});
    }
    for (i = 0,max = this.linkList.length; i < max; i++) {
        if (this.linkList[i].id == '') {
            addHandler(this.linkList[i],'click',function(e) {
                _self.switchSelect(e);
                _self.setPriceForGeo(e);
                preventDefault(e);
                return false;
            });
        }
    }
    for(i=0,max=this.tabsList.length;i<max;i++){
        addHandler(this.tabsList[i],'click',function(e){_self.switchCountry(e)});
    }
}
GeoDomainsSelector.prototype.switchSelect = function(e){
    e = e || event;
    var src = e.target || e.srcElement;
    var geoSelect = document.getElementById('dom-'+ this.id + '-select');
    for (var j = 0, max = geoSelect.length; j < max; j++) {
        if (src.firstChild.nodeValue == geoSelect[j].firstChild.nodeValue) {
            geoSelect.selectedIndex = geoSelect[j].index;
            geoSelect.style.outline = "2px solid #f8981d";
            setTimeout(function() {
                geoSelect.style.outline = 'none';
            }, 100);
        }
    }
}
GeoDomainsSelector.prototype.setPriceForGeo = function(e) {
   e = e || event;
   var src = e.target || e.srcElement, val;
   if (src.tagName.toLocaleLowerCase() == 'select') {
       val = src.options[src.selectedIndex].value
           || src.options[src.selectedIndex].text;
   } else {
       val = src.text || src.innerHTML;
   }
   if(this.geoPrices[val]) {
      if (this.geoPriceView) {
          this.geoPriceView.innerHTML = this.geoPrices[val];
      }
   } else {
      if (this.geoPriceView) {
          this.geoPriceView.innerHTML = this.geoPrices['default'];
      }
   }
}
GeoDomainsSelector.prototype.switchCountry = function(e) {
    e = e || event;
    var src = e.target || e.srcElement;
    var id = src.id;
    this.id = id;
    for (var i=0,max = this.tabsList.length; i < max; i++) {
	    DOMUtils.removeClass(this.tabsList[i],'cur');
	    DOMUtils.removeClass(this.tabsList[i].parentNode,"selected");
    }
    DOMUtils.addClass(src,'cur');
    DOMUtils.addClass(src.parentNode,'selected');
    var toHide = document.forms.domain_check_form_geo.getElementsByTagName('table')[0];
    var toHideInputs = toHide.getElementsByTagName('input');
    var toShow = document.getElementById('dom_' + id);
    var toShowInputs = toShow.getElementsByTagName('input');
    for (i=0, max = toHideInputs.length; i < max; i++) {
        for(var j=0, max2 = toShowInputs.length; j < max2; j++) {
            if (toShowInputs[j].type!='hidden'
                && (toShowInputs[j].name==toHideInputs[i].name)
                ) {
                toShowInputs[j].value=toHideInputs[i].value;
            }
        }
    }
    var toShowParent = toShow.parentNode;
    document.forms.domain_check_form_geo.replaceChild(toShow, toHide);
    toShowParent.appendChild(toHide);
    preventDefault(e);
    return false;
}

function _is_any_checked(Form, cBox, Warning) {

    for (var i = 0; i < Form.elements.length; i++) {
        if (Form.elements[i].name == cBox && Form.elements[i].checked == true) {
            return true
        }
    }
    alert(Warning);
    return false;
}


function win_info(winname, url) {
    var page_w = 800, page_h = 600;
    if (window.screen) {
        page_w = window.screen.availWidth;
        page_h = window.screen.availHeight;
        page_w = (page_w < 800) ? 800 : page_w;
        page_h = (page_h < 600) ? 600 : page_h;
    }

    var w = 600;
    var h = page_h * 0.7;
    var x = (page_w - w) * 0.5;
    var y = (page_h - h) * 0.5;
    var winProps = 'resizable=1,scrollbars=1';

    var args = 'width=' + w + ',height=' + h + ',' + winProps
            + ",screenX=" + x + ",screenY=" + y + ",left=" + x + ",top=" + y;

    winhandle = window.open(url, winname, args);
    winhandle.focus();
    return false;
}

function win_document(for_link) {

    var win_w = 800, win_h = 500;
    var x = 5, y = 10;

    if (document.all) {
        y = window.screenTop - 40;
        x = window.screenLeft;
        win_h = document.body.clientHeight - 40;
        win_w = document.body.clientWidth * .8;
        if (win_w < 800) win_w = 800;
        x += (document.body.clientWidth - win_w) * .5;
    }
    if (window.innerWidth) {
        y = window.screenY + 40;
        x = window.screenX + 4;
        win_h = window.innerHeight - 40;
        win_w = window.innerWidth * .8;
        if (win_w < 800) win_w = 800;
        x += (window.innerWidth - win_w) * .5;
    }

    var winProps = 'resizable=1,scrollbars=1,toolbar=1,status=1';

    var args = 'width=' + win_w + ',height=' + win_h + ',' + winProps +
            ',screenx=' + x + ',screeny=' + y + ',left=' + x + ',top=' + y;

    newwinhandle = window.open(for_link.href, for_link.target, args);
    newwinhandle.focus();
    return false;
}

function openwindow() {

    var x = screen.width - 50;
    var y = screen.height - 50;
    var min_x = 600;
    var min_y = 420;
    x = (x > min_x) ? x : min_x;
    y = (y > min_y) ? y : min_y;

    xleft = screen.width / 2 - x / 2;
    ytop = screen.height / 2 - y / 2;
    xleft = (xleft > 50) ? xleft : 50;
    ytop = (ytop > 50) ? ytop : 50;

    window.open('', 'new',
            'top=ytop,left=xleft,width=x,height=y,toolbar=yes,resizable=yes,scrollbars=yes,menubar=yes,location=yes,directories=yes,status=yes');
    window.blur('new');
}


function FieldEmpty(field, WMessg) {

    if (field.type == 'text' || field.type == 'textarea')
        value = field.value;
    else
        value = field.options[field.selectedIndex].value;

    if (value == "" || value == 0) {
        alert(WMessg);
        field.focus();
        return false;
    } else {
        return true;
    }
}

function paging(start_from) {

    if (document.forms.list_paging) {
        with (document.forms.list_paging) {
            start.value = start_from;
            submit();
            return false;

        }
    } else {
        return true;
    }
}

function BackTo(page_back) {

    if (page_back) {
        history.go(-page_back);
        return false;
    }
    return true;
}

//faq-list
//*****************
function FaqList(listId, ansId) {
    var _self = this;
    this.listId = listId;
    this.ansId = ansId;
    this.ansLink = document.getElementById(this.ansId);
    this.listLink = document.getElementById(this.listId);
    this.ansLink.style.display = 'none';
    DOMUtils.addClass(this.listLink, 'underline');
    var tmp = document.getElementById(this.listId).getElementsByTagName('A');
    this.qCount = tmp.length;
    this.qArr = new Array(this.qCount);
    this.savedHash = 0;
    for (var i = 0; i < this.qCount; i++) {
        var el = tmp[i];
        var id = el.hash;
        el.onclick = function(event) {
            _self.showAns(event)
        };
        id = id.substr(1, id.length);
        this.qArr[id] = {
            show: false,
            appended: false,
            elem: el.parentNode,
            ans: null
        }
    }
    //_self.savedHash = window.location.hash;
    if (window.location.hash.length > 0) {
        this.savedHash = window.location.hash;
        this.showAns(this.savedHash);
    }
    var br = navigator.userAgent.toLowerCase();
    if (br.indexOf('msie 7.0') != -1 || br.indexOf('msie 6.0') != -1) {
        var tmp = this.listLink.getElementsByTagName('OL');
        autoNumLi(this.listLink, 'outer');
        if (tmp.length > 0) {
            for (var i = 0; i < tmp.length; i++) {
                var t = tmp[i];
                autoNumLi(t, 'inner');
            }
        }
    }
}
FaqList.prototype.showAns = function(event) {
    var e;
    var id;
    if (typeof arguments[0] == 'string')
        id = arguments[0];
    else {
        e = event || window.event;
        var src = e.target || e.srcElement;
        id = src.hash;
    }
    id = id.substr(1, id.length);
    if (!this.qArr[id].appended) {
        this.qArr[id].appended = true;
        var h2 = document.getElementById(id);
        var ansBlock = h2.nextSibling;
        if (ansBlock.nodeType != 1) {
            ansBlock = ansBlock.nextSibling;
        }
        var html = ansBlock.cloneNode(true);
        this.qArr[id].ans = this.qArr[id].elem.appendChild(html);
        this.ansLink.removeChild(ansBlock);
        this.ansLink.removeChild(h2);
    }
    if (!this.qArr[id].show) {
        this.qArr[id].show = true;
        DOMUtils.addClass(this.qArr[id].elem, 'on');
        if (this.savedHash != 0) {
            this.qArr[id].elem.scrollIntoView();
            this.savedHash = 0;
            var scrolled = document.documentElement.scrollTop;
            var needScroll = this.qArr[id].elem.offsetTop + 150;
            if (scrolled < needScroll) {
                var toScroll = needScroll - scrolled;
                setTimeout(function() {
                    window.scrollBy(0, toScroll);
                }, 500);
            }
        }
    } else {
        this.qArr[id].show = false;
        DOMUtils.removeClass(this.qArr[id].elem, 'on');
    }
    window.location.replace('#' + id);
    return false;
}
function autoNumLi(elem, mode) {
    elem.style.listStyleType = 'none';
    var count = elem.childNodes.length;
    if (mode == 'inner') {
        var pLI = elem.parentNode;
        var pOL = pLI.parentNode;
        var section = 0;
        while (pOL.childNodes[section] != pLI) {
            section++;
        }
        for (var subsection = 0; subsection < count; subsection++) {
            var eLI = elem.childNodes[subsection];
            var tmp = document.createElement('SPAN');
            tmp.className = 'sub-num';
            tmp.innerHTML = (section + 1) + '. ' + (subsection + 1) + '. ';
            eLI.insertBefore(tmp, eLI.firstChild);
        }
    } else if (mode == 'outer') {
        for (var i = 0; i < count; i++) {
            if (elem.childNodes[i].nodeType == 1) {
                var tmp = document.createElement('SPAN');
                tmp.className = 'sub-num';
                tmp.innerHTML = (i + 1) + '.';
                elem.childNodes[i].insertBefore(tmp, elem.childNodes[i].childNodes[0]);
            }
        }
    }
}


function resetForm(elem, exception) {
    //elem - this
    //exception - array[string1,string2...] || string
    if (elem != undefined && elem != null && elem.nodeType == 1) {
        while (elem.tagName.toLowerCase() != 'form') elem = elem.parentNode;
        var t, tag, type, inEx, name, pattern;
        if (typeof exception == 'string') pattern = exception.replace('*', '[.]*');
        for (var i = 0; i < elem.elements.length; i++) {
            t = elem.elements[i];
            if (t != undefined && t.nodeType == 1) {
                inEx = false;
                tag = t.tagName.toLowerCase();
                type = t.type;
                name = t.name.toLowerCase();
                if (exception != undefined && exception != null && exception.length > 0) {
                    if (typeof exception == 'object') {
                        for (var j = 0; j < exception.length; j++) {
                            pattern = exception[j].replace('*', '[.]*');
                            if (name == pattern || (name.match(new RegExp(pattern)) && pattern != exception[j])) {
                                inEx = true;
                                break;
                            }
                        }
                    } else if (typeof exception == 'string') {
                        if (name == pattern || (name.match(new RegExp(pattern)) && pattern != exception)) inEx = true;
                    }
                }
                if (!inEx) {
                    if (type == 'text' || tag == 'textarea' || type == 'password') t.value = '';
                    else if (type == 'select-one' || type == 'select-multy') t.selectedIndex = 0;
                    else if (type == 'radio' || type == 'checkbox') t.checked = false;
                }
            }
        }
    }
    return false;
}

function toggle(target, callback) {
    if (target != null && target != undefined) {
        if (target.nodeType != 1) target = document.getElementById(target);
        target.style.display = target.style.display == 'none' ? 'block' : 'none';
        if (callback != null && callback != undefined && typeof calback == 'function')
            callback();
    }
}
//add handler for event
function addHandler(element, type, handler) {
    if (element.addEventListener) {
        element.addEventListener(type, handler, false);
    } else if (element.attachEvent) {
        element.attachEvent("on" + type, handler);
    } else {
        element["on" + type] = handler;
    }
}
//event remove handler
function removeHandler(element, type, handler) {
    if (element.removeEventListener) {
        element.removeEventListener(type, handler, false);
    } else if (element.detachEvent) {
        element.detachEvent("on" + type, handler);
    } else {
        element["on" + type] = null;
    }
}
//get event
function getEvent(event) {
    return event ? event : window.event;
}
//get event target
function getTarget(event) {
    return event.target || event.srcElement;
}
//undo default behaviors
function preventDefault(event) {
    if (event.preventDefault) {
        event.preventDefault();
    } else {
        event.returnValue = false;
    }
}
//stop buble for event
function stopPropagation(event) {
    if (event.stopPropagation) {
        event.stopPropagation();
    } else {
        event.cancelBubble = true;
    }
}
//get full offset position for DOM element
function getFullOffset(element) {
    var offsetLeft = offsetTop = 0;
    if (element.getBoundingClientRect) {
        var box = element.getBoundingClientRect(),
                body = document.body,
                docElem = document.documentElement,
                scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop,
                scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft,
                clientTop = docElem.clientTop || body.clientTop || 0,
                clientLeft = docElem.clientLeft || body.clientLeft || 0,
                offsetTop = box.top + scrollTop - clientTop,
                offsetLeft = box.left + scrollLeft - clientLeft
    } else {
        do {
            offsetLeft += element.offsetLeft;
            offsetTop += element.offsetTop;
        } while (element = element.offsetParent);
    }
    return {
        offsetLeft: Math.round(offsetLeft),
        offsetTop: Math.round(offsetTop)
    }
}

/**
* @description singleton object make beautiful tooltip. Very simple
**/
var ToolTips = { 
	xCord : 0,								// x pixel value of current cursor position
	yCord : 0,								// y pixel value of current cursor position
	elems: [],
	curElem: Object,							// That of which you're hovering over
	tip : Object,							// The actual toolTip itself
	active : 0,								// 0: Not Active || 1: Active
	doc: global.document,
	separator: '   ', //partition line
	timer: null, //timer
	init : function() {
		var tmp, buffer,i,max;
		this.tip = this.doc.createElement('div');
		this.tip.id = 'toolTip';
		this.doc.body.appendChild(this.tip);
		this.tip.style.top = '0';
		this.tip.style.visibility = 'hidden';
		if(this.doc.querySelectorAll){
			this.elems = this.doc.querySelectorAll('[title]');
		}else{
			buffer = this.doc.body.getElementsByTagName('*');
			for(i=0,max=buffer.length;i<max;i+=1){
				tmp = buffer[i];
				if(tmp.nodeType===1&&tmp.title){
					this.elems.push(tmp);
				}
			}
		}
		for(i=0,max=this.elems.length;i<max;i++){
			tmp = this.elems[i];
			if(DOMUtils.hasClass(tmp,'bubble')===-1&&tmp.title.length>3){
				addHandler(tmp,'mouseover',this.tipOver);
				addHandler(tmp,'mouseout',this.tipOut);
				addHandler(tmp,'mousemove',this.tipMove);
				tmp.setAttribute('tooltip',tmp.title.replace(new RegExp('   ','g'),'<br>'));
				tmp.removeAttribute('title');
			}
		}
	},
	tipMove: function(e) {
		var e = e || global.event,
				mX = e.clientX;
		ToolTips.updateXY(e);
		ToolTips.tip.style.left=[ToolTips.xCord+10,'px'].join('');
	},
	updateXY : function(e) {
		if (this.doc.captureEvents) {
			ToolTips.xCord = e.pageX;
			ToolTips.yCord = e.pageY;
		} else if (global.event.clientX) {
			ToolTips.xCord = global.event.clientX+this.doc.documentElement.scrollLeft;
			ToolTips.yCord = global.event.clientY+this.doc.documentElement.scrollTop;
		}
	},
	tipOut: function() {
		if (ToolTips.timer) {
			clearTimeout(ToolTips.timer);
		}
		ToolTips.tip.style.visibility = 'hidden';
	},
	tipOver : function(e) {
		var e = e || global.event,
				src = e.target || e.srcElement;
		if(!src.title&&!src.getAttribute('tooltip')){
			src = src.parentNode;
		}
		if(src.title&&src.title.length>3){
			src.setAttribute('tooltip',src.title);
			src.removeAttribute('title');
			addHandler(src,'mouseout',this.tipOut);
			addHandler(src,'mousemove',this.tipMove);
		}
		ToolTips.curObj = src;
		ToolTips.timer = setTimeout("ToolTips.tipShow()",200);
		ToolTips.updateXY(e);
	},
	tipShow : function() {		
		var scrX = this.xCord,
				scrY = this.yCord,
				tp = parseInt(scrY+15),
				lt = parseInt(scrX+10),
				anch = this.curObj;
		this.tip.innerHTML = anch.getAttribute('tooltip');
		if (parseInt(this.doc.documentElement.clientWidth+document.documentElement.scrollLeft,10) < parseInt(this.tip.offsetWidth+lt,10) ) {
			this.tip.style.left = parseInt(lt-(this.tip.offsetWidth+10),10)+'px';
		} else {
			this.tip.style.left = lt+'px';
		}
		if (parseInt(this.doc.documentElement.clientHeight+document.documentElement.scrollTop,10) < parseInt(this.tip.offsetHeight+tp,10) ) {
			this.tip.style.top = parseInt(tp-(this.tip.offsetHeight+10),10)+'px';
		} else {
			this.tip.style.top = tp+'px';
		}
		this.tip.style.visibility = 'visible';
	}
};
addHandler(global,'load',function () {
	ToolTips.init();
	Bubble.init();
});

var Bubble = {
      tOut: null,
			className: 'bubble',
			htmlClass: 'bubble-html',
			box: null,
			tBox: null,
			separator: /\s{3}/g,
      bX1: 0,
      bX2: 0,
      bY1: 0,
      bY2: 0,
			width: 0,
			height: 0,
			tTable: null,
			diff: 4,
			template: ['<table border="0" cellpadding="0" cellspacing="0" class="pop_or_bord" id="bubble-table"><tr>',
'<td width="6" height="6"><img src="/images/pop_up_dom_sel/c_or_1_1.gif" border="0" alt=""></td>',
    '<td class="top"><img src="/images/b.gif" border="0" alt=""></td>',
    '<td width="6"><img src="/images/pop_up_dom_sel/c_or_2_1.gif" border="0" alt=""></td></tr>',
  '<tr><td class="left"><img src="/images/pop_up_dom_sel/left_or.gif" border="0" alt=""></td>',
    '<td class="body" style="font-size:100%"><div id="bubble-text-box"></div></td>',
    '<td class="right"><img src="/images/pop_up_dom_sel/right_or.gif" border="0" alt=""></td></tr>',
  '<tr><td><img src="/images/pop_up_dom_sel/c_or_3.gif" border="0" alt=""></td>',
    '<td class="bottom"><img src="/images/pop_up_dom_sel/str_or.gif" border="0" alt=""></td>',
    '<td><img src="/images/pop_up_dom_sel/c_or_4.gif" border="0" alt=""></td></tr></table>'].join(''),
			show: function(ev) {
					var e = ev || global.event,
							src = e.target || e.srcElement,
							_bubble = Bubble,
							pos = _bubble.updatePos(ev),
							tmp;
					if(src.getAttribute('onmouseover')){
						src.removeAttribute('onmouseover');
						addHandler(src,'mouseover',_bubble.show);
						addHandler(src,'mouseout',_bubble.bOut);
					}
					if(src.title) {
						src.setAttribute('bubble',src.title);
						src.removeAttribute('title');
					}
					if (!src.getAttribute('bubble')){
						tmp = src.nextSibling.nodeType === 1 ? src.nextSibling : src.nextSibling.nextSibling;
						_bubble.tBox.innerHTML = tmp.innerHTML;
					}else{
						_bubble.tBox.innerHTML = src.getAttribute('bubble') || src.title;
					}
					var x=0,y=0;
					tmp=src;
					while(tmp.offsetParent){
						x+=tmp.offsetLeft;
						y+=tmp.offsetTop;
						tmp = tmp.offsetParent;
					}
					_bubble.width = _bubble.box.offsetWidth;
					_bubble.height = _bubble.box.offsetHeight;
					_bubble.bX1 = pos.x - _bubble.width/2;
					_bubble.bY1 = pos.y - _bubble.height;
					_bubble.bX2 = _bubble.bX1 + _bubble.width;
					_bubble.bY2 = _bubble.bY1 + _bubble.height;
					_bubble.box.style.left = x-_bubble.width/2 + 5 +'px';
					_bubble.box.style.top = y - _bubble.height - _bubble.diff + 'px';
					_bubble.box.style.visibility='visible';
					_bubble.tTable.style.visibility='visible';
      },
			out: function() {
					Bubble.tOut = setTimeout(function(){
						Bubble.box.style.visibility='hidden';
						Bubble.tTable.style.visibility='hidden';
					},300);
			},
			bOver: function(){
					Bubble.tOut = clearTimeout(Bubble.tOut);
			},
			bOut: function(event){
					var e = event || global.event,
							src = e.target || e.srcElement,
							_bubble = Bubble,
							pos = _bubble.updatePos;
					addHandler(global.document.body,'mousemove',Bubble.mMove);
			},
			mMove: function(event){
					var e = event || global.event,
							src = e.target || e.srcElement,
							pos = Bubble.updatePos(event);
					if(((pos.x>Bubble.bX1)&&(pos.x<Bubble.bX2))&&((pos.y>Bubble.bY1-5)&&(pos.y<Bubble.bY2+15))){
							Bubble.tOut = clearTimeout(Bubble.tOut);
					}else{
							Bubble.box.style.visibility='hidden';
							Bubble.tTable.style.visibility='hidden';
							removeHandler(global.document.body,'mousemove',Bubble.mMove);
					}
			},
			updatePos: function(e){
				var e = e || global.event,
						src = e.target || e.srcElement,
						x,y;
				if (global.document.captureEvents){
					x = e.pageX;
					y = e.pageY;
				}else if(global.event.clientX){
					x = e.clientX + global.document.documentElement.scrollLeft;
					y = e.clientY + global.document.documentElement.scrollTop;
				}
				return {
						x:x,
						y:y
				}
			},
			init: function(object){
				var tElem = global.document.createElement('DIV');
				var elems = [], tmp;
				tElem.id = 'bubble-box';
				tElem.className = 'bubble-box';
				tElem.style.visibility='hidden';
				this.box = global.document.body.appendChild(tElem);
				this.box.innerHTML = this.template;
				this.tBox = global.document.getElementById('bubble-text-box');
				this.tTable = global.document.getElementById('bubble-table');
				this.tTable.style.visibility='hidden';
				if(navigator.userAgent.indexOf('MSIE 6')!==-1)
					this.diff = 13;
				addHandler(this.box,'mouseover',this.bOver);
				addHandler(this.box,'mouseout',this.bOut);
				elems = DOMUtils.getElementsByClass(this.className);
				for(var i=0,max=elems.length;i<max;++i){
						tmp = elems[i];
						if(tmp.title){
							tmp.setAttribute('bubble',tmp.title.replace(this.separator,'<br>'));
							tmp.removeAttribute('title');
						}
						addHandler(tmp,'mouseover',this.show);
						addHandler(tmp,'mouseout',this.out);
				}
			}
}
var Filters = {
    onlyLatins: function(str,callback) {
        var exp = /[-0-9a-z," ]+/ig,
            res = str.match(exp), out = false,
            res2 = str.match(/[0-9-," ]+/ig);
        if (!res2 && (res && (res[0].length === str.length)) || (res && (res[0].length === str.length) && res2 && res2[0].length !== str.length)) {
            out = true;
        }
        if (typeof callback === 'function') {
            callback.call(this,out);
        }
        return out;
    },
    checkURI: function(str,callback) {
        var exp = /[^ÊÃÕËÅÎÇÛÝÚÈßÆÙ×ÁÐÒÏÌÄÖÜÑÞÓÍÉÔØÂÀ£]+/ig,
            res = str.match(exp), out = false;
        if (res && (res[0].length === str.length)) {
            out = true;
        }
        if (typeof callback === 'function') {
            callback.call(this,out);
        }
        return out;
    },
    onlyDigits: function(str,callback) {
        var exp = /[0-9]+/g,
            res = str.match(exp), out = false;
        if (res && res[0].length === str.length) {
            out = true;
        }
        if (typeof callback === 'function') {
            callback.call(this,out);
        }
        return out;
    },
    onlyLetters: function(str,callback) {
        var exp = /[a-z0-9- ]+/ig,
            res = str.match(exp), out = false;
        if (res && res[0].length === str.length) {
            out = true;
        }
        if (typeof callback === 'function') {
            callback.call(this,out);
        }
        return out;
    }
};
domReady.add(function(){
	var names = ['domain','domains','dom_substr'],
			elems, doc = global.document, max, i, tmp;
	for(i = 0,max=names.length;i<max;++i){
		elems = doc.getElementsByName(names[i]);
		if(elems.length>0){
			tmp = elems.item(0);
			if(tmp.type === 'text') {
				tmp.focus();
			  break;
			}
		}
	}
	elems = tmp = doc = null;
});

