jQuery.noConflict();
    jQuery(document).ready(function(){
    
        jQuery("div.option-two-for-search input,div.option-two-for-search select").attr("disabled","disabled");
        jQuery('div.option-two-for-search').hide();
        
        jQuery('#moxiemaps-search-area-no').click(function () {
            jQuery('#search-table-as-tab').removeClass('table-as-tab2');
            jQuery('#search-table-as-tab').addClass('table-as-tab1');
        
            jQuery("div.option-two-for-search input,div.option-two-for-search select").attr("disabled","disabled");
            jQuery('div.option-two-for-search').hide(); 
            
            jQuery("div.option-one-for-search input,div.option-one-for-search select").removeAttr('disabled');
            jQuery('div.option-one-for-search').show();       
        });
        
        jQuery('#moxiemaps-search-area-yes').click(function () {
            jQuery('#search-table-as-tab').removeClass('table-as-tab1');
            jQuery('#search-table-as-tab').addClass('table-as-tab2');
            
            jQuery("div.option-one-for-search input,div.option-one-for-search select").attr("disabled","disabled");
            jQuery('div.option-one-for-search').hide(); 
            
            jQuery("div.option-two-for-search input,div.option-two-for-search select").removeAttr('disabled');
            jQuery('div.option-two-for-search').show();       
        }); 
        
        jQuery('#adv-search-area-no').click(function () { 
            //hide
            jQuery(".adv-search-area input,.adv-search-area select").attr("disabled","disabled");
            jQuery(".adv-search-area span").addClass('disable-label');
            jQuery('.adv-search-area').hide(); 
            
            update_optionf_on_page();
        });
        
        jQuery('#adv-search-area-yes').click(function () { 
            //show
            jQuery(".adv-search-area input,.adv-search-area select").removeAttr("disabled","disabled");
            jQuery(".adv-search-area span").removeClass('disable-label');
            jQuery('.adv-search-area').show();
            
            update_optionf_on_page();
        }); 
    
        // add listing page
        jQuery('#mtAddCatBt').click(function(event){
            
            var val2 = jQuery("#mod_imwd8mtsuggest_searchword_hcat").val();
            //var txt2 = jQuery("#mod_imwd8mtsuggest_searchword").val();
            var txt2 = jQuery("#mod_imwd8mtsuggest_searchword_hcat :selected").text();  
            
            if(val2==0)
            {
                alert('Please select specialisation you want to add.');
                return false;    
            }
            
            val=val2;
            txt=txt2; 
            
            for(var a = 0; a < document.getElementById('selected-cats_dtree').length; ++a) {
            
                 if(val == document.getElementById('selected-cats_dtree')[a].value) {
                     alert('This category is already added.');
                     return false;
                 }
             }
            
            jQuery('#selected-cats_dtree').append( jQuery("<option></option>").attr("value",val).text(txt) );
            
            var selectedGroups  = new Array();
            for(var a = 0; a < document.getElementById('selected-cats_dtree').length; ++a) {
                selectedGroups.push(document.getElementById('selected-cats_dtree')[a].value); 
            } 
            
            var new_cats = selectedGroups.join(',');
            document.getElementById('other_cats').value = new_cats;
            
            //test alert('Cats= '+document.getElementById('other_cats').value+' | '.document.getElementById('cat_id').value); 
        });
       
        
        jQuery('#mtRemoveCatBt').click(function(event){
            if(document.getElementById('selected-cats_dtree').selectedIndex >= 0) {
                document.getElementById('selected-cats_dtree').options[document.getElementById('selected-cats_dtree').selectedIndex] = null;
                
                var selectedGroups  = new Array();
                for(var a = 0; a < document.getElementById('selected-cats_dtree').length; ++a) {
                    selectedGroups.push(document.getElementById('selected-cats_dtree')[a].value); 
                } 
                
                var new_cats = selectedGroups.join(',');
                document.getElementById('other_cats').value = new_cats;
            }
        });
        
        jQuery("#state").keydown(function(e){
            if(!jQuery("#country").val()) {
                alert('Please choose the country first.');  
                e.preventDefault();  
                jQuery("#state").val('');
            } 
        });
        
        function update_optionf_on_page()
        {
            jQuery(".fields-tool input,.fields-tool select").attr("disabled","disabled");
            jQuery(".fields-tool span").addClass('disable-label');
            jQuery(".fields-tool").hide();
                             
            if(jQuery('[name=cf122]').val()=='' || !jQuery('[name=cf122]').val()) return;
            
            if(jQuery('[name=cf122]').val()=='DOCTORS/PHYSICIANS/PARA-MEDICAL')    
            {
                var i=0; 
                jQuery(".link-name-field span").html("Name:");
            }     
            else
            {
                var i=1;
                jQuery(".link-name-field span").html("Clinic/Hospital Name:");                
            }
            
            for(var x=0; x<(tbl_fields[i]).length; x++)
            {                                        
                if((jQuery("input[name=adv-search-area-radio]:checked").val()==0) && jQuery(".field-cf"+tbl_fields[i][x]).hasClass('adv-search-area')) continue; 
                                                     
                jQuery(".field-cf"+tbl_fields[i][x]+" input,.field-cf"+tbl_fields[i][x]+" select").removeAttr('disabled'); 
                jQuery(".field-cf"+tbl_fields[i][x]+" span").removeClass('disable-label');
                jQuery(".field-cf"+tbl_fields[i][x]).show();
            } 
        }
        
        jQuery('[name=cf122]').change(function(){     
            update_optionf_on_page();                  
        });
        
        update_optionf_on_page(); 
        
        jQuery("a.funny_delete").click(function(){
            jQuery(this).parent().hide();
            //document.adminForm.keep_img.checked = false; 
            jQuery(this).parent().children().next().attr('checked',false);
            jQuery(this).parent().children().next().show();
        });
        
        jQuery('div.users-tab .justtab a').click(function (e) { 
            jQuery('div.users-tab .justtab').removeClass('justactivetab');    
            jQuery(this).parent().addClass('justactivetab');
            
            if(jQuery(this).attr('rel')=='DOCTORS/PHYSICIANS/PARA-MEDICAL')
            {
                jQuery('#cf122').val(jQuery(this).attr('rel')); 
            }
            else
            if(jQuery(this).attr('rel')=='CLINICS/HOSPITALS')
            {
                jQuery('#cf122').val(jQuery(this).attr('rel')); 
            }
            
            update_optionf_on_page();    
            
            e.preventDefault();
        }); 
        
    });
