setTimeout('document.getElementById("content").height = screen.height - 550', 500);

function EmptyForm()
{
    form = document.search;
    form.region.value = 0;
    form.type.value = 0;
    form.opf.value = 0;
    form.ed_level.value = 0;
    form.spec.value = 0;
    form.qualif.value = "";
    form.substr.value = "";
	updateSelectFields(null);
}

function ShowAbout()
{
    document.getElementById("lnk_info").className = 'link';
    document.getElementById("info").className = 'invisible';

    document.getElementById("lnk_about").className = 'bold';
    document.getElementById("about").className = 'visible';

}

function ShowInfo()
{
    document.getElementById("lnk_info").className = 'bold';
    document.getElementById("info").className = 'visible';

    document.getElementById("lnk_about").className = 'link';
    document.getElementById("about").className = 'invisible';
}

function CheckForm()
{
    form = document.gb;

    if ((form.name.value == "") || (form.message.value == ""))
    {
        alert("Заполните все поля отмеченные *");
        return false;
    }
    else
    {
        if (form.email.value != "")
        {
            if (!CheckEmail(form.email.value))
            {
                return false;
            }
        }
    }

    return true;
}


function CheckEmail(email)
{
    var reEmail =
    /^(([\w!#\$%&'\*\+\-\/=\?\^\{\|\}]+(\.[\w!#\$%&'\*\+\-\/=\?\^\{\|\}]+)*)|("((?=[\x20-\x7E])[^"\\]|\\[\x20-\x7E])*"))@(((?:\[\d{1,3}\.\d{1,3}\.\d{1,3}\.)|(?:([\w-]+\.)+))(?:[a-zA-Z]{2,4}|\d{1,3})\]?)$/;

    var matches = email.match(reEmail);
    if (!matches)
    {
        alert("введите корректный email");
        return false;
    }

    return true;
}


function updateSelectFields(selectedId)
{
    var o_town = document.getElementById('town');
    var o_region = document.getElementById('region');

    var selectedRegion = o_region.options[o_region.selectedIndex].value;

    if (selectedRegion == "10301" || selectedRegion == "10201")
    {
        o_town.selectedIndex = 0;
        o_town.disabled = true;
        return;
    }

    o_town.disabled = false;
    o_town.options.length = 0;

    oOption = document.createElement("OPTION");
    oOption.value = towns[0][0];
    oOption.text = towns[0][2];
    o_town.options.add(oOption);
    o_town.selectedIndex = 0;
	
	var count = 1;
	
    for (var i = 1; i < towns.length; i++)
    {
        if (selectedRegion == "0" || towns[i][1] == selectedRegion)
        {
            oOption = document.createElement("OPTION");
            oOption.value = towns[i][0];
            oOption.text = towns[i][2];
            o_town.options.add(oOption);
			
			if (oOption.value == selectedId)
			{
				o_town.selectedIndex = count;
			}
			
			count++;
        }
    }

}