jQuery(document).ready(function() {
	//
	jQuery('.ttl').click(function(){
		hideSelectOptions(window.event);
		if(jQuery(this).parent().attr("class")=="slide-block active")
		{

			jQuery(this).parent().attr("class","slide-block");



			jQuery(this).parent().find('.block').animate({
				opacity: 'hide',
				height: 'hide'
				}, 500, function() {
					jQuery(this).hide();


			});

		}
		else
		{
			jQuery(this).parent().attr("class","slide-block active");
			jQuery(this).parent().find('.block').animate({
				opacity: 'show',
				height: 'show'
				}, 500, function() {
					jQuery(this).show();				
			});			
		}

		return false;
	});	
});
	
function homeSearchOnPriceChange(t)
{
	var src = jQuery("option:selected", t).val();

	var priceto='';
	var pricefrom='';
	switch(src)
	{
		case '1':
			pricefrom='';
			priceto='2000';
			break;
		case '2':
			pricefrom='2000';
			priceto='3000';
			break;
		case '3':
			pricefrom='3000';
			priceto='5000';
			break;
		case '4':
			pricefrom='5000';
			priceto='10000';
			break;
		case '5':
			pricefrom='10000';
			priceto='30000';
			break;									
		case '6':
			pricefrom='30000';
			priceto='100000';
			break;	
		case '7':
			pricefrom='30000';
			priceto='100000';
			break;				
		default:
			pricefrom='';
			priceto='';
	}
	//alert(src+' '+pricefrom+' '+priceto);
	jQuery("#pricefrom").val(pricefrom);
	jQuery("#priceto").val(priceto);	
	
}
function homeSearchOnCountryChange(t)
{
        var src = jQuery("option:selected", t).val();
		jQuery.ajax({
			type : 'POST',
			url : '/chanau/index.php/countrychange/ajax/getRegion/',
			dataType : 'json',
			data: {
				id : src
			},
			success : function(data){
				jQuery('#locality').parent().find('.disabled').css('display','block');
				//jQuery('#region_wine').parent().find('.disabled').css('display','none');
				jQuery('#region_wine').html(data);
				jQuery('#region_wine').parent().find('div').remove();
				//populateSelectOptions(document.getElementById('region_wine'))
				jQuery('#optionsDiv1').remove();
				jQuery('#region_wine').attr('disabled', 'disabled');
			//	jQuery('#region_wine').attr("disabled",'');
				if(data.length>50){
					jQuery('#region_wine').removeAttr("disabled");				
					jQuery('#region_wine').parent().find('.disabled').css('display','none');				
					jQuery('#region_wine').attr('onChange','homeSearchOnRegionChange(this)');				
				}
				//alert(data.length);
				document.getElementById('region_wine').replaced=false;replaceSelects();
				jQuery('#region_wine').parent().find('div').attr("class","selectArea slide-sel");								
				/*jQuery('#region_wine').change(function(){
					homeSearchOnRegionChange(this);
				});*/
				//alert(data);

			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
			}
		});
}

function homeSearchOnRegionChange(t)
{
        var src = jQuery("option:selected", t).val();
		jQuery.ajax({
			type : 'POST',
			url : '/chanau/index.php/countrychange/ajax/getLocality/',
			dataType : 'json',
			data: {
				id : src
			},
			success : function(data){

				jQuery('#locality').parent().find('.disabled').css('display','none');
				jQuery('#locality').html(data);
				jQuery('#locality').parent().find('div').remove();
				//populateSelectOptions(document.getElementById('region_wine'))
				jQuery('#optionsDiv5').remove();
				if(data.length>50)
				{
				jQuery('#locality').removeAttr("disabled");


				jQuery('#locality').parent().find('.disabled').css('display','none');				
				}
				document.getElementById('locality').replaced=false;replaceSelects();
				jQuery('#locality').parent().find('div').attr("class","selectArea slide-sel");												
				//jQuery('#locality').attr('onChange','homeSearchOnRegionChange(this)');
							

				//alert(data.length);

			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
			}
		});
}

