//-------------------------------------------------------------
// функция проверки обязательных полей
//-------------------------------------------------------------
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)
{

	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.name;

	var FirstSize = 	th.parentNode.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" name="'+ FirstName + FileIdArray[j][1] +'" id="'+ FirstName + FileIdArray[j][1] +'"><input id type="button" name="button" value="Удалить" onClick="DeleteFileField(this)">';
	// Добавляем новый узел в конец списка полей
	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 nomove()
{
}

//-------------------------------------------------------------
// ф-ия для показа инвестиционных проектов
//-------------------------------------------------------------
function showinvest(id)
{
	if (ge('invest_time_'+id).style.display == "none")
	{
		ge('invest_time_'+id).style.display =	"";
		ge('invest_budget_'+id).style.display =	"";
		ge('invest_financ_'+id).style.display =	"";
		ge('invest_descr_'+id).style.display =	"";
		ge('invest_stat_'+id).style.display =	"";
		ge('invest_local_'+id).style.display =	"";
	}
	else {		ge('invest_time_'+id).style.display =	"none";
		ge('invest_budget_'+id).style.display =	"none";
		ge('invest_financ_'+id).style.display =	"none";
		ge('invest_descr_'+id).style.display =	"none";
		ge('invest_stat_'+id).style.display =	"none";
		ge('invest_local_'+id).style.display =	"none";
	}
}//function showinvest(id)


/* getElementByClass
/**********************/
var allHTMLTags = new Array();

function getElementByClass(theClass) {

    //Create Array of All HTML Tags
    var allHTMLTags=document.getElementsByTagName('*');

    //Loop through all tags using a for loop
    for (i=0; i<allHTMLTags.length; i++) {

	    //Get all tags with the specified class name.
	    if (allHTMLTags[i].className==theClass) {

		    //Place any code you want to apply to all
		    //pages with the class specified.
		    //In this example is to “display:none;” them
		    //Making them all dissapear on the page.

		    allHTMLTags[i].style.display='none';

	    }//if (allHTMLTags[i].className==theClass) {

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

}//function getElementByClass(theClass) {