jQuery(document).ready(function(){

    //Выравниваем высоту левой и правой части
    var left=jQuery('#left').height();
    var center=jQuery('#center_table').height();
    if (left>center) jQuery('#center_table').height(left);


    //Показываем карусльки
    jQuery('ul.listOfItems').show();

    //Двигаем верхнее меню
    jQuery('li.item10 a').mouseover(function(e) {
        var moved=jQuery('li.'+e.relatedTarget.className);
        moved.stop();
        moved.animate({
            'height': 120
        }, 'slow');
    });
		
    jQuery('li.item11 a').mouseover(function(e) {
        var moved=jQuery('li.'+e.relatedTarget.className);
        moved.stop();
        moved.animate({
            'height': 120
        }, 'slow');
    });
		
    jQuery('li.item12 a').mouseover(function(e) {
        var moved=jQuery('li.'+e.relatedTarget.className);
        moved.stop();
        moved.animate({
            'height': 120
        }, 'slow');
    });
		
    jQuery('li.item13 a').mouseover(function(e) {
        var moved=jQuery('li.'+e.relatedTarget.className);
        moved.stop();
        moved.animate({
            'height': 120
        }, 'slow');
    });
		
    jQuery('#top_menu li').mouseout(function(e) {
        var moved=jQuery('#top_menu li');
        moved.stop();
        moved.animate({
            'height': 30
        }, 'slow');
    });
	
	
    //Смена типа недвижимости
    jQuery("select#property_type_sea").change(function(){
        jQuery('select#main_type_sea option:selected').removeAttr('selected');
    });

    //Смена категории
    jQuery("select#main_type_sea").change(function(){
        jQuery('img.loading-sea').show();

        var component = jQuery("select#property_type_sea   option:selected").val();
		var id=jQuery(this).val();
   
        jQuery.getJSON("index2.php",{
            option: 'com_ajax',
			component: component,
            task: 'getTypes',
            id: id,
            no_html: '1'
        }, function(j){
            var options = '<option value="0">Выберите тип</option>';
            for (var i = 0; i < j.length; i++) {
                options += '<option value="' + j[i].catid + '">' + j[i].catname + '</option>';
            }
            jQuery("select#catid_sea").attr("disabled","");
            jQuery("select#catid_sea").html(options);
	  
            jQuery('img.loading-sea').hide();
        })
	
    })
	
    jQuery("select#city_sea").change(function(){
        jQuery('img.loading-sea').show();
         jQuery.getJSON("index2.php",{
            option: 'com_ajax',
            task: 'getStreets',
            city_id: jQuery(this).val(),
            no_html: '1'
        }, function(j){
            var options = '<option value=""></option>';
            for (var i = 0; i < j.length; i++) {
                options += '<option value="' + j[i].streetid + '">' + j[i].streetname + '</option>';
            }
            jQuery("select#street_sea").attr("disabled","");
            jQuery("select#street_sea").html(options);
	  
        })
        jQuery.getJSON("index2.php",{
            option: 'com_ajax',
            task: 'getDistricts',
            city_id: jQuery(this).val(),
            no_html: '1'
        }, function(j){
            var options = '<option value=""></option>';
            for (var i = 0; i < j.length; i++) {
                options += '<option value="' + j[i].disid + '">' + j[i].disname + '</option>';
            }
            jQuery("select#district_sea").attr("disabled","");
            jQuery("select#district_sea").html(options);
            jQuery('img.loading-sea').hide();
        })
	
    })
});


function testInputInSearch()
{
	var form=jQuery('#house_sea');
	if (jQuery('select#main_type_sea option:selected').val()<1) 
	{alert('Заполните все необходимые поля. Недостаточно данных...');return false}
	if (jQuery('select#catid_sea option:selected').val()<1) 
	{alert('Заполните все необходимые поля. Недостаточно данных...');return false}
	
	form.submit();
	return true;
	
}

