  function preselectCity(parentId, childId) {
    if ($('#'+ childId +' :checked').size() > 0) {
      $('#'+ parentId +'').attr('checked', 'checked');
      $('#'+ childId +'').slideDown('slow');
    }
  }

	$('document').ready(function(){
  	formUtil.init("form1");
  	formUtil.populate();

    // prop type	
    var segmentid = formUtil.getFormValue('SegmentID');
    var propClass = formUtil.getFormValue('class');
    if (segmentid == "2682685" && propClass != "CON") {
      $('#RadioRES').attr('checked', 'checked');
    }

    // condo search
    $('#RadioCON').click(function() {
      $('#HiddenClass').attr('checked', 'checked');
    });
    $('#RadioRES').click(function() {
      $('#HiddenClass').attr('checked', '');
    });

    // city
    preselectCity('NassauCountyCitiesShow', 'NassauCountyCityList');
    preselectCity('SuffolkCountyCitiesShow', 'SuffolkCountyCityList');
    preselectCity('QueensCountyCitiesShow', 'QueensCountyCityList');
    preselectCity('OtherCountyCitiesShow', 'OtherCountyCityList');

		$('#NassauCountyCitiesShow').click(function(){
				if (this.checked) $('#NassauCountyCityList').slideDown('slow');
				else{
					$('#NassauCountyCityList').slideUp('slow');
					$('#NassauCountyCityList').find('#city').each(function(i){
						CheckBoxUncheck(this);
					});
				}
				$('#NassauCountyCitiesHide').attr("checked",false);
			});
		
		$('#NassauCountyCitiesHide').click(function(){
				$('#NassauCountyCityList').slideUp('slow');
				$('#NassauCountyCitiesShow').attr("checked",false);
				$('#NassauCountyCityList').find('#city').each(function(i){
					CheckBoxUncheck(this);
					});
			});
			
		$('#SuffolkCountyCitiesShow').click(function(){
				if (this.checked) $('#SuffolkCountyCityList').slideDown('slow');
				else{
					$('#SuffolkCountyCityList').slideUp('slow');
					$('#SuffolkCountyCityList').find('#city').each(function(i){
						CheckBoxUncheck(this);
					});
				}
				$('#SuffolkCountyCitiesHide').attr("checked",false);
			});
			
		$('#SuffolkCountyCitiesHide').click(function(){
				$('#SuffolkCountyCityList').slideUp('slow');
				$('#SuffolkCountyCitiesShow').attr("checked",false);
				$('#SuffolkCountyCityList').find('#city').each(function(i){
					CheckBoxUncheck(this);
					});
			});
			
		$('#QueensCountyCitiesShow').click(function(){
				if (this.checked) $('#QueensCountyCityList').slideDown('slow');
				else{
					$('#QueensCountyCityList').slideUp('slow');
					$('#QueensCountyCityList').find('#city').each(function(i){
						CheckBoxUncheck(this);
					});
				}
				$('#QueensCountyCitiesHide').attr("checked",false);
			});
			
		$('#QueensCountyCitiesHide').click(function(){
				$('#QueensCountyCityList').slideUp('slow');
				$('#QueensCountyCitiesShow').attr("checked",false);
				$('#QueensCountyCityList').find('#city').each(function(i){
					CheckBoxUncheck(this);
					});
			});
			
		$('#OtherCountyCitiesShow').click(function(){
				if (this.checked) $('#OtherCountyCityList').slideDown('slow');
				else{
					$('#OtherCountyCityList').slideUp('slow');
					$('#OtherCountyCityList').find('#city').each(function(i){
						CheckBoxUncheck(this);
					});
				}
				$('#OtherCountyCitiesHide').attr("checked",false);
			});
		
		$('#OtherCountyCitiesHide').click(function(){
				$('#OtherCountyCityList').slideUp('slow');
				$('#OtherCountyCitiesShow').attr("checked",false);
				$('#OtherCountyCityList').find('#city').each(function(i){
					CheckBoxUncheck(this);
					});
			});
			
		function CheckBoxUncheck(i)
		{
			i.checked = false;
		}
		
		$('#savedclick').click(function(){
			$('#form1').attr("action","/Summary/SavedSearches.aspx");
			$('#op').attr("value","add");
		});
		
	
	});

