<?php
    $GLOBALS['img']='advanced';
    get_header();
    the_post();
?>

<?php if(of_get_option('show_server_adv')){?>

<div class="container top">
  
    <?php if(of_get_option('show_adv_server')){?>
    
    <?php 
        for($i=1; $i<=of_get_option('adv_server_num'); $i++){
        if($i==1){echo '<div class="row-fluid">';}        
        $img_float = '<div class="span3"><img src="'.of_get_option('adv_server_img'.$i).'" class="animated bounceInLeft" alt=""></div>';
    ?>
	
    <div class="span6">
          
        <div class="features">
            
            <div class="row-fluid">
              
                <?php if(of_get_option('adv_server_img_pos'.$i)=='1'){echo $img_float;}?>
                
                <div class="span9">
                
                    <h3 <?php echo colors('h3');?> ><?php echo of_get_option('adv_server_title'.$i);?></h3>
                  
                    <span <?php echo colors('h1s');?> ><i><?php echo of_get_option('adv_server_detail'.$i);?></i></span>
                  
                    <p <?php echo colors('p');?> ><?php echo of_get_option('adv_server_desc'.$i);?></p>
                  
                </div>
                
                <?php if(of_get_option('adv_server_img_pos'.$i)=='2'){echo $img_float;}?>
                
            </div>

        </div>
            
    </div>
          
    <?php 
        if($i%2==0){ 
        echo '</div>';
        if($i+1<=of_get_option('adv_server_num')){
        echo '<div class="row-fluid">';
        }
        }elseif($i==of_get_option('adv_server_num')){
        echo '</div>';
        }
        }
    ?> 
    
    <?php }?>
	
    <?php if(of_get_option('show_adv_plans')){?> 
    
        <?php
        $args=array(
            'post_type' => 'plan',
            'post_status' => 'publish',
            'posts_per_page' => -1,
        );
        $my_query = null;
        $my_query = new WP_Query($args);
        $plan = array();
        
        while ($my_query->have_posts()) {
            $my_query->the_post();
            $plan[] = array(
                'title' => get_the_title(),
                'subtitle' => get_field('subtitle'),
                'price' => get_field('price'),
                'freq' => get_field('frequency'),
                'options' => get_field('options'),
                'category' => get_field('categoria'),
                'btn_title' => get_field('btn_title'),
                'btn_link' => get_field('btn_link')
            );
        }
        $c = 0;
        $planes_count = 0;
        foreach($plan as $key){
            if($key['category'] == of_get_option('advanced_plan')){
                $planes_count++;    
            }
        }
        foreach($plan as $key){
             
             if($key['category'] == of_get_option('advanced_plan')){
             $c++;
              //  if(of_get_option('price_first_plan'.$c) == 1 ){
              if($c==1){echo '<div class="row-fluid top">';}
     
     ?>
    
        <div class="span3">
      
            <!-- Item table -->
        
            <div class="item_table option_pricing">
        
                <div class="head_table">
          
                    <div class="head_title">    
            
                        <h1 <?php echo colors('h1');?> ><?php echo $key['title'];?></h1>
              
                        <span <?php echo colors('h1s');?> ><?php echo $key['subtitle'];?></span>
              
                    </div>
            
                    <h2 <?php echo colors('h2');?> ><?php echo $key['price'];?><span <?php echo colors('h1s');?> > $/ <?php echo $key['freq'];?></span></h2>                        
            
                </div>

                <ul class="items">
          
                    <?php foreach($key['options'] as $data){?>
          
                    <li><?php echo $data['icon'];?> <?php echo $data['descripotion'];?></li>
            
                    <?php }?>
                            
                </ul> 

                <a <?php echo colors('a');?>  href="<?php echo $key['btn_link'];?>" class="botton"><?php echo $key['btn_title'];?></a>  

            </div>
        
            <!-- End Item table -->
        
        </div>
      
        <?php 
                    if($c%4==0){ 
                    echo '</div>';
                    if($c+1<=$planes_count){
                        echo '<div class="row-fluid top">';
                    }
                    }elseif($c==$planes_count){
                        echo '</div>';
                    }
                }
            }
        ?>
	
    <?php }?>
    
   </div>
   
</div>

<?php } get_footer(); ?>