function showflash(param, version) {
	document.writeln(param); 
}


function popup(url, w, h, resize, scroll) {
	window.open(url,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+scroll+",resizable="+resize+",width="+w+",height="+h+",left=50,top=50");
	return false;
}


var evt = {
  add: function(elem, evt, todo) {
    if(elem.addEventListener) {
      elem.addEventListener(evt, todo, false);
    }
    else if (elem.attachEvent) { // ie
      elem.attachEvent('on' + evt, todo);
    }
  },
  
  remove: function(elem, evt, todo) {
    if(elem.removeEventListener) {
      elem.removeEventListener(evt, todo, false);
    }
    else if (elem.detachEvent) { // ie
      elem.detachEvent('on' + evt, todo);
    }
  }
}






efx = Class.create();
efx.prototype = {
  initialize: function(obj, property, from, to, startTime, duration, frequency, quantity) {
    this.object = obj;
    this.property = property;
    this.from = from;
    this.to = to;
    this.duration = duration; 
    this.frequency = frequency;
    this.quantity = quantity;
    this.startTime = startTime;
    
    this.go();
  },
  
  go: function() {
    this.runTime = (new Date).getTime();
    this.clock = setInterval(this.run.bind(this), '1');
  },
  
  run: function() {
    if(((new Date).getTime() - this.runTime) >= this.startTime) {
      this.runTime = (new Date).getTime();
      clearInterval(this.clock);
      this.clock = setInterval(this.step.bind(this), this.frequency);
    }
  },
  
  step: function() {
    var curTime = (new Date).getTime();
    if((curTime - this.runTime) >= this.duration) {
      if(this.property == "opacity") {
        this.object.style.filter = "alpha(opacity="+this.to+")";
        this.object.style.opacity = this.to/100;
      }
      else {
        this.object.style[this.property] = this.to + this.quantity;
      }
      clearInterval(this.clock);
    }
    else {
      var normTime = (curTime - this.runTime) / this.duration;
      var curRes = (((this.to - this.from) * ((-Math.cos(Math.PI*normTime)/2) + 0.5) ) + parseFloat(this.from));
      
      if(this.property == "opacity") {
        this.object.style.filter = "alpha(opacity="+curRes+")";
        this.object.style.opacity = curRes/100;
      }
      else {
        this.object.style[this.property] = curRes + this.quantity;
      }
    }
  }
}


function getElementComputedStyle(elem, prop){  
  if (typeof elem!="object") elem = document.getElementById(elem);    
  // external stylesheet for Mozilla, Opera 7+ and Safari 1.3+  
  if (document.defaultView && document.defaultView.getComputedStyle)  {    
    if (prop.match(/[A-Z]/)) prop = prop.replace(/([A-Z])/g, "-$1").toLowerCase();    
    return document.defaultView.getComputedStyle(elem, "").getPropertyValue(prop);  
  }    

// external stylesheet for Explorer and Opera 9  
  if (elem.currentStyle)  {    
    var i;    while ((i=prop.indexOf("-"))!=-1) prop = prop.substr(0, i) + prop.substr(i+1,1).toUpperCase() + prop.substr(i+2);    
    return elem.currentStyle[prop];  
  }    return "";
}





var formchecker = Class.create();

formchecker.prototype = {
  initialize: function(formname) {

  
    this.formelement = document.getElementById(formname);

    if(this.formelement!=null) {  
      this.req = this.getrequiredfiels();
      this.checkformonrun();
    
      for(var i=0; i<this.req.length; i++) {
        this.req[i].onblur = this.onchangefieldvalue.bindAsEventListener(this);
        this.req[i].onkeyup = this.onchangefieldvalue.bindAsEventListener(this);
      }
      
      formElements = this.getFormElements();
      
      for(var i=0; i<formElements.length; i++) {
        if(formElements[i].className=='phone' || formElements[i].className=='phone require') {
          formElements[i].onkeydown = this.interceptValueAndMakeDigits.bindAsEventListener(this);
        }
      }
      
    }
  },
  
  interceptValueAndMakeDigits: function(evt) {
    var element = Event.element(evt);

    if(evt.keyCode) var code = evt.keyCode;
    else if(evt.which) var code = evt.which;

    if((code>=48 && code<=57) || (code>=97 && code<=105) || (code>=37 && code<=40) || (code==8 || code==9 || code==13 || code==46)) return true;
    else return false;
  },
  
  getfieldtype: function(element) {

    var elemclassname = element.className;
    
    var re = /phone/;
    if(re.test(elemclassname)) { return 'phone';  }
    
    var re = /email/;
    if(re.test(elemclassname)) { return 'email';  }
    else {  return 'default';   }
  },
  
  getrequiredfiels: function() {
    var allelems = this.formelement.elements;
    var elems = new Array();
    var re = /require/i; // regexp
    var j = 0;
    
    for(var i=0; i<allelems.length; i++) {
      if(re.test(allelems[i].className)) {
        elems[j] = allelems[i];
        j++;
      }
      
    }
    

    var req = new Array();
    var j = 0;
    for(var i in elems) {
      if(elems[i].className) {
        req[j] = elems[i];
        j++;
      }
    }
    return req;
  },
  
  getFormElements: function() {
    return this.formelement.elements;
  },
  
  checkfield: function(element) {
    var type = this.getfieldtype(element);
    switch(type) {
      case 'default' : return (element.value.length > 1) ? true : false; break;
      case 'email' : return this.checkfield_email(element); break;
      case 'phone' : return this.checkfield_phone(element); break;
    } 
    
  },
  
  checkfield_email: function(element) {
    //if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(element.value)){ 
    
    if (/^[A-Za-z0-9\.-]+@[A-Za-z0-9\.-]+(\.\w{2,4})+$/.test(element.value)){ 
      return true 
    } 
    else { return false; }
  }, 

  checkfield_phone: function(element) {
    
    if (element.value.length > 7){ 
      var re = /^[0-9]{8,15}?/;
      if(re.test(element.value)) {
        return true;
      }
      else { return false; }
    } 
    else { return false; }
  },
  
  checkallfields: function() {
    for(var i=0; i<this.req.length; i++) {
      if(this.checkfield(this.req[i]) == false) {return false;}
    }
    return true;
  },
  
  onchangefieldvalue: function(evt) {
    var element = Event.element(evt);
    if(this.checkfield(element)) {
      this.fieldactivation(element);
    }
    else {
      this.fielddeactivation(element);
    }
    
    if(this.checkallfields()) { this.formactivation();  }
    else { this.formdeactivation();  }
  },
  
  checkformonrun: function() { 

    for(var i=0; i<this.req.length; i++) {
     
      if(this.checkfield(this.req[i]) == false) {
        this.fielddeactivation(this.req[i]);
      }else {
        this.fieldactivation(this.req[i]);
      }
    }
    
    if(this.checkallfields()) { this.formactivation();  }
    else { this.formdeactivation();  }
    
  },
  
  formactivation: function(element) {
    var submitbtn = this.findsubmit();
    submitbtn.disabled = false;
  },
  
  formdeactivation: function(element) {
    var submitbtn = this.findsubmit();
    submitbtn.disabled = true;
  },
  
  fieldactivation: function(element) {
    element.style.color = 'black';
    var brothers = element.parentNode.childNodes;
    for(var i=0; i<brothers.length; i++) {
      if(brothers[i].className == 'bullet') {
        
        brothers[i].style.display = 'none';
      }
    }
  },

  fielddeactivation: function(element) {
    element.style.color = 'red';
    var brothers = element.parentNode.childNodes;
    for(var i=0; i<brothers.length; i++) {
      if(brothers[i].className == 'bullet') {
        brothers[i].style.display = 'inline';
      }
    }

  },
  
  findsubmit: function() {
    for(var i=0; i<this.formelement.elements.length; i++) {
      if(this.formelement.elements[i].type == 'submit') {
        return this.formelement.elements[i];
      }
    }
  }

}




var autocomplete = Class.create();
autocomplete.prototype = {
  initialize: function(elementClassName, type) {
    this.type = type;
    this.elementClassName = elementClassName;
    var elements = $$('input');
    for(var i=0; i<elements.length; i++) {
      if(elements[i].className == this.elementClassName) {
        (this.type == 'password') ? this.replaceElement(elements[i], 'text', elements[i].defaultValue) : '';
        elements[i].onfocus = this.focused.bindAsEventListener(this);
        elements[i].onblur =  this.blured.bindAsEventListener(this);
      }

    }
  },
  focused: function(evt) {
		var element = Event.element(evt);
    if(element.value == element.defaultValue) {
      this.type == 'password' ? this.replaceElement(element, 'password', '') : ''; 
      element.value = '';
      //element.className = this.elementClassName + ' active';
      element.style.color = '#000000';
    }
  },
  blured: function(evt) {
    var element = Event.element(evt)
      if(element.value == '') {
        this.type == 'password' ? this.replaceElement(element, 'text', element.defaultValue) : ''; 
        element.value = element.defaultValue;
        //element.className = element.className.replace(/\ active/, '');
        element.style.color = '#9f9f9f';
      }
  },
  replaceElement: function (element, type, setValue) {
    var newelement = document.createElement('input');
    newelement.className = element.className;
    newelement.defaultClass = element.defaultClass;
    newelement.setAttribute('type', type);
    newelement.setAttribute('name', element.name);
    newelement.setAttribute('style', element.style);
    newelement.defaultValue = element.defaultValue;
    newelement.value = setValue;
    element.parentNode.appendChild(newelement);
    if(setValue == '') {  newelement.focus(); /*newelement.className += ' active';*/ newelement.style.color = '#000000'; }
    else {/*newelement.className = newelement.className.replace(/\ active/, '');*/ newelement.style.color = '#9f9f9f'; }

    element.parentNode.removeChild(element);
    newelement.onfocus = this.focused.bindAsEventListener(this);
    newelement.onblur =  this.blured.bindAsEventListener(this);
    
    return newelement;
  }

  
};





var commonMenu = Class.create();
commonMenu.prototype = {
  initialize: function() {
    this.btn = $('commonMenuButton');
    this.menu = $('additionalSites');
    if(this.btn && this.menu) {
      this.btn.onclick = this.clicked.bindAsEventListener(this);
    }
  },
  clicked: function(evt) {
    var menuHeight = getElementComputedStyle(this.menu, 'height');
    if(menuHeight == "0px") {
      new efx(this.menu, "height", 0, this.menu.scrollHeight, 10, 250, 10, "px");
      this.switchOn();
      
    }
    else {
      new efx(this.menu, "height", this.menu.scrollHeight, 0, 10, 250, 10, "px");
      this.switchOff();
    }
    
  }, 
  switchOn: function() {
    this.btn.parentNode.className = "additional-items-on";
    $('onCommonMenuBtn').style.display = "none";
    $('offCommonMenuBtn').style.display = "inline";
  },
  switchOff: function() {
    this.btn.parentNode.className = "additional-items";
    $('onCommonMenuBtn').style.display = "inline";
    $('offCommonMenuBtn').style.display = "none";
  }
  
}


calculatorMenu = Class.create();
calculatorMenu.prototype = {
  initialize: function() {
    this.menu = $("calculator_menu");
    this.link = $("link_calc");
    this.calculator_ico = $("calculator_ico");
    this.closeBtn = $("popup_btn_close");
    
    if(this.menu && this.link) {
      this.link.onclick = this.clicked.bindAsEventListener(this);
      this.calculator_ico.onclick = this.clicked.bindAsEventListener(this);
      this.closeBtn.onclick = this.close.bindAsEventListener(this);
      
    }
    
  }, 
  clicked: function() {
    new efx(this.menu, "height", 0, 191, 10, 250, 10, "px");
    new efx(this.menu, "top", 0, -192, 10, 250, 10, "px");
  },
  
  close: function() {
    new efx(this.menu, "height", 191, 0, 10, 250, 10, "px");
    new efx(this.menu, "top", -192, 0, 10, 250, 10, "px");
  }
}




subway2 = Class.create();
subway2.prototype = {
  initialize: function(elementId, type) {
    this.elemBody = $(elementId);
    this.type = type;
    if(this.elemBody) {
      for(var i=0; i<this.elemBody.childNodes.length; i++) {
        if(this.elemBody.childNodes[i].tagName == "LI") {
          
          var link = this.getChildByClassName(this.elemBody.childNodes[i], "link");
          
          if(link.className == "link act") {
            var sister = this.getSisterByClassName(link, "description");
            this.rollOverClickedElem(sister);
          }
          
          link.onclick = this.clickedOnLink.bindAsEventListener(this);
          
          
        }
      }
    }
  },
  
  clickedOnLink: function(evt) {
    var elem = Event.element(evt);
    this.lastClicked = elem;
    
    if(this.type == "single") {
      this.rollOutAll();
    }
    
    var sister = this.getSisterByClassName(elem, "description");
    var sisterHeight = getElementComputedStyle(sister, 'height');
    
    if(elem.className == "link") {
      elem.className = "link act";
    }
    else {
      elem.className = "link";
    }

    if(sisterHeight !== "0px") {
      this.rollOutClickedElem(sister);
    }
    else {
      this.rollOverClickedElem(sister);
    }
    
    

  },
  
  
  rollOutAll: function() {
    for(var i=0; i<this.elemBody.childNodes.length; i++) {
        if(this.elemBody.childNodes[i].tagName == "LI") {
          var link = this.getChildByClassName(this.elemBody.childNodes[i], "link");
          
          if(link.className == "link act" && this.lastClicked !== link) {
            var sister = this.getSisterByClassName(link, "description");
            this.rollOutClickedElem(sister);
            link.className = "link";
          }
        }
    }
  },
  
  getChildByClassName: function(parentEl, classNm) {
    for(var i=0; i<parentEl.childNodes.length; i++) {
      
      if(parentEl.childNodes[i].className == classNm || parentEl.childNodes[i].className == classNm + ' act') {
        return parentEl.childNodes[i];
      }
      else {
        var reqElem = this.getChildByClassName(parentEl.childNodes[i], classNm);
      }
    }
    return reqElem;
  },
  
  getSisterByClassName: function(elem, classNm) {
    return this.getChildByClassName(elem.parentNode, classNm);
  },
  
  rollOverClickedElem: function(elem) {
    new efx(elem, "height", 0, elem.scrollHeight, 10, 250, 10, "px");
  },
  
  rollOutClickedElem: function(elem) {
    new efx(elem, "height", elem.scrollHeight, 0, 10, 250, 10, "px");
  }
  
}








subway3 = Class.create();
subway3.prototype = {
  initialize: function() {
    //this.elems = document.getElementsByClassName("subway-subway");
    
    this.elems = $$("div.subway-subway");
    
    if(this.elems.length > 0) {
      for(var j=0; j<this.elems.length; j++) {
        
        for(var i=0; i<this.elems[j].childNodes.length; i++) {
          if(this.elems[j].childNodes[i].className == "link-link") {
            
            var link = this.elems[j].childNodes[i];
            
            //var link = this.getChildByClassName(this.elemBody.childNodes[i], "link");
            
            /*if(link.className == "link act") {
              var sister = this.getSisterByClassName(link, "description");
              this.rollOverClickedElem(sister);
            }*/
            
            link.onclick = this.clickedOnLink.bindAsEventListener(this);
            
            
          }
        }
      }
    }
  },
  
  clickedOnLink: function(evt) {
    var elem = Event.element(evt);
    this.lastClicked = elem;
    
    /*if(this.type == "single") {
      this.rollOutAll();
    }*/
    
    var sister = this.getSisterByClassName(elem, "content-content");
    var sisterHeight = getElementComputedStyle(sister, 'height');
    
    if(elem.className == "link-link") {
      elem.className = "link-link act";
    }
    else {
      elem.className = "link-link";
    }

    if(sisterHeight !== "0px") {
      this.rollOutClickedElem(sister);
    }
    else {
      this.rollOverClickedElem(sister);
    }
    
    

  },
  
  /*
  rollOutAll: function() {
    for(var i=0; i<this.elemBody.childNodes.length; i++) {
        if(this.elemBody.childNodes[i].tagName == "LI") {
          var link = this.getChildByClassName(this.elemBody.childNodes[i], "link");
          
          if(link.className == "link act" && this.lastClicked !== link) {
            var sister = this.getSisterByClassName(link, "description");
            this.rollOutClickedElem(sister);
            link.className = "link";
          }
        }
    }
  },*/
  
  getChildByClassName: function(parentEl, classNm) {
    for(var i=0; i<parentEl.childNodes.length; i++) {
      
      if(parentEl.childNodes[i].className == classNm || parentEl.childNodes[i].className == classNm + ' act') {
        return parentEl.childNodes[i];
      }
      else {
        var reqElem = this.getChildByClassName(parentEl.childNodes[i], classNm);
      }
    }
    return reqElem;
  },
  
  getSisterByClassName: function(elem, classNm) {
    return this.getChildByClassName(elem.parentNode, classNm);
  },
  
  rollOverClickedElem: function(elem) {
    new efx(elem, "height", 0, elem.scrollHeight, 10, 250, 10, "px");
  },
  
  rollOutClickedElem: function(elem) {
    new efx(elem, "height", elem.scrollHeight, 0, 10, 250, 10, "px");
  }
  
}












zebra = Class.create();
zebra.prototype = {
  initialize: function() {
    //this.elems = document.getElementsByClassName('table');
    //alert($$('div.table').length);
    this.elems = $$('div.table');
    
    //alert(document.getElementsByClassName("table")[0]);
    if(this.elems) {
     
        for(var i=0; i<this.elems.length; i++) {
          //var elemsBrothers = this.elems[i].getElementsByClassName("tr");
          var elemsBrothers = this.elems[i].$$("div.tr");
          
          for(var j=0; j<elemsBrothers.length; j++) {
            elemsBrothers[j].onmouseover = this.mouseOvered.bindAsEventListener(this);
            elemsBrothers[j].onmouseout = this.mouseOuted.bindAsEventListener(this);
          }
        }

    } 

  },
  
  mouseOvered: function(evt) {
    var elem = Event.element(evt);
    var elem = this.getParent(elem);
    if(getElementComputedStyle(elem, "background-color")!=="#93abe0" && getElementComputedStyle(elem, "background-color")!=="rgb(147, 171, 224)") {
      elem.style.background = "#ededed";
    }

  },
  
  mouseOuted: function(evt) {
    var elem = Event.element(evt);
    var elem = this.getParent(elem);
    if(getElementComputedStyle(elem, "background-color")!=="#93abe0" && getElementComputedStyle(elem, "background-color")!=="rgb(147, 171, 224)") {
      elem.style.background = "#FFFFFF";
    }
  },
  
  getParent: function(elem) {
    if(elem.className == "tr") {
      return elem;
    }
    else {
      var result = this.getParent(elem.parentNode);
    }
    
    return result;
  }
  
}



mpAdsBlockWidth = Class.create();
mpAdsBlockWidth.prototype = {
  initialize: function() {
    if(document.getElementById("mp_4ads_block")){
      this.ress();
      this.bodyElem = document.getElementsByTagName('body')[0];
      this.bodyElem.onresize = this.ress.bindAsEventListener(this);
      window.onresize = this.ress.bindAsEventListener(this);
    }
    
  },
  ress: function() {
    
    var adsElem = document.getElementById("mp_4ads_block");
    var newsMp = document.getElementById("newsMp");
    var privatMp = document.getElementById("privatMp");
    var compMp = document.getElementById("compMp");
    
    
    //if(document.body.clientWidth <=1280 && document.body.clientWidth >=975) {
    if(document.body.clientWidth <=1177 && document.body.clientWidth >=975) {  
      
      var wdh = document.body.clientWidth - 325 - (document.body.clientWidth/40);
      
      adsElem.style.width = wdh + "px";
      
      newsMp.style.width = wdh + 14 + "px";
      privatMp.style.width = wdh + 14 + "px";
      compMp.style.width = wdh + 14 + "px";
      
      
    }
    else if(document.body.clientWidth <975) {
      adsElem.style.width = "623px";
      newsMp.style.width = "637px";
      privatMp.style.width = "637px";
      compMp.style.width = "637px";
      
      
    }
    else if(document.body.clientWidth >1177) {
      adsElem.style.width = "820px";
      newsMp.style.width = "834px";
      privatMp.style.width = "834px";
      compMp.style.width = "834px";
    }
    /*else if(document.body.clientWidth >1280) {
      adsElem.style.width = "922px";
    }*/

    
  }
}




iconsHints = Class.create();
iconsHints.prototype = {
  initialize: function() {
    this.iconsPlace = $$("div.sections_serv_icons2");
    this.hintPopup = $("hint_icons");
  
    
    if(this.iconsPlace.length > 0) {
    
      this.globalSwitch = "0";
      this.globalSwitchOff();
    
      var elem = this.getChildByClassName(this.iconsPlace[0], "icons_ul");
      for(var i=0; i<elem.childNodes.length; i++) {
        
        if(elem.childNodes[i].className == "icooo") {
          elem.childNodes[i].onmouseover = this.overed.bindAsEventListener(this);
          elem.childNodes[i].onmouseout = this.outed.bindAsEventListener(this);
        }
      }
      
      
      this.hintPopup.onmouseout = this.outedFromPopup.bindAsEventListener(this);
      this.hintPopup.onmouseover = this.overdToPopup.bindAsEventListener(this);
      
     // $("hint_close_btn").onclick = this.closeBtn.bindAsEventListener(this);
      
    }
  },
  
  overed: function(evt) {
    this.globalSwitch = "1";
    this.globalSwitchOff();
    var elem = Event.element(evt);
    
    this.hintPopup.style.display = "block";
    
    var linkEl = this.getChildByTagName(elem, "A");
    var linkDetails = linkEl.rel.split("#"); 
   
    // Browser scroll height
    var scrollH = document.documentElement.scrollTop >= document.body.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
    
    // Browser work space
    var screenH = document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;



    
    if(screenH + scrollH < 895) {
      var plann = "a";
    }
    else {
      var plann = "b";
    }   
 
 

 
 
    if(linkDetails[2]=="1") {
      this.hintPopup.style.left = "20px";
      if(plann == "b") {
        $("calloutus").style.left = "35px";
        $("calloutus").style.background = "url(/img/hint-icons-callout.png) no-repeat";

        this.showTopCallout();
      }
      else {
        $("calloutus_bottom").style.left = "35px";
        $("calloutus_bottom").style.background = "url(/img/hint-icons-callout_bottom.png) no-repeat";

        this.showBottomCallout();
      }
    }
    else if(linkDetails[2]=="2") {
      this.hintPopup.style.left = "15%";
      if(plann == "b") {
        $("calloutus").style.left = "120px";
        $("calloutus").style.background = "url(/img/hint-icons-callout.png) no-repeat";
        
        this.showTopCallout();
      }
      else {
        $("calloutus_bottom").style.left = "120px";
        $("calloutus_bottom").style.background = "url(/img/hint-icons-callout_bottom.png) no-repeat";
        
        this.showBottomCallout();
      }
    }
    else if(linkDetails[2]=="3") {
      this.hintPopup.style.left = "20%";
      if(plann == "b") {
        $("calloutus").style.left = "250px";
        $("calloutus").style.background = "url(/img/hint-icons-callout2.png) no-repeat";
        
        this.showTopCallout();
      }
      else {
        $("calloutus_bottom").style.left = "250px";
        $("calloutus_bottom").style.background = "url(/img/hint-icons-callout_bottom2.png) no-repeat";
        
        this.showBottomCallout();
      }
    }
    else if(linkDetails[2]=="4") {
      this.hintPopup.style.left = "23%";
      if(plann == "b") {
        $("calloutus").style.left = "420px";
        $("calloutus").style.background = "url(/img/hint-icons-callout2.png) no-repeat";
        
        this.showTopCallout();
      }
      else {
        $("calloutus_bottom").style.left = "420px";
        $("calloutus_bottom").style.background = "url(/img/hint-icons-callout_bottom2.png) no-repeat";
        
        this.showBottomCallout();
      }
    }
    
    $("heaad_heaad").innerHTML = linkDetails[0];
    $("coonent").innerHTML = linkDetails[1];
    
    
  },
  
  showTopCallout: function() {
    $("calloutus").style.display = "block";
    $("calloutus_bottom").style.display = "none";
    this.hintPopup.style.bottom = "auto";
    this.hintPopup.style.top = "60px";
  },
  
  showBottomCallout: function() {
    $("calloutus").style.display = "none";
    $("calloutus_bottom").style.display = "block";
    this.hintPopup.style.top = "auto";
    this.hintPopup.style.bottom = "-20px";
  },
  
  
  outed: function(evt) {
    this.globalSwitch = "0";
    this.globalSwitchOff();
  },
  
  outedFromPopup: function(evt) {
    this.globalSwitch = "0";
    this.globalSwitchOff();
  },
  
  
  overdToPopup: function(evt) {
    this.globalSwitch = "1";
    this.globalSwitchOff();
  },
  
  
  closeBtn: function() {
    $("hint_icons").style.display = "none";
  },
  
  
  globalSwitchOff: function() {
    this.clock = setInterval(this.globalSwitchOff_OFF.bind(this), '5');
    
  },
  
  globalSwitchOff_OFF: function() {
    if(this.globalSwitch == '0') {
      $("hint_icons").style.display = "none";
    }
    clearInterval(this.clock);
  },
  
  
  getChildByClassName: function(parentEl, classNm) {
    for(var i=0; i<parentEl.childNodes.length; i++) {
      
      if(parentEl.childNodes[i].className == classNm) {
        return parentEl.childNodes[i];
      }
      else {
        var reqElem = this.getChildByClassName(parentEl.childNodes[i], classNm);
      }
    }
    return reqElem;
  },
  
  
  getChildByTagName: function(parentEl, tagNm) {
    for(var i=0; i<parentEl.childNodes.length; i++) {
      
      if(parentEl.childNodes[i].tagName == tagNm) {
        return parentEl.childNodes[i];
      }
      else {
        var reqElem = this.getChildByClassName(parentEl.childNodes[i], tagNm);
      }
    }
    return reqElem;
  }
  
}




function showOverlay() {
  var place = document.getElementById('overlaypopup');
  
  var closeBtn = document.getElementById("closebtn");
  
  place.style.display = 'inline';
  var body = document.getElementsByTagName('body').item(0);
  
  var canvas = document.getElementById("overleyCanvas");
  
  //var hh = !window.opera ? document.documentElement.clientHeight : document.body.clientHeight;

  bodyCH = document.body.clientHeight;
  bodySH = document.getElementsByTagName('body').item(0).scrollHeight;
  
  
  hh = bodyCH > bodySH ? bodyCH : bodySH;
  
  
  if(  navigator.userAgent.indexOf('Firefox') != -1 ) { 
    var eeee = $$("div.head");
    var eeee2 = $$("div.content-layout");
    var eeee3 = $$("div.under-content-part");
    
    var tmp_h = eeee2[0].scrollHeight + eeee3[0].scrollHeight
    
    hh =  hh < tmp_h ? tmp_h : hh;
  } 
  
  
  place.style.height = hh + "px";
  
  
  var canvasW = canvas.scrollWidth;
  var browserW = document.body.clientWidth;
  
  var canvasLeftPoint = (browserW/2 - canvasW/2);
  var closeBtnLeftPoint = (browserW/2 + canvasW/2);
  

  
  
  // browser Scroll Height
  var scrollH = document.documentElement.scrollTop >= document.body.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
  
   
  canvas.style.left = canvasLeftPoint + "px";
  canvas.style.top = (scrollH + 20) + "px";
  
  closeBtn.style.left = (closeBtnLeftPoint + 20) + "px";
  closeBtn.style.top = (scrollH + 10) + "px";
  
  closeBtn.onclick = function() {
    $("overlaypopup").style.display = "none";
  }

  
}


assignOverlayBtn = Class.create();
assignOverlayBtn.prototype = {
  initialize: function() {
    if($("overlay_btn")) {
      $("overlay_btn").onclick = function() {
        showOverlay();
      }
    }
    if($("overlay_icon")) {
      $("overlay_icon").onclick = function() {
        showOverlay();
      }
    }
  }
}















iconsHintsMP = Class.create();
iconsHintsMP.prototype = {
  initialize: function() {
    this.iconsPlace = $$("ul.privatPersMp");
    this.hintPopup = $("hint_icons");
  
    
    if(this.iconsPlace.length > 0) {
    
      this.globalSwitch = "0";
      this.globalSwitchOff();
    
      var elem = this.iconsPlace[0];
      for(var i=0; i<elem.childNodes.length; i++) {
        
        if(elem.childNodes[i].tagName == "LI") {
          elem.childNodes[i].onmouseover = this.overed.bindAsEventListener(this);
          elem.childNodes[i].onmouseout = this.outed.bindAsEventListener(this);
        }
      }
      
      
      this.hintPopup.onmouseout = this.outedFromPopup.bindAsEventListener(this);
      this.hintPopup.onmouseover = this.overdToPopup.bindAsEventListener(this);
      
     // $("hint_close_btn").onclick = this.closeBtn.bindAsEventListener(this);
      
    }
  },
  
  overed: function(evt) {
    this.globalSwitch = "1";
    this.globalSwitchOff();
    var elem = Event.element(evt);
    
    
    this.hintPopup.style.display = "block";
    
    if(elem.tagName == "A") {
      var linkEl = elem;
    }
    else {
      var linkEl = this.getChildByTagName(elem, "A");
    }
    var linkDet = linkEl.rel.split("#");
    var linkDetails = $(linkDet[0]);
    
    for(var i=0; i<linkDetails.childNodes.length; i++) {
      if(linkDetails.childNodes[i].tagName == "H4") {
        var linkDetailslHead = linkDetails.childNodes[i].innerHTML;
      }
      if(linkDetails.childNodes[i].tagName == "P") {
        var linkDetailslCont = linkDetails.childNodes[i].innerHTML;
      }
    }
    
     
   
    // Browser scroll height
    var scrollH = document.documentElement.scrollTop >= document.body.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
    
    // Browser work space
    var screenH = document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;



    
    if(screenH + scrollH < 770) {
      var plann = "a";
    }
    else {
      var plann = "b";
    }   
 
 

 
 
    if(linkDet[1]=="1") {
      this.hintPopup.style.left = "20px";
      if(plann == "b") {
        $("calloutus").style.left = "35px";
        $("calloutus").style.background = "url(/img/hint-icons-callout.png) no-repeat";

        this.showTopCallout();
      }
      else {
        $("calloutus_bottom").style.left = "35px";
        $("calloutus_bottom").style.background = "url(/img/hint-icons-callout_bottom.png) no-repeat";

        this.showBottomCallout();
      }
    }
    else if(linkDet[1]=="2") {
      this.hintPopup.style.left = "12%";
      if(plann == "b") {
        $("calloutus").style.left = "100px";
        $("calloutus").style.background = "url(/img/hint-icons-callout.png) no-repeat";
        
        this.showTopCallout();
      }
      else {
        $("calloutus_bottom").style.left = "100px";
        $("calloutus_bottom").style.background = "url(/img/hint-icons-callout_bottom.png) no-repeat";
        
        this.showBottomCallout();
      }
    }
    else if(linkDet[1]=="3") {
      this.hintPopup.style.left = "16%";
      if(plann == "b") {
        $("calloutus").style.left = "190px";
        $("calloutus").style.background = "url(/img/hint-icons-callout.png) no-repeat";
        
        this.showTopCallout();
      }
      else {
        $("calloutus_bottom").style.left = "190px";
        $("calloutus_bottom").style.background = "url(/img/hint-icons-callout_bottom.png) no-repeat";
        
        this.showBottomCallout();
      }
    }
    else if(linkDet[1]=="4") {
      this.hintPopup.style.left = "24%";
      //this.hintPopup.style.left = "auto";
      //this.hintPopup.style.right = "50px";
      if(plann == "b") {
        $("calloutus").style.left = "220px";
        $("calloutus").style.background = "url(/img/hint-icons-callout2.png) no-repeat";
        
        this.showTopCallout();
      }
      else {
        $("calloutus_bottom").style.left = "220px";
        $("calloutus_bottom").style.background = "url(/img/hint-icons-callout_bottom2.png) no-repeat";
        
        this.showBottomCallout();
      }
    }
    else if(linkDet[1]=="5") {
      this.hintPopup.style.left = "auto";
      this.hintPopup.style.right = "30px";
      if(plann == "b") {
        $("calloutus").style.left = "320px";
        $("calloutus").style.background = "url(/img/hint-icons-callout2.png) no-repeat";
        
        this.showTopCallout();
      }
      else {
        $("calloutus_bottom").style.left = "320px";
        $("calloutus_bottom").style.background = "url(/img/hint-icons-callout_bottom2.png) no-repeat";
        
        this.showBottomCallout();
      }
    }
    
    else if(linkDet[1]=="6") {
      this.hintPopup.style.left = "auto";
      this.hintPopup.style.right = "10px";
      if(plann == "b") {
        $("calloutus").style.left = "420px";
        $("calloutus").style.background = "url(/img/hint-icons-callout2.png) no-repeat";
        
        this.showTopCallout();
      }
      else {
        $("calloutus_bottom").style.left = "420px";
        $("calloutus_bottom").style.background = "url(/img/hint-icons-callout_bottom2.png) no-repeat";
        
        this.showBottomCallout();
      }
    }
    
    
    
    
    $("heaad_heaad").innerHTML = linkDetailslHead;
    $("coonent").innerHTML = linkDetailslCont;
    
    
  },
  
  showTopCallout: function() {
    $("calloutus").style.display = "block";
    $("calloutus_bottom").style.display = "none";
    this.hintPopup.style.bottom = "auto";
    this.hintPopup.style.top = "60px";
  },
  
  showBottomCallout: function() {
    $("calloutus").style.display = "none";
    $("calloutus_bottom").style.display = "block";
    this.hintPopup.style.top = "auto";
    this.hintPopup.style.bottom = "-20px";
  },
  
  
  outed: function(evt) {
    this.globalSwitch = "0";
    this.globalSwitchOff();
  },
  
  outedFromPopup: function(evt) {
    this.globalSwitch = "0";
    this.globalSwitchOff();
  },
  
  
  overdToPopup: function(evt) {
    this.globalSwitch = "1";
    this.globalSwitchOff();
  },
  
  
  closeBtn: function() {
    $("hint_icons").style.display = "none";
  },
  
  
  globalSwitchOff: function() {
    this.clock = setInterval(this.globalSwitchOff_OFF.bind(this), '5');
    
  },
  
  globalSwitchOff_OFF: function() {
    if(this.globalSwitch == '0') {
      $("hint_icons").style.display = "none";
    }
    clearInterval(this.clock);
  },
  
  
  getChildByClassName: function(parentEl, classNm) {
    for(var i=0; i<parentEl.childNodes.length; i++) {
      
      if(parentEl.childNodes[i].className == classNm) {
        return parentEl.childNodes[i];
      }
      else {
        var reqElem = this.getChildByClassName(parentEl.childNodes[i], classNm);
      }
    }
    return reqElem;
  },
  
  
  getChildByTagName: function(parentEl, tagNm) {
    for(var i=0; i<parentEl.childNodes.length; i++) {
      
      if(parentEl.childNodes[i].tagName == tagNm) {
        return parentEl.childNodes[i];
      }
      else {
        var reqElem = this.getChildByClassName(parentEl.childNodes[i], tagNm);
      }
    }
    return reqElem;
  }
  
}












function run() {
  new commonMenu();
  new formchecker('form');
  new autocomplete('search', '');
  new calculatorMenu();
  new subway2('bank_details', 'single');
  new subway2('razvorachivalka', '');
  new mpAdsBlockWidth();
  //new zebra();
  new subway3();
  new iconsHints();
  new iconsHintsMP();
  new assignOverlayBtn();
  
}


evt.add(window, 'load', run);  

