load_jq = function() {
  load_jq.getScript("http://js.russianpostcalc.ru/js/jquery-1.4.2.min.js");
  load_jq.tryReady(0); // We will write this function later. It's responsible for waiting until jQuery loads before using it.
}

// dynamically load any javascript file.
load_jq.getScript = function(filename) {
  var script = document.createElement('script')
  script.setAttribute("type","text/javascript")
  script.setAttribute("src", filename)
  if (typeof script!="undefined")
  {
	document.getElementsByTagName("head")[0].appendChild(script)
  }
}

load_jq.tryReady = function(time_elapsed)
{
	
	if (typeof $ == "undefined")
	{
		if (time_elapsed <= 50000)
		{
			setTimeout("load_jq.tryReady(" + (time_elapsed + 200) + ")", 200);
		} else
		{
			alert("Timed out while loading jQuery.");
		}
	}else
	{
		rpc_loadnext();
	}
}

function rpc_loadnext()
{
	if (jQuery.isFunction(jQuery.autocomplete))
	{
		
		//alert('skip2');
		jQuery.getScript("http://js.russianpostcalc.ru/form.php");
		jQuery.getScript("http://js.russianpostcalc.ru/js/help.js");
		
	}else
	{
		jQuery.getScript("http://js.russianpostcalc.ru/js/jquery.autocomplete.min.js", function()
		{
			
			
			jQuery.getScript("http://js.russianpostcalc.ru/form.js", function(){

				//alert('dd11');
				if (jQuery("#rpc_href").attr('href')=="http://russianpostcalc.ru/")
				{
						jQuery.getScript("http://js.russianpostcalc.ru/js/help.js", function(){
									//jQuery("#rpc_init").html('<table width=100% border=1><tr><td>sfsdf</td></tr></table>');
								});
				}else
				{
					jQuery("#rpc_init").html(':(');
				}

			});
			
			
			
		});
	}


	
}

if (typeof jQuery == 'undefined')
{
	load_jq();
}else
{
	
	rpc_loadnext();
}




