function resizebg (flag) {
	var hheader = 290;
	var w = $(window).width();
	var h = $(window).height();
	$("#mainscreen").height(h - 0);
	$("#nework").css("top",h - 220*(h/550) + "px");
	var ch = h-hheader;
	if (ch < 70) ch = 70;
	$("#resplist").css("height", ch + "px");
	$("#resptxt").css("height", ch + "px");
	$("#worklist").css("height", ch + "px");
	$("#maincont").css("height", ch + "px");

	if (w > 1300) {
		var fw = w*0.75;
		var fh = 0.725 * fw;
		var fb = -0.075 * fw;
		$("#flashcont").css("width",fw + "px");
		$("#flashcont").css("height",fh + "px");
		$("#flashcont").css("bottom", fb + "px");
	}

	//alert(w + "/" + h);
	if (w > $("#mainbg").width()) $("#mainbg").width(w);
	if (h > $("#mainbg").height()) $("#mainbg").height(h);
	if (flag) {
		//alert('f');
		//$("#mainbg").fadeOut(1);
		$("#mainbg").css("display","block");
		//$("#mainbg").fadeIn(1500);
	}
}


//-------------------------------------------------------------
// функция проверки обязательных полей
//-------------------------------------------------------------
function CheckReqField(field)
{

	if (typeof(fldreq)!='undefined')
	{

		var k=0;
		for(k=0;k<fldreq.length;k++){
			if(document.getElementById(fldreq[k][0])){
				var block=document.getElementById(fldreq[k][0]);
				switch(fldreq[k][1]){
				case 'input':
					switch(block.type){
						case 'text':
						case 'password':
							if(block.value.length==0){
								alert('Заполните поле - '+fldreq[k][2]);
								DisabledSubmit(true);
								return false;
							}
							break;
						case 'radio':
							var arr_r_name = new Array();
							elem = document.getElementsByTagName('input');
							var i, iarr;
							for( i = 0, iarr = 0; i < elem.length; i++) {
							   var att = elem[i].getAttribute("name");
							   if(att == block.name) {
								   arr_r_name[iarr] = elem[i].checked;
								   iarr++;
							   }
							}
							var j=0;
							for(i=0; i<arr_r_name.length; i++){
								if(arr_r_name[i]==true) j=1;
							}
							if(j==0){
								alert('Выберите - '+ fldreq[k][2]);
								DisabledSubmit(true);
								return false;
							}
							break;
						case 'checkbox':
							if(block.checked==false){
								alert('Выберите - '+ fldreq[k][2]);
								DisabledSubmit(true);
								return false;
							}
							break;
						default:
							break;
					}
				break;
				case 'select':
					if(block.value==''){
						alert('Выберите значение из списка - '+fldreq[k][2]);
						DisabledSubmit(true);
						return false;
					}
				break;
				case 'textarea':
					if(block.value.length==0){
						alert('Заполните поле - '+fldreq[k][2]);
						DisabledSubmit(true);
						return false;
					}
				break;
				default:
				break;
				}
			}//if end
		}//for end


	}//if (typeof(fldreq)!='undefined')

DisabledSubmit(false);

}//function CheckReqField(field)

//---------------------------------------------------------------------------
// функция включает и выключает кнопку отправки
//---------------------------------------------------------------------------
function DisabledSubmit(mod)
{
	return false;

	if (typeof(document.getElementById('mainsubmit'))!='undefined')
	{
		if (document.getElementById('mainsubmit')!=null)
		{
			if (mod)
			{
				document.getElementById('mainsubmit').disabled=true;
			}
			else {
				document.getElementById('mainsubmit').disabled=false;
			}
		}//if (document.getElementById('mainsubmit')!=null)
	}//if (typeof(document.getElementById('MainSubmit'))!='undefined')
	else {

		//alert('error');

	}//else {

}//function (mod)

var FileIdArray = 	new Array;
var divFileClass = 	"divFileClass";

function AddFileField(th)
{

	//дабы не пользовалься всякими гетбуид, однозначно определяем элимент куда будет добавлять
	var Eliment = 		th.parentNode.firstChild;

	//определили название базового элимента
	var FirstName = 	th.parentNode.firstChild.firstChild.firstChild.name;

	var FirstSize = 	th.parentNode.firstChild.firstChild.firstChild.size;

	//определяем начальное положение id по умолчанию
	var j = 0;

	//выставляем начальное положение id
	for(i=0;i<FileIdArray.length;i++)
	{

		//файловое поле уже есть в массиве, возвращаем его id
		if (FileIdArray[i][0] == FirstName)
		{
			j = 	i;
			break;
		}//if (FileIdArray[i][0] == FirstName)

	}//for(i=0;i<nodei.length;i++)

	//будем добавлять поле, для того чтобы не пересекались надо увеличить счетчик
	if (FileIdArray.length > 0)//чтение элиментов
	{
		FileIdArray[j][1]++;
	}//if (j > 0)
	else {//запись элиментов

		//если такого инпут файла ещё небыло, надо добавить его
		j = 	FileIdArray.length;

		FileIdArray[j] = 		new Array;
		FileIdArray[j][0] = 	FirstName;
		FileIdArray[j][1] = 	0;

	}//else {

	var div = 		document.createElement("div");
	div.id = 		FirstName + FileIdArray[j][1] + 'div';

	//div.class = 	divFileClass;
	// Добавляем HTML-контент с пом. свойства innerHTML
	//div.innerHTML = '<input type="file" class="file" name="'+ FirstName + FileIdArray[j][1] +'" id="'+ FirstName + FileIdArray[j][1] +'"><input id type="button" name="button" value="Удалить" onClick="DeleteFileField(this)">';
	//div.innerHTML = '<input type="file" class="file" name="'+ FirstName + FileIdArray[j][1] +'" id="'+ FirstName + FileIdArray[j][1] +'"><input id type="button" name="button" value="X" class=delfile onClick="DeleteFileField(this)">';
	div.innerHTML = '<input type="file" class="file" name="'+ FirstName + FileIdArray[j][1] +'" id="'+ FirstName + FileIdArray[j][1] +'"><img onClick="DeleteFileField(this)" class=delfile src="/i/cform-delfile.png">';
	// Добавляем новый узел в конец списка полей
	Eliment.appendChild(div);

	document.getElementById(FirstName + FileIdArray[j][1]).size = 	FirstSize;

}//function AddFileField()

function ge(id)
{
	if (typeof(document.getElementById(id)) != 'undefined')
	{
		if (document.getElementById(id) != null)
		{
			return document.getElementById(id);
		}
	}
return false;
}

function sform(mod)
{

	if (mod)
	{

		ge('mfrm').style.display = 	"block";

	}//if (mod)
	else {

		ge('mfrm').style.display = 	"none";

	}//else {

}//function sform()


function sformres(mod)
{

	if (mod)
	{

		ge('sformres').style.display = 	"block";

	}//if (mod)
	else {

		ge('sformres').style.display = 	"none";
		window.document.location.href = "/ru/contacts/";

	}//else {

}//function sform()


function del(delelement)
{

  var parent =	delelement.parentNode;
  parent.removeChild(delelement);

}//function del(delelement)

function DeleteFileField(id)
{
	del(id.parentNode);
}//function DeleteFileField(id)

function nomove()
{
}

function ShowImageLikeLiteBox(img)
{
	if ($("#NewLiteBox").length == 0)
	{

		CreateNewLiteBox();

	}//if ($("#NewLiteBox").length == 0)

	var width 	= $(document).width();
	var height	= $(document).height();

	$("#newlitebox").css("width",width).css("height",height).css("opacity","0").show().fadeTo(1500,0.85);

	//if ($.browser.msie) {
	if (true) {

		//alert ('IE');

		$("#newliteboximg").attr("src",img);

		//alert ("Изображение загружено");

		var ImageWidth 		= $("#newliteboximg").width();
		var ImageHeight 	= $("#newliteboximg").height();

		var ImageLeft 		= (width-ImageWidth)/2;
		var ImageTop 		= 30;

		var CloseLeft		= ImageLeft+ImageWidth;
		var CloseTop		= 30;

		$("#newliteboximg").css("left",ImageLeft).css("top",ImageTop).css("opacity","0").show().fadeTo(1000,1,function(data)
		{
			$("#CloseNewListBox").css("left",CloseLeft).css("top",CloseTop).css("opacity","0").show().fadeTo(300,1);
		});

	}
	else {

		$("#newliteboximg").attr("src",img).load(function(data)
		{

			var ImageWidth 		= $("#newliteboximg").width();
			var ImageHeight 	= $("#newliteboximg").height();

			var ImageLeft 		= (width-ImageWidth)/2;
			var ImageTop 		= 30;

			var CloseLeft		= ImageLeft+ImageWidth;
			var CloseTop		= 30;

			$("#newliteboximg").css("left",ImageLeft).css("top",ImageTop).css("opacity","0").show().fadeTo(1000,1,function(data)
			{
				$("#CloseNewListBox").css("left",CloseLeft).css("top",CloseTop).css("opacity","0").show().fadeTo(300,1);
			});

		});

	}

	//alert ($("#newliteboximg").attr("src"));

}//function ShowImageLikeLiteBox(img)

function ShowVimeoLikeLiteBox(img)
{
	if ($("#NewLiteBox").length == 0)
	{

		CreateNewLiteBox();

	}//if ($("#NewLiteBox").length == 0)

	var width 	= $(window).width();
	var height	= $(window).height();

	$("#newlitebox").css("width",width).css("height",height).css("opacity","0").show().fadeTo(1500,0.85);

	//if ($.browser.msie) {
	if (true) {

		var left = Math.ceil((width-640)/2);
		var top = Math.ceil((height-512)/2);	

		$('#litebox_data').html('<iframe src="http://player.vimeo.com/video/'+img+'?title=0&amp;byline=0&amp;portrait=0&amp;color=ffffff&amp;autoplay=1" width="640" height="512" frameborder="0"></iframe>');
		$('#litebox_data').css('position','absolute').css('top',top+'px').css('left',left+'px').css('z-index','10000');
		$('#CloseNewListBox').fadeTo(3500,1).css('top',top+'px').css('left',(left+640)+'px');

	}

	//alert ($("#newliteboximg").attr("src"));

}//function ShowImageLikeLiteBox(img)

function CreateNewLiteBox()
{

 	var my_div = $('<a href="javascript: nomove();" onClick="CloseNewLiteBox()" id="CloseLink"><div id="newlitebox" style="z-index: 9999; position: absolute; top: 0; left: 0; background-color: #000;"></div><span id="litebox_data"><img src="" id="newliteboximg" style="z-index: 10000;  position: absolute; top: 0; left: 0; opacity: 0; display: none;"></span><img id="CloseNewListBox" src="/i/close.png" style="z-index: 10000; position: absolute; top: 0; left: 0; opacity: 0; display: none;"></a>');
	my_div.appendTo("body");

}//function CreateNewLiteBox()

function CloseNewLiteBox()
{

	$("#newliteboximg").attr("src","");
	$("#newlitebox").css("opacity","0").hide();
	$("#newliteboximg").css("opacity","0").hide();
	$("#CloseNewListBox").css("opacity","0").hide();	
	$('#litebox_data').html('');
	$("#NewLiteBox").length = 0;
	
}//function CloseNewLiteBox()

function CloseBanner()
{

	$("#bmain").css("opacity","0").hide();

}//function CloseNewLiteBox()

function ShowJSNews(mod)
{

	var i = DisplayNowNews+1;

	if (i > DisplayStopNews)
	{
		i = 0;
	}//if (i > DisplayStopNews)

	jQuery("#news"+DisplayNowNews).hide();
	var j 	= DisplayNowNews+1;
	jQuery("#news_button_"+DisplayNowNews).attr("src","/i/hdot-p-"+j+".png")

	jQuery("#news"+i).show();
	var j 	= i+1;
	jQuery("#news_button_"+i).attr("src","/i/hdot-a-"+j+".png")


	DisplayNowNews = i;

	timeoutID = setTimeout(function(){ShowJSNews(false);}, DisplayTimer);


}//function ShowJSNews()

function ShowJSNewsNow(i)
{

	clearTimeout(timeoutID);

	jQuery("#news"+DisplayNowNews).hide();
	var j 	= DisplayNowNews+1;
	jQuery("#news_button_"+DisplayNowNews).attr("src","/i/hdot-p-"+j+".png")

	jQuery("#news"+i).show();
	var j 	= i+1;
	jQuery("#news_button_"+i).attr("src","/i/hdot-a-"+j+".png")

	DisplayNowNews = i;

	timeoutID = setTimeout(function(){ShowJSNews(true);}, DisplayTimer);

}//function ShowJSNewsNow()
