userAgent = window.navigator.userAgent;
browserVers = parseInt(userAgent.charAt(userAgent.indexOf("/")+1),10);
function findElement(n,ly) {
	if (browserVers < 4)		return document[n];
	var curDoc = ly ? ly.document : document;
	var elem = curDoc[n];
	if (!elem) {
		for (var i=0;i<curDoc.layers.length;i++) {
			elem = findElement(n,curDoc.layers[i]);
			if (elem) return elem;
		}
	}
	return elem;
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images) {
		var img;
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			img = null;
			if (document.layers) {
				img = findElement(changeImages.arguments[i],0);
			}
			else {
				img = document.images[changeImages.arguments[i]];
			}
			if (img) {
				img.src = changeImages.arguments[i+1];
			}
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		button_over = newImage("/images/button-over.gif");
		button_s_over = newImage("/images/button_s-over.gif");
		preloadFlag = true;
	}
}


isDOM=document.getElementById //DOM1 browser (MSIE 5+, Netscape 6, Opera 5+)
isMSIE=document.all && document.all.item //Microsoft Internet Explorer 4+
isNetscape4=document.layers //Netscape 4.*
isOpera=window.opera //Opera
isOpera5=isOpera && isDOM //Opera 5+
isMSIE5=isDOM && isMSIE && !isOpera //MSIE 5+
isMozilla=isNetscape6=isDOM && !isMSIE && !isOpera

var obj;
var obj_old;

function getLayer(layerName, parentLayerName){
  if(isDOM){ return document.getElementById(layerName); }
  if(isMSIE){ return document.all[layerName]; }
  if(isNetscape4){ return eval('document.layers[layerName]'); }
  return false;
}

function ts(e,what){
	tc();
  mousex = e.clientX;
  mousey = e.clientY;
  pagexoff = 0;
  pageyoff = 0;
  if(isMSIE5){
    pagexoff = document.body.scrollLeft;
    pageyoff = document.body.scrollTop;
  }
  else{
    pagexoff = window.pageXOffset;
     pageyoff = window.pageYOffset;
  }
  if(getLayer(what)){
    if(isNetscape4)
      obj = getLayer(what);
    else
      obj = getLayer(what).style;

          if(obj){
            leftoff = mousex-pagexoff;
            obj.left = (mousex+pagexoff);

            topoff = mousey-pageyoff;
              obj.top = (mousey+pageyoff) + 20;


            if(isNetscape4)
              obj.visibility = 'show';
            else
              obj.visibility = 'visible';
          }
      obj_old = obj;
   }
  return true;
}

function tc(){
  if(obj_old){
    if(isNetscape4)
      obj_old.visibility = 'hide';
    else
      obj_old.visibility='hidden';
  }
  return true
}

var popUpWin=0;

function popUpWindow(URLStr, left, top, width, height, nameWin) {
  
  popUpWin = popUpWin;
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, nameWin, 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=auto,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}



function getflash(swf_file,swf_width,swf_height) {
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;

    if(plugin){
        plugin=(parseInt(plugin.description.substring(plugin.description.indexOf(".")-1))>=6 || parseInt(plugin.description.substring(plugin.description.indexOf(".")-2)) >=10 );
    }
    else
        if((navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0)&&((navigator.userAgent.indexOf("Windows 95")>=0)||(navigator.userAgent.indexOf("Windows 98")>=0)||(navigator.userAgent.indexOf("Windows NT")>=0))){
            document.write('<'+'script language="VBScript"'+'>\non error resume next\nplugin=(IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8")))\n</'+'script'+'>');
        }

    if(plugin){
        document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+swf_width+'" height="'+swf_height+'"><param name="movie" value="'+swf_file+'"><param name="quality" value="high"><param name="bgcolor" value="#FFFFFF"><embed src="'+swf_file+'" quality="high" bgcolor="#FFFFFF" swLiveConnect="false" width="'+swf_width+'" height="'+swf_height+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object>');
    }
    else {
        document.write('<h2><a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">Нажмите, чтобы установить Flash Player</a></h2>');
    }

}

function NW(url, width, height){
	var namePage;
	if (NW.arguments.length == 4) {
		namePage = NW.arguments[3];
	} else {
		namePage = 'new_window';
	}
	
	window.open(url, namePage, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=' + width + ', height=' + height);
}


function isInteger (s) {
	var i;

	if (isEmpty(s)) {
		if (isInteger.arguments.length == 1) return 0;
		else return (isInteger.arguments[1] == true);
	}
	for (i = 0; i < s.length; i++)
	{
		var c = s.charAt(i);

		if (!isDigit(c)) return false;
	}

	return true;
}

function isEmpty(s) {
	return ((s == null) || (s.length == 0))
}

function isDigit (c) {
	return ((c >= "0") && (c <= "9"))
}
