var _ISLOAD = false;
var mousex, mousey;
var Seted;
var _close;
var _msg_width;

isDOM = document.getElementById;
isOpera=isOpera5=window.opera && isDOM; //Opera 5+
isOpera6=isOpera && window.print; //Opera 6+
isOpera7=isOpera && document.readyState; //Opera 7+
isMSIE=document.all && document.all.item && !isOpera; //Microsoft Internet Explorer 4+
isMSIE5=isDOM && isMSIE; //MSIE 5+
isNetscape4=document.layers; //Netscape 4.*
isMozilla=isDOM && navigator.appName=="Netscape"; //Mozilla или Netscape 6.*
isFirefox=isDOM && navigator.userAgent.toLowerCase().indexOf('firefox') != -1;


function addLoadEvent(fn) {
      var old = window.onload;
      if (typeof window.onload != 'function') {
         window.onload = fn;
      }
      else {
         window.onload = function() {
         old();
         fn();
         }
      }
   }


document.onmousemove = function _onMove(e) {
 if(!_ISLOAD)
   return false;

 if(!e)
   e = window.event;
   _getmousePos(e);
}




function getBodyScrollTop() {
  return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}
function getBodyScrollLeft() {
  return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
}


document.onclick = function () {
 if(!_ISLOAD)
   return false;

  _unsetId(Seted);
  _unsetId('_closeDiv');
}

function _getmousePos(e) {
   if (!e) 
     e = window.event;

    if (e.pageX || e.pageY) {
     mousex = e.pageX;
     mousey = e.pageY;
    }
  else if (e.clientX || e.clientY) {
    mousex = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
    mousey = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
  }
}


function getEl(el) {
 if(document.getElementById(el))
   return document.getElementById(el);
 else 
   return false;
}

function _unsetId(id) {
  if(getEl(id)) {
    getEl(id).style.left = -1000+'px';
    getEl(id).style.top = -1000+'px';
    getEl(id).style.visibility = 'hidden';  
  }
}




function CheckForm(_alert) {
var arr;
  for(var z=0;z< document.contacts.elements.length;z++)  {
     if(document.contacts.elements[z].type == 'text' || document.contacts.elements[z].type == 'textarea')  {
        arr = document.contacts.elements[z].id.split('_') ;        
        if(document.contacts.elements[z].value == '' && arr[1] != 's')  {
          ttl = document.contacts.elements[z].name;

          alert(_alert+" : " +ttl+"!");
          document.contacts.elements[z].focus();
          return false;
          }
      }

  }
  document.contacts.submit();
}


function focusON (frm, thisname) {
 if ( (frm.value == thisname ) && (frm.defaultValue == thisname) ) frm.value = '';

 frm.className = 'input_auth';
}

function focusOFF (frm, thisname) {
// if ( (frm.value == '' ) && (frm.defaultValue == thisname) ) frm.value = thisname;

 frm.className = thisname;
// frm.className = defaultClass;
}


AC_FL_RunContent = 0; 
DetectFlashVer = 0;

function getElemText(node){
    return node.text || node.textContent || (function(node){
        var _result = "";
        if (node == null) {
            return _result;
        }
        var childrens = node.childNodes;
        var i = 0;
        while (i < childrens.length) {
            var child = childrens.item(i);
            switch (child.nodeType) {
                case 1: // ELEMENT_NODE
                case 5: // ENTITY_REFERENCE_NODE
                    _result += arguments.callee(child);
                    break;
                case 3: // TEXT_NODE
                case 2: // ATTRIBUTE_NODE
                case 4: // CDATA_SECTION_NODE
                    _result += child.nodeValue;
                    break;
                case 6: // ENTITY_NODE
                case 7: // PROCESSING_INSTRUCTION_NODE
                case 8: // COMMENT_NODE
                case 9: // DOCUMENT_NODE
                case 10: // DOCUMENT_TYPE_NODE
                case 11: // DOCUMENT_FRAGMENT_NODE
                case 12: // NOTATION_NODE
                // skip
                break;
            }
            i++;
        }
        return _result;
    }(node));
}

function XmlGetVal(ID) {
   tmp =  response.getElementsByTagName(ID)[0];

   if (tmp.getAttributeNode("val"))
	  return  tmp.getAttributeNode("val").value;
	 else {
		return getElemText(tmp);
	}	
}


function clearForm(form) {
 getEl(form).reset();
}

function sendOrder(form) {
 getEl(form).submit();
}


function checkSc() {
	if (getEl('contentTbl').clientHeight > getEl('contentDiv').clientHeight) {
			getEl('scrollHere').style.visibility = "visible";
			getEl('scrollHere').style.display = "block";
	}
}


//getEl('room'+id).style.filter = 'alpha(opacity=70)';
function _showroom(id) {
getEl('room'+id).style.zIndex = '100';

}

function _hideroom(id) {
getEl('room'+id).style.zIndex = '1';
}


function _resolution() {
  
  if (screen.width == 1024) {
   getEl('topCont').style.width = 1004+'px';
   getEl('topCont').style.overflow = 'hidden';
   if(getEl('state_rootTable'))
   	getEl('state_rootTable').style.width = 1004+'px';
   if(getEl('rooTABLE'))
   	getEl('rooTABLE').style.width = 1004+'px';
  }
  else if (screen.width > 1024) {
   getEl('topCont').style.width = 1259+'px';
   getEl('topCont').style.overflow = 'hidden';
   if(getEl('state_rootTable'))
   	getEl('state_rootTable').style.width = 1259+'px';
   if(getEl('rooTABLE'))
   	getEl('rooTABLE').style.width = 1259+'px';
  }

}

function jumpmenu(URL) {

  if (URL.options[URL.selectedIndex].value != "")
    self.parent.location = URL.options[URL.selectedIndex].value;

  return true;
}

function _opacity(obj, b) {

   if(isMSIE)
		var oAlpha = obj.filters['DXImageTransform.Microsoft.alpha'] || obj.filters.alpha;

  if (b) {
	 obj.style.opacity = 0.7;
 	 if (oAlpha) oAlpha.opacity = 70;
	 else obj.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity=70)";
  }

  else {
	 obj.style.opacity = 1;

 	 if (oAlpha) oAlpha.opacity = 100;
	 else obj.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";   
	 }

}

function _opacity2(obj,b,bot) {

 if(b)
 	obj.className = 'IsImgF'+bot+' iTopBg'+bot;
 else
 	obj.className = 'IsImgF'+bot;
}


function _blact(id,state) {

	if (state) {
	 getEl('lbimg'+id).src 		= '/site/img/la.gif';
	 getEl('cb'+id).className = 'left cba';
	 getEl('rbimg'+id).src 		= '/site/img/ra.gif';
	}
	else {
	 getEl('lbimg'+id).src 		= '/site/img/l.gif';
	 getEl('cb'+id).className = 'left cb';
	 getEl('rbimg'+id).src 		= '/site/img/r.gif';
	}


}


function bookmarksite(title, url) {
if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) window.sidebar.addPanel (title, url, "");
else if (typeof window.external == "object") window.external.AddFavorite(url, title);
else return false;
return true;
}




addLoadEvent( function() {_ISLOAD=true;_resolution(); } ) ;
