var ie = 0;
var ie6 = 0;
var brie = navigator.userAgent.toLowerCase();
if (brie.indexOf("msie")>-1) ie = 1;
if (brie.indexOf("msie 6")>-1 || brie.indexOf("msie 5")>-1) ie6 = 1;



var zcounter = 100;
var inhand = null;
function n(){}


//Скрипты для управления выпадающим меню
var preload_mn1 = new Image(); preload_mn1.src = '/style/i/a_menu_red.png';
var preload_mn2 = new Image(); preload_mn2.src = '/style/i/a_menu_white.png';
var preload_mn3 = new Image(); preload_mn3.src = '/style/i/a_menu_01.png';
var preload_mn4 = new Image(); preload_mn4.src = '/style/i/a_menu_02.png';
var preload_mn5 = new Image(); preload_mn5.src = '/style/i/a_menu_03.png';

var topmenu = new Array('menu_rus','menueng_service','menueng_events','menueng_partners','menueng_company','menueng_contacts');
function MenuHL (mid) {
	if (document.getElementById('tm'+mid) != null) {
		document.getElementById('mimg_'+mid).src = '/style/i/'+topmenu[mid]+'_a.png';
		if (mid != 0) document.getElementById('tm'+mid).style.display = "block";
	}
}
function MenuDL (mid) {
	if (document.getElementById('tm'+mid) != null) {
		document.getElementById('mimg_'+mid).src = '/style/i/'+topmenu[mid]+'_p.png';
		if (mid != 0) document.getElementById('tm'+mid).style.display = "none";
	}
}
function HLTM (obj, obj2) {
	obj.style.background = "url('/style/i/a_menu_red.png') bottom repeat-x";
	obj.style.color = "#c20002";
	document.getElementById(obj2).style.color = "#c20002";
}
function DLTM (obj, obj2) {
	obj.style.background = "url('/style/i/a_menu_white.png') bottom repeat-x";
	obj.style.color = "#000000";
	document.getElementById(obj2).style.color = "#000000";
}
function GTTM (url, obj2) {
	window.location = url;
}
//Скрипты для подсвечивания списка новостей
var preload_ev1 = new Image(); preload_ev1.src = '/style/i/a_event_red.png';
var preload_ev2 = new Image(); preload_ev2.src = '/style/i/a_arrow.png';
var preload_ev3 = new Image(); preload_ev3.src = '/style/i/a_date_red.png';
function HLEV (obj, id, obj2) {
	obj.style.background = "url('/style/i/a_event_red.png') bottom repeat-x";
	obj.style.color = "#c20002";
	document.getElementById(obj2).style.color = "#c20002";
	document.getElementById(obj2+'b').style.color = "#c20002";
	if (document.getElementById(obj2+'c') != null) document.getElementById(obj2+'c').style.color = "#c20002";
	
	document.getElementById(id+'_ar').src = '/style/i/a_arrow.png';
	document.getElementById(id+'_date').style.background = "url(/style/i/a_date_red.png)";
}
function DLEV (obj, id, obj2) {
	obj.style.background = "url('/style/i/spacer.gif') bottom repeat-x";
	obj.style.color = "#222222";
	document.getElementById(obj2).style.color = "#222222";
	document.getElementById(obj2+'b').style.color = "#222222";
	if (document.getElementById(obj2+'c') != null) document.getElementById(obj2+'c').style.color = "#222222";
	document.getElementById(id+'_ar').src = '/style/i/spacer.gif';
	document.getElementById(id+'_date').style.background = "url(/style/i/a_date_grey.png)";
}
function GTEV (url, obj, id, obj2) {
	obj.style.background = "url('/style/i/spacer.gif') bottom repeat-x";
	obj.style.color = "#222222";
	document.getElementById(obj2).style.color = "#222222";
	document.getElementById(obj2+'b').style.color = "#222222";
	if (document.getElementById(obj2+'c') != null) document.getElementById(obj2+'c').style.color = "#222222";
	document.getElementById(id+'_ar').src = '/style/i/spacer.gif';
	document.getElementById(id+'_date').style.background = "url(/style/i/a_date_grey.png)";
	window.location = url;
}

	function CHL (cid, imgsrc) {
		document.getElementById('clidiv_'+cid).style.background = "url('/style/i/a_redhl.png') repeat-x bottom";
		document.getElementById('client_'+cid).style.color = '#c20002';
		document.getElementById('clientpix_'+cid).src = '/company/footage/cl_'+imgsrc;
	}
	function CDL (cid, imgsrc) {
		document.getElementById('clidiv_'+cid).style.background = "url('/style/i/spacer.gif') repeat-x bottom";
		document.getElementById('client_'+cid).style.color = '#000000';
		document.getElementById('clientpix_'+cid).src = '/company/footage/cl_'+imgsrc;
	}
	function CGT (url, cid, imgsrc) {
		CDL (cid, imgsrc);
		window.location = url;
	}	


function findPosY(id) {
	fobj = document.getElementById(id);
	var curtop = 0;
	while (fobj.offsetParent) { curtop += fobj.offsetTop; fobj = fobj.offsetParent; }
	return curtop;
}
function findPosX(id) {
	fobj = document.getElementById(id);
	var curtop = 0;
	while (fobj.offsetParent) { curtop += fobj.offsetLeft; fobj = fobj.offsetParent;}
	return curtop;
}

//Скрипты для всплывающих картинок
var zoomhand = null;

function Zoomer(zoomid, imageurl, iw, ih){
	this.id = zoomid;
	this.url = imageurl;
	this.imagewidth = iw;
	this.imageheight = ih;
	this.starter = document.getElementById(this.id+'_a');
	this.frame = document.getElementById(this.id+'_div');
	this.cont = document.getElementById(this.id+'_cont');
	this.steps = 14;
	this.timer = null;
	this.x = 0;
	this.y = 0;
	this.downx = 0;
	this.downy = 0;
	this.distx=0;
	this.disty=0;
	this.flag = false;
}

Zoomer.prototype.open = function zoomopen() {
	eval('clobj = ZoomPapa.'+this.id+'.flag');
	if (clobj == false) {
	eval('ZoomPapa.'+this.id+'.flag = true');
	this.img  = new Image(this.imagewidth, this.imageheight);
	this.img.src = this.url;
	this.starterx = findPosX(this.id+'_a');
	this.startery = findPosY(this.id+'_a');
	this.starterw = this.starter.offsetWidth;
	this.starterh = this.starter.offsetHeight;
	this.startx = this.starterx + this.starterw/2;
	this.starty = this.startery + this.starterh/2;
	py = document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
	clh = ie?document.body.parentElement.clientHeight==0?document.body.clientHeight:document.body.parentElement.clientHeight:window.innerHeight;
	this.finaly = py+clh/2;
	if (this.finaly < this.imageheight/2 + 30) this.finaly = this.imageheight/2 + 30;
	this.finalx = document.body.clientWidth / 2;
	this.stepx = (this.finalx - this.startx)/this.steps;
	this.stepy = (this.finaly - this.starty)/this.steps;
	this.stepw = this.imagewidth/this.steps;
	this.steph = this.imageheight/this.steps;
	this.shiftw = 0;
	this.shifth = 0;
	this.opacity = 1;
	this.frame.style.top = parseInt(this.starty - parseInt(this.frame.offsetHeight/2))+'px';
	this.frame.style.left = parseInt(this.startx - parseInt(this.frame.offsetWidth/2))+'px';
	this.frame.style.visibility = 'visible';
	this.frame.style.zIndex = zcounter; zcounter ++;
	zoomhand = this;
	this.img.style.visibility = 'hidden';
	zoom();
	}
}
Zoomer.prototype.close = function zoomclose() {
	zoomhand = this;
	document.onmousemove=null;
	zoomfade();
	eval('ZoomPapa.'+this.id+'.flag = false');
}

function zoomfade() {
	me = zoomhand;
	if (me.opacity < 0.11) {
		me.img.style.visibility = 'hidden';
		me.frame.style.visibility = 'hidden';
		me.cont.removeChild(me.img);
		me.frame.style.opacity = 1;
	}
	if (me.opacity >= 0.11) {
		me.opacity -= 0.1;
		me.frame.style.opacity = me.opacity;
		me.timer = setTimeout('zoomfade()', 20);
	}
}


Zoomer.prototype.control = function zoomcontrol() {
	inhand = this.id;
	document.onmousemove=eventzoommove;
}
Zoomer.prototype.move = function zoommove() {
	inhand = this.id;
	this.frame.style.zIndex = zcounter; zcounter ++;
	dx = this.frame.style.left;
	dy = this.frame.style.top;
	this.distx = this.downx - dx.substring(0,dx.length-2)*1;
	this.disty = this.downy - dy.substring(0,dy.length-2)*1;
	document.onmousemove=eventzoommove2;
}
Zoomer.prototype.demove = function zoomdemove() {
	document.onmousemove=eventzoommove2;
}
Zoomer.prototype.stopcontrol = function zoomstopcontrol() {
	document.onmousemove=null;
}
function eventzoommove(e){
	abj = zoomhand;
	abj.downx = ie?event.x:e.pageX;
	abj.downy = ie?event.y:e.pageY;
	if (ie==1) abj.downy=document.body.scrollTop+abj.downy;
}
function eventzoommove2(e){
	abj = zoomhand;
	abj.x = ie?event.x:e.pageX;
	abj.y = ie?event.y:e.pageY;
	if (ie==1) abj.y=document.body.scrollTop+abj.y;
	abj.frame.style.left=abj.x-abj.distx; abj.frame.style.top=abj.y-abj.disty;
}
function zoom() {
	me = zoomhand;
	if ((me.shifth == me.imageheight) || (me.shiftw == me.imagewidth)) {
		me.cont.appendChild(me.img);
		me.img.style.visibility = 'visible';
	}
	if ((me.shifth+1 < me.imageheight) || (me.shiftw+1 < me.imagewidth)) {
		if (me.shiftw + me.stepw+1 > me.imagewidth) {
			me.shiftw = me.imagewidth;
			me.startx = me.finalx;
		} else {
			me.shiftw += me.stepw; me.startx += me.stepx;
		}
		if (me.shifth + me.steph+1 > me.imageheight) {
			me.shifth = me.imageheight;
			me.starty = me.finaly;
		} else {
			me.shifth += me.steph; me.starty += me.stepy;
		}
		me.cont.style.height = parseInt(me.shifth)+'px';
		me.cont.style.width = parseInt(me.shiftw)+'px';
		me.frame.style.top = parseInt(me.starty - me.frame.offsetHeight/2)+'px';
		me.frame.style.left = parseInt(me.startx - me.frame.offsetWidth/2)+'px';

		me.timer = setTimeout('zoom()', 20);
	}
}



function Chk() {
	chk = document.message_form.form_control.value;
	if (chk == '5') document.getElementById('form_c').style.backgroundColor = '#d3fac2';
	else document.getElementById('form_c').style.backgroundColor = '#ffefed';
	
}
