isDOM=document.getElementById //DOM1 browser (MSIE 5+, Netscape 6, Opera 5+)
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.*




function openPhoto_(img,wi,he) {
url = "ShowPhoto.asp?img="+img+"&wi="+wi+"&he="+he; 
photo = window.open(url,"photo",'width=100,height=100,left='+(screen.availWidth-wi)/2+',top='+(screen.availHeight-he)/2+'');
return false;
}

function openPhoto(wi,he) {
photo = window.open("about:blank","photo",'width='+(wi+150)+',height='+(he+250));
return true;
}

function openWin(wi,he) {
win = window.open("about:blank","win",'width='+wi+',height='+he+',scrollbars=yes');
return true;
}


function show(i){
	if (isNetscape4) {
		if (o = document.layers["nav"+i]) o.visibility = "visible"
	} else {
	obj = (o = document.getElementById("nav"+i)) ? o : ((o = document.all["nav"+i]) ? o : (0))
	if (obj.filters) {
		obj.style.filter = "blendTrans(duration=0.3)";
		if (obj.filters.length > 0) obj.filters[0].Apply();
	}
	obj.style.visibility = "visible"
	if (obj.filters) if (obj.filters.length > 0) obj.filters[0].Play(); 
	}
}

function hide(i){
	if (isNetscape4) {
		if (o = document.layers["nav"+i]) o.visibility = "hide"
	} else {
	obj = (o = document.getElementById("nav"+i)) ? o : ((o = document.all["nav"+i]) ? o : (0))
	if (obj.filters) {
		obj.style.filter = "blendTrans(duration=0.3)";
		if (obj.filters.length > 0) obj.filters[0].Apply();
	}
	obj.style.visibility = "hidden"
	if (obj.filters) if (obj.filters.length > 0) obj.filters[0].Play(); 
	}
}

var fix = 0
var l=0
var t=0
var wi=0
var he=0
var active=0
var sdvig=0;

mousex = 0
mousey = 0
if(isNetscape4) document.captureEvents(Event.MOUSEMOVE)
if(isMSIE || isOpera7){
  document.onmousemove=function(){
    mousex=event.clientX+document.body.scrollLeft
    mousey=event.clientY+document.body.scrollTop
    MenuUpdate()
    return true
  }
}else if(isOpera){
  document.onmousemove=function(){
    mousex=event.clientX
    mousey=event.clientY
    MenuUpdate()
    return true
  }
}else if(isNetscape4 || isMozilla){
  document.onmousemove=function(e){
    mousex = e.pageX
    mousey = e.pageY
    MenuUpdate()
    return true
  }  
}

function over(i,sdv){
 active = i
 sdvig=sdv;
}

function sover(i){
 active = 0
 fix = i
}

function out(i){
 active = 0;
}

addH = 125
tpositionFlag = new Array()


function MenuUpdate(){
	
	
	if (active) {
		if (fix != active) {
		
			if (fix!=0) hide(fix)
			if (navigator.appName.indexOf('Microsoft') != -1 )
				{boo=0+sdvig}
			else
			{
				brbr=0;
			//	if (isMozilla) {brbr=20;}
				boo=0-sdvig-2*active+brbr;
			
			
			}
				
			if (isNetscape4) {
				if (o = document.layers["nav"+active]) {
					if (!tpositionFlag[active] && addH != 0) {
						tpositionFlag[active] = true
//						o.pageY = o.pageY + addH
						o.pageY = document.layers["nn_point"+active].pageY;
						o.pageX = document.layers["nn_point"+active].pageX
						//alert(document.layers["nn_point"+active].pageX);
					}
					l=o.pageX
					t=o.pageY
					wi=o.document.width
					he=o.document.height
				}
			} else {
				obj = (o = document.getElementById("nav"+active)) ? o : ((o = document.all["nav"+active]) ? o : (0))
				if (obj){
					if (!tpositionFlag[active] && addH != 0) {
						tpositionFlag[active] = true
//						obj.style.top = obj.offsetTop + addH
						obj2= (o = document.getElementById("point"+active)) ? o : ((o = document.all["point"+active]) ? o : (0))
						obj.style.top = obj2.offsetTop+boo
						obj.style.left = obj2.offsetLeft+170
						//alert(obj2.offsetLeft);
					}
//obj2 = (o = document.getElementById("point2")) ? o : ((o = document.all["point2"]) ? o : (0))
//document.forms[0].email.value =obj2.offsetTop
//obj2 = (o = document.getElementById("nnpoint2")) ? o : ((o = document.all["nnpoint2"]) ? o : (0))
//document.forms[0].email.value += "  " + obj2.offsetTop

					l=obj.offsetLeft
					t=obj.offsetTop
					if (isOpera) {
						wi=obj.style.pixelWidth
						he=obj.style.pixelHeight
					} else {
						wi=obj.offsetWidth
						he=obj.offsetHeight
					}
//document.forms[0].email.value = l + " " + t + " " + wi + " " + he
				}
			}
			fix = active			
			show(fix)
		}
	 
	}
	if ((mousex < l || mousex > (l+wi) || mousey < t || mousey > (t+he)) && fix != 0 && fix != active){
		tmp = fix
		setTimeout("if (active!=tmp) {hide(tmp); if (tmp == fix) fix = 0}",5)
	} 
}


function swapOn(name,page){
	obj = document.images[name]
	if (obj.filters) {
		obj.style.filter = "blendTrans(duration=0.25)";
		if (obj.filters.length > 0) obj.filters[0].Apply();
	}
	obj.src = "i/menu/"+page+"/"+name+"a.gif"
	if (obj.filters) if (obj.filters.length > 0) obj.filters[0].Play(); 
}

function swapOff(name,page){
	obj = document.images[name]
	if (obj.filters) {
		obj.style.filter = "blendTrans(duration=0.25)";
		if (obj.filters.length > 0) obj.filters[0].Apply();
	}
	obj.src = "i/menu/"+page+"/"+name+".gif"
	if (obj.filters) if (obj.filters.length > 0) obj.filters[0].Play(); 
}

function back(){
history.back()
return false
}


var starspath='i/stars/';
var starssrc=new Array('1.png','2.png','3.png','4.png','5.png','6.png');  
var stars=new Array();
var curstar=null;
var curstaroffset_x=curstaroffset_y=null;
var starnum=1;
function init()
  {
  var starscont=document.getElementById('stars_container');
  if(starscont)
    {
    create_stars(starscont,3,'',50,-400,200);
    create_stars(starscont,6,350,50,'',200);
    create_stars(starscont,2,'',550,-400,700);
    create_stars(starscont,3,350,550,'',700);
    dh=parseInt(document.body.scrollHeight);
    //alert(dh);
    if(dh>1000)
      {
      create_stars(starscont,5,'',dh-400,-400,dh-100);
      create_stars(starscont,5,350,dh-400,'',dh-100);      
      }
    }
  }
function create_stars(container,num,x1,y1,x2,y2)
  {
  txt1='';
  x1=x1!=''?x1:(-1*parseInt(document.body.clientWidth/2));
  y1=y1!=''?y1:0;
  x2=x2!=''?x2:(parseInt(document.body.clientWidth/2)-78);
  y2=y2!=''?y2:document.body.clientHeight;
  txt1+="1: "+x1+", "+y1+"<br>"+"2: "+x2+", "+y2+"<br><br>";
  for(var i=0;i<num;i++)
    {
    var new_star=document.createElement('div');
    starnum++;
    if(starnum>=starssrc.length)starnum=0;    
    new_star.className='stardiv';
    new_star.style.left=Math.round(x1+Math.random()*(Math.abs(x2-x1)))+"px";
    new_star.style.top=Math.round(y1+Math.random()*(Math.abs(y2-y1)))+"px";
    txt1+="Star"+i+": "+new_star.style.left+", "+new_star.style.top+"<br>";
    new_star.onmousedown=stardrag_start;
    container.appendChild(new_star);
    
    var new_star_img=document.createElement('img');
    new_star_img.src=starspath+starssrc[Math.floor(Math.random()*num)];
    new_star_img.ondragstart=function(){return false;};
    new_star.appendChild(new_star_img);
    }
  //document.write(txt);
  }

function stardrag_start()
  {
  curstar=this;
  if(curstar.tagName!='DIV') alert(curstar.tagName);
  //alert(curstar);
  document.onmouseup=stardrag_stop;  
  document.onmousemove=stardrag_mov;
  return false;
  }

function stardrag_mov(e)
  {  
  var evt=e?e:event;
  if(curstaroffset_x===null)
    {
    var starobj=evt.target?evt.target:evt.srcElement;
    curstaroffset_x=parseInt(evt.clientX)-parseInt(curstar.style.left);
    curstaroffset_y=parseInt(evt.clientY)-parseInt(curstar.style.top);
    }
    
  curstar.style.left=(parseInt(evt.clientX)-curstaroffset_x)+"px";
  curstar.style.top=(parseInt(evt.clientY)-curstaroffset_y)+"px";
  }

function stardrag_stop()
  {
  //alert(1);
  curstar=null;
  document.onmousemove=null;
  document.onmouseup=null;
  curstaroffset_x=curstaroffset_y=null;
  }
window.onload=init;

