Advertisement
Krypt

AdvanceSearchViewController.m

Feb 28th, 2012
3,135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  AdvanceSearchViewController.m
  3. //  %%%
  4. //
  5. //  Created by %%% on 17/12/08.
  6. //  Copyright 2008 %%%. All rights reserved.
  7. //
  8.  
  9. #import "AdvanceSearchViewController.h"
  10. #import "CellTextField.h"
  11. #import "AdvanceSearchDataSource.h"
  12. #import "CustomRatingPicker.h"
  13. #import "AdvanceSearchPicker.h"
  14.  
  15. #import "BandSearchParser.h"
  16. #import "SongAndBandSearchParser.h"
  17.  
  18. #import "SearchResults.h"
  19.  
  20. #import "DisplaySongsWithBands.h"
  21. #import "DisplaySongDetail.h"
  22. #import "GuitarAppDelegate.h"
  23. #import "DisplayBandSongs.h"
  24. #import "Song.h"
  25. #import "Band.h"
  26. #import "DisplayBands.h"
  27.  
  28. #import "CreateCustomButton.h"
  29.  
  30. #define PARAM_SECTION 3
  31.  
  32. @implementation AdvanceSearchViewController
  33.  
  34. @synthesize  myTableView, songNameTextField , bandNameTextField;
  35. //@synthesize pickerToolBar;
  36. //@synthesize tuningPicker , levelPicker, typePicker , type2Picker;
  37. @synthesize contentView, /*ratingPicker ,*/ searchButton;
  38.  
  39. @synthesize dataSource;
  40.  
  41. @synthesize activeParamsIndex;
  42.  
  43. - (id)init
  44. {
  45.     if (self = [super init])
  46.     {
  47.         // Initialization code
  48.         ////self.title = @"Advance Search";
  49.         /*      UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithTitle:@"Search" style:UIBarButtonItemStyleBordered
  50.          target:self action:@selector(startSearching)];
  51.          self.navigationItem.rightBarButtonItem = barButton;
  52.          [barButton release];
  53.          */
  54.        
  55.         //alreadyUp=NO;
  56.     }
  57.     return self;
  58. }
  59.  
  60. - (id)initWithDataSource:(id<ElementsDataSource>)theDataSource
  61. {
  62.     if ([self init])
  63.     {
  64.         rowH = 0.0;
  65.         self.dataSource = theDataSource;
  66.        
  67.         self.title = [dataSource name];
  68.         self.tabBarItem.image = [dataSource tabBarImage];
  69.        
  70.         self.navigationItem.title=[dataSource navigationBarName];
  71.        
  72.         UIBarButtonItem *temporaryBarButtonItem=[[UIBarButtonItem alloc] init];
  73.         temporaryBarButtonItem.title=@"Back";
  74.         self.navigationItem.backBarButtonItem = temporaryBarButtonItem;
  75.         [temporaryBarButtonItem release];
  76.        
  77.         [AdvanceSearchDataSource sharedAdvanceSearchDataSource];
  78.         alreadyUp=NO;
  79.        
  80.         advParams = [[NSMutableArray alloc] init];
  81.         [advParams addObject:@"0"];
  82.         [advParams addObject:@"1"];
  83.         [advParams addObject:@"2"];
  84.         [advParams addObject:@"3"];
  85.         [advParams addObject:@"4"];
  86.        
  87.         typeMenu = [[NSMutableArray alloc] initWithObjects:@"0", @"0", @"0", nil];
  88.         partMenu = [[NSMutableArray alloc] initWithObjects:@"0", @"0", @"0", @"0", nil];
  89.         ratingMenu = [[NSMutableArray alloc] initWithObjects:@"0", @"0", @"0", @"0", @"0", nil];
  90.         difficultyLevelMenu = [[NSMutableArray alloc] initWithObjects:@"0", @"0", @"0", nil];
  91.         tuningMenu = [[NSMutableArray alloc] initWithObjects:@"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", nil];
  92.        
  93.         self.activeParamsIndex = -1;
  94.         [SharedElements sharedSharedElements].activeParamsIndex = -1;
  95.     }
  96.     return self;
  97. }
  98.  
  99. - (NSString *) name
  100. {
  101.     return @"Advanced";
  102. }
  103.  
  104. - (NSString *) navigationBarName
  105. {
  106.     return @"Advanced Tab Search";
  107. }
  108.  
  109. - (BOOL) showDisclosureIcon
  110. {
  111.     return NO;
  112. }
  113.  
  114. - (UIImage *) tabBarImage
  115. {
  116.     return [UIImage imageNamed:@"2_.png"];
  117. }
  118.  
  119. /*
  120.  Implement loadView if you want to create a view hierarchy programmatically
  121.  */
  122. - (void) loadView
  123. {  
  124.     contentView = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,480)];
  125.     self.view  = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,480)];
  126.    
  127.     /*UIImage *buttonBackgroundPressed = [UIImage imageNamed:@"whiteButton.png"];
  128.     UIImage *buttonBackground = [UIImage imageNamed:@"blueButton.png"];
  129.     self.searchButton = [CreateCustomButton buttonWithTitle:@"SEARCH"
  130.                                 target:self
  131.                                 selector:@selector(startSearching:)
  132.                                 frame: CGRectMake(10.0, 5.0, 280.0,35.0)
  133.                                 image:buttonBackground
  134.                                 imagePressed:buttonBackgroundPressed
  135.                                 darkTextColor:NO];*/
  136.    
  137.     UITableView *tempTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 387) style:UITableViewStyleGrouped];
  138.     //[tempTable setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
  139.     [self.navigationController.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bg_new.png"]]];
  140.     //tempTable.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg_new.png"]];
  141.     self.myTableView = tempTable;
  142.     myTableView.delegate=self;
  143.     myTableView.dataSource=self;
  144.     //myTableView.rowHeight = 43;
  145.     //myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  146.     myTableView.separatorColor = [UIColor clearColor];
  147.     [tempTable release];
  148.  
  149.     UIImage *imgSearchBG = [UIImage imageNamed:@"search-bg2.png"];
  150.     UIImageView *imgSearchBGView = [[UIImageView alloc] initWithImage:imgSearchBG];
  151.     imgSearchBGView.frame = CGRectMake(9.0, 10.0, 302.0, 137.0);
  152.     [myTableView addSubview:imgSearchBGView];
  153.     [imgSearchBGView release];
  154.    
  155.     myTableView.backgroundColor = [UIColor clearColor];
  156.    
  157.     [contentView addSubview:myTableView];
  158.    
  159.     self.bandNameTextField = [self createTextField];
  160.     bandNameTextField.placeholder = @"Band Name";
  161.     bandNameTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
  162.     bandNameTextField.text=@"";
  163.     bandNameTextField.delegate=self;
  164.    
  165.     self.songNameTextField = [self createTextField];
  166.     songNameTextField.placeholder = @"Song Name";
  167.     songNameTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
  168.     songNameTextField.text = @"";
  169.     songNameTextField.delegate=self;
  170.    
  171.     /*pickerToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0,206,320,44)];
  172.  
  173.     UIBarButtonItem *systemItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelPicker:)];
  174.     systemItem.style = UIBarButtonItemStylePlain;
  175.  
  176.     UIBarButtonItem *systemItem1 = [[UIBarButtonItem alloc]
  177.                                                 initWithBarButtonSystemItem:UIBarButtonSystemItemDone
  178.                                                 target:self action:@selector(donePicker:)];
  179.    
  180.     systemItem1.style = UIBarButtonItemStylePlain;
  181.        
  182.     NSArray *items = [NSArray arrayWithObjects: systemItem, systemItem1, nil];
  183.     [systemItem release];
  184.     [systemItem1 release];
  185.    
  186.    
  187.     [pickerToolBar setItems:items animated:NO];
  188.     pickerToolBar.barStyle = UIBarStyleBlackOpaque;
  189.    
  190.     pickerToolBar.hidden=YES;*/
  191.    
  192.     [self.view addSubview:contentView];
  193.    
  194.     //[self.view addSubview:pickerToolBar];
  195.     //[self createPicker];
  196.    
  197.     [contentView release];
  198. }
  199.  
  200. -(void) donePicker:(id)sender
  201. {
  202.     /*pickerToolBar.hidden=YES;
  203.     [self hideAllPickers];
  204.    
  205.     alreadyUp=NO;
  206.     [self setViewMovedUp:NO];
  207.    
  208.     [self.myTableView reloadData];
  209.     [self.myTableView deselectRowAtIndexPath:[self.myTableView indexPathForSelectedRow] animated:YES];*/
  210. }
  211.  
  212. -(void) cancelPicker:(id)sender
  213. {  
  214.     /*if(selectedIndex.row==TUNING_PICKER){
  215.         [tuningPicker resetPickerTicks];
  216.     } else if(selectedIndex.row==TYPE_PICKER){
  217.         [typePicker resetPickerTicks];
  218.     }else if(selectedIndex.row==TYPE2_PICKER){
  219.         [type2Picker resetPickerTicks];
  220.     }else if(selectedIndex.row==RATING_PICKER){
  221.         [ratingPicker resetPickerTicks];
  222.     }else if(selectedIndex.row==DIFFICULTY_PICKER){
  223.         [levelPicker resetPickerTicks];
  224.     }*/
  225.     /*Need to clear all selected values here*/
  226.     /*[[AdvanceSearchDataSource sharedAdvanceSearchDataSource] cancelParametersFor:selectedIndex.row];
  227.     [self hideAllPickers];  
  228.     pickerToolBar.hidden=YES;
  229.     [self setViewMovedUp:NO];
  230.    
  231.     [self.myTableView reloadData];
  232.     [self.myTableView deselectRowAtIndexPath:[self.myTableView indexPathForSelectedRow] animated:YES];*/
  233. }
  234.  
  235. - (void) createPicker
  236. {
  237.     /*CGRect pickerFrame = CGRectMake(0,250,320,230);
  238.    
  239.     tuningPicker = [[AdvanceSearchPicker alloc] initWithType:TUNING_PICKER];
  240.     tuningPicker.frame = pickerFrame;
  241.     [self.view addSubview:tuningPicker];
  242.    
  243.     levelPicker = [[AdvanceSearchPicker alloc] initWithType:DIFFICULTY_PICKER];
  244.     levelPicker.frame = pickerFrame;
  245.     [self.view addSubview:levelPicker];
  246.    
  247.     typePicker = [[AdvanceSearchPicker alloc] initWithType:TYPE_PICKER];
  248.     typePicker.frame = pickerFrame;
  249.     [self.view addSubview:typePicker];
  250.    
  251.     type2Picker = [[AdvanceSearchPicker alloc] initWithType:TYPE2_PICKER];
  252.     type2Picker.frame = pickerFrame;
  253.     [self.view addSubview:type2Picker];
  254.    
  255.     ratingPicker = [[CustomRatingPicker alloc] init];
  256.     ratingPicker.frame = pickerFrame;
  257.     [self.view addSubview:ratingPicker];
  258.    
  259.     [self hideAllPickers];*/
  260. }
  261.  
  262. -(void) hideAllPickers
  263. {
  264.     /*tuningPicker.hidden=YES;
  265.     levelPicker.hidden=YES;
  266.     typePicker.hidden=YES;
  267.     type2Picker.hidden=YES;
  268.     ratingPicker.hidden=YES;*/
  269. }
  270.  
  271. - (UITextField *) createTextField
  272. {  
  273.     CGRect frame = CGRectMake(10.0, 0.0, 280,30);
  274.     UITextField *returnTextField = [[UITextField alloc] initWithFrame:frame];
  275.    
  276.     returnTextField.borderStyle = UITextBorderStyleRoundedRect;
  277.     returnTextField.textColor = [UIColor blackColor];
  278.     returnTextField.font = [UIFont systemFontOfSize:17.0];
  279.     returnTextField.backgroundColor = [UIColor clearColor];
  280.     returnTextField.autocorrectionType = UITextAutocorrectionTypeDefault;   // no auto correction support
  281.     returnTextField.keyboardType = UIKeyboardTypeDefault;   // use the default type input method (entire keyboard)
  282.     returnTextField.returnKeyType = UIReturnKeyDone;
  283.     returnTextField.clearButtonMode = UITextFieldViewModeWhileEditing;  // has a clear 'x' button to the right
  284.  
  285.     return [returnTextField autorelease];
  286. }
  287.  
  288. /*Whenever a row is selected within Type or Type , row number would be incremented and then
  289.  added in the datasource*/
  290. -(void) startSearching:(id) sender
  291. {
  292.     //if ([[SharedElements sharedSharedElements] isInternetAvailable] == NO)
  293.     if ([[SharedElements sharedSharedElements].statusConnection isEqualToString:@"Offline"])
  294.     {
  295.         GuitarAppDelegate *appDelegate = (GuitarAppDelegate*)[[UIApplication sharedApplication] delegate];
  296.         [appDelegate displayAlertOnNetworkError];
  297.     }
  298.     else
  299.     {
  300.     //  [SharedElements sharedSharedElements].isBandSearch = NO;
  301.     //  [SharedElements sharedSharedElements].isSongWithBandSearch =NO;
  302.        
  303.     [[SearchResults sharedSearchResults] resetAllData];
  304.     [[SharedElements sharedSharedElements] setBandName:@""];
  305.     [[SharedElements sharedSharedElements] setSongName:@""];
  306.    
  307.     NSString *bandName = (![bandNameTextField text] || [[bandNameTextField text] isEqualToString:@""]) ? @"" : [bandNameTextField text];
  308.     NSString *songName = (![songNameTextField text] || [[songNameTextField text] isEqualToString:@""]) ? @"" : [songNameTextField text];
  309.    
  310.     BOOL paramSelected = NO;
  311.     BOOL songOrBandNameEntered=YES;
  312.    
  313.     if ([bandName length] > 0)
  314.     {
  315.         [[SharedElements sharedSharedElements] setBandName:bandName];
  316.     }
  317.    
  318.     if ([songName length] >= 3)
  319.     {
  320.         [[SharedElements sharedSharedElements] setSongName:songName];
  321.     }
  322.    
  323.     if ([bandNameTextField.text isEqualToString:@""] && [songNameTextField.text isEqualToString:@""])
  324.     {
  325.         /*UIAlertView* dialog = [[[UIAlertView alloc] init] retain];
  326.         [dialog setDelegate:self];
  327.         [dialog setTitle:@"Notification"];
  328.         [dialog setMessage:@"Fields for search is empty."];
  329.         [dialog addButtonWithTitle:@"OK"];
  330.         [dialog show];
  331.         return;*/
  332.        
  333.         UIAlertView* dialog = [[[UIAlertView alloc] init] retain];
  334.         [dialog setDelegate:self];
  335.         [dialog setTitle:@"Search"];
  336.         [dialog setMessage:@"Please enter search query."];
  337.         [dialog addButtonWithTitle:@"OK"];
  338.         [dialog show];
  339.        
  340.         songOrBandNameEntered = NO;
  341.        
  342.         return;
  343.     }
  344.    
  345.     if ([songNameTextField.text length] >= 1 && [songNameTextField.text length] < 3)
  346.     {
  347.         //Show Alert View Here
  348.         UIAlertView* dialog = [[[UIAlertView alloc] init] retain];
  349.         [dialog setDelegate:self];
  350.         [dialog setTitle:@"Search"];
  351.         [dialog setMessage:@"The song name must be at least 3 letters long."];
  352.         [dialog addButtonWithTitle:@"OK"];
  353.         [dialog show];
  354.         return;
  355.     }
  356.    
  357.     NSString *url = [NSString stringWithFormat: @"http://%%%/search.php?band_name=%@&song_name=%@&iphone=1", bandNameTextField.text, songNameTextField.text];
  358.     NSLog(@"URL BEFORE: \n%@", url);
  359.         //==========
  360.     //Need to create the search url here!
  361.     //NSString *eachParam;
  362.     //NSMutableArray *paramValuesArray;
  363.    
  364.     //NSString *currParamForUrl=@"";
  365.    
  366.     //int index=0;
  367.     //NSString *currParam;
  368.    
  369.     /*for (eachParam in [[AdvanceSearchDataSource sharedAdvanceSearchDataSource] paramNames])
  370.     {
  371.         if (paramValuesArray = [[[AdvanceSearchDataSource sharedAdvanceSearchDataSource] paramSelectedValues] valueForKey:eachParam])
  372.         {
  373.             for (currParam in paramValuesArray)
  374.             {
  375.                 currParamForUrl = [[[AdvanceSearchDataSource sharedAdvanceSearchDataSource] parameterNamesForUrl] objectAtIndex:index];
  376.                 currParamForUrl = [currParamForUrl stringByAppendingString:currParam];
  377.                 url = [url stringByAppendingString:currParamForUrl];
  378.                 paramSelected=YES;
  379.             }
  380.         }
  381.         index++;
  382.     }*/
  383.     //==========
  384.     if ([self paramValueExistsAtIndex:0]) // 200/400/300
  385.     {
  386.         for (int i=0; i<[typeMenu count]; i++)
  387.             if ([[typeMenu objectAtIndex:i] isEqualToString:@"1"])
  388.             {
  389.                 url = [url stringByAppendingString:@"&"];
  390.                 url = [url stringByAppendingString:@"type[]="];
  391.                 if (i==0)
  392.                     url = [url stringByAppendingString:[NSString stringWithFormat:@"%d", 200]];
  393.                 else
  394.                     if (i==1)
  395.                         url = [url stringByAppendingString:[NSString stringWithFormat:@"%d", 400]];
  396.                 else
  397.                     if (i==2)
  398.                         url = [url stringByAppendingString:[NSString stringWithFormat:@"%d", 300]];
  399.                 paramSelected=YES;
  400.             }
  401.         [[SharedElements sharedSharedElements] setTypeMenu:typeMenu];
  402.     }
  403.     if ([self paramValueExistsAtIndex:1])
  404.     {
  405.         for (int i=0; i<[partMenu count]; i++)
  406.             if ([[partMenu objectAtIndex:i] isEqualToString:@"1"])
  407.             {
  408.                 url = [url stringByAppendingString:@"&"];
  409.                 url = [url stringByAppendingString:@"type2[]="];
  410.                 if (i==0)
  411.                     url = [url stringByAppendingString:[NSString stringWithFormat:@"%d", 40000]];
  412.                 else
  413.                     if (i==1)
  414.                         url = [url stringByAppendingString:[NSString stringWithFormat:@"%d", 20000]];
  415.                     else
  416.                         if (i==2)
  417.                             url = [url stringByAppendingString:[NSString stringWithFormat:@"%d", 30000]];
  418.                         else
  419.                             if (i==3)
  420.                                 url = [url stringByAppendingString:[NSString stringWithFormat:@"%d", 10000]];
  421.                 //url = [url stringByAppendingString:[NSString stringWithFormat:@"%d", i+1]];
  422.                 paramSelected=YES;
  423.             }
  424.         [[SharedElements sharedSharedElements] setPartMenu:partMenu];
  425.     }
  426.     if ([self paramValueExistsAtIndex:2])
  427.     {
  428.         for (int i=0; i<[ratingMenu count]; i++)
  429.             if ([[ratingMenu objectAtIndex:i] isEqualToString:@"1"])
  430.             {
  431.                 int h = 0;
  432.                
  433.                 if (i==0) h = 5; else
  434.                 if (i==1) h = 4; else
  435.                 if (i==2) h = 3; else
  436.                 if (i==3) h = 2; else
  437.                 if (i==4) h = 1;
  438.                
  439.                 url = [url stringByAppendingString:@"&"];
  440.                 url = [url stringByAppendingString:@"rating[]="];
  441.                 url = [url stringByAppendingString:[NSString stringWithFormat:@"%d", h]];
  442.                 paramSelected=YES;
  443.             }
  444.         [[SharedElements sharedSharedElements] setRatingMenu:ratingMenu];
  445.     }
  446.     if ([self paramValueExistsAtIndex:3])
  447.     {
  448.         for (int i=0; i<[difficultyLevelMenu count]; i++)
  449.             if ([[difficultyLevelMenu objectAtIndex:i] isEqualToString:@"1"])
  450.             {
  451.                 url = [url stringByAppendingString:@"&"];
  452.                 url = [url stringByAppendingString:@"level[]="];
  453.                 url = [url stringByAppendingString:[NSString stringWithFormat:@"%d", i+1]];
  454.                 //url = [url stringByAppendingString:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].levelParams objectAtIndex:i]];
  455.                 paramSelected=YES;
  456.             }
  457.         [[SharedElements sharedSharedElements] setDifficultyLevelMenu:difficultyLevelMenu];
  458.     }
  459.     if ([self paramValueExistsAtIndex:4])
  460.     {
  461.         for (int i=0; i<[tuningMenu count]; i++)
  462.             if ([[tuningMenu objectAtIndex:i] isEqualToString:@"1"])
  463.             {
  464.                 url = [url stringByAppendingString:@"&"];
  465.                 url = [url stringByAppendingString:@"tuning[]="];
  466.                 url = [url stringByAppendingString:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:i]];
  467.                 paramSelected=YES;
  468.             }
  469.         [[SharedElements sharedSharedElements] setTuningMenu:tuningMenu];
  470.     }
  471.    
  472.     url = [url stringByReplacingOccurrencesOfString:@" " withString:@"+"];
  473.     url = [url stringByReplacingOccurrencesOfString:@"#" withString:@"%23"];
  474.    
  475.     //[SearchResults sharedSearchResults].currentSearchUrl = url;
  476.    
  477.     if (paramSelected == NO && songOrBandNameEntered == NO)
  478.     {
  479.         return;
  480.     }
  481.    
  482.     //url = [url stringByAppendingString:@"&results_format=xml"];
  483.    
  484.     NSLog(@"URL AFTER: \n%@", url);
  485.    
  486.     if (![songNameTextField.text isEqualToString:@""])
  487.     {
  488.         NSLog(@"DISPLAY_MODE_SONGS");
  489.         [SharedElements sharedSharedElements].isSongWithBandSearch = NO;
  490.         [SharedElements sharedSharedElements].searchMode = 1;
  491.         [SearchResults sharedSearchResults].searchMode = SEARCH_MODE_SONG;
  492.         [SearchResults sharedSearchResults].displayMode = DISPLAY_MODE_SONGS;
  493. /*      SongAndBandSearchParser *songAndBandSearchParser = [[SongAndBandSearchParser alloc] init];
  494.         [songAndBandSearchParser search%%%With:url andPage:1 sortMode:0];
  495.         [songAndBandSearchParser release];*/
  496.     }
  497.     else
  498.     {
  499.         if (![bandNameTextField.text isEqualToString:@""])
  500.         {
  501.             if (paramSelected == YES)
  502.             {
  503.                 NSLog(@"DISPLAY_MODE_BANDS");
  504.                 [SharedElements sharedSharedElements].isSongWithBandSearch =NO;
  505.                 [SharedElements sharedSharedElements].searchMode = 1;
  506.                 [SearchResults sharedSearchResults].searchMode = SEARCH_MODE_SONG;
  507.                 [SearchResults sharedSearchResults].displayMode = DISPLAY_MODE_SONGS;
  508.         /*      SongAndBandSearchParser *songAndBandSearchParser = [[SongAndBandSearchParser alloc] init];
  509.                 [songAndBandSearchParser search%%%With:url andPage:1 sortMode:0];
  510.                 [songAndBandSearchParser release];*/
  511.             }
  512.             else
  513.             {
  514.                 NSLog(@"DISPLAY_MODE_BANDS");
  515.                 [SharedElements sharedSharedElements].isBandSearch = NO;
  516.                 [SharedElements sharedSharedElements].searchMode = 2;
  517.                 [SearchResults sharedSearchResults].searchMode = SEARCH_MODE_BAND;
  518.                 [SearchResults sharedSearchResults].displayMode = DISPLAY_MODE_BANDS;
  519.         /*      BandSearchParser *bandSearchParser = [[BandSearchParser alloc] init];
  520.                 [bandSearchParser search%%%With:url andPage:1 sortMode:1];
  521.                 [bandSearchParser release];*/
  522.             }
  523.         }
  524.         else
  525.         {
  526.             //Both are entered
  527.             NSLog(@"SEARCH_MODE_BANDANDSONG");
  528.             [SharedElements sharedSharedElements].isBandSearch = NO;
  529.             [SharedElements sharedSharedElements].searchMode = 2;
  530.             [SearchResults sharedSearchResults].searchMode = SEARCH_MODE_BANDANDSONG;
  531.             //[SearchResults sharedSearchResults].displayMode = DISPLAY_MODE_SONGS;
  532.     /*      SongAndBandSearchParser *songAndBandSearchParser = [[SongAndBandSearchParser alloc] init];
  533.             [songAndBandSearchParser search%%%With:url andPage:1 sortMode:0];
  534.             [songAndBandSearchParser release];*/
  535.         }
  536.     }
  537.    
  538.     /*
  539.     if (![songNameTextField.text isEqualToString:@""] || paramSelected==YES)
  540.     {  
  541.         NSLog(@"DISPLAY_MODE_SONGS");
  542.         [SharedElements sharedSharedElements].searchMode = 1;
  543.         [SearchResults sharedSearchResults].searchMode = SEARCH_MODE_SONG;
  544.         [SearchResults sharedSearchResults].displayMode = DISPLAY_MODE_SONGS;
  545.         SongAndBandSearchParser *songAndBandSearchParser = [[SongAndBandSearchParser alloc] init];
  546.         [songAndBandSearchParser search%%%With:url andPage:1 sortMode:0];
  547.         [songAndBandSearchParser release];
  548.     }
  549.     else
  550.     {
  551.         // comes here only and only IF Band Name is entered.
  552.         NSLog(@"DISPLAY_MODE_BANDS");
  553.         [SharedElements sharedSharedElements].searchMode = 2;
  554.         [SearchResults sharedSearchResults].searchMode = SEARCH_MODE_BAND;
  555.         [SearchResults sharedSearchResults].displayMode = DISPLAY_MODE_BANDS;
  556.         BandSearchParser *bandSearchParser = [[BandSearchParser alloc] init];
  557.         [bandSearchParser search%%%With:url andPage:1 sortMode:1];
  558.         [bandSearchParser release];
  559.     }
  560.    
  561.     if (![songNameTextField.text isEqualToString:@""] && ![bandNameTextField.text isEqualToString:@""])
  562.     {
  563.         //Both are entered
  564.         NSLog(@"SEARCH_MODE_BANDANDSONG");
  565.         [SearchResults sharedSearchResults].searchMode = SEARCH_MODE_BANDANDSONG;
  566.         [SharedElements sharedSharedElements].searchMode = 2;
  567.     }*/
  568.    
  569.     //[SharedElements sharedSharedElements].activeParamsIndex = self.activeParamsIndex;
  570.         [SharedElements sharedSharedElements].selParam = paramSelected;
  571.         [SearchResults sharedSearchResults].currentSearchUrl = url;
  572.     [self displaySearchResults];
  573.     }
  574. }
  575.  
  576. -(void) searchInfo
  577. {
  578.     BOOL paramSelected = [SharedElements sharedSharedElements].selParam;
  579.     NSString *url = [SearchResults sharedSearchResults].currentSearchUrl;
  580.    
  581.     if (![[[SharedElements sharedSharedElements] getSongName] isEqualToString:@""])
  582.     {
  583.         NSLog(@"DISPLAY_MODE_SONGS");
  584.         SongAndBandSearchParser *songAndBandSearchParser = [[SongAndBandSearchParser alloc] init];
  585.         [songAndBandSearchParser search%%%With:url andPage:1 sortMode:0];
  586.         [songAndBandSearchParser release];
  587.     }
  588.     else
  589.     {
  590.         if (![[[SharedElements sharedSharedElements] getBandName] isEqualToString:@""])
  591.         {
  592.             if (paramSelected == YES)
  593.             {
  594.                 SongAndBandSearchParser *songAndBandSearchParser = [[SongAndBandSearchParser alloc] init];
  595.                 [songAndBandSearchParser search%%%With:url andPage:1 sortMode:0];
  596.                 [songAndBandSearchParser release];
  597.             }
  598.             else
  599.             {
  600.                 BandSearchParser *bandSearchParser = [[BandSearchParser alloc] init];
  601.                 [bandSearchParser search%%%With:url andPage:1 sortMode:1];
  602.                 [bandSearchParser release];
  603.             }
  604.         }
  605.         else
  606.         {
  607.             //Both are entered
  608.             //[SearchResults sharedSearchResults].displayMode = DISPLAY_MODE_SONGS;
  609.             SongAndBandSearchParser *songAndBandSearchParser = [[SongAndBandSearchParser alloc] init];
  610.             [songAndBandSearchParser search%%%With:url andPage:1 sortMode:0];
  611.             [songAndBandSearchParser release];
  612.         }
  613.     }
  614. }
  615.  
  616. /*Copied Exactly From SimpleSearch*/
  617. - (void) displaySearchResults
  618. {
  619.     @try
  620.     {
  621.     //[songNameTextField setText:@""];
  622.     //[bandNameTextField setText:@""];
  623.     [[AdvanceSearchDataSource sharedAdvanceSearchDataSource] clearAll];
  624.    
  625.     //Remove Picker Ticks As Well
  626.     /*[tuningPicker resetPickerTicks];
  627.     [levelPicker resetPickerTicks];
  628.     [typePicker resetPickerTicks];
  629.     [type2Picker resetPickerTicks];
  630.     [ratingPicker resetPickerTicks];*/
  631.    
  632.     [self.myTableView reloadData];
  633. /*  if([[SearchResults sharedSearchResults] didParseErrorOccur])
  634.     {
  635.         GuitarAppDelegate *appDelegate = (GuitarAppDelegate*)[[UIApplication sharedApplication] delegate];
  636.         [appDelegate displayAlertOnNoResultFound];
  637.         [SearchResults sharedSearchResults].noResultsFound = NO;
  638.         //[appDelegate displayAlertOnNetworkError];
  639.         return;
  640.     }
  641.    
  642.     if([[SearchResults sharedSearchResults] noResultsFound])
  643.     {
  644.         GuitarAppDelegate *appDelegate = (GuitarAppDelegate*)[[UIApplication sharedApplication] delegate];
  645.         [appDelegate displayAlertOnNoResultFound];
  646.         [SearchResults sharedSearchResults].noResultsFound = NO;
  647.         return;
  648.     }*/
  649.    
  650.     if([SearchResults sharedSearchResults].searchMode == SEARCH_MODE_BAND)
  651.     {  
  652.         if([SearchResults sharedSearchResults].displayMode == DISPLAY_MODE_SONGS)
  653.         {
  654.             Band *tempBand = [[[SearchResults sharedSearchResults] bandObjects] objectAtIndex:0];
  655.             [self displaySongForBandName:tempBand.bandName];
  656.             return;
  657.         }
  658.        
  659.         if ([[[SearchResults sharedSearchResults] bandObjects] count] == 1)
  660.         {  
  661.             [SearchResults sharedSearchResults].displayMode = DISPLAY_MODE_SONGS;
  662.            
  663.             NSLog(@"Display Mode is Now %@" , [SearchResults sharedSearchResults].displayMode);
  664.             Band *tempBand = [[[SearchResults sharedSearchResults] bandObjects] objectAtIndex:0];
  665.             SongAndBandSearchParser *songAndBandSearchParser = [[SongAndBandSearchParser alloc] init];
  666.             [songAndBandSearchParser search%%%With:tempBand.url andPage:1 sortMode:0];
  667.             [self displaySongForBandName:tempBand.bandName];
  668.             [songAndBandSearchParser release];         
  669.         }
  670.         else
  671.         {
  672.             DisplayBands *allBands = [[DisplayBands alloc] initWithStyle:UITableViewStylePlain];
  673.             [self.navigationController pushViewController:allBands animated:YES];
  674.             [allBands release];
  675.         }
  676.        
  677.        
  678.     }
  679.     else
  680.         if([SearchResults sharedSearchResults].searchMode == SEARCH_MODE_SONG || [SearchResults sharedSearchResults].searchMode == SEARCH_MODE_BANDANDSONG)
  681.         {
  682.             if ([[[SearchResults sharedSearchResults] songObjects] count] == 1)
  683.             {
  684.                 DisplaySongDetail *songTabsList = [[DisplaySongDetail alloc] initWithStyle:UITableViewStylePlain];
  685.                 songTabsList.songName = [(Song*)[[[SearchResults sharedSearchResults] songObjects] objectAtIndex:0] songName];
  686.                 songTabsList.songArtist = [(Song*)[[[SearchResults sharedSearchResults] songObjects] objectAtIndex:0] songArtist];
  687.                 songTabsList.title = [NSString stringWithFormat:@"%@ Tabs", songTabsList.songName];
  688.                 [self.navigationController.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bg_new.png"]]];
  689.                 [self.navigationController pushViewController:songTabsList animated:YES];
  690.                 [songTabsList release];
  691.             }
  692.             else
  693.             {
  694.                 DisplaySongsWithBands *tempView = [[DisplaySongsWithBands alloc] initWithStyle:UITableViewStylePlain];
  695.                 [self.navigationController.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bg_new.png"]]];
  696.                 [self.navigationController pushViewController:tempView animated:YES];
  697.                 [tempView release];
  698.             }
  699.         }
  700.     else
  701.     {
  702.        
  703.         NSLog(@"Yikes !! Error in Search Mode !!!!");
  704.     }
  705.  
  706.     }
  707.     @catch (NSException *exception)
  708.     {
  709.         NSLog (@"!!! Caught %@%@", [exception name], [exception reason]);
  710.     }
  711. }
  712.  
  713. -(void) displaySongForBandName:(NSString*)name
  714. {  
  715.     DisplayBandSongs *temp = [[DisplayBandSongs alloc] initWithStyle:UITableViewStylePlain];
  716.     temp.band = name;
  717.     [self.navigationController pushViewController:temp animated:YES];
  718.     [temp release];
  719. }
  720.  
  721. -(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  722. {
  723.     if (section==0)
  724.     {
  725.         //tableView.separatorColor = [UIColor clearColor];
  726.         tableView.sectionHeaderHeight = 19;
  727.         tableView.sectionFooterHeight = 9;
  728.     }
  729.     else
  730.         if (section==1)
  731.         {
  732.             //tableView.separatorColor = [UIColor clearColor];
  733.             tableView.sectionHeaderHeight = 0;
  734.             tableView.sectionFooterHeight = 0;         
  735.         }
  736.         else
  737.             if (section==2)
  738.             {
  739.                 //tableView.separatorColor = [UIColor clearColor];
  740.                 tableView.sectionHeaderHeight = 10;
  741.                 tableView.sectionFooterHeight = 12;        
  742.             }
  743.            
  744.     return 10.0;
  745. }
  746.  
  747. -(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  748. {
  749.     if (indexPath.section==0 || indexPath.section==1)
  750.         return 30.0;
  751.     else
  752.     if (indexPath.section==2)
  753.         return 35.0;
  754.     else
  755.     {
  756.         if (self.activeParamsIndex == 0)
  757.         {
  758.             if (indexPath.row > 0 && indexPath.row <= 3)
  759.             {
  760.                 return 35.0;
  761.             }
  762.         }
  763.         if (self.activeParamsIndex == 1)
  764.         {
  765.             if (indexPath.row > 1 && indexPath.row <= 5)
  766.             {
  767.                 return 35.0;
  768.             }
  769.         }
  770.         if (self.activeParamsIndex == 2)
  771.         {
  772.             if (indexPath.row > 2 && indexPath.row <= 7)
  773.             {
  774.                 return 35.0;
  775.             }
  776.         }
  777.         if (self.activeParamsIndex == 3)
  778.         {
  779.             if (indexPath.row > 3 && indexPath.row <= 6)
  780.             {
  781.                 return 35.0;
  782.             }
  783.         }
  784.         if (self.activeParamsIndex == 4)
  785.         {
  786.             if (indexPath.row > 4 && indexPath.row <= 19)
  787.             {
  788.                 return 35.0;
  789.             }
  790.         }          
  791.  
  792.         return 43.0;
  793.     }
  794. }
  795.  
  796. -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView
  797. {
  798.     return 4;
  799. }
  800.  
  801. -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  802. {
  803.     if (section == PARAM_SECTION)
  804.     {
  805.         return [advParams count];
  806.         /*if (self.activeParamsIndex == 1)
  807.         {
  808.             return [advParams count];
  809.            
  810.         }
  811.         else
  812.         if (self.activeParamsIndex == -1)
  813.         {
  814.             return [advParams count];
  815.            
  816.         }*/
  817.     }
  818.    
  819.     return 1;
  820. }
  821.  
  822. -(void) setStars:(UITableViewCell *)aCell atIndex:(int)ind_
  823. {
  824.     int min = [self getMinArrayIndex:2];
  825.    
  826.     UIImage *img;
  827.     UIImageView *imgV;
  828.     UILabel *lbl;
  829.    
  830.     if (min == 0)
  831.     {
  832.         img = [[UIImage imageNamed:@"5s.png"] retain];
  833.     }
  834.     else
  835.         if (min == 1)
  836.         {
  837.             img = [[UIImage imageNamed:@"4s.png"] retain];
  838.             //imgV = [[UIImageView alloc] initWithFrame:CGRectMake(72.0, 15.0, 58.0, 13.0)];
  839.         }
  840.         else
  841.             if (min == 2)
  842.             {
  843.                 img = [[UIImage imageNamed:@"3s.png"] retain];
  844.                 //imgV = [[UIImageView alloc] initWithFrame:CGRectMake(72.0, 15.0, 43.0, 13.0)];
  845.             }
  846.             else
  847.                 if (min == 3)
  848.                 {
  849.                     img = [[UIImage imageNamed:@"2s.png"] retain];
  850.                     //imgV = [[UIImageView alloc] initWithFrame:CGRectMake(72.0, 15.0, 28.0, 13.0)];
  851.                 }
  852.                 else
  853.                     if (min == 4)
  854.                     {
  855.                         img = [[UIImage imageNamed:@"1s.png"] retain];
  856.                         //imgV = [[UIImageView alloc] initWithFrame:CGRectMake(72.0, 15.0, 13.0, 13.0)];
  857.                     }
  858.    
  859.     //imgV.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
  860.     imgV = [[UIImageView alloc] initWithFrame:CGRectMake(115.0, 15.0, 75.0, 13.0)];
  861.     [imgV setContentMode:UIViewContentModeRight];
  862.    
  863.     if (min == 0)
  864.     {
  865.         imgV.frame = CGRectMake(193.0, 15.0, 75.0, 13.0);
  866.     }
  867.    
  868.     imgV.image = img;
  869.    
  870.     lbl = [[UILabel alloc] init];
  871.     lbl.frame = CGRectMake(97.0f, 9.0f, 181.0f, 30.0f);
  872.     [lbl setText:@"AND HIGHER"];
  873.     [lbl setTextAlignment:UITextAlignmentRight];
  874.     [lbl setFont: [UIFont fontWithName:@"Arial-BoldMT" size:11.0f]];
  875.     [lbl setTextColor:[UIColor colorWithRed:61.0/255.0 green:96.0/255.0 blue:131.0/255.0 alpha:1.0]];
  876.     [lbl setBackgroundColor:[UIColor clearColor]];
  877.    
  878.     if (min != 0)
  879.         [aCell addSubview:lbl];
  880.    
  881.     [aCell.contentView addSubview:imgV];
  882.  
  883.     [lbl release];
  884.     [img release];
  885.     [imgV release];
  886. }
  887.  
  888. -(void) setLabels:(UITableViewCell *)aCell atIndex:(int)ind_
  889. {
  890.     UILabel *params = [[UILabel alloc] init];
  891.    
  892.     /*if (ind_ == 0)
  893.         params.frame = CGRectMake(66.0f, 8.0f, 200.0f, 30.0f);
  894.     else
  895.     if (ind_ == 1)
  896.         params.frame = CGRectMake(63.0f, 8.0f, 200.0f, 30.0f);
  897.     else
  898.     if (ind_ == 2)
  899.         params.frame = CGRectMake(79.0f, 8.0f, 200.0f, 30.0f);
  900.     else
  901.     if (ind_ == 3)
  902.         params.frame = CGRectMake(146.0f, 8.0f, 140.0f, 30.0f);
  903.     else
  904.     if (ind_ == 4)
  905.         params.frame = CGRectMake(83.0f, 8.0f, 200.0f, 30.0f);*/
  906.    
  907.     params.frame = CGRectMake(97.0f, 9.0f, 181.0f, 30.0f);
  908.     params.textAlignment = UITextAlignmentRight;
  909.    
  910.     [params setText:[[self getParamString:ind_] uppercaseString]];
  911.     [params setFont: [UIFont fontWithName:@"Arial-BoldMT" size:11.0f]];
  912.     //[params setFont: [UIFont boldSystemFontOfSize:14.0f]];
  913.     [params setTextColor:[UIColor colorWithRed:61.0/255.0 green:96.0/255.0 blue:131.0/255.0 alpha:1.0]];
  914.     params.highlightedTextColor = [UIColor whiteColor];
  915.     [params setBackgroundColor:[UIColor clearColor]];
  916.     [aCell addSubview:params];
  917.     [params release];
  918. }
  919.  
  920. -(void) setImages:(UITableViewCell *)aCell atIndex:(int)ind_
  921. {  
  922.     UIImage *img;
  923.     UIImageView *imgV;
  924.    
  925.     if (ind_ == 3)
  926.     {
  927.         if ([[ratingMenu objectAtIndex:0] isEqualToString:@"0"])
  928.         {
  929.             img = [[UIImage imageNamed:@"5bw.png"] retain];
  930.             imgV = [[UIImageView alloc] initWithFrame:CGRectMake(10.0, 8.0, 111.0, 18.0)];
  931.         }
  932.         else
  933.         {
  934.             img = [[UIImage imageNamed:@"5.png"] retain];
  935.             imgV = [[UIImageView alloc] initWithFrame:CGRectMake(10.0, 8.0, 111.0, 18.0)];
  936.         }
  937.     }
  938.     else
  939.         if (ind_ == 4)
  940.         {
  941.             if ([[ratingMenu objectAtIndex:1] isEqualToString:@"0"])
  942.             {
  943.                 img = [[UIImage imageNamed:@"4bw.png"] retain];
  944.                 imgV = [[UIImageView alloc] initWithFrame:CGRectMake(10.0, 8.0, 111.0, 18.0)];
  945.             }
  946.             else
  947.             {
  948.                 img = [[UIImage imageNamed:@"4.png"] retain];
  949.                 imgV = [[UIImageView alloc] initWithFrame:CGRectMake(10.0, 8.0, 111.0, 18.0)];
  950.             }
  951.         }
  952.         else
  953.             if (ind_ == 5)
  954.             {
  955.                 if ([[ratingMenu objectAtIndex:2] isEqualToString:@"0"])
  956.                 {
  957.                     img = [[UIImage imageNamed:@"3bw.png"] retain];
  958.                     imgV = [[UIImageView alloc] initWithFrame:CGRectMake(10.0, 8.0, 111.0, 18.0)];
  959.                 }
  960.                 else
  961.                 {
  962.                     img = [[UIImage imageNamed:@"3.png"] retain];
  963.                     imgV = [[UIImageView alloc] initWithFrame:CGRectMake(10.0, 8.0, 111.0, 18.0)];
  964.                 }
  965.             }
  966.             else
  967.                 if (ind_ == 6)
  968.                 {
  969.                     if ([[ratingMenu objectAtIndex:3] isEqualToString:@"0"])
  970.                     {
  971.                         img = [[UIImage imageNamed:@"2bw.png"] retain];
  972.                         imgV = [[UIImageView alloc] initWithFrame:CGRectMake(10.0, 8.0, 111.0, 18.0)];
  973.                     }
  974.                     else
  975.                     {
  976.                         img = [[UIImage imageNamed:@"2.png"] retain];
  977.                         imgV = [[UIImageView alloc] initWithFrame:CGRectMake(10.0, 8.0, 111.0, 18.0)];
  978.                     }
  979.                 }
  980.                 else
  981.                     if (ind_ == 7)
  982.                     {
  983.                         if ([[ratingMenu objectAtIndex:4] isEqualToString:@"0"])
  984.                         {
  985.                             img = [[UIImage imageNamed:@"1bw.png"] retain];
  986.                             imgV = [[UIImageView alloc] initWithFrame:CGRectMake(10.0, 8.0, 111.0, 18.0)];
  987.                         }
  988.                         else
  989.                         {
  990.                             img = [[UIImage imageNamed:@"1.png"] retain];
  991.                             imgV = [[UIImageView alloc] initWithFrame:CGRectMake(10.0, 8.0, 111.0, 18.0)];
  992.                         }
  993.                     }  
  994.    
  995.     //imgV.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
  996.     imgV.image = img;
  997.     [aCell.contentView addSubview:imgV];
  998.    
  999.     [img release];
  1000.     [imgV release];
  1001. }
  1002.  
  1003. -(NSString*) getParamString:(int)ind_
  1004. {
  1005.     if (ind_ == 0)
  1006.     {
  1007.         NSString *str = [[[NSString alloc] init] autorelease];
  1008.         for (int i=0; i<[typeMenu count]; i++)
  1009.             if ([[typeMenu objectAtIndex:i] isEqualToString:@"1"])
  1010.             {
  1011.                 str = [str stringByAppendingString:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].typeParams objectAtIndex:i]];
  1012.                 str = [str stringByAppendingString:@", "];
  1013.             }
  1014.         str = [str substringToIndex:[str length]-2];
  1015.         return str;
  1016.     }
  1017.     else
  1018.         if (ind_ == 1)
  1019.         {
  1020.             NSString *str = [[[NSString alloc] init] autorelease];
  1021.             for (int i=0; i<[partMenu count]; i++)
  1022.                 if ([[partMenu objectAtIndex:i] isEqualToString:@"1"])
  1023.                 {
  1024.                     str = [str stringByAppendingString:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].type2Params objectAtIndex:i]];
  1025.                     str = [str stringByAppendingString:@", "];
  1026.                 }
  1027.             str = [str substringToIndex:[str length]-2];
  1028.             return str;
  1029.         }
  1030.         else
  1031.             if (ind_ == 2)
  1032.             {
  1033.                 NSString *str = [[[NSString alloc] init] autorelease];
  1034.                 for (int i=0; i<[ratingMenu count]; i++)
  1035.                     if ([[ratingMenu objectAtIndex:i] isEqualToString:@"1"])
  1036.                     {
  1037.                         str = [str stringByAppendingString:@"*"];
  1038.                         str = [str stringByAppendingString:@", "];
  1039.                     }
  1040.                 str = [str substringToIndex:[str length]-2];
  1041.                 return str;
  1042.             }
  1043.             else
  1044.                 if (ind_ == 3)
  1045.                 {
  1046.                     NSString *str = [[[NSString alloc] init] autorelease];
  1047.                     for (int i=0; i<[difficultyLevelMenu count]; i++)
  1048.                         if ([[difficultyLevelMenu objectAtIndex:i] isEqualToString:@"1"])
  1049.                         {
  1050.                             str = [str stringByAppendingString:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].levelParams objectAtIndex:i]];
  1051.                             str = [str stringByAppendingString:@", "];
  1052.                         }
  1053.                     str = [str substringToIndex:[str length]-2];
  1054.                     return str;
  1055.                 }
  1056.                 else
  1057.                     if (ind_ == 4)
  1058.                     {
  1059.                         NSString *str = [[[NSString alloc] init] autorelease];
  1060.                         for (int i=0; i<[tuningMenu count]; i++)
  1061.                             if ([[tuningMenu objectAtIndex:i] isEqualToString:@"1"])
  1062.                             {
  1063.                                 str = [str stringByAppendingString:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:i]];
  1064.                                 str = [str stringByAppendingString:@", "];
  1065.                             }
  1066.                         str = [str substringToIndex:[str length]-2];
  1067.                         return str;
  1068.                     }
  1069.     return @"none";
  1070. }
  1071. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1072. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1073. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1074. -(UITableViewCell *) tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  1075. {
  1076.     NSString *identifier = @"the-cell";
  1077.    
  1078.     //UITableViewCell *cell = (UITableViewCell *)[aTableView dequeueReusableCellWithIdentifier:identifier];
  1079.     UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"just-cell"] autorelease];
  1080.    
  1081.     if (indexPath.section==2)
  1082.     {
  1083.         ////[cell addSubview:searchButton];
  1084.         cell = [[[CellTextField alloc] initWithFrame:CGRectZero reuseIdentifier:identifier forButton:YES] autorelease];
  1085.         //searchButton.frame = CGRectMake(0.0, 0.0, 100.0, 35.0);
  1086.        
  1087.         UIImage *buttonBackgroundPressed = [UIImage imageNamed:@"whiteButton.png"];
  1088.         UIImage *buttonBackground = [UIImage imageNamed:@"blueButton.png"];
  1089.         self.searchButton = [CreateCustomButton buttonWithTitle:@"SEARCH"
  1090.                                                             target:self
  1091.                                                             selector:@selector(startSearching:)
  1092.                                                             frame: CGRectMake(10.0, 0.0, 280.0,35.0)
  1093.                                                             image:buttonBackground
  1094.                                                             imagePressed:buttonBackgroundPressed
  1095.                                                             darkTextColor:NO];
  1096.         self.searchButton.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
  1097.  
  1098.         [cell.contentView addSubview:self.searchButton];
  1099.         cell.backgroundColor = [UIColor clearColor];
  1100.         //((CellTextField *)cell).backgroundColor = [UIColor clearColor];
  1101.     }
  1102.     else
  1103.         if (indexPath.section==PARAM_SECTION)
  1104.         {
  1105.             //[cell setText:[[[AdvanceSearchDataSource sharedAdvanceSearchDataSource] paramNames] objectAtIndex:indexPath.row]];
  1106.            
  1107.             cell.contentView.center = CGPointMake(50.0, 10.0);
  1108.            
  1109.             [cell.textLabel setFont: [UIFont fontWithName:@"Arial-BoldMT" size:15.0f]];
  1110.             //[cell.textLabel setFont: [UIFont boldSystemFontOfSize:16.0f]];
  1111.             cell.textLabel.text = [self getRowText:indexPath.row];
  1112.            
  1113.             int pos;// = [cell.textLabel.text rangeOfString:@" "].location;
  1114.            
  1115.             if (![cell.textLabel.text isEqual:@"Type"] && ![cell.textLabel.text isEqual:@"Part"] && ![cell.textLabel.text isEqual:@"Rating"] && ![cell.textLabel.text isEqual:@"Difficulty"] && ![cell.textLabel.text isEqual:@"Tuning"])
  1116.                 pos = 0;
  1117.             else
  1118.                 pos = 1;
  1119.                    
  1120.            
  1121.             //if ([[aTableView cellForRowAtIndexPath:indexPath] accessoryType] == UITableViewCellAccessoryDisclosureIndicator)
  1122.             ////if ([[aTableView cellForRowAtIndexPath:indexPath] accessoryType] != UITableViewCellAccessoryNone || [[aTableView cellForRowAtIndexPath:indexPath] accessoryType] != UITableViewCellAccessoryCheckmark)
  1123.                 if ([self paramValueExistsAtIndex:indexPath.row] && self.activeParamsIndex == -1)
  1124.                 {
  1125.                     if ([self paramValueExistsAtIndex:2] && indexPath.row == 2) // If there is a rating we draw stars on the first cell
  1126.                     {
  1127.                         [self setStars:cell atIndex:indexPath.row];
  1128.                     }
  1129.                     else
  1130.                     {
  1131.                         [self setLabels:cell atIndex:indexPath.row]; // For others we write the text
  1132.                     }
  1133.                 }
  1134.            
  1135.             /*if ([self paramValueExistsAtIndex:0] && [[aTableView cellForRowAtIndexPath:indexPath] accessoryType] == UITableViewCellAccessoryDisclosureIndicator)
  1136.                 {
  1137.                     [self setLabels:cell atIndex:0];
  1138.                 }*/
  1139.  
  1140.             if (self.activeParamsIndex == 2 && (indexPath.row >= 3 && indexPath.row <= 7))
  1141.             {
  1142.                 [self setImages:cell atIndex:indexPath.row];
  1143.             }
  1144.            
  1145.             if ([self paramValueExistsAtIndex:indexPath.row])
  1146.             {
  1147.                 //CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
  1148.                 //const CGFloat myColor[] = {0.0, 0.32, 0.96, 1.0};
  1149.                 [cell.textLabel setTextColor:[UIColor colorWithRed:189.0/255.0 green:213.0/255.0 blue:253.0/255.0 alpha:1.0]];//[[[UIColor alloc] initWithCGColor:CGColorCreate(rgb, myColor)] autorelease];
  1150.                 //CGColorSpaceRelease(rgb);
  1151.             }
  1152.             else
  1153.             {
  1154.                 //cell.textColor = [UIColor blackColor];
  1155.                 [cell.textLabel setTextColor:[UIColor colorWithRed:189.0/255.0 green:213.0/255.0 blue:253.0/255.0 alpha:1.0]];
  1156.             }
  1157.            
  1158.             if (pos == 0)
  1159.             {
  1160.                 //rowH = 25.0;
  1161.                 //aTableView.rowHeight = 25.0;
  1162.                 //NSLog(@"ROW HEIGHT: %f", aTableView.rowHeight);
  1163.                
  1164.                 UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_cell_filter_item.png"]];
  1165.                 cell.backgroundView = imgView;
  1166.                 [imgView release];
  1167.                 UIImageView *imgView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_cell_filter_item_act.png"]];
  1168.                 cell.selectedBackgroundView = imgView1;
  1169.                 [imgView1 release];
  1170.                
  1171.                 if (self.activeParamsIndex == 0)
  1172.                 {
  1173.                     if (indexPath.row == 1)
  1174.                     {
  1175.                         if (![[typeMenu objectAtIndex:0] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1176.                         else
  1177.                         {
  1178.                             [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1179.                             cell.textLabel.textColor = [UIColor whiteColor];
  1180.                             UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1181.                             cell.accessoryView = imgView;
  1182.                             [imgView release];
  1183.                         }
  1184.                        
  1185.                         UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_cell_filter_shadow.png"]];
  1186.                         cell.backgroundView = imgView;
  1187.                         [imgView release];
  1188.                         UIImageView *imgView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_cell_filter_shadow_act.png"]];
  1189.                         cell.selectedBackgroundView = imgView1;
  1190.                         [imgView1 release];
  1191.                     }
  1192.                     else
  1193.                         if (indexPath.row == 2)
  1194.                         {
  1195.                             if (![[typeMenu objectAtIndex:1] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1196.                             else
  1197.                             {
  1198.                                 [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1199.                                 cell.textLabel.textColor = [UIColor whiteColor];
  1200.                                 UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1201.                                 cell.accessoryView = imgView;
  1202.                                 [imgView release];
  1203.                             }
  1204.                         }
  1205.                         else
  1206.                             if (indexPath.row == 3)
  1207.                             {
  1208.                                 if (![[typeMenu objectAtIndex:2] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1209.                                 else
  1210.                                 {
  1211.                                     [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1212.                                     cell.textLabel.textColor = [UIColor whiteColor];
  1213.                                     UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1214.                                     cell.accessoryView = imgView;
  1215.                                     [imgView release];
  1216.                                 }
  1217.                             }
  1218.                 }
  1219.                 else
  1220.                     if (self.activeParamsIndex == 1)
  1221.                     {
  1222.                         if (indexPath.row == 2)
  1223.                         {
  1224.                             if (![[partMenu objectAtIndex:0] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1225.                             else
  1226.                             {
  1227.                                 [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1228.                                 cell.textLabel.textColor = [UIColor whiteColor];
  1229.                                 UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1230.                                 cell.accessoryView = imgView;
  1231.                                 [imgView release];
  1232.                             }
  1233.                             UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_cell_filter_shadow.png"]];
  1234.                             cell.backgroundView = imgView;
  1235.                             [imgView release];
  1236.                             UIImageView *imgView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_cell_filter_shadow_act.png"]];
  1237.                             cell.selectedBackgroundView = imgView1;
  1238.                             [imgView1 release];
  1239.                         }
  1240.                         else
  1241.                             if (indexPath.row == 3)
  1242.                             {
  1243.                                 if (![[partMenu objectAtIndex:1] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1244.                                 else
  1245.                                 {
  1246.                                     [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1247.                                     cell.textLabel.textColor = [UIColor whiteColor];
  1248.                                     UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1249.                                     cell.accessoryView = imgView;
  1250.                                     [imgView release];
  1251.                                 }
  1252.                             }
  1253.                             else
  1254.                                 if (indexPath.row == 4)
  1255.                                 {
  1256.                                     if (![[partMenu objectAtIndex:2] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1257.                                     else
  1258.                                     {
  1259.                                         [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1260.                                         cell.textLabel.textColor = [UIColor whiteColor];
  1261.                                         UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1262.                                         cell.accessoryView = imgView;
  1263.                                         [imgView release];
  1264.                                     }
  1265.                                 }
  1266.                                 else
  1267.                                     if (indexPath.row == 5)
  1268.                                     {
  1269.                                         if (![[partMenu objectAtIndex:3] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1270.                                         else
  1271.                                         {
  1272.                                             [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1273.                                             cell.textLabel.textColor = [UIColor whiteColor];
  1274.                                             UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1275.                                             cell.accessoryView = imgView;
  1276.                                             [imgView release];
  1277.                                         }
  1278.                                     }
  1279.                     }
  1280.                     else
  1281.                         if (self.activeParamsIndex == 2)
  1282.                         {
  1283.                             if (indexPath.row == 3)
  1284.                             {
  1285.                                 if (![[ratingMenu objectAtIndex:0] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1286.                                 else
  1287.                                 {
  1288.                                     [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1289.                                     cell.textLabel.textColor = [UIColor whiteColor];
  1290.                                     UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1291.                                     cell.accessoryView = imgView;
  1292.                                     [imgView release];
  1293.                                 }
  1294.                                 UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_cell_filter_shadow.png"]];
  1295.                                 cell.backgroundView = imgView;
  1296.                                 [imgView release];
  1297.                                 UIImageView *imgView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_cell_filter_shadow_act.png"]];
  1298.                                 cell.selectedBackgroundView = imgView1;
  1299.                                 [imgView1 release];
  1300.                             }
  1301.                             else
  1302.                                 if (indexPath.row == 4)
  1303.                                 {
  1304.                                     if (![[ratingMenu objectAtIndex:1] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1305.                                     else
  1306.                                     {
  1307.                                         [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1308.                                         cell.textLabel.textColor = [UIColor whiteColor];
  1309.                                         UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1310.                                         cell.accessoryView = imgView;
  1311.                                         [imgView release];
  1312.                                     }
  1313.                                 }
  1314.                                 else
  1315.                                     if (indexPath.row == 5)
  1316.                                     {
  1317.                                         if (![[ratingMenu objectAtIndex:2] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1318.                                         else
  1319.                                         {
  1320.                                             [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1321.                                             cell.textLabel.textColor = [UIColor whiteColor];
  1322.                                             UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1323.                                             cell.accessoryView = imgView;
  1324.                                             [imgView release];
  1325.                                         }
  1326.                                     }
  1327.                                     else
  1328.                                         if (indexPath.row == 6)
  1329.                                         {
  1330.                                             if (![[ratingMenu objectAtIndex:3] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1331.                                             else
  1332.                                             {
  1333.                                                 [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1334.                                                 cell.textLabel.textColor = [UIColor whiteColor];
  1335.                                                 UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1336.                                                 cell.accessoryView = imgView;
  1337.                                                 [imgView release];
  1338.                                             }
  1339.                                         }
  1340.                                         else
  1341.                                             if (indexPath.row == 7)
  1342.                                             {
  1343.                                                 if (![[ratingMenu objectAtIndex:4] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1344.                                                 else
  1345.                                                 {
  1346.                                                     [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1347.                                                     cell.textLabel.textColor = [UIColor whiteColor];
  1348.                                                     UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1349.                                                     cell.accessoryView = imgView;
  1350.                                                     [imgView release];
  1351.                                                 }
  1352.                                             }
  1353.                         }
  1354.                         else
  1355.                             if (self.activeParamsIndex == 3)
  1356.                             {
  1357.                                 if (indexPath.row == 4)
  1358.                                 {
  1359.                                     if (![[difficultyLevelMenu objectAtIndex:0] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1360.                                     else
  1361.                                     {
  1362.                                         [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1363.                                         cell.textLabel.textColor = [UIColor whiteColor];
  1364.                                         UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1365.                                         cell.accessoryView = imgView;
  1366.                                         [imgView release];
  1367.                                     }
  1368.                                     UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_cell_filter_shadow.png"]];
  1369.                                     cell.backgroundView = imgView;
  1370.                                     [imgView release];
  1371.                                     UIImageView *imgView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_cell_filter_shadow_act.png"]];
  1372.                                     cell.selectedBackgroundView = imgView1;
  1373.                                     [imgView1 release];
  1374.                                 }
  1375.                                 else
  1376.                                     if (indexPath.row == 5)
  1377.                                     {
  1378.                                         if (![[difficultyLevelMenu objectAtIndex:1] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1379.                                         else
  1380.                                         {
  1381.                                             [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1382.                                             cell.textLabel.textColor = [UIColor whiteColor];
  1383.                                             UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1384.                                             cell.accessoryView = imgView;
  1385.                                             [imgView release];
  1386.                                         }
  1387.                                     }
  1388.                                     else
  1389.                                         if (indexPath.row == 6)
  1390.                                         {
  1391.                                             if (![[difficultyLevelMenu objectAtIndex:2] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1392.                                             else
  1393.                                             {
  1394.                                                 [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1395.                                                 cell.textLabel.textColor = [UIColor whiteColor];
  1396.                                                 UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1397.                                                 cell.accessoryView = imgView;
  1398.                                                 [imgView release];
  1399.                                             }
  1400.                                         }
  1401.                             }
  1402.                             else
  1403.                                 if (self.activeParamsIndex == 4)
  1404.                                 {
  1405.                                     if (indexPath.row == 5)
  1406.                                     {
  1407.                                         if (![[tuningMenu objectAtIndex:0] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1408.                                         else
  1409.                                         {
  1410.                                             [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1411.                                             cell.textLabel.textColor = [UIColor whiteColor];
  1412.                                             UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1413.                                             cell.accessoryView = imgView;
  1414.                                             [imgView release];
  1415.                                         }
  1416.                                         UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_cell_filter_shadow.png"]];
  1417.                                         cell.backgroundView = imgView;
  1418.                                         [imgView release];
  1419.                                         UIImageView *imgView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_cell_filter_shadow_act.png"]];
  1420.                                         cell.selectedBackgroundView = imgView1;
  1421.                                         [imgView1 release];
  1422.                                     }
  1423.                                     else
  1424.                                         if (indexPath.row == 6)
  1425.                                         {
  1426.                                             if (![[tuningMenu objectAtIndex:1] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1427.                                             else
  1428.                                             {
  1429.                                                 [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1430.                                                 cell.textLabel.textColor = [UIColor whiteColor];
  1431.                                                 UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1432.                                                 cell.accessoryView = imgView;
  1433.                                                 [imgView release];
  1434.                                             }
  1435.                                         }
  1436.                                         else
  1437.                                             if (indexPath.row == 7)
  1438.                                             {
  1439.                                                 if (![[tuningMenu objectAtIndex:2] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1440.                                                 else
  1441.                                                 {
  1442.                                                     [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1443.                                                     cell.textLabel.textColor = [UIColor whiteColor];
  1444.                                                     UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1445.                                                     cell.accessoryView = imgView;
  1446.                                                     [imgView release];
  1447.                                                 }
  1448.                                             }
  1449.                                             else
  1450.                                                 if (indexPath.row == 8)
  1451.                                                 {
  1452.                                                     if (![[tuningMenu objectAtIndex:3] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1453.                                                     else
  1454.                                                     {
  1455.                                                         [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1456.                                                         cell.textLabel.textColor = [UIColor whiteColor];
  1457.                                                         UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1458.                                                         cell.accessoryView = imgView;
  1459.                                                         [imgView release];
  1460.                                                     }
  1461.                                                 }
  1462.                                                 else
  1463.                                                     if (indexPath.row == 9)
  1464.                                                     {
  1465.                                                         if (![[tuningMenu objectAtIndex:4] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1466.                                                         else
  1467.                                                         {
  1468.                                                             [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1469.                                                             cell.textLabel.textColor = [UIColor whiteColor];
  1470.                                                             UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1471.                                                             cell.accessoryView = imgView;
  1472.                                                             [imgView release];
  1473.                                                         }
  1474.                                                     }
  1475.                                                     else
  1476.                                                         if (indexPath.row == 10)
  1477.                                                         {
  1478.                                                             if (![[tuningMenu objectAtIndex:5] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1479.                                                             else
  1480.                                                             {
  1481.                                                                 [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1482.                                                                 cell.textLabel.textColor = [UIColor whiteColor];
  1483.                                                                 UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1484.                                                                 cell.accessoryView = imgView;
  1485.                                                                 [imgView release];
  1486.                                                             }
  1487.                                                         }
  1488.                                                         else
  1489.                                                             if (indexPath.row == 11)
  1490.                                                             {
  1491.                                                                 if (![[tuningMenu objectAtIndex:6] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1492.                                                                 else
  1493.                                                                 {
  1494.                                                                     [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1495.                                                                     cell.textLabel.textColor = [UIColor whiteColor];
  1496.                                                                     UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1497.                                                                     cell.accessoryView = imgView;
  1498.                                                                     [imgView release];
  1499.                                                                 }
  1500.                                                             }
  1501.                                                             else
  1502.                                                                 if (indexPath.row == 12)
  1503.                                                                 {
  1504.                                                                     if (![[tuningMenu objectAtIndex:7] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1505.                                                                     else
  1506.                                                                     {
  1507.                                                                         [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1508.                                                                         cell.textLabel.textColor = [UIColor whiteColor];
  1509.                                                                         UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1510.                                                                         cell.accessoryView = imgView;
  1511.                                                                         [imgView release];
  1512.                                                                     }
  1513.                                                                 }
  1514.                                                                 else
  1515.                                                                     if (indexPath.row == 13)
  1516.                                                                     {
  1517.                                                                         if (![[tuningMenu objectAtIndex:8] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1518.                                                                         else
  1519.                                                                         {
  1520.                                                                             [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1521.                                                                             cell.textLabel.textColor = [UIColor whiteColor];
  1522.                                                                             UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1523.                                                                             cell.accessoryView = imgView;
  1524.                                                                             [imgView release];
  1525.                                                                         }
  1526.                                                                     }
  1527.                                                                     else
  1528.                                                                         if (indexPath.row == 14)
  1529.                                                                         {
  1530.                                                                             if (![[tuningMenu objectAtIndex:9] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1531.                                                                             else
  1532.                                                                             {
  1533.                                                                                 [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1534.                                                                                 cell.textLabel.textColor = [UIColor whiteColor];
  1535.                                                                                 UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1536.                                                                                 cell.accessoryView = imgView;
  1537.                                                                                 [imgView release];
  1538.                                                                             }
  1539.                                                                         }
  1540.                                                                         else
  1541.                                                                             if (indexPath.row == 15)
  1542.                                                                             {
  1543.                                                                                 if (![[tuningMenu objectAtIndex:10] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1544.                                                                                 else
  1545.                                                                                 {
  1546.                                                                                     [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1547.                                                                                     cell.textLabel.textColor = [UIColor whiteColor];
  1548.                                                                                     UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1549.                                                                                     cell.accessoryView = imgView;
  1550.                                                                                     [imgView release];
  1551.                                                                                 }
  1552.                                                                             }
  1553.                                                                             else
  1554.                                                                                 if (indexPath.row == 16)
  1555.                                                                                 {
  1556.                                                                                     if (![[tuningMenu objectAtIndex:11] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1557.                                                                                     else
  1558.                                                                                     {
  1559.                                                                                         [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1560.                                                                                         cell.textLabel.textColor = [UIColor whiteColor];
  1561.                                                                                         UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1562.                                                                                         cell.accessoryView = imgView;
  1563.                                                                                         [imgView release];
  1564.                                                                                     }
  1565.                                                                                 }
  1566.                                                                                 else
  1567.                                                                                     if (indexPath.row == 17)
  1568.                                                                                     {
  1569.                                                                                         if (![[tuningMenu objectAtIndex:12] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1570.                                                                                         else
  1571.                                                                                         {
  1572.                                                                                             [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1573.                                                                                             cell.textLabel.textColor = [UIColor whiteColor];
  1574.                                                                                             UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1575.                                                                                             cell.accessoryView = imgView;
  1576.                                                                                             [imgView release];
  1577.                                                                                         }
  1578.                                                                                     }
  1579.                                                                                     else
  1580.                                                                                         if (indexPath.row == 18)
  1581.                                                                                         {
  1582.                                                                                             if (![[tuningMenu objectAtIndex:13] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1583.                                                                                             else
  1584.                                                                                             {
  1585.                                                                                                 [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1586.                                                                                                 cell.textLabel.textColor = [UIColor whiteColor];
  1587.                                                                                                 UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1588.                                                                                                 cell.accessoryView = imgView;
  1589.                                                                                                 [imgView release];
  1590.                                                                                             }
  1591.                                                                                         }
  1592.                                                                                         else
  1593.                                                                                             if (indexPath.row == 19)
  1594.                                                                                             {
  1595.                                                                                                 if (![[tuningMenu objectAtIndex:14] isEqualToString:@"1"]) [cell setAccessoryType:UITableViewCellAccessoryNone];
  1596.                                                                                                 else
  1597.                                                                                                 {
  1598.                                                                                                     [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
  1599.                                                                                                     cell.textLabel.textColor = [UIColor whiteColor];
  1600.                                                                                                     UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkbox.png"]];
  1601.                                                                                                     cell.accessoryView = imgView;
  1602.                                                                                                     [imgView release];
  1603.                                                                                                 }
  1604.                                                                                             }
  1605.                                 }
  1606.                
  1607.                 cell.backgroundColor = [UIColor clearColor];
  1608.                
  1609.                 if ([[aTableView cellForRowAtIndexPath:indexPath] accessoryType] == UITableViewCellAccessoryNone)
  1610.                 {
  1611.                     if (![cell.textLabel.textColor isEqual:[UIColor whiteColor]])
  1612.                         [cell.textLabel setTextColor:[UIColor colorWithRed:121.0/255.0 green:154.0/255.0 blue:236.0/255.0 alpha:1.0]];
  1613.                 }
  1614.                
  1615.                 cell.textLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:15];
  1616.                 cell.textLabel.textColor = [UIColor colorWithRed:189.0/255.0 green:213.0/255.0 blue:253.0/255.0 alpha:1.0];
  1617.             }
  1618.             else
  1619.             {
  1620.                 //rowH = 42.0;
  1621.                 //aTableView.rowHeight = 42.0;
  1622.                
  1623.                 cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  1624.                
  1625.                 cell.backgroundColor = [UIColor clearColor];
  1626.                
  1627.                 UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_cell_filter.png"]];
  1628.                 cell.backgroundView = imgView;
  1629.                 [imgView release];
  1630.                 UIImageView *imgView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_cell_filter.png"]];
  1631.                 cell.selectedBackgroundView = imgView1;
  1632.                 [imgView1 release];
  1633.                 cell.textLabel.textColor = [UIColor whiteColor];
  1634.                
  1635.                 if ((self.activeParamsIndex == 0 && indexPath.row == 0) || (self.activeParamsIndex == 1 && indexPath.row == 1) || (self.activeParamsIndex == 2 && indexPath.row == 2) || (self.activeParamsIndex == 3 && indexPath.row == 3) || (self.activeParamsIndex == 4 && indexPath.row == 4))
  1636.                 {
  1637.                     CGRect frame = CGRectMake(20, 20, 30, 30);
  1638.                     UIView *v = [[UIView alloc] initWithFrame:frame];
  1639.                     CGRect accessoryCustomFrame = CGRectMake(5, 4, 30, 30);
  1640.                     UILabel *accessoryCustomView = [[UILabel alloc] initWithFrame:accessoryCustomFrame];
  1641.                     accessoryCustomView.backgroundColor = [UIColor clearColor];
  1642.                     accessoryCustomView.font = [UIFont fontWithName:@"CourierNewPS-BoldMT" size:26];
  1643.                     accessoryCustomView.textColor = [UIColor colorWithRed:255.0/255.0 green:198.0/255.0 blue:0.0/255.0 alpha:1.0];
  1644.                     accessoryCustomView.highlightedTextColor = [UIColor whiteColor];
  1645.                     accessoryCustomView.textAlignment = UITextAlignmentCenter;
  1646.                     accessoryCustomView.text = @"^";
  1647.                     [v addSubview:accessoryCustomView];
  1648.                     [accessoryCustomView release];
  1649.                     cell.accessoryView = v;
  1650.                     [v release];
  1651.                 }
  1652.                 else
  1653.                 {
  1654.                     CGRect frame = CGRectMake(20, 20, 30, 30);
  1655.                     UIView *v = [[UIView alloc] initWithFrame:frame];
  1656.                     CGRect accessoryCustomFrame = CGRectMake(5, -4, 30, 30);
  1657.                     UILabel *accessoryCustomView = [[UILabel alloc] initWithFrame:accessoryCustomFrame];
  1658.                     accessoryCustomView.backgroundColor = [UIColor clearColor];
  1659.                     accessoryCustomView.font = [UIFont fontWithName:@"CourierNewPS-BoldMT" size:26];
  1660.                     accessoryCustomView.textColor = [UIColor colorWithRed:255.0/255.0 green:198.0/255.0 blue:0.0/255.0 alpha:1.0];
  1661.                     accessoryCustomView.highlightedTextColor = [UIColor whiteColor];
  1662.                     accessoryCustomView.textAlignment = UITextAlignmentCenter;
  1663.                     accessoryCustomView.text = @"^";
  1664.                     accessoryCustomView.transform = CGAffineTransformMakeRotation(1.0*M_PI);
  1665.                     [v addSubview:accessoryCustomView];
  1666.                     [accessoryCustomView release];
  1667.                     cell.accessoryView = v;
  1668.                     [v release];
  1669.                 }
  1670.             }
  1671.         }
  1672.         else
  1673.         {
  1674.             if (indexPath.section==0)
  1675.             {
  1676.                 cell = [[[CellTextField alloc] initWithFrame:CGRectZero reuseIdentifier:identifier forButton:NO] autorelease];
  1677.                 [cell.contentView addSubview:bandNameTextField];
  1678.                 cell.backgroundColor = [UIColor clearColor];
  1679.                 //((CellTextField *)cell).view = bandNameTextField;
  1680.                 //((CellTextField *)cell).backgroundColor = [UIColor clearColor];
  1681.             }
  1682.             else
  1683.                 if (indexPath.section==1)
  1684.                 {
  1685.                     cell = [[[CellTextField alloc] initWithFrame:CGRectZero reuseIdentifier:identifier forButton:NO] autorelease];
  1686.                     [cell.contentView addSubview:songNameTextField];
  1687.                     cell.backgroundColor = [UIColor clearColor];
  1688.                     //((CellTextField *)cell).view = songNameTextField;
  1689.                     //((CellTextField *)cell).backgroundColor = [UIColor clearColor];
  1690.                 }
  1691.         }
  1692.    
  1693.     return cell;
  1694. }
  1695.  
  1696. -(BOOL)paramValueExistsAtIndex:(int)rowIndex
  1697. {
  1698.     if (rowIndex == 0)
  1699.     {
  1700.         for (int i=0; i<[typeMenu count]; i++)
  1701.             if ([[typeMenu objectAtIndex:i] isEqualToString:@"1"])
  1702.                 return YES;
  1703.     }
  1704.     else
  1705.         if (rowIndex == 1)
  1706.         {
  1707.             for (int i=0; i<[partMenu count]; i++)
  1708.                 if ([[partMenu objectAtIndex:i] isEqualToString:@"1"])
  1709.                     return YES;
  1710.         }
  1711.         else
  1712.             if (rowIndex == 2)
  1713.             {
  1714.                 for (int i=0; i<[ratingMenu count]; i++)
  1715.                     if ([[ratingMenu objectAtIndex:i] isEqualToString:@"1"])
  1716.                         return YES;
  1717.             }
  1718.             else
  1719.                 if (rowIndex == 3)
  1720.                 {
  1721.                     for (int i=0; i<[difficultyLevelMenu count]; i++)
  1722.                         if ([[difficultyLevelMenu objectAtIndex:i] isEqualToString:@"1"])
  1723.                             return YES;
  1724.                 }
  1725.                 else
  1726.                     if (rowIndex == 4)
  1727.                     {
  1728.                         for (int i=0; i<[tuningMenu count]; i++)
  1729.                             if ([[tuningMenu objectAtIndex:i] isEqualToString:@"1"])
  1730.                                 return YES;
  1731.                     }
  1732.     return NO;
  1733. }
  1734.  
  1735. #pragma mark UITableViewDelegateMethods
  1736.  
  1737. - (void) deselect
  1738. {  
  1739.     [self.myTableView deselectRowAtIndexPath:[self.myTableView indexPathForSelectedRow] animated:YES];
  1740. }
  1741.  
  1742. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1743. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1744. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1745. -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  1746. {  
  1747.     selectedIndex = indexPath;
  1748.    
  1749.     if (indexPath.section==PARAM_SECTION)
  1750.     {
  1751.         /*if ([[tableView cellForRowAtIndexPath:indexPath] accessoryType] == UITableViewCellAccessoryDisclosureIndicator)
  1752.         {
  1753.             if (self.activeParamsIndex == 0)
  1754.         }*/
  1755.  
  1756.        
  1757.        
  1758.         if ([[tableView cellForRowAtIndexPath:indexPath] accessoryType] == UITableViewCellAccessoryNone)
  1759.         {
  1760.             [[tableView cellForRowAtIndexPath:indexPath] setAccessoryType:UITableViewCellAccessoryCheckmark];
  1761.             [self performSelector:@selector(deselect) withObject:nil afterDelay:0.02f];
  1762.             NSLog(@"SELECT");
  1763.             if (self.activeParamsIndex == 0)
  1764.             {
  1765.                 if (indexPath.row == 1)
  1766.                     [typeMenu replaceObjectAtIndex:0 withObject:@"1"];
  1767.                 else
  1768.                     if (indexPath.row == 2)
  1769.                         [typeMenu replaceObjectAtIndex:1 withObject:@"1"];
  1770.                     else
  1771.                         if (indexPath.row == 3)
  1772.                             [typeMenu replaceObjectAtIndex:2 withObject:@"1"];
  1773.                 [self reloadType:tableView];
  1774.             }
  1775.             else
  1776.                 if (self.activeParamsIndex == 1)
  1777.                 {
  1778.                     if (indexPath.row == 2)
  1779.                         [partMenu replaceObjectAtIndex:0 withObject:@"1"];
  1780.                     else
  1781.                         if (indexPath.row == 3)
  1782.                             [partMenu replaceObjectAtIndex:1 withObject:@"1"];
  1783.                         else
  1784.                             if (indexPath.row == 4)
  1785.                                 [partMenu replaceObjectAtIndex:2 withObject:@"1"];
  1786.                             else
  1787.                                 if (indexPath.row == 5)
  1788.                                     [partMenu replaceObjectAtIndex:3 withObject:@"1"];
  1789.                     [self reloadPart:tableView];
  1790.                 }
  1791.                 else
  1792.                     if (self.activeParamsIndex == 2)
  1793.                     {
  1794.                         if (indexPath.row == 2)
  1795.                             [ratingMenu replaceObjectAtIndex:0 withObject:@"1"];
  1796.                         else
  1797.                             if (indexPath.row == 3)
  1798.                                 [ratingMenu replaceObjectAtIndex:1 withObject:@"1"];
  1799.                             else
  1800.                                 if (indexPath.row == 4)
  1801.                                     [ratingMenu replaceObjectAtIndex:2 withObject:@"1"];
  1802.                                 else
  1803.                                     if (indexPath.row == 5)
  1804.                                         [ratingMenu replaceObjectAtIndex:3 withObject:@"1"];
  1805.                                     else
  1806.                                         if (indexPath.row ==6)
  1807.                                             [ratingMenu replaceObjectAtIndex:4 withObject:@"1"];
  1808.                         [self reloadRating:tableView];
  1809.                     }
  1810.                     else
  1811.                         if (self.activeParamsIndex == 3)
  1812.                         {
  1813.                             if (indexPath.row == 4)
  1814.                                 [difficultyLevelMenu replaceObjectAtIndex:0 withObject:@"1"];
  1815.                             else
  1816.                                 if (indexPath.row == 5)
  1817.                                     [difficultyLevelMenu replaceObjectAtIndex:1 withObject:@"1"];
  1818.                                 else
  1819.                                     if (indexPath.row == 6)
  1820.                                         [difficultyLevelMenu replaceObjectAtIndex:2 withObject:@"1"];
  1821.                             [self reloadLevel:tableView];
  1822.                         }
  1823.                         else
  1824.                             if (self.activeParamsIndex == 4)
  1825.                             {
  1826.                                 if (indexPath.row == 5)
  1827.                                     [tuningMenu replaceObjectAtIndex:0 withObject:@"1"];
  1828.                                 else
  1829.                                     if (indexPath.row == 6)
  1830.                                         [tuningMenu replaceObjectAtIndex:1 withObject:@"1"];
  1831.                                     else
  1832.                                         if (indexPath.row == 7)
  1833.                                             [tuningMenu replaceObjectAtIndex:2 withObject:@"1"];
  1834.                                         else
  1835.                                             if (indexPath.row == 8)
  1836.                                                 [tuningMenu replaceObjectAtIndex:3 withObject:@"1"];
  1837.                                             else
  1838.                                                 if (indexPath.row == 9)
  1839.                                                     [tuningMenu replaceObjectAtIndex:4 withObject:@"1"];
  1840.                                                 else
  1841.                                                     if (indexPath.row == 10)
  1842.                                                         [tuningMenu replaceObjectAtIndex:5 withObject:@"1"];
  1843.                                                     else
  1844.                                                         if (indexPath.row == 11)
  1845.                                                             [tuningMenu replaceObjectAtIndex:6 withObject:@"1"];
  1846.                                                         else
  1847.                                                             if (indexPath.row == 12)
  1848.                                                                 [tuningMenu replaceObjectAtIndex:7 withObject:@"1"];
  1849.                                                             else
  1850.                                                                 if (indexPath.row == 13)
  1851.                                                                     [tuningMenu replaceObjectAtIndex:8 withObject:@"1"];
  1852.                                                                 else
  1853.                                                                     if (indexPath.row == 14)
  1854.                                                                         [tuningMenu replaceObjectAtIndex:9 withObject:@"1"];
  1855.                                                                     else
  1856.                                                                         if (indexPath.row == 15)
  1857.                                                                             [tuningMenu replaceObjectAtIndex:10 withObject:@"1"];
  1858.                                                                         else
  1859.                                                                             if (indexPath.row == 16)
  1860.                                                                                 [tuningMenu replaceObjectAtIndex:11 withObject:@"1"];
  1861.                                                                             else
  1862.                                                                                 if (indexPath.row == 17)
  1863.                                                                                     [tuningMenu replaceObjectAtIndex:12 withObject:@"1"];
  1864.                                                                                 else
  1865.                                                                                     if (indexPath.row == 18)
  1866.                                                                                         [tuningMenu replaceObjectAtIndex:13 withObject:@"1"];
  1867.                                                                                     else
  1868.                                                                                         if (indexPath.row == 19)
  1869.                                                                                             [tuningMenu replaceObjectAtIndex:14 withObject:@"1"];
  1870.                                 [self reloadTuning:tableView];
  1871.                             } //if (self.activeParamsIndex == 4)
  1872.         }
  1873.         else
  1874.             if ([[tableView cellForRowAtIndexPath:indexPath] accessoryType] == UITableViewCellAccessoryCheckmark)
  1875.             {
  1876.                 [[tableView cellForRowAtIndexPath:indexPath] setAccessoryType:UITableViewCellAccessoryNone];
  1877.                 [self performSelector:@selector(deselect) withObject:nil afterDelay:0.02f];
  1878.                
  1879.                 if (self.activeParamsIndex == 0)
  1880.                 {
  1881.                     if (indexPath.row == 1)
  1882.                         [typeMenu replaceObjectAtIndex:0 withObject:@"0"];
  1883.                     else
  1884.                         if (indexPath.row == 2)
  1885.                             [typeMenu replaceObjectAtIndex:1 withObject:@"0"];
  1886.                         else
  1887.                             if (indexPath.row == 3)
  1888.                                 [typeMenu replaceObjectAtIndex:2 withObject:@"0"];
  1889.                     [self reloadType:tableView];
  1890.                 }
  1891.                 else
  1892.                     if (self.activeParamsIndex == 1)
  1893.                     {
  1894.                         if (indexPath.row == 2)
  1895.                             [partMenu replaceObjectAtIndex:0 withObject:@"0"];
  1896.                         else
  1897.                             if (indexPath.row == 3)
  1898.                                 [partMenu replaceObjectAtIndex:1 withObject:@"0"];
  1899.                             else
  1900.                                 if (indexPath.row == 4)
  1901.                                     [partMenu replaceObjectAtIndex:2 withObject:@"0"];
  1902.                                 else
  1903.                                     if (indexPath.row == 5)
  1904.                                         [partMenu replaceObjectAtIndex:3 withObject:@"0"];
  1905.                         [self reloadPart:tableView];
  1906.                     }
  1907.                     else
  1908.                         if (self.activeParamsIndex == 2)
  1909.                         {
  1910.                             if (indexPath.row == 2)
  1911.                                 [ratingMenu replaceObjectAtIndex:0 withObject:@"0"];
  1912.                             else
  1913.                                 if (indexPath.row == 3)
  1914.                                     [ratingMenu replaceObjectAtIndex:1 withObject:@"0"];
  1915.                                 else
  1916.                                     if (indexPath.row == 4)
  1917.                                         [ratingMenu replaceObjectAtIndex:2 withObject:@"0"];
  1918.                                     else
  1919.                                         if (indexPath.row == 5)
  1920.                                             [ratingMenu replaceObjectAtIndex:3 withObject:@"0"];
  1921.                                         else
  1922.                                             if (indexPath.row ==6)
  1923.                                                 [ratingMenu replaceObjectAtIndex:4 withObject:@"0"];
  1924.                             [self reloadRating:tableView];
  1925.                         }
  1926.                         else
  1927.                             if (self.activeParamsIndex == 3)
  1928.                             {
  1929.                                 if (indexPath.row == 4)
  1930.                                     [difficultyLevelMenu replaceObjectAtIndex:0 withObject:@"0"];
  1931.                                 else
  1932.                                     if (indexPath.row == 5)
  1933.                                         [difficultyLevelMenu replaceObjectAtIndex:1 withObject:@"0"];
  1934.                                     else
  1935.                                         if (indexPath.row == 6)
  1936.                                             [difficultyLevelMenu replaceObjectAtIndex:2 withObject:@"0"];
  1937.                                 [self reloadLevel:tableView];
  1938.                             }
  1939.                             else
  1940.                                 if (self.activeParamsIndex == 4)
  1941.                                 {
  1942.                                     if (indexPath.row == 5)
  1943.                                         [tuningMenu replaceObjectAtIndex:0 withObject:@"0"];
  1944.                                     else
  1945.                                         if (indexPath.row == 6)
  1946.                                             [tuningMenu replaceObjectAtIndex:1 withObject:@"0"];
  1947.                                         else
  1948.                                             if (indexPath.row == 7)
  1949.                                                 [tuningMenu replaceObjectAtIndex:2 withObject:@"0"];
  1950.                                             else
  1951.                                                 if (indexPath.row == 8)
  1952.                                                     [tuningMenu replaceObjectAtIndex:3 withObject:@"0"];
  1953.                                                 else
  1954.                                                     if (indexPath.row == 9)
  1955.                                                         [tuningMenu replaceObjectAtIndex:4 withObject:@"0"];
  1956.                                                     else
  1957.                                                         if (indexPath.row == 10)
  1958.                                                             [tuningMenu replaceObjectAtIndex:5 withObject:@"0"];
  1959.                                                         else
  1960.                                                             if (indexPath.row == 11)
  1961.                                                                 [tuningMenu replaceObjectAtIndex:6 withObject:@"0"];
  1962.                                                             else
  1963.                                                                 if (indexPath.row == 12)
  1964.                                                                     [tuningMenu replaceObjectAtIndex:7 withObject:@"0"];
  1965.                                                                 else
  1966.                                                                     if (indexPath.row == 13)
  1967.                                                                         [tuningMenu replaceObjectAtIndex:8 withObject:@"0"];
  1968.                                                                     else
  1969.                                                                         if (indexPath.row == 14)
  1970.                                                                             [tuningMenu replaceObjectAtIndex:9 withObject:@"0"];
  1971.                                                                         else
  1972.                                                                             if (indexPath.row == 15)
  1973.                                                                                 [tuningMenu replaceObjectAtIndex:10 withObject:@"0"];
  1974.                                                                             else
  1975.                                                                                 if (indexPath.row == 16)
  1976.                                                                                     [tuningMenu replaceObjectAtIndex:11 withObject:@"0"];
  1977.                                                                                 else
  1978.                                                                                     if (indexPath.row == 17)
  1979.                                                                                         [tuningMenu replaceObjectAtIndex:12 withObject:@"0"];
  1980.                                                                                     else
  1981.                                                                                         if (indexPath.row == 18)
  1982.                                                                                             [tuningMenu replaceObjectAtIndex:13 withObject:@"0"];
  1983.                                                                                         else
  1984.                                                                                             if (indexPath.row == 19)
  1985.                                                                                                 [tuningMenu replaceObjectAtIndex:14 withObject:@"0"];
  1986.                                     [self reloadTuning:tableView];
  1987.                                 } //if (self.activeParamsIndex == 4)
  1988.             }
  1989.        
  1990.         if (self.activeParamsIndex == -1)
  1991.         {
  1992.             if (indexPath.row == 0)
  1993.             {
  1994.                 self.activeParamsIndex = 0;
  1995.                 [SharedElements sharedSharedElements].activeParamsIndex = 0;
  1996.            
  1997.                 if ([advParams count] != 0)
  1998.                 {
  1999.                     [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].typeParams objectAtIndex:0] atIndex:1];
  2000.                     [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].typeParams objectAtIndex:1] atIndex:2];
  2001.                     [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].typeParams objectAtIndex:2] atIndex:3];
  2002.                     NSArray *insertIndexPaths = [NSArray arrayWithObjects:
  2003.                                                                          [NSIndexPath indexPathForRow:1 inSection:3],
  2004.                                                                          [NSIndexPath indexPathForRow:2 inSection:3],
  2005.                                                                          [NSIndexPath indexPathForRow:3 inSection:3],
  2006.                                                                          nil]
  2007.                     [self.myTableView beginUpdates];
  2008.                     [self.myTableView  insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationFade];
  2009.                     [self.myTableView endUpdates];
  2010.                    
  2011.                     [self reloadType:tableView];
  2012.                 }
  2013.             }
  2014.             else
  2015.                 if (indexPath.row == 1)
  2016.                 {
  2017.                     self.activeParamsIndex = 1;
  2018.                     [SharedElements sharedSharedElements].activeParamsIndex = 1;
  2019.                    
  2020.                     if ([advParams count] != 0)
  2021.                     {
  2022.                         [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].type2Params objectAtIndex:0] atIndex:2];
  2023.                         [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].type2Params objectAtIndex:1] atIndex:3];
  2024.                         [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].type2Params objectAtIndex:2] atIndex:4];
  2025.                         [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].type2Params objectAtIndex:3] atIndex:5];
  2026.                         NSArray *insertIndexPaths = [NSArray arrayWithObjects:
  2027.                                                                                  [NSIndexPath indexPathForRow:2 inSection:3],
  2028.                                                                                  [NSIndexPath indexPathForRow:3 inSection:3],
  2029.                                                                                  [NSIndexPath indexPathForRow:4 inSection:3],
  2030.                                                                                  [NSIndexPath indexPathForRow:5 inSection:3],
  2031.                                                                                  nil];
  2032.                         [self.myTableView beginUpdates];
  2033.                         [self.myTableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationFade];  
  2034.                         [self.myTableView endUpdates];
  2035.                        
  2036.                         [self reloadPart:tableView];
  2037.                     }
  2038.                 }
  2039.                 else
  2040.                     if (indexPath.row == 2)
  2041.                     {
  2042.                         self.activeParamsIndex = 2;
  2043.                         [SharedElements sharedSharedElements].activeParamsIndex = 2;
  2044.                        
  2045.                         if ([advParams count] != 0)
  2046.                         {
  2047.                             [advParams insertObject:@" *****" atIndex:3];
  2048.                             [advParams insertObject:@" ****" atIndex:4];
  2049.                             [advParams insertObject:@" ***" atIndex:5];
  2050.                             [advParams insertObject:@" **" atIndex:6];
  2051.                             [advParams insertObject:@" *" atIndex:7];
  2052.                             NSArray *insertIndexPaths = [NSArray arrayWithObjects:                                                                                   
  2053.                                                                                      [NSIndexPath indexPathForRow:3 inSection:3],
  2054.                                                                                      [NSIndexPath indexPathForRow:4 inSection:3],
  2055.                                                                                      [NSIndexPath indexPathForRow:5 inSection:3],
  2056.                                                                                      [NSIndexPath indexPathForRow:6 inSection:3],
  2057.                                                                                      [NSIndexPath indexPathForRow:7 inSection:3],
  2058.                                                                                      nil];
  2059.                             [self.myTableView beginUpdates];
  2060.                             [self.myTableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationFade];  
  2061.                             [self.myTableView endUpdates];
  2062.                            
  2063.                             [self reloadRating:tableView];
  2064.                         }
  2065.                     }
  2066.                     else
  2067.                         if (indexPath.row == 3)
  2068.                         {
  2069.                             self.activeParamsIndex = 3;
  2070.                             [SharedElements sharedSharedElements].activeParamsIndex = 3;
  2071.                            
  2072.                             if ([advParams count] != 0)
  2073.                             {
  2074.                                 [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].levelParams objectAtIndex:0] atIndex:4];
  2075.                                 [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].levelParams objectAtIndex:1] atIndex:5];
  2076.                                 [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].levelParams objectAtIndex:2] atIndex:6];
  2077.                                 NSArray *insertIndexPaths = [NSArray arrayWithObjects:
  2078.                                                                                          [NSIndexPath indexPathForRow:4 inSection:3],
  2079.                                                                                          [NSIndexPath indexPathForRow:5 inSection:3],
  2080.                                                                                          [NSIndexPath indexPathForRow:6 inSection:3],
  2081.                                                                                          nil];
  2082.                                 [self.myTableView beginUpdates];
  2083.                                 [self.myTableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationFade];  
  2084.                                 [self.myTableView endUpdates];
  2085.                                
  2086.                                 [self reloadLevel:tableView];
  2087.                             }
  2088.                         }
  2089.                         else
  2090.                             if (indexPath.row == 4)
  2091.                             {
  2092.                                 self.activeParamsIndex = 4;
  2093.                                 [SharedElements sharedSharedElements].activeParamsIndex = 4;
  2094.                                
  2095.                                 if ([advParams count] != 0)
  2096.                                 {
  2097.                                     [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:0] atIndex:5];
  2098.                                     [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:1] atIndex:6];
  2099.                                     [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:2] atIndex:7];
  2100.                                     [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:3] atIndex:8];
  2101.                                     [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:4] atIndex:9];
  2102.                                     [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:5] atIndex:10];
  2103.                                     [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:6] atIndex:11];
  2104.                                     [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:7] atIndex:12];
  2105.                                     [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:8] atIndex:13];
  2106.                                     [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:9] atIndex:14];
  2107.                                     [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:10] atIndex:15];
  2108.                                     [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:11] atIndex:16];
  2109.                                     [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:12] atIndex:17];
  2110.                                     [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:13] atIndex:18];
  2111.                                     [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:14] atIndex:19];
  2112.                                     NSArray *insertIndexPaths = [NSArray arrayWithObjects:
  2113.                                                                                              [NSIndexPath indexPathForRow:5 inSection:3],
  2114.                                                                                              [NSIndexPath indexPathForRow:6 inSection:3],
  2115.                                                                                              [NSIndexPath indexPathForRow:7 inSection:3],
  2116.                                                                                              [NSIndexPath indexPathForRow:8 inSection:3],
  2117.                                                                                              [NSIndexPath indexPathForRow:9 inSection:3],
  2118.                                                                                              [NSIndexPath indexPathForRow:10 inSection:3],
  2119.                                                                                              [NSIndexPath indexPathForRow:11 inSection:3],
  2120.                                                                                              [NSIndexPath indexPathForRow:12 inSection:3],
  2121.                                                                                              [NSIndexPath indexPathForRow:13 inSection:3],
  2122.                                                                                              [NSIndexPath indexPathForRow:14 inSection:3],
  2123.                                                                                              [NSIndexPath indexPathForRow:15 inSection:3],
  2124.                                                                                              [NSIndexPath indexPathForRow:16 inSection:3],
  2125.                                                                                              [NSIndexPath indexPathForRow:17 inSection:3],
  2126.                                                                                              [NSIndexPath indexPathForRow:18 inSection:3],
  2127.                                                                                              [NSIndexPath indexPathForRow:19 inSection:3],
  2128.                                                                                              nil];
  2129.                                     [self.myTableView beginUpdates];
  2130.                                     [self.myTableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationFade];  
  2131.                                     [self.myTableView endUpdates];
  2132.                                    
  2133.                                     [self reloadTuning:tableView];
  2134.                                 }
  2135.                             }
  2136.         }
  2137.         else
  2138.             if (self.activeParamsIndex == 0)
  2139.             {
  2140.                 if ([[tableView cellForRowAtIndexPath:indexPath] accessoryType] == UITableViewCellAccessoryDisclosureIndicator)
  2141.                 {
  2142.                     [advParams removeObjectAtIndex:3];
  2143.                     [advParams removeObjectAtIndex:2];
  2144.                     [advParams removeObjectAtIndex:1];
  2145.                     NSArray *deleteIndexPaths = [NSArray arrayWithObjects:
  2146.                                                                             [NSIndexPath indexPathForRow:3 inSection:3],
  2147.                                                                             [NSIndexPath indexPathForRow:2 inSection:3],
  2148.                                                                             [NSIndexPath indexPathForRow:1 inSection:3],
  2149.                                                                             nil];  
  2150.                     [self.myTableView beginUpdates];
  2151.                     [self.myTableView deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade];
  2152.                     [self.myTableView endUpdates];
  2153.                    
  2154.                     self.activeParamsIndex = -1;
  2155.                     [SharedElements sharedSharedElements].activeParamsIndex = -1;
  2156.                    
  2157.                     [self performSelector:@selector(reloadRows) withObject:nil afterDelay:1.0/40.0];
  2158.                     [self.myTableView deselectRowAtIndexPath:indexPath animated:YES];
  2159.                                
  2160.                 if (indexPath.row == 4)
  2161.                     ind = 1;
  2162.                 else
  2163.                     if (indexPath.row == 5)
  2164.                         ind = 2;
  2165.                     else
  2166.                         if (indexPath.row == 6)
  2167.                             ind = 3;
  2168.                         else
  2169.                             if (indexPath.row == 7)
  2170.                                 ind = 4;
  2171.                
  2172.                 if (indexPath.row != 0)
  2173.                     [self performSelector:@selector(expandByArrayNum) withObject:nil afterDelay:1.0/20.0];
  2174.                 }
  2175.             }
  2176.             else
  2177.                 if (self.activeParamsIndex == 1)
  2178.                 {
  2179.                     if ([[tableView cellForRowAtIndexPath:indexPath] accessoryType] == UITableViewCellAccessoryDisclosureIndicator)
  2180.                     {
  2181.                         [advParams removeObjectAtIndex:5];
  2182.                         [advParams removeObjectAtIndex:4];
  2183.                         [advParams removeObjectAtIndex:3];
  2184.                         [advParams removeObjectAtIndex:2];
  2185.                         NSArray *deleteIndexPaths = [NSArray arrayWithObjects:
  2186.                                                                                  [NSIndexPath indexPathForRow:5 inSection:3],
  2187.                                                                                  [NSIndexPath indexPathForRow:4 inSection:3],
  2188.                                                                                  [NSIndexPath indexPathForRow:3 inSection:3],
  2189.                                                                                  [NSIndexPath indexPathForRow:2 inSection:3],
  2190.                                                                                  nil]
  2191.                         [self.myTableView beginUpdates];
  2192.                         [self.myTableView deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade];
  2193.                         [self.myTableView endUpdates];
  2194.                        
  2195.                         self.activeParamsIndex = -1;
  2196.                         [SharedElements sharedSharedElements].activeParamsIndex = -1;
  2197.                        
  2198.                         [self performSelector:@selector(reloadRows) withObject:nil afterDelay:1.0/40.0];
  2199.                         [self.myTableView deselectRowAtIndexPath:indexPath animated:YES];
  2200.                    
  2201.                     if (indexPath.row == 0)
  2202.                         ind = 0;
  2203.                     else
  2204.                         if (indexPath.row == 6)
  2205.                             ind = 2;
  2206.                         else
  2207.                             if (indexPath.row == 7)
  2208.                                 ind = 3;
  2209.                             else
  2210.                                 if (indexPath.row == 8)
  2211.                                     ind = 4;
  2212.                    
  2213.                     if (indexPath.row != 1)
  2214.                         [self performSelector:@selector(expandByArrayNum) withObject:nil afterDelay:1.0/20.0];
  2215.                     }
  2216.                 }
  2217.                 else
  2218.                     if (self.activeParamsIndex == 2)
  2219.                     {
  2220.                         if ([[tableView cellForRowAtIndexPath:indexPath] accessoryType] == UITableViewCellAccessoryDisclosureIndicator)
  2221.                         {
  2222.                             [advParams removeObjectAtIndex:7];
  2223.                             [advParams removeObjectAtIndex:6];
  2224.                             [advParams removeObjectAtIndex:5];
  2225.                             [advParams removeObjectAtIndex:4];
  2226.                             [advParams removeObjectAtIndex:3];
  2227.                             NSArray *deleteIndexPaths = [NSArray arrayWithObjects:
  2228.                                                                                      [NSIndexPath indexPathForRow:7 inSection:3],
  2229.                                                                                      [NSIndexPath indexPathForRow:6 inSection:3],
  2230.                                                                                      [NSIndexPath indexPathForRow:5 inSection:3],
  2231.                                                                                      [NSIndexPath indexPathForRow:4 inSection:3],
  2232.                                                                                      [NSIndexPath indexPathForRow:3 inSection:3],
  2233.                                                                                      nil]
  2234.                             [self.myTableView beginUpdates];
  2235.                             [self.myTableView deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade];
  2236.                             [self.myTableView endUpdates];
  2237.                            
  2238.                             self.activeParamsIndex = -1;
  2239.                             [SharedElements sharedSharedElements].activeParamsIndex = -1;
  2240.                            
  2241.                             [self performSelector:@selector(reloadRows) withObject:nil afterDelay:1.0/40.0];
  2242.                             [self.myTableView deselectRowAtIndexPath:indexPath animated:YES];
  2243.                        
  2244.                         if (indexPath.row == 0)
  2245.                             ind = 0;
  2246.                         else
  2247.                             if (indexPath.row == 1)
  2248.                                 ind = 1;
  2249.                             else
  2250.                                 if (indexPath.row == 8)
  2251.                                     ind = 3;
  2252.                                 else
  2253.                                     if (indexPath.row == 9)
  2254.                                         ind = 4;
  2255.                        
  2256.                         if (indexPath.row != 2)
  2257.                             [self performSelector:@selector(expandByArrayNum) withObject:nil afterDelay:1.0/20.0];
  2258.                         }
  2259.                     }
  2260.                     else
  2261.                         if (self.activeParamsIndex == 3)
  2262.                         {
  2263.                             if ([[tableView cellForRowAtIndexPath:indexPath] accessoryType] == UITableViewCellAccessoryDisclosureIndicator)
  2264.                             {
  2265.                                 [advParams removeObjectAtIndex:6];
  2266.                                 [advParams removeObjectAtIndex:5];
  2267.                                 [advParams removeObjectAtIndex:4];
  2268.                                 NSArray *deleteIndexPaths = [NSArray arrayWithObjects:  
  2269.                                                                                          [NSIndexPath indexPathForRow:6 inSection:3],
  2270.                                                                                          [NSIndexPath indexPathForRow:5 inSection:3],
  2271.                                                                                          [NSIndexPath indexPathForRow:4 inSection:3],  
  2272.                                                                                          nil]
  2273.                                 [self.myTableView beginUpdates];
  2274.                                 [self.myTableView deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade];
  2275.                                 [self.myTableView endUpdates];
  2276.                                
  2277.                                 self.activeParamsIndex = -1;
  2278.                                 [SharedElements sharedSharedElements].activeParamsIndex = -1;
  2279.                                
  2280.                                 [self performSelector:@selector(reloadRows) withObject:nil afterDelay:1.0/40.0];
  2281.                                 [self.myTableView deselectRowAtIndexPath:indexPath animated:YES];
  2282.                            
  2283.                             if (indexPath.row == 0)
  2284.                                 ind = 0;
  2285.                             else
  2286.                                 if (indexPath.row == 1)
  2287.                                     ind = 1;
  2288.                                 else
  2289.                                     if (indexPath.row == 2)
  2290.                                         ind = 2;
  2291.                                     else
  2292.                                         if (indexPath.row == 7)
  2293.                                             ind = 4;
  2294.                            
  2295.                             if (indexPath.row != 3)
  2296.                                 [self performSelector:@selector(expandByArrayNum) withObject:nil afterDelay:1.0/20.0];
  2297.                             }
  2298.                         }
  2299.                         else
  2300.                             if (self.activeParamsIndex == 4)
  2301.                             {
  2302.                                 if ([[tableView cellForRowAtIndexPath:indexPath] accessoryType] == UITableViewCellAccessoryDisclosureIndicator)
  2303.                                 {
  2304.                                     [advParams removeObjectAtIndex:19];
  2305.                                     [advParams removeObjectAtIndex:18];
  2306.                                     [advParams removeObjectAtIndex:17];
  2307.                                     [advParams removeObjectAtIndex:16];
  2308.                                     [advParams removeObjectAtIndex:15];
  2309.                                     [advParams removeObjectAtIndex:14];
  2310.                                     [advParams removeObjectAtIndex:13];
  2311.                                     [advParams removeObjectAtIndex:12];
  2312.                                     [advParams removeObjectAtIndex:11];
  2313.                                     [advParams removeObjectAtIndex:10];
  2314.                                     [advParams removeObjectAtIndex:9];
  2315.                                     [advParams removeObjectAtIndex:8];
  2316.                                     [advParams removeObjectAtIndex:7];
  2317.                                     [advParams removeObjectAtIndex:6];
  2318.                                     [advParams removeObjectAtIndex:5];
  2319.                                     NSArray *deleteIndexPaths = [NSArray arrayWithObjects:
  2320.                                                                                              [NSIndexPath indexPathForRow:19 inSection:3],
  2321.                                                                                              [NSIndexPath indexPathForRow:18 inSection:3],
  2322.                                                                                              [NSIndexPath indexPathForRow:17 inSection:3],
  2323.                                                                                              [NSIndexPath indexPathForRow:16 inSection:3],
  2324.                                                                                              [NSIndexPath indexPathForRow:15 inSection:3],
  2325.                                                                                              [NSIndexPath indexPathForRow:14 inSection:3],
  2326.                                                                                              [NSIndexPath indexPathForRow:13 inSection:3],
  2327.                                                                                              [NSIndexPath indexPathForRow:12 inSection:3],
  2328.                                                                                              [NSIndexPath indexPathForRow:11 inSection:3],
  2329.                                                                                              [NSIndexPath indexPathForRow:10 inSection:3],
  2330.                                                                                              [NSIndexPath indexPathForRow:9 inSection:3],
  2331.                                                                                              [NSIndexPath indexPathForRow:8 inSection:3],
  2332.                                                                                              [NSIndexPath indexPathForRow:7 inSection:3],
  2333.                                                                                              [NSIndexPath indexPathForRow:6 inSection:3],
  2334.                                                                                              [NSIndexPath indexPathForRow:5 inSection:3],
  2335.                                                                                              nil]
  2336.                                     [self.myTableView beginUpdates];
  2337.                                     [self.myTableView deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade];
  2338.                                     [self.myTableView endUpdates];
  2339.                                    
  2340.                                     self.activeParamsIndex = -1;
  2341.                                     [SharedElements sharedSharedElements].activeParamsIndex = -1;
  2342.                                    
  2343.                                     [self performSelector:@selector(reloadRows) withObject:nil afterDelay:1.0/40.0];
  2344.                                     [self.myTableView deselectRowAtIndexPath:indexPath animated:YES];
  2345.  
  2346.                                 if (indexPath.row == 0)
  2347.                                     ind = 0;
  2348.                                 else
  2349.                                     if (indexPath.row == 1)
  2350.                                         ind = 1;
  2351.                                     else
  2352.                                         if (indexPath.row == 2)
  2353.                                             ind = 2;
  2354.                                         else
  2355.                                             if (indexPath.row == 3)
  2356.                                                 ind = 3;
  2357.                                
  2358.                                 if (indexPath.row != 4)
  2359.                                     [self performSelector:@selector(expandByArrayNum) withObject:nil afterDelay:1.0/20.0];
  2360.                                 }
  2361.                             }
  2362.         if (self.activeParamsIndex == 2)
  2363.         {
  2364.             if ([self paramValueExistsAtIndex:2])
  2365.             {
  2366.                 if ([self getRowAsArrayIndex:indexPath.row arrayNum:2] == [self getMinArrayIndex:2])
  2367.                 {
  2368.                     [ratingMenu replaceObjectAtIndex:4 withObject:@"0"];
  2369.                     [ratingMenu replaceObjectAtIndex:3 withObject:@"0"];
  2370.                     [ratingMenu replaceObjectAtIndex:2 withObject:@"0"];
  2371.                     [ratingMenu replaceObjectAtIndex:1 withObject:@"0"];
  2372.                     [ratingMenu replaceObjectAtIndex:0 withObject:@"0"];
  2373.                    
  2374.                     [self reloadRating:tableView];
  2375.                     return;
  2376.                 }
  2377.             }
  2378.            
  2379.             if (indexPath.row == 3)
  2380.             {
  2381.                 [ratingMenu replaceObjectAtIndex:4 withObject:@"0"];
  2382.                 [ratingMenu replaceObjectAtIndex:3 withObject:@"0"];
  2383.                 [ratingMenu replaceObjectAtIndex:2 withObject:@"0"];
  2384.                 [ratingMenu replaceObjectAtIndex:1 withObject:@"0"];
  2385.                 [ratingMenu replaceObjectAtIndex:0 withObject:@"1"];
  2386.                 [self reloadRating:tableView];
  2387.             }
  2388.             else
  2389.                 if (indexPath.row == 4)
  2390.                 {
  2391.                     [ratingMenu replaceObjectAtIndex:4 withObject:@"0"];
  2392.                     [ratingMenu replaceObjectAtIndex:3 withObject:@"0"];
  2393.                     [ratingMenu replaceObjectAtIndex:2 withObject:@"0"];
  2394.                     [ratingMenu replaceObjectAtIndex:1 withObject:@"1"];
  2395.                     [ratingMenu replaceObjectAtIndex:0 withObject:@"1"];
  2396.                     [self reloadRating:tableView];
  2397.                 }
  2398.                 else
  2399.                     if (indexPath.row == 5)
  2400.                     {
  2401.                         [ratingMenu replaceObjectAtIndex:4 withObject:@"0"];
  2402.                         [ratingMenu replaceObjectAtIndex:3 withObject:@"0"];
  2403.                         [ratingMenu replaceObjectAtIndex:2 withObject:@"1"];
  2404.                         [ratingMenu replaceObjectAtIndex:1 withObject:@"1"];
  2405.                         [ratingMenu replaceObjectAtIndex:0 withObject:@"1"];
  2406.                         [self reloadRating:tableView];
  2407.                     }
  2408.                     else
  2409.                         if (indexPath.row == 6)
  2410.                         {
  2411.                             [ratingMenu replaceObjectAtIndex:4 withObject:@"0"];
  2412.                             [ratingMenu replaceObjectAtIndex:3 withObject:@"1"];
  2413.                             [ratingMenu replaceObjectAtIndex:2 withObject:@"1"];
  2414.                             [ratingMenu replaceObjectAtIndex:1 withObject:@"1"];
  2415.                             [ratingMenu replaceObjectAtIndex:0 withObject:@"1"];
  2416.                             [self reloadRating:tableView];
  2417.                         }
  2418.                         else
  2419.                             if (indexPath.row == 7)
  2420.                             {
  2421.                                 [ratingMenu replaceObjectAtIndex:4 withObject:@"1"];
  2422.                                 [ratingMenu replaceObjectAtIndex:3 withObject:@"1"];
  2423.                                 [ratingMenu replaceObjectAtIndex:2 withObject:@"1"];
  2424.                                 [ratingMenu replaceObjectAtIndex:1 withObject:@"1"];
  2425.                                 [ratingMenu replaceObjectAtIndex:0 withObject:@"1"];
  2426.                                 [self reloadRating:tableView];
  2427.                             }  
  2428.         }
  2429.        
  2430.        
  2431.        
  2432.         NSLog(@"row: %D", [selectedIndex row]);
  2433.         NSLog(@"table frame: origin: {%D; %D}; size: {%D; %D};; contentOffset: {%F; %F};",
  2434.               [myTableView frame].origin.x,
  2435.               [myTableView frame].origin.y,
  2436.               [myTableView frame].size.width,
  2437.               [myTableView frame].size.height,
  2438.               [myTableView contentOffset].x,
  2439.               [myTableView contentOffset].y);
  2440.         [myTableView setContentOffset:CGPointMake(0, -240)];
  2441.         //[tableView  selectedIndex
  2442.        
  2443.         //NSIndexPath *scrollIndexPath = [NSIndexPath indexPathForRow:(1) inSection:1];
  2444.         //[tableView scrollToRowAtIndexPath:scrollIndexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
  2445.         //[tableView scrollRectToVisible:CGRectMake(10,10,10,10) animated:YES];
  2446.         [tableView scrollsToTop];
  2447.         //[tableView reloadData];
  2448.     }
  2449. }
  2450.  
  2451.  
  2452.  
  2453. -(void) expandByArrayNum
  2454. {  
  2455.     if (ind == 0)
  2456.     {
  2457.         self.activeParamsIndex = 0;
  2458.         [SharedElements sharedSharedElements].activeParamsIndex = 0;
  2459.        
  2460.         if ([advParams count] != 0)
  2461.         {
  2462.             [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].typeParams objectAtIndex:0] atIndex:1];
  2463.             [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].typeParams objectAtIndex:1] atIndex:2];
  2464.             [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].typeParams objectAtIndex:2] atIndex:3];
  2465.             NSArray *insertIndexPaths = [NSArray arrayWithObjects:
  2466.                                                                      [NSIndexPath indexPathForRow:1 inSection:3],
  2467.                                                                      [NSIndexPath indexPathForRow:2 inSection:3],
  2468.                                                                      [NSIndexPath indexPathForRow:3 inSection:3],
  2469.                                                                      nil]
  2470.             [self.myTableView beginUpdates];
  2471.             [self.myTableView  insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationFade];
  2472.             [self.myTableView endUpdates];
  2473.            
  2474.             [self reloadType:self.myTableView];
  2475.         }
  2476.     }
  2477.     else
  2478.         if (ind == 1)
  2479.         {
  2480.             self.activeParamsIndex = 1;
  2481.             [SharedElements sharedSharedElements].activeParamsIndex = 1;
  2482.            
  2483.             if ([advParams count] != 0)
  2484.             {
  2485.                 [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].type2Params objectAtIndex:0] atIndex:2];
  2486.                 [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].type2Params objectAtIndex:1] atIndex:3];
  2487.                 [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].type2Params objectAtIndex:2] atIndex:4];
  2488.                 [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].type2Params objectAtIndex:3] atIndex:5];
  2489.                 NSArray *insertIndexPaths = [NSArray arrayWithObjects:
  2490.                                                                          [NSIndexPath indexPathForRow:2 inSection:3],
  2491.                                                                          [NSIndexPath indexPathForRow:3 inSection:3],
  2492.                                                                          [NSIndexPath indexPathForRow:4 inSection:3],
  2493.                                                                          [NSIndexPath indexPathForRow:5 inSection:3],
  2494.                                                                          nil];
  2495.                 [self.myTableView beginUpdates];
  2496.                 [self.myTableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationFade];  
  2497.                 [self.myTableView endUpdates];
  2498.                
  2499.                 [self reloadPart:self.myTableView];
  2500.             }
  2501.         }
  2502.         else
  2503.             if (ind == 2)
  2504.             {
  2505.                 self.activeParamsIndex = 2;
  2506.                 [SharedElements sharedSharedElements].activeParamsIndex = 2;
  2507.                
  2508.                 if ([advParams count] != 0)
  2509.                 {
  2510.                     [advParams insertObject:@"*****" atIndex:3];
  2511.                     [advParams insertObject:@"****" atIndex:4];
  2512.                     [advParams insertObject:@"***" atIndex:5];
  2513.                     [advParams insertObject:@"**" atIndex:6];
  2514.                     [advParams insertObject:@"*" atIndex:7];
  2515.                     NSArray *insertIndexPaths = [NSArray arrayWithObjects:                                                                                   
  2516.                                                                              [NSIndexPath indexPathForRow:3 inSection:3],
  2517.                                                                              [NSIndexPath indexPathForRow:4 inSection:3],
  2518.                                                                              [NSIndexPath indexPathForRow:5 inSection:3],
  2519.                                                                              [NSIndexPath indexPathForRow:6 inSection:3],
  2520.                                                                              [NSIndexPath indexPathForRow:7 inSection:3],
  2521.                                                                              nil];
  2522.                     [self.myTableView beginUpdates];
  2523.                     [self.myTableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationFade];  
  2524.                     [self.myTableView endUpdates];
  2525.                    
  2526.                     [self reloadRating:self.myTableView];
  2527.                 }
  2528.             }
  2529.             else
  2530.                 if (ind == 3)
  2531.                 {
  2532.                     self.activeParamsIndex = 3;
  2533.                     [SharedElements sharedSharedElements].activeParamsIndex = 3;
  2534.                    
  2535.                     if ([advParams count] != 0)
  2536.                     {
  2537.                         [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].levelParams objectAtIndex:0] atIndex:4];
  2538.                         [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].levelParams objectAtIndex:1] atIndex:5];
  2539.                         [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].levelParams objectAtIndex:2] atIndex:6];
  2540.                         NSArray *insertIndexPaths = [NSArray arrayWithObjects:
  2541.                                                                                  [NSIndexPath indexPathForRow:4 inSection:3],
  2542.                                                                                  [NSIndexPath indexPathForRow:5 inSection:3],
  2543.                                                                                  [NSIndexPath indexPathForRow:6 inSection:3],
  2544.                                                                                  nil];
  2545.                         [self.myTableView beginUpdates];
  2546.                         [self.myTableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationFade];  
  2547.                         [self.myTableView endUpdates];
  2548.                        
  2549.                         [self reloadLevel:self.myTableView];
  2550.                     }
  2551.                 }
  2552.                 else
  2553.                     if (ind == 4)
  2554.                     {
  2555.                         self.activeParamsIndex = 4;
  2556.                         [SharedElements sharedSharedElements].activeParamsIndex = 4;
  2557.                        
  2558.                         if ([advParams count] != 0)
  2559.                         {
  2560.                             [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:0] atIndex:5];
  2561.                             [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:1] atIndex:6];
  2562.                             [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:2] atIndex:7];
  2563.                             [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:3] atIndex:8];
  2564.                             [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:4] atIndex:9];
  2565.                             [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:5] atIndex:10];
  2566.                             [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:6] atIndex:11];
  2567.                             [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:7] atIndex:12];
  2568.                             [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:8] atIndex:13];
  2569.                             [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:9] atIndex:14];
  2570.                             [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:10] atIndex:15];
  2571.                             [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:11] atIndex:16];
  2572.                             [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:12] atIndex:17];
  2573.                             [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:13] atIndex:18];
  2574.                             [advParams insertObject:[[AdvanceSearchDataSource sharedAdvanceSearchDataSource].tuningParams objectAtIndex:14] atIndex:19];
  2575.                             NSArray *insertIndexPaths = [NSArray arrayWithObjects:
  2576.                                                                                      [NSIndexPath indexPathForRow:5 inSection:3],
  2577.                                                                                      [NSIndexPath indexPathForRow:6 inSection:3],
  2578.                                                                                      [NSIndexPath indexPathForRow:7 inSection:3],
  2579.                                                                                      [NSIndexPath indexPathForRow:8 inSection:3],
  2580.                                                                                      [NSIndexPath indexPathForRow:9 inSection:3],
  2581.                                                                                      [NSIndexPath indexPathForRow:10 inSection:3],
  2582.                                                                                      [NSIndexPath indexPathForRow:11 inSection:3],
  2583.                                                                                      [NSIndexPath indexPathForRow:12 inSection:3],
  2584.                                                                                      [NSIndexPath indexPathForRow:13 inSection:3],
  2585.                                                                                      [NSIndexPath indexPathForRow:14 inSection:3],
  2586.                                                                                      [NSIndexPath indexPathForRow:15 inSection:3],
  2587.                                                                                      [NSIndexPath indexPathForRow:16 inSection:3],
  2588.                                                                                      [NSIndexPath indexPathForRow:17 inSection:3],
  2589.                                                                                      [NSIndexPath indexPathForRow:18 inSection:3],
  2590.                                                                                      [NSIndexPath indexPathForRow:19 inSection:3],
  2591.                                                                                      nil];
  2592.                             [self.myTableView beginUpdates];
  2593.                             [self.myTableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationFade];  
  2594.                             [self.myTableView endUpdates];
  2595.                            
  2596.                             [self reloadTuning:self.myTableView];
  2597.                         }
  2598.                     }
  2599. }
  2600.  
  2601. ///////////////////////////////////////// reload headers
  2602. -(void) reloadHeader0:(UITableView*)tblView
  2603. {
  2604.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:0 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2605. }
  2606. -(void) reloadHeader1:(UITableView*)tblView
  2607. {
  2608.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:1 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2609. }
  2610. -(void) reloadHeader2:(UITableView*)tblView
  2611. {
  2612.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:2 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2613. }
  2614. -(void) reloadHeader3:(UITableView*)tblView
  2615. {
  2616.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:3 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2617. }
  2618. -(void) reloadHeader4:(UITableView*)tblView
  2619. {
  2620.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:4 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2621. }
  2622. //////////////////////////////////////// end of reload headers
  2623.  
  2624. -(void) reloadType:(UITableView*)tblView
  2625. {
  2626.     [self reloadHeader0:tblView];
  2627.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:1 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2628.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:2 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2629.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:3 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2630. }
  2631.  
  2632. -(void) reloadPart:(UITableView*)tblView
  2633. {
  2634.     [self reloadHeader1:tblView];
  2635.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:2 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2636.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:3 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2637.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:4 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2638.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:5 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2639. }
  2640.  
  2641. -(void) reloadRating:(UITableView*)tblView
  2642. {
  2643.     [self reloadHeader2:tblView];
  2644.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:3 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2645.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:4 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2646.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:5 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2647.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:6 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2648.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:7 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2649. }
  2650.  
  2651. -(void) reloadLevel:(UITableView*)tblView
  2652. {
  2653.     [self reloadHeader3:tblView];
  2654.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:4 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2655.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:5 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2656.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:6 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];  
  2657. }
  2658.  
  2659. -(void) reloadTuning:(UITableView*)tblView
  2660. {
  2661.     [self reloadHeader4:tblView];
  2662.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:5 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2663.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:6 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2664.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:7 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2665.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:8 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2666.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:9 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2667.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:10 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2668.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:11 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2669.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:12 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2670.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:13 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2671.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:14 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2672.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:15 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2673.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:16 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2674.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:17 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2675.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:18 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2676.     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:19 inSection:3],nil] withRowAnimation:UITableViewRowAnimationNone];
  2677. }
  2678.  
  2679. -(int) getRowAsArrayIndex:(int)rowIndex arrayNum:(int)aIndex
  2680. {
  2681.     int res = 0;
  2682.     if (aIndex == 2)
  2683.     {
  2684.         if (rowIndex == 3)
  2685.             res = 0;
  2686.         else
  2687.             if (rowIndex == 4)
  2688.                 res = 1;   
  2689.             else
  2690.                 if (rowIndex == 5)
  2691.                     res = 2;
  2692.                 else
  2693.                     if (rowIndex == 6)
  2694.                         res = 3;
  2695.                     else
  2696.                         if (rowIndex == 7)
  2697.                             res = 4;
  2698.     }
  2699.     return res;
  2700. }
  2701.  
  2702. -(int) getMinArrayIndex:(int)arrayIndex
  2703. {
  2704.     int res = 0;
  2705.     if (arrayIndex == 2)
  2706.         for (int i=[ratingMenu count]-1; i != -1; i--)
  2707.             if ([[ratingMenu objectAtIndex:i] isEqualToString:@"1"])
  2708.             {
  2709.                 res = i;
  2710.                 break;
  2711.             }
  2712.     return res;
  2713. }
  2714.  
  2715. -(void) reloadRows
  2716. {
  2717.     NSArray *reloadIndexPaths = [NSArray arrayWithObjects:
  2718.                                                          [NSIndexPath indexPathForRow:0 inSection:3],
  2719.                                                          [NSIndexPath indexPathForRow:1 inSection:3],
  2720.                                                          [NSIndexPath indexPathForRow:2 inSection:3],
  2721.                                                          [NSIndexPath indexPathForRow:3 inSection:3],
  2722.                                                          [NSIndexPath indexPathForRow:4 inSection:3],
  2723.                                                          nil]
  2724.     [self.myTableView reloadRowsAtIndexPaths:reloadIndexPaths withRowAnimation:UITableViewRowAnimationNone];
  2725. }
  2726.  
  2727. -(NSString*) getRowText:(int)rowIndex
  2728. {  
  2729.     if (self.activeParamsIndex == 0)
  2730.     {
  2731.         switch (rowIndex)
  2732.         {
  2733.             case 0:
  2734.                 return @"Type";
  2735.             case 1:
  2736.                 return @"Tab";
  2737.             case 2:
  2738.                 return @"Bass Tab";
  2739.             case 3:
  2740.                 return @"Chords";
  2741.             case 4:
  2742.                 return @"Part";
  2743.             case 5:
  2744.                 return @"Rating";
  2745.             case 6:
  2746.                 return @"Difficulty";
  2747.             case 7:
  2748.                 return @"Tuning";
  2749.         }
  2750.     }
  2751.     else
  2752.         if (self.activeParamsIndex == 1)
  2753.         {
  2754.             switch (rowIndex)
  2755.             {
  2756.                 case 0:
  2757.                     return @"Type";
  2758.                 case 1:
  2759.                     return @"Part";
  2760.                 case 2:
  2761.                     return @"Whole Song";
  2762.                 case 3:
  2763.                     return @"Intro";
  2764.                 case 4:
  2765.                     return @"Solo";
  2766.                 case 5:
  2767.                     return @"Album";   
  2768.                 case 6:
  2769.                     return @"Rating";
  2770.                 case 7:
  2771.                     return @"Difficulty";
  2772.                 case 8:
  2773.                     return @"Tuning";
  2774.             }
  2775.         }
  2776.         else
  2777.             if (self.activeParamsIndex == 2)
  2778.             {
  2779.                 switch (rowIndex)
  2780.                 {
  2781.                     case 0:
  2782.                         return @"Type";
  2783.                     case 1:
  2784.                         return @"Part";
  2785.                     case 2:
  2786.                         return @"Rating";  
  2787.                     case 3:
  2788.                         return @"";
  2789.                     case 4:
  2790.                         return @"";
  2791.                     case 5:
  2792.                         return @"";
  2793.                     case 6:
  2794.                         return @"";
  2795.                     case 7:
  2796.                         return @"";
  2797.                     case 8:
  2798.                         return @"Difficulty";
  2799.                     case 9:
  2800.                         return @"Tuning";
  2801.                 }
  2802.             }
  2803.             else
  2804.                 if (self.activeParamsIndex == 3)
  2805.                 {
  2806.                     switch (rowIndex)
  2807.                     {
  2808.                         case 0:
  2809.                             return @"Type";
  2810.                         case 1:
  2811.                             return @"Part";
  2812.                         case 2:
  2813.                             return @"Rating";
  2814.                         case 3:
  2815.                             return @"Difficulty";
  2816.                         case 4:
  2817.                             return @"Novice";
  2818.                         case 5:
  2819.                             return @"Intermediate";
  2820.                         case 6:
  2821.                             return @"Advance"
  2822.                         case 7:
  2823.                             return @"Tuning";
  2824.                     }
  2825.                 }
  2826.                 else
  2827.                     if (self.activeParamsIndex == 4)
  2828.                     {
  2829.                         switch (rowIndex)
  2830.                         {
  2831.                             case 0:
  2832.                                 return @"Type";
  2833.                             case 1:
  2834.                                 return @"Part";
  2835.                             case 2:
  2836.                                 return @"Rating";
  2837.                             case 3:
  2838.                                 return @"Difficulty";
  2839.                             case 4:
  2840.                                 return @"Tuning";
  2841.                             case 5:
  2842.                                 return @"Standard";
  2843.                             case 6:
  2844.                                 return @"Half-Step Down";
  2845.                             case 7:
  2846.                                 return @"B Tuning";
  2847.                             case 8:
  2848.                                 return @"C Tuning";
  2849.                             case 9:
  2850.                                 return @"D Tuning";
  2851.                             case 10:
  2852.                                 return @"Drop A";
  2853.                             case 11:
  2854.                                 return @"Drop A#";
  2855.                             case 12:
  2856.                                 return @"Drop B";
  2857.                             case 13:
  2858.                                 return @"Drop C";
  2859.                             case 14:
  2860.                                 return @"Drop C#";
  2861.                             case 15:
  2862.                                 return @"Drop D";
  2863.                             case 16:
  2864.                                 return @"Open C";
  2865.                             case 17:
  2866.                                 return @"Open D";
  2867.                             case 18:
  2868.                                 return @"Open E";
  2869.                             case 19:
  2870.                                 return @"Open G";
  2871.                         }
  2872.                     }
  2873.                     else
  2874.                         if (self.activeParamsIndex == -1)
  2875.                         {
  2876.                             switch (rowIndex)
  2877.                             {
  2878.                                 case 0:
  2879.                                     return @"Type";
  2880.                                 case 1:
  2881.                                     return @"Part";
  2882.                                 case 2:
  2883.                                     return @"Rating";
  2884.                                 case 3:
  2885.                                     return @"Difficulty";
  2886.                                 case 4:
  2887.                                     return @"Tuning";
  2888.                             }
  2889.                         }
  2890.     return @"none";
  2891. }
  2892.  
  2893. // Animate the entire view up or down, to prevent the keyboard from covering the author field.
  2894. -(void) setViewMovedUp:(BOOL)movedUp
  2895. {
  2896.     [UIView beginAnimations:nil context:NULL];
  2897.     [UIView setAnimationDuration:0.3];
  2898.     // Make changes to the view's frame inside the animation block. They will be animated instead
  2899.     // of taking place immediately.
  2900.     CGRect rect = contentView.frame;
  2901.    
  2902.     if (movedUp)
  2903.     {
  2904.         // If moving up, not only decrease the origin but increase the height so the view
  2905.         // covers the entire screen behind the keyboard.
  2906.         rect.origin.y -= kOFFSET_FOR_KEYBOARD;
  2907.         rect.size.height += kOFFSET_FOR_KEYBOARD;
  2908.     }
  2909.     else
  2910.     {
  2911.         // If moving down, not only increase the origin but decrease the height.
  2912.         rect.origin.y += kOFFSET_FOR_KEYBOARD;
  2913.         rect.size.height -= kOFFSET_FOR_KEYBOARD;
  2914.         alreadyUp=NO;
  2915.     }
  2916.     contentView.frame = rect;
  2917.    
  2918.     [UIView commitAnimations];
  2919. }
  2920.  
  2921. -(BOOL) textFieldShouldReturn:(UITextField *)textField
  2922. {
  2923.     [songNameTextField resignFirstResponder];
  2924.     [bandNameTextField resignFirstResponder];
  2925.     return YES;
  2926. }
  2927.  
  2928. -(void) viewWillAppear:(BOOL)animated
  2929. {
  2930.     if ([advParams count] == 0)
  2931.     {
  2932.         [advParams addObject:@"0"];
  2933.         [advParams addObject:@"1"];
  2934.         [advParams addObject:@"2"];
  2935.         [advParams addObject:@"3"];
  2936.         [advParams addObject:@"4"];
  2937.        
  2938.         typeMenu = [[NSMutableArray alloc] initWithObjects:@"0", @"0", @"0", nil];
  2939.         partMenu = [[NSMutableArray alloc] initWithObjects:@"0", @"0", @"0", @"0", nil];
  2940.         ratingMenu = [[NSMutableArray alloc] initWithObjects:@"0", @"0", @"0", @"0", @"0", nil];
  2941.         difficultyLevelMenu = [[NSMutableArray alloc] initWithObjects:@"0", @"0", @"0", nil];
  2942.         tuningMenu = [[NSMutableArray alloc] initWithObjects:@"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", nil];
  2943.        
  2944.         self.activeParamsIndex = -1;
  2945.     }
  2946.    
  2947.     NSLog(@"INDEX_____________%d", self.activeParamsIndex );
  2948.    
  2949.     [self.myTableView reloadData]
  2950.    
  2951.     if ([[[SharedElements sharedSharedElements] getBandName] length] > 0)
  2952.         bandNameTextField.text = [[SharedElements sharedSharedElements] getBandName];
  2953.     if ([[[SharedElements sharedSharedElements] getSongName] length] > 0)
  2954.         songNameTextField.text = [[SharedElements sharedSharedElements] getSongName];
  2955. }
  2956.  
  2957. -(void)viewDidAppear:(BOOL)animated
  2958. {
  2959.     [super viewDidAppear:animated];;
  2960.     //return;
  2961. }
  2962.  
  2963.  -(void)viewWillDisappear:(BOOL)animated
  2964. {
  2965.     [[SharedElements sharedSharedElements] setAdvParams:advParams];
  2966.     [[SharedElements sharedSharedElements] setTypeMenu:typeMenu];
  2967.     [[SharedElements sharedSharedElements] setPartMenu:partMenu];
  2968.     [[SharedElements sharedSharedElements] setRatingMenu:ratingMenu];
  2969.     [[SharedElements sharedSharedElements] setDifficultyLevelMenu:difficultyLevelMenu];
  2970.     [[SharedElements sharedSharedElements] setTuningMenu:tuningMenu];
  2971. }
  2972.    
  2973. /*
  2974.  - (void)keyboardWillShow:(NSNotification *)notif{
  2975.  
  2976.  //The keyboard will be shown.
  2977.  [self setViewMovedUp:YES];
  2978.  
  2979.  }
  2980.  
  2981.  - (void)keyboardWillHide:(NSNotification *)notif{
  2982.  //The keyboard will now be removed.
  2983.  [self setViewMovedUp:NO];
  2984.  }
  2985.  
  2986.  
  2987.  #pragma mark - UIViewController delegate methods
  2988.  
  2989.  
  2990.  
  2991.  - (void)viewWillDisappear:(BOOL)animated{
  2992.  
  2993.  //unregister for keyboard notifications while not visible.
  2994.  [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
  2995.  //unregister for keyboard notifications while not visible.
  2996.  [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
  2997.  
  2998.  [songNameTextField resignFirstResponder];
  2999.  [bandNameTextField resignFirstResponder];
  3000.  
  3001.  
  3002.  }
  3003.  */
  3004.  
  3005. /*
  3006.  If you need to do additional setup after loading the view, override viewDidLoad.
  3007.  - (void)viewDidLoad {
  3008.  }
  3009.  */
  3010. /*
  3011. - (void)willAnimateFirstHalfOfRotationFromInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
  3012. {
  3013.     NSLog(@"wilRotateFromInterfaceOrientation 3.0: %d", interfaceOrientation);
  3014. }
  3015.  
  3016. - (void)wilRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
  3017. {
  3018.     NSLog(@"wilRotateFromInterfaceOrientation: %d", fromInterfaceOrientation);
  3019. }*/
  3020. /*
  3021. - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
  3022. {
  3023.     NSLog(@"1");
  3024. }
  3025.  
  3026. - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
  3027. {
  3028.     NSLog(@"2");
  3029. }
  3030.  
  3031. - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
  3032. {
  3033.     NSLog(@"3");
  3034. }
  3035.  
  3036. - (void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
  3037. {
  3038.     NSLog(@"4");
  3039. }
  3040.  
  3041. - (void)didAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
  3042. {
  3043.     NSLog(@"5");
  3044. }
  3045.  
  3046. - (void)willAnimateSecondHalfOfRotationFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation duration:(NSTimeInterval)duration
  3047. {
  3048.     NSLog(@"6");
  3049. }
  3050. */
  3051. -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  3052. {
  3053.     return NO;
  3054.     //NSLog(@"Say from Advanced view controller");
  3055.     //(interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationLandscapeLeft
  3056.     //|| interfaceOrientation == UIInterfaceOrientationLandscapeRight);
  3057.     // Return YES for supported orientations
  3058.     //return YES;//(interfaceOrientation == UIInterfaceOrientationPortrait);
  3059. }
  3060.  
  3061. -(void) didReceiveMemoryWarning
  3062. {
  3063.     [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
  3064.     // Release anything that's not essential, such as cached data
  3065. }
  3066.  
  3067. -(void) dealloc
  3068. {
  3069.     [advParams release];
  3070.     [typeMenu release];
  3071.     [partMenu release];
  3072.     [ratingMenu release];
  3073.     [difficultyLevelMenu release];
  3074.     [tuningMenu release];  
  3075.    
  3076.     [dataSource release];
  3077.     [searchButton release];
  3078.     [contentView release];
  3079.     [myTableView release];
  3080.     [super dealloc];
  3081.    
  3082.     //[ratingPicker release];
  3083.     //[typePicker release];
  3084.     //[type2Picker release];
  3085.     //[levelPicker release];
  3086.     //[tuningPicker release];
  3087.     //[pickerToolBar release];
  3088. }
  3089.  
  3090. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement