<?php
// gppThemes Admin Interface

function gppthemes_add_admin() {

    global $query_string;
    $options =  get_option('gpp_template');      
    $themename =  get_option('gpp_themename');      
    $shortname =  get_option('gpp_shortname');      

    if ( $_REQUEST['page'] == 'gppthemes' ) {
        if ( 'save' == $_REQUEST['gpp_save'] ) {
                $upload_tracking = array();
                foreach ($options as $key => $value) {
                
                        $id = $value['id'];
                                         
                        if ( is_array($value['type']) && $value['type'] != 'upload') {
                            foreach($value['type'] as $array){
                                if($array['type'] == 'text'){
                                $id = $array['id']; 
                                update_option( $id, $_REQUEST[ $id ]);
                                }
                            }                 
                        }
                        elseif($value['type'] == 'checkbox'){
                             if(isset( $_REQUEST[$id])){update_option( $id, $_REQUEST[ $id] );} else { update_option( $id, 'false' ); }
                        } 
                        elseif($value['type'] == 'select'){
                             if(isset( $_REQUEST[$id])){ update_option( $id, htmlentities($_REQUEST[ $id] ));
                             } else { delete_option( htmlentities( $id )); }
                               
                        } 
                        elseif($value['type'] == 'upload' ){
                            $override['test_form'] = false;
                            $override['action'] = 'gpp_save';
                            
                             if(!empty( $_FILES['attachement_'.$id]['name'])){ //New upload          
                                    $uploaded_file = wp_handle_upload($_FILES['attachement_' . $id ],$override); 
                                    $uploaded_file['option_name']  = $value['name'];
                                    $upload_tracking[] = $uploaded_file;
                                    update_option( $id , $uploaded_file['url'] );
                                    }
                             elseif(isset( $_REQUEST[ $id ])){ // No new file, just the already saved file
                                    update_option( $id , $_REQUEST[$id] );
                                }
                        }
                        elseif($value['type'] != 'multicheck'){
                             if(isset( $_REQUEST[ $value['id'] ])){update_option( $id, $_REQUEST[$id] );} else { delete_option( $id); }
                        }

                        else  // Multicheck
                        {
                            foreach($value['options'] as $mc_key => $mc_value){
                                $up_opt = $id . '_' . $mc_key;
                                 if(isset( $_REQUEST[ $up_opt ])){update_option( $up_opt, $_REQUEST[ $up_opt ] );}  else {update_option($up_opt, 'false' );}
                            }
                        }
                }
                update_option('gpp_upload_tracking', $upload_tracking);
                
                //Create, Encrypt and Update the Saved Settings
                global $wpdb;
                $query = "SELECT * FROM $wpdb->options WHERE option_name LIKE 'gpp_%' AND NOT option_name = 'gpp_template' AND NOT option_name = 'gpp_custom_template' AND NOT option_name = 'gpp_settings_encode'";
                $results = $wpdb->get_results($query);
                
                $output = "<ul>";
                foreach ($results as $result){
                        $output .= '<li><strong>' . $result->option_name . '</strong> - ' . $result->option_value . '</li>';
                }
                $output .= "</ul>";
                $output = base64_encode($output);
                update_option('gpp_settings_encode',$output);
                //End

                $send = $_GET['page'];
                header("Location: admin.php?page=gppthemes&saved=true");                                
            
            die;

        } else if ( 'reset' == $_REQUEST['gpp_save'] ) {
            global $wpdb;
            $query = "DELETE FROM $wpdb->options WHERE option_name LIKE 'gpp_%'";
            $wpdb->query($query);
            header("Location: admin.php?page=gppthemes&reset=true");
            die;
        }

    }

    // Check all the Options, then if the no options are created for a ralitive sub-page... it's not created.
    if(function_exists(add_object_page))
    {
        add_object_page ('Page Title', $themename, 8,'gppthemes', 'gppthemes_page', get_bloginfo('template_url'). '/functions/images/gpp-icon.png');
    }
    else
    {
        add_menu_page ('Page Title', $themename, 8,'gppthemes_home', 'gppthemes_page', get_bloginfo('template_url'). '/functions/images/gpp-icon.png'); 
    }
    add_submenu_page('gppthemes', $themename, 'Theme Options', 8, 'gppthemes','gppthemes_page'); // Default
    add_submenu_page('gppthemes', 'Available gppThemes', 'Buy Themes', 8, 'gppthemes_themes', 'gppthemes_more_themes_page');  
}

function gppthemes_page(){
 
    $options =  get_option('gpp_template');      
    $themename =  get_option('gpp_themename');      
    $shortname =  get_option('gpp_shortname');
    $instructionsurl = get_option('gpp_instructions');
    $manualurl =  get_option('gpp_manual');
    $videosurl =  get_option('gpp_videos');
    $supporturl =  get_option('gpp_support');  
    
    //Version in Backend Head
    $theme_data = get_theme_data(STYLESHEETPATH . '/style.css');
    $local_version = $theme_data['Version'];
    $update_message = '<span class="update">v.'. $local_version .'</span>';
?>
</strong>
<?php
// END
?>
<div class="wrap" id="gpp_options">
    <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post"  enctype="multipart/form-data">
        <h2><?php echo $themename; ?> Options <?php echo $update_message; ?></h2>
        <div class="info"><strong>Need help?</strong> See the <a href="<?php echo $instructionsurl; ?>" target="_blank">Instructions</a>, <a href="<?php echo $manualurl; ?>" target="_blank">F.A.Q.</a>, <a href="<?php echo $videosurl; ?>" target="blank">Video Tutorials</a> or <a href="<?php echo $supporturl; ?>" target="blank">Support Forum</a></div>    
        
        <?php if ( $_REQUEST['saved'] ) { ?><div style="clear:both;height:20px;"></div><div class="happy"><?php echo $themename; ?>'s Options has been updated!</div><?php } ?>
        <?php if ( $_REQUEST['reset'] ) { ?><div style="clear:both;height:20px;"></div><div class="warning"><?php echo $themename; ?>'s Options has been reset!</div><?php } ?>    
                    
        <?php //Errors
        $error_occurred = false;
        $upload_tracking = get_option('gpp_upload_tracking');
        if(!empty($upload_tracking)){
        $output = '<div style="clear:both;height:20px;"></div><div class="errors"><ul>' . "\n";
            $error_shown == false;
            foreach($upload_tracking as $array )
            {
                 if(array_key_exists('error', $array)){
                        $error_occurred = true;
                        $errors_print .= '<li><strong>' . $array['option_name']. '</strong>: ' .  $array['error'] . '</li>' . "\n";
                }
            }
        } 
        if($error_occurred) {
            $output = '<div style="clear:both;height:20px;"></div><div class="errors"><ul>' . "\n";
            $output .= $errors_print;
            $output .= '</ul></div>' . "\n";
            echo $output;
        }
            
        delete_option('gpp_upload_tracking');
        ?>

        <div style="clear:both;height:10px;"></div>
        <?php echo gppthemes_machine($options,$page);  //The real work horse  ?>
        <div style="clear:both;"></div>
        <?php  wp_nonce_field('reset_options'); echo "\n"; ?>

        <p class="submit submit-footer">
            <input name="save" type="submit" value="Save All Changes" />
            <input type="hidden" name="gpp_save" value="save" />
        </p>
    </form>
        
    <form action="<?php echo wp_specialchars( $_SERVER['REQUEST_URI'] ) ?>" method="post">
        <p class="submit submit-footer submit-footer-reset">
        <input name="reset" type="submit" value="Reset Options" class="reset-button" onclick="return confirm('Click OK to reset. Any settings will be lost!');" />
        <input type="hidden" name="gpp_save" value="reset" />
        </p>
    </form>
<div style="clear:both;"></div>    
</div><!--wrap-->

 <?php
}

function gppthemes_machine($options,$page) {
        
    $counter = 0;
    foreach ($options as $value) {
        
        if($page != $value['page']){
        $counter = 0; //Reset the Counter once a new page settings page is selected
        }
        elseif($page == $value['page']){
        $counter++;
        $val = '';
        //Start Heading
         if ( $value['type'] != "heading" )
         {
            $output .= '<div class="option option-'. $value['type'] .'">'."\n".'<div class="option-inner '.$value['id'].'">'."\n";
            $output .= '<label class="titledesc">'. $value['name'] .'</label>'."\n";
            $output .= '<div class="formcontainer">'."\n".'<div class="forminp">'."\n";
         } 
         //End Heading
        $select_value = '';                                   
        switch ( $value['type'] ) {
        case 'text':
             if (get_settings( $value['id'] ) === FALSE) { $val = $value['std']; } else { $val = get_settings( $value['id'] ); }            
            $output .= '<input name="'. $value['id'] .'" id="'. $value['id'] .'" type="'. $value['type'] .'" value="'. $val .'" />';
        break;
        
        case 'select':

            $output .= '<select name="'. $value['id'] .'" id="'. $value['id'] .'">';
        
            $select_value = get_settings( $value['id']);
            
            
             
            foreach ($value['options'] as $key => $option) {               
                
                $selected = '';
                
                   if($select_value != '') {
                        if ( $select_value == $key) { $selected = ' selected="selected"';} 
                   } else {
                    if ($value['std'] == $key) { $selected = ' selected="selected"'; }
                   }
                  
                $output .= '<option value="'. $key .'" '. $selected .'>';
                $output .= $option;
                $output .= '</option>';
             } 
             $output .= '</select>';

            
        break;
        case 'textarea':
            $ta_options = $value['options'];
            //$ta_value = $value['std'];
            //if( get_settings($value['id']) != "") { $ta_value = stripslashes(get_settings($value['id'])); }
            if (get_settings( $value['id'] ) === FALSE) {$ta_value = $value['std']; } else { $ta_value = stripslashes(get_settings($value['id'])); } 
            $output .= '<textarea name="'. $value['id'] .'" id="'. $value['id'] .'" cols="'. $ta_options['cols'] .'" rows="8">'.$ta_value.'</textarea>';
            
        break;
        case "radio":
            
             $select_value = get_settings( $value['id']);
                   
             foreach ($value['options'] as $key => $option) 
             { 

                 $checked = '';
                   if($select_value != '') {
                        if ( $select_value == $key) { $checked = ' checked'; } 
                   } else {
                    if ($value['std'] == $key) { $checked = ' checked'; }
                   }
                $output .= '<input type="radio" name="'. $value['id'] .'" value="'. $key .'" '. $checked .' />' . $option .'<br />';
            
            }
             
        break;
        case "checkbox": 
        
           $std = $value['std'];  
           
           $saved_std = get_option($value['id']);
           
           $checked = '';
            
            if(!empty($saved_std)) {
                if($saved_std == 'true') {
                $checked = 'checked="checked"';
                }
                else{
                   $checked = '';
                }
            }
            elseif( $std == 'true') {
               $checked = 'checked="checked"';
            }
            else {
                $checked = '';
            }

            $output .= '<input type="checkbox" class="checkbox" name="'.  $value['id'] .'" id="'. $value['id'] .'" value="true" '. $checked .' />';

        break;
        case "multicheck":
        
            $std =  $value['std'];         
            
            foreach ($value['options'] as $key => $option) {
                                             
            $gpp_key = $value['id'] . '_' . $key;
            $saved_std = get_option($gpp_key);
                    
            if(!empty($saved_std)) 
            { 
                  if($saved_std == 'true'){
                     $checked = 'checked="checked"';  
                  } 
                  else{
                      $checked = '';     
                  }    
            } 
            elseif( $std == $key) {
               $checked = 'checked="checked"';
            }
            else {
                $checked = '';                                                                                                                                                                                                                          }
            
            $output .= '<input type="checkbox" class="checkbox" name="'. $gpp_key .'" id="'. $gpp_key .'" value="true" '. $checked .' /><label for="'. $gpp_key .'">'. $option .'</label><br />';
                                        
            }
            
        break;
        case "upload":
            
            $output .= gppthemes_uploader_function($value['id'],$value['std'],'options');
            
        break;
        case "heading":
            
            if($counter >= 2){
               $output .= '</div>'."\n";
            }
     
            $output .= '<div class="title">';
            $output .= '<p class="submit"><input name="save" type="submit" value="Save Changes" /></p>';
            $output .= '<h3><span class="gpp-expand">+</span>'. $value['name'] .'</h3>'."\n";    
            $output .= '</div>'."\n";
            $output .= '<div class="option_content">'."\n";
        break;
        case "group":
     
            $output .= '<div class="gpp_group">'; 
            $output .= '</div>'."\n";
            $output .= '<div class="option_content">'."\n";
        break;
        case "groupEnd":

            $output .= '</div>'."\n";
        break;                               
        } 
        
        if ( is_array($value['type'])) {
            
            foreach($value['type'] as $array){
            
                    $id =   $array['id']; 
                    $std =   $array['std'];
                    $saved_std = get_option($id);
                    if($saved_std != $std && !empty($saved_std) ){$std = $saved_std;} 
                    $meta =   $array['meta'];
                    
                    if($array['type'] == 'text') { // Only text at this point
                         
                         $output .= '<input class="input-text-small" name="'. $id .'" id="'. $id .'" type="text" value="'. $std .'" />';  
                         $output .= '<span class="meta-two">'.$meta.'</span>';
                    }
                }
        }
        
        if ( $value['type'] != "heading" ) { 
            if ( $value['type'] != "checkbox" ) 
                { 
                $output .= '<br/>';
                }
                
            $output .= '</div><div class="desc">'. $value['desc'] .'</div></div>'."\n";
            $output .= '</div></div><div class="clear"></div>'."\n";
        
            }
        }
    }
    
    $output .= '</div>';
    return $output;
    
}

// gppThemes Uploader
function gppthemes_uploader_function($id,$std){

    $uploader .= '<input type="file" name="attachement_'.$id.'" class="upload_input"></input>';
    $uploader .= '<span class="submit"><input name="save" type="submit" value="Upload" class="button upload_save" /></span>';

    $upload = get_option($id);
    
    $uploader .= '<div class="clear"></div>';
    if (empty($upload) || $upload == $std)
    {
    $uploader .= '<input class="upload-input-text" name="'.$id.'" value="'.$std.'"/>';
    }
    else
    {
    $uploader .= '<input class="upload-input-text" name="'.$id.'" value="'.$upload.'"/>';
    $uploader .= '<div class="clear"></div>';
    $uploader .= '<a href="'. $upload . '">';
    $uploader .= '<img src="'.get_bloginfo('template_url').'/includes/timthumb.php?src='.$upload.'&w=290" alt="" />';
    $uploader .= '</a>'; 
    }
return $uploader;
}

function wf_admin_head() { 
?>
<!-- Import Colorpicker's Css & JS & images -->
<style type="text/css" media="screen">
@import url("<?php bloginfo('template_url');?>/styles/colorpicker/colorpicker.css");
</style>

<script type="text/javascript" src="<?php bloginfo('template_url');?>/includes/js/colorpicker/colorpicker.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_url');?>/includes/js/colorpicker/eye.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_url');?>/includes/js/colorpicker/layout.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_url');?>/includes/js/colorpicker/utils.js"></script>

<script type="text/javascript">
    jQuery(document).ready(function(){

        try {
        
        var timer = null;  
        var offset = jQuery('#scrollme').offset().top;
          
        jQuery(document).scroll(function(e){
            clearTimeout(timer);
            timer = setTimeout(function(){
                jQuery('#scrollme').animate({
                    top: jQuery(document).scrollTop() + offset 
                }, 'fast');
            }, 200);
        });
          
        } catch(exception) {
          // #scrollme is not on page load.
        }
        
        jQuery('#gpp_options .title h3').parent().next('.option_content').slideUp();
        
        var initChar;
        jQuery('#gpp_options .title h3').hover(function(){
            initChar = jQuery(this).children('span').html();
            if (jQuery(this).parent().next('.option_content').css('display') == 'none'){  
                jQuery(this).children('span').html("&darr;");
            }
            else
            {
               jQuery(this).children('span').html("&uarr;");  
            }
        }
        ,function(){
            jQuery(this).children('span').html(initChar)  
        })   
  
        jQuery('#gpp_options .title h3').click(function(){
            if (jQuery(this).parent().next('.option_content').css('display') == 'none'){
             jQuery(this).children('span').html("+");
             initChar = "-"; 
            }
            else{
            jQuery(this).children('span').html("-");
            initChar = "+";   
            
            }
            
            jQuery(this).parent().next('.option_content').slideToggle('slow');
        });
        
        // Checkbox background change
        jQuery(':checkbox').change(
    			function() {
      			if ( this.checked )
        			jQuery(this).parents('.option-inner').animate({backgroundColor:'#ccffcc'},100).animate({backgroundColor:'#F9F9F9'},1000);
      			else
        			jQuery(this).parents('.option-inner').animate({backgroundColor:'#ffcccc'},100).animate({backgroundColor:'#F9F9F9'},1000);
    			}
				); 
				
				// Logo Toggle
				jQuery('#gpp_logo_off').is(':checked') ? jQuery(".gpp_logo").hide() : jQuery(".gpp_logo").show();

       	jQuery('#gpp_logo_off').change(function() {
       	
               if(jQuery(this).is(':checked')){
                       jQuery('.gpp_logo').slideUp('fast');
                       return false;
               } else {
                       jQuery('.gpp_logo').slideDown('fast');
                       return false;
               }
       });
       
       	// Color Toggle
				jQuery('#gpp_css').is(':checked') ? jQuery(".gpp_background_color,.gpp_background_image,.gpp_background_repeat,.gpp_page_color,.gpp_border_color,.gpp_footer_color,.gpp_logo_color,.gpp_font_color,.gpp_link_color,.gpp_hover_color,.gpp_nav_bg_color,.gpp_nav_bg_hover_color,.gpp_nav_link_color,.gpp_nav_link_hover_color,.gpp_custom_css").show() : jQuery(".gpp_background_color,.gpp_background_image,.gpp_background_repeat,.gpp_page_color,.gpp_border_color,.gpp_footer_color,.gpp_logo_color,.gpp_font_color,.gpp_link_color,.gpp_hover_color,.gpp_nav_bg_color,.gpp_nav_bg_hover_color,.gpp_nav_link_color,.gpp_nav_link_hover_color,.gpp_custom_css").hide();

       	jQuery('#gpp_css').change(function() {
       	
               if(jQuery(this).is(':checked')){
                       jQuery('.gpp_background_color,.gpp_background_image,.gpp_background_repeat,.gpp_page_color,.gpp_border_color,.gpp_footer_color,.gpp_logo_color,.gpp_font_color,.gpp_link_color,.gpp_hover_color,.gpp_nav_bg_color,.gpp_nav_bg_hover_color,.gpp_nav_link_color,.gpp_nav_link_hover_color,.gpp_custom_css').slideDown('fast');
                       return false;
               } else {
                       jQuery('.gpp_background_color,.gpp_background_image,.gpp_background_repeat,.gpp_page_color,.gpp_border_color,.gpp_footer_color,.gpp_logo_color,.gpp_font_color,.gpp_link_color,.gpp_hover_color,.gpp_nav_bg_color,.gpp_nav_bg_hover_color,.gpp_nav_link_color,.gpp_nav_link_hover_color,.gpp_custom_css').slideUp('fast');
                       return false;
               }
       });

				// Nav Toggle PhotoShelter
				jQuery('#gpp_photoshelter').is(':checked') ? jQuery(".gpp_photoshelter_name").show() : jQuery(".gpp_photoshelter_name").hide();

       	jQuery('#gpp_photoshelter').change(function() {
       	
               if(jQuery(this).is(':checked')){
                       jQuery('.gpp_photoshelter_name').slideDown('fast');
                       return false;
               } else {
                       jQuery('.gpp_photoshelter_name').slideUp('fast');
                       return false;
               }
       });
       
       // Nav Toggle Contact Info
       jQuery('#gpp_contact_info').is(':checked') ? jQuery(".gpp_phone,.gpp_email").show() : jQuery(".gpp_phone,.gpp_email").hide();
       
       jQuery('#gpp_contact_info').change(function() {
       	
               if(jQuery(this).is(':checked')){
                       jQuery('.gpp_phone,.gpp_email').slideDown('fast');
                       return false;
               } else {
                       jQuery('.gpp_phone,.gpp_email').slideUp('fast');
                       return false;
               }
       });
       
       // Nav Toggle Link Addition
       jQuery('#gpp_link_addition').is(':checked') ? jQuery(".gpp_link_title,.gpp_link_title_2,.gpp_link_title_3,.gpp_link_title_4,.gpp_link_title_5,.gpp_link_title_6,.gpp_link_title_7,.gpp_link_URL,.gpp_link_URL_2,.gpp_link_URL_3,.gpp_link_URL_4,.gpp_link_URL_5,.gpp_link_URL_6,.gpp_link_URL_7").show() : jQuery(".gpp_link_title,.gpp_link_title_2,.gpp_link_title_3,.gpp_link_title_4,.gpp_link_title_5,.gpp_link_title_6,.gpp_link_title_7,.gpp_link_URL,.gpp_link_URL_2,.gpp_link_URL_3,.gpp_link_URL_4,.gpp_link_URL_5,.gpp_link_URL_6,.gpp_link_URL_7").hide();
       
       jQuery('#gpp_link_addition').change(function() {
       	
               if(jQuery(this).is(':checked')){
                       jQuery('.gpp_link_title,.gpp_link_title_2,.gpp_link_title_3,.gpp_link_title_4,.gpp_link_title_5,.gpp_link_title_6,.gpp_link_title_7,.gpp_link_URL,.gpp_link_URL_2,.gpp_link_URL_3,.gpp_link_URL_4,.gpp_link_URL_5,.gpp_link_URL_6,.gpp_link_URL_7').slideDown('fast');
                       return false;
               } else {
                       jQuery('.gpp_link_title,.gpp_link_title_2,.gpp_link_title_3,.gpp_link_title_4,.gpp_link_title_5,.gpp_link_title_6,.gpp_link_title_7,.gpp_link_URL,.gpp_link_URL_2,.gpp_link_URL_3,.gpp_link_URL_4,.gpp_link_URL_5,.gpp_link_URL_6,.gpp_link_URL_7').slideUp('fast');
                       return false;
               }
       });
       
       // Welcome Toggle
       jQuery('#gpp_welcome').is(':checked') ? jQuery(".gpp_welcome_title,.gpp_welcome_content").show() : jQuery(".gpp_welcome_title,.gpp_welcome_content").hide();
       
       jQuery('#gpp_welcome').change(function() {
       	
               if(jQuery(this).is(':checked')){
                       jQuery('.gpp_welcome_title,.gpp_welcome_content').slideDown('fast');
                       return false;
               } else {
                       jQuery('.gpp_welcome_title,.gpp_welcome_content').slideUp('fast');
                       return false;
               }
       });
       
       // Slideshow Toggle
       jQuery('#gpp_slideshow').is(':checked') ? jQuery(".gpp_slideshow_image_1,.gpp_slideshow_image_2,.gpp_slideshow_image_3,.gpp_slideshow_image_4,.gpp_slideshow_image_5,.gpp_slideshow_height,.gpp_slideshow_time,.gpp_slideshow_speed").show() : jQuery(".gpp_slideshow_image_1,.gpp_slideshow_image_2,.gpp_slideshow_image_3,.gpp_slideshow_image_4,.gpp_slideshow_image_5,.gpp_slideshow_height,.gpp_slideshow_time,.gpp_slideshow_speed").hide();
       
       jQuery('#gpp_slideshow').change(function() {
       	
               if(jQuery(this).is(':checked')){
                       jQuery('.gpp_slideshow_image_1,.gpp_slideshow_image_2,.gpp_slideshow_image_3,.gpp_slideshow_image_4,.gpp_slideshow_image_5,.gpp_slideshow_height,.gpp_slideshow_time,.gpp_slideshow_speed').slideDown('fast');
                       return false;
               } else {
                       jQuery('.gpp_slideshow_image_1,.gpp_slideshow_image_2,.gpp_slideshow_image_3,.gpp_slideshow_image_4,.gpp_slideshow_image_5,.gpp_slideshow_height,.gpp_slideshow_time,.gpp_slideshow_speed').slideUp('fast');
                       return false;
               }
       });
       
       // Only show iPhone file path if iPhone option is checked
       jQuery('#gpp_iphone').is(':checked') && jQuery('#gpp_video').is(':checked') ? jQuery(".gpp_iphone_file").show() : jQuery(".gpp_iphone_file").hide();
       
       jQuery('#gpp_iphone,#gpp_video').change(function() {
           
               if(jQuery('#gpp_iphone').is(':checked') && jQuery('#gpp_video').is(':checked')){
                       jQuery('.gpp_iphone_file').slideDown('fast');
                       return false;
               } else {
                       jQuery('.gpp_iphone_file').slideUp('fast');
                       return false;
               }
       });
       
       // Video Toggle
       jQuery('#gpp_video').is(':checked') ? jQuery(".gpp_video_file,.gpp_video_thumbnail,.gpp_video_width,.gpp_video_height").show() : jQuery(".gpp_video_file,.gpp_video_thumbnail,.gpp_video_width,.gpp_video_height").hide();
       
       jQuery('#gpp_video').change(function() {
       	
               if(jQuery(this).is(':checked')){
                       jQuery('.gpp_video_file,.gpp_video_thumbnail,.gpp_video_width,.gpp_video_height').slideDown('fast');
                       return false;
               } else {
                       jQuery('.gpp_video_file,.gpp_video_thumbnail,.gpp_video_width,.gpp_video_height').slideUp('fast');
                       return false;
               }
       });
       
       	// Slider Toggle
				jQuery('#gpp_slider').is(':checked') ? jQuery(".gpp_slider_cat").show() : jQuery(".gpp_slider_cat").hide();

       	jQuery('#gpp_slider').change(function() {
       	
               if(jQuery(this).is(':checked')){
                       jQuery('.gpp_slider_cat').slideDown('fast');
                       return false;
               } else {
                       jQuery('.gpp_slider_cat').slideUp('fast');
                       return false;
               }
       });
       
        // Sliding Post Toggle
				jQuery('#gpp_slider_posts').is(':checked') ? jQuery(".gpp_slider_posts_cat").show() : jQuery(".gpp_slider_posts_cat").hide();

       	jQuery('#gpp_slider_posts').change(function() {
       	
               if(jQuery(this).is(':checked')){
                       jQuery('.gpp_slider_posts_cat').slideDown('fast');
                       return false;
               } else {
                       jQuery('.gpp_slider_posts_cat').slideUp('fast');
                       return false;
               }
       });
       
        // Featured Posts Toggle
				jQuery('#gpp_featured').is(':checked') ? jQuery(".gpp_featured_cat").show() : jQuery(".gpp_featured_cat").hide();

       	jQuery('#gpp_featured').change(function() {
       	
               if(jQuery(this).is(':checked')){
                       jQuery('.gpp_featured_cat').slideDown('fast');
                       return false;
               } else {
                       jQuery('.gpp_featured_cat').slideUp('fast');
                       return false;
               }
       });
       
        // Blog Toggle
				jQuery('#gpp_blog').is(':checked') ? jQuery(".gpp_blog_cat,.gpp_blog_number").show() : jQuery(".gpp_blog_cat,.gpp_blog_number").hide();

       	jQuery('#gpp_blog').change(function() {
       	
               if(jQuery(this).is(':checked')){
                       jQuery('.gpp_blog_cat,.gpp_blog_number').slideDown('fast');
                       return false;
               } else {
                       jQuery('.gpp_blog_cat,.gpp_blog_number').slideUp('fast');
                       return false;
               }
       });
       
        // Category Toggle
				jQuery('#gpp_category_columns').is(':checked') ? jQuery(".gpp_category_column_1,.gpp_category_column_2,.gpp_category_column_3,.gpp_category_column_4,.gpp_category_column_5").show() : jQuery(".gpp_category_column_1,.gpp_category_column_2,.gpp_category_column_3,.gpp_category_column_4,.gpp_category_column_5").hide();

       	jQuery('#gpp_category_columns').change(function() {
       	
               if(jQuery(this).is(':checked')){
                       jQuery('.gpp_category_column_1,.gpp_category_column_2,.gpp_category_column_3,.gpp_category_column_4,.gpp_category_column_5').slideDown('fast');
                       return false;
               } else {
                       jQuery('.gpp_category_column_1,.gpp_category_column_2,.gpp_category_column_3,.gpp_category_column_4,.gpp_category_column_5').slideUp('fast');
                       return false;
               }
       });
       
       
       
    });
</script>

<?php }

add_action('admin_head', 'wf_admin_head');    
?>