function GetCode()
	{
		var size = parseInt($('#params input[name="size"]:checked').val());
		var type = parseInt($('#params input[name="type"]:checked').val());
		var url  = null;
		switch(type)
		{
		case 1:
			url = "/widget/map/user/"+user_name;
			break;
		case 2:
			url = "/widget/map/user/"+user_name+"/friends";
			break;
		case 21:
			url = "/widget/map/user/"+user_name+"/favourites";
			break;
		case 22:
			url = "/widget/map/user/"+user_name+"/wantgo";
			break;
		case 3:
			url = '/widget/map/places/'+ getCountryVal();
			if (getStateVal() != '')
				url += '/' + getStateVal();
			url += '/'+ getCityVal();
			break;
		case 4:
			url = '/widget/map/places/'+ getCountryVal();
			if (getStateVal() != '')
				url += '/' + getStateVal();
			url += '/'+ getCityVal() + '/' + getAreaVal();
			break;
		}
		url = server_name + url;
		if(size != 300)
			url += "?width=" + size;
		$("#widget_frame").attr('src', url);
		$("#widget_frame").attr('width', size);
		$("#area_code").val("<!-- Begin TrustedPlaces Map Widget -->\n" +
			"<iframe style=\"width:" + size + "px; height:515px; border:none\" scrolling=\"no\" \nsrc=\"" +
			url + "\">\n</iframe>\n<br/>" +
			"Widget by <a href='" + server_name + "'>TrustedPlaces</a>. " +
			"<a href='" + server_name + "/widget/map/get" + "'>Get yours</a>" +
			"<!-- End TrustedPlaces Map Widget -->");
		return false;
	}

	function getCountryVal()
	{
		var country = $('#country :selected').text();
		if (country == '')
			return 'uk';

		switch(country)
		{
			case 'United Kingdom':			country = 'uk'; 	break;
			case 'United States of America':country = 'us'; 	break;
			case 'United Arab Emirates':	country = 'uae'; 	break;
		}
		return alphaNumeric(country.trim());
	}

	function getStateVal()
	{
		if ($('#state').get(0) != undefined)
		{
			var state = $('#state :selected').text();
			// who wants to use javascripts RegExp - welcome... I can't dealing with them
			var arr1 = state.split('(')	;
			var arr2 = arr1[1].split(')');
			return alphaNumeric(arr2[0].trim());
		}
		else
			return '';
	}

	function getCityVal()
	{
		var city = $('#city :selected').text();
		return alphaNumeric(city.trim());
	}

	function getAreaVal()
	{
		if ($('#district').get(0))
		{
			var district = $('#district :selected').text();
			return alphaNumeric(district.trim());
		}
		else
		{
			alert('Districts are available for London, UK only!');
			return '';
		}
	}

	function alphaNumeric(str)
	{
		return str.toLowerCase().replace(/ /g, '-');
	}