function ChangeLanguage(languageCode)
{
	document.cookie =  "LanguageCode = " + escape(languageCode) + "; expires=Mon, 01-Jan-2010 00:00:00 GMT; path=/";
	document.location.reload();
}

function StartList() 
{ 
	CalculateCoordinates();
	window.onresize = CalculateCoordinates;

	if (document.all && document.getElementById) 
	{ 
		var navRoot = document.getElementById("navsub").getElementsByTagName("td"); 
				
		for (var i=0, len=navRoot.length; i<len; i++) 
			if (navRoot[i].className == "MenuItem")
			{
				navRoot[i].onmouseover=function() { this.className+=" over"; } 
				navRoot[i].onmouseout=function() { this.className = this.className.replace (" over", ""); } 
			}
	}
} 

function CalculateCoordinates()
{
	if (document.getElementById)
	{
		var adj = 0;
		if (document.all)
		{
			adj = 2;
		}
		var TDTags = document.getElementsByTagName("TD");
		var c, n, m;
		for (var i = 0; i < TDTags.length; i++)
		{
			if (TDTags[i].id && TDTags[i].id.substring(0,4) == "dddd")
			{
				for (var j = 0; j < TDTags[i].childNodes.length; j++)
				{
					if (TDTags[i].childNodes[j].id && TDTags[i].childNodes[j].id.substring(0,4) == "ssss")
					{
						c =  GetAbsolutePos(TDTags[i]);
						n = c.x + 188 + adj;
						TDTags[i].childNodes[j].style.left = n + "px";
						TDTags[i].childNodes[j].style.top = c.y + "px";
					}
				}
			}
		}
	}
}

function GetAbsolutePos(el)
{
	var SL = 0, ST = 0;
	var is_div = /^div$/i.test(el.tagName);
	if (is_div && el.scrollLeft)
		SL = el.scrollLeft;
	if (is_div && el.scrollTop)
		ST = el.scrollTop;
	var r = { x: el.offsetLeft - SL, y: el.offsetTop - ST };
	if (el.offsetParent)
	{
		var tmp = GetAbsolutePos(el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	}
	return r;
}


function  click_distance()
{
	var url = 'http://www.ruscargoservice.ru/distance/distance.php?simple=yes&bgcolor=FFFFFF&color1=AA0000&color2=000000&title=%C0%EB%FC%F4%E0%F2%F0%E0%ED%F1';
 	var temp = document.distance.from_city.value;
	url += '&from_city=' + temp;  temp = document.distance.to_city.value; url += '&to_city=' + temp;
  	if(document.distance.from_city.value == '' || document.distance.to_city.value == '') 
  	{
    	alert(GetTranslation("no-cities"));
  	} 
  	else 
  		window.open(url, '', 'toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=1, resizable=1, width=700, height=500');
  	return false; 
}

function submit_tc_price()
{
	var form = document.TransportCalculationRequest;
	
	var errorMessage= "";
	
	if (form.formTCLoad.value == "")
	{
		errorMessage += GetTranslation("tcform-no-load") + "\n";
	}

	if (form.formTCRelief.value == "")
	{
		errorMessage += GetTranslation("tcform-no-relief") + "\n";
	}

	if (form.formTCLoadDescription.value == "")
	{
		errorMessage += GetTranslation("tcform-no-loaddescription") + "\n";;
	}

	if (!(form.formTCLoadVolume.value.match(/^[0-9]{1,4}$/)))
	{
		errorMessage += GetTranslation("tcform-no-volume") + "\n";;
	}

	if (form.formTCClientName.value == "")
	{
		errorMessage += GetTranslation("tcform-no-name") + "\n";
	}
	
	if (!(form.formTCEmail.value.match(/^[a-z,0-9]+([-_\.]?[a-z,0-9]+)+@[a-z,0-9]+([-_\.]?[a-z,0-9]+)+\.([a-z]{2,4})$/)))
	{
		errorMessage += GetTranslation("tcform-no-email") + "\n";
	}
	
	if (form.formTCBodyType.value == "0")
	{
		errorMessage += GetTranslation("tcform-no-bodytype") + "\n";
	}

	if (form.formTCLoadType.value == "0")
	{
		errorMessage += GetTranslation("tcform-no-loadtype") + "\n";
	}

	if (errorMessage != "") 
	{
		alert(errorMessage);
		return false;
	}
	else 
		return true;
}