function eget(id)
{
	if (document.all)
	{
		var el = document.getElementById(id) ? document.getElementById(id) : document.all[id];
	}
	else
	{
		var el = document.getElementById(id);
	}

	if (el)
	{
		return el;
	}
	else
	{
		return null;
	}
}

var xmlHttp = getHTTPObject();
function getHTTPObject()
{
	var xmlHttp;
	try
	{
		xmlHttp = new XMLHttpRequest();
	}
	catch(e)
	{
		var XmlHttpVersions = new Array("MSXML2.XMLHTTP.7.0", "MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP");

		for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
		{
			try
			{
				xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
			} catch (e) {}
		}
	}

	if (!xmlHttp) alert("Error creating the XMLHttpRequest object.");
	else return xmlHttp;
}

function process(gourl, eid)
{
	var r = getHTTPObject();
	r.open("GET", gourl);
	r.onreadystatechange =
	function()
	{
		if (r.readyState == 4)
		{
			eget(eid).innerHTML = r.responseText;
			if (eget(eid).innerHTML.length>3456)
			{
				$.scrollTo('#'+eid, 1000);
			}
		}
	}

	r.send(null);
}

function submit_message(lang)
{
	process("/ajax/register.php?from=" + escape(eget("from").value) + "&email=" + eget("email").value + "&text=" + escape(eget("text").value) + "&lang=" + escape(lang) + "&send=1","register");
}

function request(lang)
{
	var request, tmp;
        var arr = new Array ('from', 'phone', 'otinp2', 'surft_imp', 'stypa_inp', 'mail', 'region', 'adres', 'object_type', 'system_type', 'source_type', 'surface_type', 'input1', 'nfloor', 'input2', 'input3', 'input4', 'input5', 'input6', 'text');
		
	for (i=0; i<arr.length; i++)
	{
		try{tmp = '&' + arr[i] +'=' + escape(eget(arr[i]).value);}catch(e){}
		if (tmp.length > 0)
		{
			request = request + tmp;
		}
		tmp = '';
	}
	process('/ajax/request.php?' + 'lang=' + lang + request + '&send=1','request');
//	process('/ajax/request.php?from=' + escape(eget('from').value) + '&phone=' + escape(eget('phone').value) + '&mail=' + escape(eget('mail').value) + '&region=' + escape(eget('region').value) + '&adres=' + escape(eget('adres').value) + '&object_type=' + escape(eget('object_type').value) + '&system_type=' + escape(eget('system_type').value) + '&source_type=' + escape(eget('source_type').value) + '&surface_type=' + escape(eget('surface_type').value) + '&input1=' + escape(eget('input1').value) + '&input2=' + escape(eget('input2').value) + '&input3=' + escape(eget('input3').value) + '&input4=' + escape(eget('input4').value) + '&input5=' + escape(eget('input5').value) + '&text=' + escape(eget('text').value) + '&lang=$lang' + '&send=1','request');
}
function otc()
{
	if (eget("object_type").selectedIndex==3)
	{
		$("#ota").show('medium');
	}
	else
	{
		$("#ota").hide('medium');
	}
}

function stc()
{
//	alert(eget("system_type").value);
	if (eget("system_type").selectedIndex==0)
	{
		$("#sinput1").html('Отапливаемая площадь&nbsp;(м&sup2;):');
		$("#snfloor").show('Количество этажей с ВТП:');
		$("#stype3").hide();
		$("#stype2").hide();
		$("#stype1").show('medium');
	} else if (eget("system_type").selectedIndex==1)
	{
		$("#sinput1").html('Отапливаемая площадь&nbsp;(м&sup2;):');
		$("#snfloor").show('Количество этажей с ВТП:');
		$("#stype3").hide();
		$("#stype1").hide();
		$("#stype2").show('medium');
	} else if (eget("system_type").selectedIndex==2)
	{
		$("#sinput1").html('Отапливаемая площадь&nbsp;(м&sup2;):');
		$("#snfloor").show('Количество этажей с ВТП:');
		$("#stype2").hide();
		$("#stype1").hide();
		$("#stype3").show('medium');
	} else if (eget("system_type").selectedIndex==3)
	{
		$("#sinput1").html('Площадь снеготаяния&nbsp;(м&sup2;):');
		$("#snfloor").hide();
		$("#stype3").hide('medium');
		$("#stype2").hide('medium');
		$("#stype1").hide('medium');
	}
}


function surftc()
{
	if (eget("surface_type").selectedIndex==3)
	{
		$("#surfta").show('medium');
	}
	else
	{
		$("#surfta").hide('medium');
	}
}

function stypc()
{
	if (eget("source_type").selectedIndex==3)
	{
		$("#stypa").show('medium');
	}
	else
	{
		$("#stypa").hide('medium');
	}
}


function inp6c()
{
	if (eget("input6").selectedIndex==1)
	{
		$("#inp60, #inp61").show('medium');
	}
	else
	{
		$("#inp60, #inp61").hide('medium');
	}
}
