﻿function openWindow(url, key, widthVal, heightVal) {
    if (!widthVal) widthVal = 550;
    if (!heightVal) heightVal = 450;

    leftVal = (screen.width - widthVal) / 2;
    topVal = (screen.height - heightVal) / 2;

    parameters = 'status=1,toolbar=0,menubar=0,height=' + heightVal + ',width=' + widthVal + ',left=' + leftVal + ',top=' + topVal + ',scrollbars=1'
    window.open(url, key, parameters);
}

function checkForEnter(e, funEnter, funEsc) {
    if (!e) e = window.event;

    if (e.keyCode == 13 && funEnter) {
        funEnter(); return false;
    }
    else if (e.keyCode == 27 && funEsc) {
   
    funEsc();  return false;
    }
}

 // TabManager управляет отображением 'вкладок'
 function TabManager(containerId)
 {
    this.container_ = $get(containerId);
 }
 
 TabManager.prototype.selectTab = function(tabId)
 {
    var tabToSelect = $get(tabId);
        if (!tabToSelect) return;
             
    for (i = 0; i < this.container_.childNodes.length; i++)
      if (this.container_.childNodes[i].nodeName == "DIV")
        this.container_.childNodes[i].style.display = "none";
    
   tabToSelect.style.display = "block";
 }

 function showDiv(divId) {document.getElementById(divId).style.display = "block";}

 function hideDiv(divId) {document.getElementById(divId).style.display = "none";} 
 
 function validateEmail(email) {
     var expr = new RegExp("^\s*[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\s*$", "i");
     if (expr.test(email)) return true;
     else {alert("Неверный Email адрес");return false;}
 }


 // Equaliation left and right column on main page
 function ShowDim(objectID1,objectID2)
 {
     var el1 = document.getElementById(objectID1);
     var el2 = document.getElementById(objectID2);
     if (el1 && el2)
         el1.style.height = el2.offsetHeight - 65 + 'px';
 }
 
         

  

 