<?php
function serpentsoft_styles_ltr(){
    // Bootstrap & FontAwesome
    wp_register_style( 'serpentsoft_style_bootstrap', get_template_directory_uri() . '/framework/bootstrap/css/bootstrap.min.css' , array(), '2.3.2', 'screen' );
    wp_register_style( 'serpentsoft_style_fontawesome', get_template_directory_uri() . '/framework/fontawesome/css/font-awesome.min.css' , array(), '3.1.0' );
    
    // Slider
    wp_register_style( 'serpentsoft_style_flexslider_shThemeDefault', get_template_directory_uri() . '/framework/sliders/flex/css/shThemeDefault.css' , array(), '1.5.2' );
    wp_register_style( 'serpentsoft_style_flexslider_shCore', get_template_directory_uri() . '/framework/sliders/flex/css/shCore.css' , array(), '1.5.2' );
    wp_register_style( 'serpentsoft_style_flexslider', get_template_directory_uri() . '/framework/sliders/flex/css/flexslider.css' , array(), '1.5.2', 'screen' );
    
    // Lightbox
    wp_register_style( 'serpentsoft_style_fancybox', get_template_directory_uri() . '/framework/fancybox/prettyPhoto.css' , array(), '1.5.2' );
        
    // Theme Skin
    wp_register_style( 'serpentsoft_style_light_skin', get_template_directory_uri() . '/skin-and-color/light-skin.css' , array(), '1.0.0' );
    wp_register_style( 'serpentsoft_style_skin_color', get_template_directory_uri() . '/skin-and-color/skin-color.css' , array(), '1.0.0' );
    
    // Main Styles.css
    wp_register_style( 'serpentsoft_main_style', get_stylesheet_uri(), array(), '1.0.0', 'all' );
    
    // Styles
    wp_register_style( 'serpentsoft_style_combine_styles', get_template_directory_uri() . '/combine-styles.css' , array(), '1.0.0' );
    
    // Ticker
    wp_register_style( 'serpentsoft_style_ticker_breaking_news', get_template_directory_uri() . '/framework/ticker/breaking-news-ticker/ticker-style.css' , array(), '1.0.0' );
    
    // Fix Firefox Browsers
    wp_register_style( 'serpentsoft_style_fix_firefox', get_template_directory_uri() . '/css/fix-ie/firefox.css' , array(), '1.0.0' );
    
    // Custom Styles /css/custom_styles.css
    wp_register_style( 'serpentsoft_custom_style', get_template_directory_uri() . '/css/custom_styles.css', array(), '1.0.0', 'all' );
    
    
    // Responsiveness
    wp_register_style( 'serpentsoft_style_bootstrap_responsive', get_template_directory_uri() . '/framework/bootstrap/css/bootstrap-responsive.min.css' , array(), '2.3.2' );
    wp_register_style( 'serpentsoft_style_responsive', get_template_directory_uri() . '/responsive.css' , array(), '1.0.0' );
    
    // Responsive 2 Columns
    wp_register_style( 'serpentsoft_2_columns_responsive', get_template_directory_uri() . '/css/layout-2-cols-responsive.css' , array(), '1.0.0' );
    
    wp_enqueue_style( 'serpentsoft_style_bootstrap' );
    wp_enqueue_style( 'serpentsoft_style_fontawesome' );
    
    wp_enqueue_style( 'serpentsoft_style_flexslider_shThemeDefault' );
    wp_enqueue_style( 'serpentsoft_style_flexslider_shCore' );
    wp_enqueue_style( 'serpentsoft_style_flexslider' );
    
    wp_enqueue_style( 'serpentsoft_style_fancybox' );
    
    wp_enqueue_style( 'serpentsoft_style_light_skin' );
    wp_enqueue_style( 'serpentsoft_style_skin_color' );
    
    wp_enqueue_style( 'serpentsoft_main_style' );
    
    wp_enqueue_style( 'serpentsoft_style_combine_styles' );
    
    if( serpentsoft_get_data('serpentsoft_switch_breakingnews') ){ wp_enqueue_style( 'serpentsoft_style_ticker_breaking_news' ); }
    
    wp_enqueue_style( 'serpentsoft_style_fix_firefox' );
    
    wp_enqueue_style( 'serpentsoft_custom_style' );
    
    /* Page Layout */
    $page_layout = serpentsoft_get_data('serpentsoft_pagelayout');
    
    /* Responsive */
    $responsiveness = serpentsoft_get_data('serpentsoft_switch_responsiveness');
    
    // isset for old users
    if( isset($responsiveness) ){
        
        // Responsive Enabled
        if ( $responsiveness ){
            wp_enqueue_style( 'serpentsoft_style_bootstrap_responsive' );
            
            if( $page_layout == 'left' || $page_layout == 'middle' || $page_layout == 'right' ){
                wp_enqueue_style( 'serpentsoft_style_responsive' );
            }
            elseif ($page_layout == '2cols-left' || $page_layout == '2cols-right') {
                wp_enqueue_style( 'serpentsoft_2_columns_responsive' );
            }
            else {
                //wp_enqueue_style( 'serpentsoft_style_responsive' );
            }
        }
        
        // Responsive Disabled
        else{
            wp_register_style( 'serpentsoft_responsive_disable', get_template_directory_uri() . '/css/responsive-disable.css' , array(), '1.0.0' );
            wp_enqueue_style( 'serpentsoft_responsive_disable' );
        }
    }
    else{
        // Not Set for Old Users
        wp_enqueue_style( 'serpentsoft_style_bootstrap_responsive' );
        wp_enqueue_style( 'serpentsoft_style_responsive' );
    }
    
    if( $page_layout == '2cols-left' || $page_layout == '2cols-right' ){
        wp_register_style( 'serpentsoft_2cols', get_template_directory_uri() . '/css/layout-2-cols.css', array(), '1.0.0', 'all' );
        wp_enqueue_style( 'serpentsoft_2cols' );
    }
}

add_action( 'wp_enqueue_scripts', 'serpentsoft_scripts' );
function serpentsoft_scripts() {
    global $wp_styles;
    global $is_IE;
    
    ## Register All Scripts
    /*/* Without Args = Define in Header Portion */
    wp_register_script( 'serpentsoft_modernizer', get_template_directory_uri() . '/js/modernizr.js', array( 'jquery' ) );

    /* Serpentsoft Scripts */
    wp_register_script( 'serpentsoft_scripts', get_template_directory_uri() . '/js/jsAdamsMag.js', array( 'jquery' ) );
    
    /* Bootstrap */
    wp_register_script( 'serpentsoft_bootstrap', get_template_directory_uri() . '/js/core/bootstrap.min.js', array( 'jquery' ), false, true );
    
    wp_register_script( 'serpentsoft_easing', get_template_directory_uri() . '/js/core/jquery.easing.1.3.js', array( 'jquery' ), false, true );
    
    //wp_register_script( 'serpentsoft_jPlayer', get_template_directory_uri() . '/framework/jPlayer-220/jquery.jplayer.min.js', array( ), false, true );
    
    /* Flex Slider Helpeing */
    wp_register_script( 'serpentsoft_flexslider_2', get_template_directory_uri() . '/framework/sliders/flex/js/shCore.js', array( 'jquery' ), false, true );
    wp_register_script( 'serpentsoft_flexslider_3', get_template_directory_uri() . '/framework/sliders/flex/js/shBrushXml.js', array( 'jquery' ), false, true );
    wp_register_script( 'serpentsoft_flexslider_4', get_template_directory_uri() . '/framework/sliders/flex/js/shBrushJScript.js', array( 'jquery' ), false, true );

    
    
    /* Get Global Scripts */
    wp_enqueue_script( 'serpentsoft_modernizer' );
    wp_enqueue_script( 'serpentsoft_scripts' );
    
    
    // Footer scripts
    // jPlayer
    //wp_enqueue_script( 'serpentsoft_jPlayer' );
    
    wp_enqueue_script( 'serpentsoft_bootstrap' );
    wp_enqueue_script( 'serpentsoft_easing' );
    
    
    
    wp_enqueue_script( 'serpentsoft_flexslider_2' );
    wp_enqueue_script( 'serpentsoft_flexslider_3' );
    wp_enqueue_script( 'serpentsoft_flexslider_4' );
    
    
    
    
    /* Register all css */
    if( is_rtl() ){
        serpentsoft_styles_ltr();
    }
    else{
        serpentsoft_styles_ltr();
    }
    
    /* Fix Facebook and Google+ Thumb issu */
    if( is_page() || is_single() ) {
        serpentsoft_og_image();
        serpentsoft_facebook_opengraph_advanced();
    }
    
    /* Internet Explorer Issues */
    // Loads HTML5 JavaScript file to add support for HTML5 elements in older IE versions. ?>
    <!--[if lt IE 9]>
        <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
    <![endif]-->
    
    <?php if($is_IE) { echo '<meta http-equiv="X-UA-Compatible" content="IE=edge" />'; }
    
    wp_register_style( 'serpentsoft-ie7', get_template_directory_uri() . '/framework/fontawesome/css/font-awesome-ie7.min.css', array( 'serpentsoft_main_style' ), '20130921' );
    $wp_styles->add_data( 'serpentsoft-ie7', 'conditional', 'IE 7' );
    wp_enqueue_style( 'serpentsoft-ie7' );
    
    wp_register_style( 'serpentsoft-lt-ie9', get_template_directory_uri() . '/css/fix-ie/ie9.css', array( 'serpentsoft_main_style' ), '20130921' );
    $wp_styles->add_data( 'serpentsoft-lt-ie9', 'conditional', 'lt IE 9' );
    wp_enqueue_style( 'serpentsoft-lt-ie9' );
    
    wp_register_style( 'serpentsoft-gt-ie9', get_template_directory_uri() . '/css/fix-ie/ie10.css', array( 'serpentsoft_main_style' ), '20130921' );
    $wp_styles->add_data( 'serpentsoft-gt-ie9', 'conditional', 'gt IE 9' );
    wp_enqueue_style( 'serpentsoft-gt-ie9' );
    
    wp_register_style( 'serpentsoft-ie10', get_template_directory_uri() . '/css/fix-ie/ie10.css', array( 'serpentsoft_main_style' ), '20130921' );
    $wp_styles->add_data( 'serpentsoft-ie10', 'conditional', 'IE 10' );
    wp_enqueue_style( 'serpentsoft-ie10' );
    
}

/* add_action('wp_print_styles', 'load_fonts'); */
//add_action('wp_enqueue_scripts', 'load_fonts');
function load_fonts() {
    //wp_enqueue_style('OpenSans' , 'http://fonts.googleapis.com/css?family=Open+Sans');
}

/* =============================================================================== */
// Header Function
/* =============================================================================== */
add_action('wp_head', 'serpentsoft_header_code');
function serpentsoft_header_code(){
    $header_code = serpentsoft_get_data('serpentsoft_headerCode');
    if(!empty($header_code)) { echo htmlspecialchars_decode($header_code); }
    
}

/* =============================================================================== */
// Footer Function
/* =============================================================================== */
add_action('wp_footer', 'serpentsoft_footer_code');
function serpentsoft_footer_code(){
    $footer_code = serpentsoft_get_data('serpentsoft_footerCode');
    if(!empty($footer_code)) { echo htmlspecialchars_decode($footer_code); }
    
    if( serpentsoft_get_data('serpentsoft_switch_gotoTopButton') ) {
        echo '<div id="divGoToTop" rel="tooltip" data-toggle="tooltip" data-placement="top" data-original-title="' . __( 'Scroll To Top', 'serpentsoft' ) . '" title=""><i class="icon-chevron-up"></i></div>'; }
} ?>