startColor = "#8297B5";
endColor = "#FFFFFF";

stepIn = 17;
stepOut = 25;
autoFade = false;
sloppyClass = false;

hexa = new makearray(16);
for(var i = 0; i < 10; i++)
    hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";

document.onmouseover = domouseover;
document.onmouseout = domouseout;

startColor = dehexize(startColor.toLowerCase());
endColor = dehexize(endColor.toLowerCase());

var fadeId = new Array();

function dehexize(Color){
	var colorArr = new makearray(3);
	for (i=1; i<7; i++){
		for (j=0; j<16; j++){
			if (Color.charAt(i) == hexa[j]){
				if (i%2 !=0)
					colorArr[Math.floor((i-1)/2)]=eval(j)*16;
				else
					colorArr[Math.floor((i-1)/2)]+=eval(j);
			}
		}
	}
	return colorArr;
}

function domouseover() {
  if(document.all){
  	var srcElement = event.srcElement;
  	if ((srcElement.tagName == "A" && autoFade) || srcElement.className == "fade" || (sloppyClass && srcElement.className.indexOf("fade") != -1))
        fade(startColor,endColor,srcElement.uniqueID,stepIn);
   }
}

function domouseout() {
  if (document.all){
  	var srcElement = event.srcElement;
    if ((srcElement.tagName == "A" && autoFade) || srcElement.className == "fade" || (sloppyClass && srcElement.className.indexOf("fade") != -1))
        fade(endColor,startColor,srcElement.uniqueID,stepOut);
    }
}

function makearray(n) {
    this.length = n;
    for(var i = 1; i <= n; i++)
        this[i] = 0;
    return this;
}

function hex(i) {
    if (i < 0)
        return "00";
    else if (i > 255)
        return "ff";
    else
       return "" + hexa[Math.floor(i/16)] + hexa[i%16];}

function setColor(r, g, b, element) {
      var hr = hex(r); var hg = hex(g); var hb = hex(b);
      element.style.color = "#"+hr+hg+hb;
}

function fade(s,e, element,step){
	var sr = s[0]; var sg = s[1]; var sb = s[2];
	var er = e[0]; var eg = e[1]; var eb = e[2];

	if (fadeId[0] != null && fade[0] != element){
		setColor(sr,sg,sb,eval(fadeId[0]));
		var i = 1;
		while(i < fadeId.length){
			clearTimeout(fadeId[i]);
			i++;
			}
		}

    for(var i = 0; i <= step; i++) {
    	fadeId[i+1] = setTimeout("setColor(Math.floor(" +sr+ " *(( " +step+ " - " +i+ " )/ " +step+ " ) + " +er+ " * (" +i+ "/" +
			step+ ")),Math.floor(" +sg+ " * (( " +step+ " - " +i+ " )/ " +step+ " ) + " +eg+ " * (" +i+ "/" +step+
			")),Math.floor(" +sb+ " * ((" +step+ "-" +i+ ")/" +step+ ") + " +eb+ " * (" +i+ "/" +step+ ")),"+element+");",i*step);
		}
	fadeId[0] = element;
}


nereidFadeObjects = new Object();
nereidFadeTimers = new Object();
function nereidFade(object, destOp, rate, delta){
if (!document.all)
return
	if (object != "[object]"){  //do this so I can take a string too
	        setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
	        return;}

	    clearTimeout(nereidFadeTimers[object.sourceIndex]);
	    diff = destOp-object.filters.alpha.opacity;
	    direction = 1;
	    if (object.filters.alpha.opacity > destOp){
	    direction = -1;}

	    delta=Math.min(direction*diff,delta);
	    object.filters.alpha.opacity+=direction*delta;
	    if (object.filters.alpha.opacity != destOp){
	    nereidFadeObjects[object.sourceIndex]=object;
	    nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);}}

//
//Разворот списка
//

www = (document.getElementById) ? true : false;
var opened=0;
function list(idname){
var div;
if(!(www||ie4))return;
if(www){
	div=document.getElementById(idname);
}else{
	div=document.all[idname];
}
if(opened){
	opened.style.display='none';
	if(opened==div){opened=0;return false;}
}
div.style.display='block';
opened=div;
return false;
}


//
//Всплывающие подсказки
//

dom = (document.getElementById) ? true : false;
nn4 = (document.layers) ? true : false;
ie = (document.all) ? true : false;
ie4 = ie && !dom;
function empty(){}
if(nn4) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = stdMouseMove;

var stdMouseX = -1, stdMouseY = -1;
var MouseMoved = 0;
var hint="";
var MouseMove = empty;
var Init = empty;

function stdMouseMove(e)
{
	stdMouseX = (nn4) ? (e.pageX):(event.x + document.body.scrollLeft);
	stdMouseY = (nn4) ? (e.pageY):(event.y + document.body.scrollTop);
	MouseMoved++;
	MouseMove(e);
	HintMouseMove();
}


function HintMouseMove()
{
	if(hint)moveElem(hint, stdMouseX-130, stdMouseY+10);
}

function showElem(elemId) {
if (dom) document.getElementById(elemId).style.visibility = "visible";
	else if (ie4) document.all[elemId].style.visibility = "visible";
		else if (nn4) document.layers[elemId].visibility = "show";
}

function hideElem(elemId) {
if (dom) document.getElementById(elemId).style.visibility = "hidden";
	else if (ie4) document.all[elemId].style.visibility = "hidden";
		else if (nn4) document.layers[elemId].visibility = "hide";
}

function moveElem(idname,x,y)
{
if (dom)
	with(eval(idname)){
		style.left = x;
		style.top = y;
	}
else if(nn4){
		document.layers[idname].left=x;
		document.layers[idname].top=y;
	}
}

function OverIm(id)
{
	if(hint)hideElem(hint);
	hint=id;
	moveElem(hint, stdMouseX-130, stdMouseY+10);
	showElem(hint);
}

function OutIm()
{
	hideElem(hint);
	hint="";
}

//
//drop down menu function
//

function GoUrl(s)
{	var d = s.options[s.selectedIndex].value
	window.top.location.href = d
	s.selectedIndex=0
}



//set up layer call
var isIE, isNS, isNS6, isDOM, lR, sR, vis, invis, myTimeOut, goName;
	if (document.all) {isIE= true;lR="document.all.";sR=".style";vis="visible";invis="hidden";}
	if (document.layers){isNS = true;lR="document.layers.";sR="";vis="show";invis="hide";}
	if (document.getElementById &&!isIE) {isDOM=true;lR = "document.getElementById('";sR = "').style";invis ="hidden";vis = "visible"}
	if (isDOM == true && navigator.appName =="Netscape") isNS6 = true;

var oldwhich = 0;
var x=0;
var layerTimer;

//turn on layer and rollover
	function layOver(which)
	{
	x=0;
	l = eval(lR + "l" + which + sR);
	l.visibility = vis;
	oldwhich = which;
	clearTimeout(layerTimer);
	return;
	}

//turn off layer and rollover if user is completely off nav
	function stopOver()
	{
		if (x<5) x++;
		else
		{
		ol = eval(lR + "l" + oldwhich + sR);
		ol.visibility = invis;
		x=0;
		}
	layerTimer = setTimeout("stopOver()",40)
	}

//turn off layer //fix by Skull
	function stopOff(which)
	{
		l = eval(lR + "l" + which + sR);
		l.visibility = invis;
	}

//reset the timer
	function startOver()
	{
	x=0
	clearTimeout(layerTimer);
	}

//change subnav background color (ie5+ ns6+)
	function changebg(item, color)
{
	if (document.getElementById)
	{
	theone = eval("document.getElementById('"+item+"')")
	theone.style.background = color
	}

}


//netscape resize bug fix
function NSresize() {
  if (document.FIX.NSfix.initWindowWidth != window.innerWidth || document.FIX.NSfix.initWindowHeight != window.innerHeight) {
    document.location = document.location;
  }
}

function NSCheck() {
  if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) {
    if (typeof document.FIX == 'undefined'){
      document.FIX = new Object;
    }
    if (typeof document.FIX.FIX_scaleFont == 'undefined') {
      document.FIX.NSfix = new Object;
      document.FIX.NSfix.initWindowWidth = window.innerWidth;
      document.FIX.NSfix.initWindowHeight = window.innerHeight;
    }
    window.onresize = NSresize;
  }
}

NSCheck()


function setUp()
	{
		for (i=1; i < animLayerCount; i++){
		layer = eval(lR + "z" + i + sR);
		if (isIE) layer.pixelLeft = -320;
		else layer.left = -320;
		layer.visibility = vis;
		}
	}

var timer;


function moveIt(whichLayer, toWhere, speed)
{
layer = eval(lR + whichLayer + sR);

if (isIE) theleft = parseInt(layer.pixelLeft)
else theleft = parseInt(layer.left)

// calculate the distance remaining
rDistance = toWhere - theleft;
// set the speed to a fraction of the remaining distance
speed = rDistance * .05;
// create a pocket buffer just a short distance before destination
toWhereBuffer = toWhere - 6;
// if object has not reached the buffer zone
if ( theleft <= 152)
{
	if(isIE) layer.pixelLeft = parseInt(layer.pixelLeft) + speed
	else layer.left = parseInt(layer.left) + speed
}
else
{
	// if object has reached buffer zone, set object to destination
	return;
}
//loop
harold = "\"moveIt('" + whichLayer + "', 172, 2)\"";
eval ("timer= setTimeout(" + harold + ", 1)")

}

function textAnimate (){
	if (goNum >= animLayerCount){
	clearTimeout (myTimeOut);
	return;
	} else {
	goName = "z" + goNum;
	moveIt(goName, 152, 2);
	pauseCount=pauseCount+300;


	if (goName=="z3") pauseCount = 300
	goNum++;
	}
	myTimeOut = setTimeout("textAnimate()", pauseCount);
}


function pickBrowser()
{
if (isIE) moveLayers()
else {location.reload()}
}

var width
function moveLayers()
{
if (isNS || isNS6) width= window.innerWidth
if (isIE) width= document.body.clientWidth

	for (q=1;q<6;q++)
	{
	l = eval(lR + "p" +q+ sR);
	if (q > 1) lOld = eval(lR + "p" + (q-1) + sR)
		if(width > 745)
		{
			if (q==1)
			{
				if (isIE) l.pixelLeft = width-267
				else if (isNS6)l.left = width-267
				else l.left = width-282
			}
			if (q>2)
			{
			if(isIE || isNS6) end = width - 5
			else end = width-20
			start = 312
			middle = end-start
				if(isIE) l.pixelLeft = parseInt(lOld.pixelLeft) + middle/3
				else l.left = parseInt(lOld.left) + middle/3
			}
		}
		else if (width <745)
		{
			if (q==1)
			{
			if(isIE) l.pixelLeft = 476
			else l.left = 476
			}
			if (q>2)
			{
			if(isIE) l.pixelLeft = parseInt(lOld.pixelLeft) + 142
			else l.left = parseInt(lOld.left) + 142
			}
		}
	}
}

function move(form) {
        var i = form.dest.selectedIndex
        location = form.dest.options[i].value
    }


