function selector(selectid1,selectid2,id1,id2,lng)
{
	/*
	var dataString = '';
	jQuery.ajax({
		type: "GET",
		url: "/"+lng+"/properties/getregions/"+id1,
		data: dataString,
		success: function(html) {
			jQuery("#"+selectid1).html(html)
		}
	});
	*/
	
	
	$(document).ready(function(){ 
		$.getJSON(
			"/"+lng+"/properties/getregions/",
			function(data){
			if(id1=='' || id1 == 0)
			{
				$("select."+selectid2).attr("disabled", true);
				$("select."+selectid2).html('<option value="">'+data.regions[1000002].name+'</option>');
			}
			var options = '<option value="0">'+data.regions[1000].name+'</option>';
			
			$.each(data.regions, function(i,item){
				selected = '';
				if(item.id!="1000" && item.id!="1000002")
				{
					if(item.id == id1)selected=" selected"
					options += '<option value="' + item.id + '"'+selected+'>' + item.name + '</option>';
				}
			});
			$("select."+selectid1).html(options);
		});
		var c1 = 0;
		$("select."+selectid1).change(function(){
			$.getJSON(
				"/"+lng+"/properties/getlocations/" + this.value,
				function(data){
					$("select."+selectid2).attr("disabled", true);
					$("select."+selectid2).html('<option value="">'+data.locations[1000003].name+'</option>');
					var options = '<option value="0">'+data.locations[1000001].name+'</option>';
					$.each(data.locations, function(i,item){
						if(item.id!="1000001" && item.id!="1000002" && item.id!="1000003")
						{
							options += '<option value="' + item.id + '">' + item.name + '</option>';
							c1++;
						}
					});
					if(c1>0){
						$("select."+selectid2).html(options);
						$("select."+selectid2).attr("disabled", false);
					} else {
						$("select."+selectid2).attr("disabled", true);
						$("select."+selectid2).html('<option value="">'+data.locations[1000002].name+'</option>');
					}
			});
		});

		if(id1!='' || id1>0)
		{
			var c = 0;
			$.getJSON(
				"/"+lng+"/properties/getlocations/" + id1,
				function(data){
					$("select."+selectid2).html('<option value="">'+data.locations[1000003].name+'</option>');
					var options = '<option value="0">'+data.locations[1000001].name+'</option>';
					//alert( data.locations ); 
					$.each(data.locations, function(i,item){
						if(item.id!="1000001" && item.id!="1000002" && item.id!="1000003")
						{
							selected = '';
							if(item.id == id2)selected=" selected"
							options += '<option value="' + item.id + '"'+selected+'>' + item.name + '</option>';
							c++;
						}
					});
					$("select."+selectid2).html(options);
					$("select."+selectid2).attr("disabled", false);
					/*if(c>0)
					{
						$("select."+selectid2).html(options);
						$("select."+selectid2).attr("disabled", false);
					} else {
						$("select."+selectid2).attr("disabled", true);
						$("select."+selectid2).html('<option value="">'+data.locations[1000002].name+'</option>');
					}*/
			});
		}
		
	}); 

	
	
}


function box(title,url)
{
	$(document).ready(function() {

		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: title,
			'width'			: 680,
			'height'		: 495,
			'href'			: url,
			'type'			: 'iframe'
		});

	});
}
