<?php
if(!function_exists('ts_js')){

	/*
	 * javascript
	*/
	function ts_js()
	{
		if(!is_admin())
		{

			wp_enqueue_script('jquery');

			wp_register_script('ddsmoothmenu', THEMESTUDIO_JS . '/mainmenu/ddsmoothmenu.js', false, THEMESTUDIO_THEME_VERSION, true);
			wp_enqueue_script( 'ddsmoothmenu' );

			wp_register_script('selectnav', THEMESTUDIO_JS . '/mainmenu/selectnav.js', false, THEMESTUDIO_THEME_VERSION, true);
			wp_enqueue_script( 'selectnav' );

			wp_register_script('jquery.jcarousel.min', THEMESTUDIO_JS . '/jcarousel/jquery.jcarousel.min.js', false, THEMESTUDIO_THEME_VERSION, true);
			wp_enqueue_script( 'jquery.jcarousel.min' );

			wp_register_script('jquery.themepunch.revolution.min', THEMESTUDIO_JS . '/revolutionslider/rs-plugin/js/jquery.themepunch.revolution.min.js', false, THEMESTUDIO_THEME_VERSION, true);
			wp_enqueue_script( 'jquery.themepunch.revolution.min' );

			wp_register_script('scripts', THEMESTUDIO_JS . '/mainmenu/scripts.js', false, THEMESTUDIO_THEME_VERSION, true);
			wp_enqueue_script( 'scripts' );

			wp_register_script('tabs', THEMESTUDIO_JS . '/tabs/tabs.js', false, THEMESTUDIO_THEME_VERSION, true);
			wp_enqueue_script( 'tabs' );

			wp_register_script('tabs-style2', THEMESTUDIO_JS . '/tabs/tabs-style2.js', false, THEMESTUDIO_THEME_VERSION, true);
			wp_enqueue_script( 'tabs-style2' );

			wp_register_script('accordion-custom', THEMESTUDIO_JS . '/accordion/custom.js', false, THEMESTUDIO_THEME_VERSION, true);
			wp_enqueue_script( 'accordion-custom' );

			wp_register_script('menu-core', THEMESTUDIO_JS . '/sticky-menu/core.js', false, THEMESTUDIO_THEME_VERSION, true);
			wp_enqueue_script( 'menu-core' );

		    wp_register_script('modernizr.custom.75180', THEMESTUDIO_JS.'/sticky-menu/modernizr.custom.75180.js', false, THEMESTUDIO_THEME_VERSION, true );
		    wp_enqueue_script( 'modernizr.custom.75180' );

			wp_register_script('jquery.flexslider-min', THEMESTUDIO_JS . '/jquery.flexslider-min.js', false, THEMESTUDIO_THEME_VERSION, true);
			wp_enqueue_script( 'jquery.flexslider-min' );

			wp_register_script('custom-js', THEMESTUDIO_JS . '/custom.js', false, THEMESTUDIO_THEME_VERSION, true);
			wp_enqueue_script( 'custom-js' );

		}
	}
	add_action('wp_enqueue_scripts','ts_js');

}

if(!function_exists('ts_onepage_menu_js')){
	function ts_onepage_menu_js(){
	  	wp_register_script('jquery.scrollto.min', THEMESTUDIO_JS.'/mainmenu/jquery.scrollto.min.js', false, THEMESTUDIO_THEME_VERSION, true );
		wp_enqueue_script( 'jquery.scrollto.min' );
	  	wp_register_script('jquery.nav', THEMESTUDIO_JS.'/mainmenu/jquery.nav.js', false, THEMESTUDIO_THEME_VERSION, true );
		wp_enqueue_script( 'jquery.nav' );
	}
}

if(!function_exists('metabox_js')){
	add_action('admin_enqueue_scripts','metabox_js');
	function    metabox_js()
	{
	    if(is_admin())
	    {
	        wp_register_script('custommetabox', THEMESTUDIO_THEME_LIBS_URL . '/admin/metaboxes/js/custommetabox.js', false, THEMESTUDIO_THEME_VERSION, true);
	        wp_enqueue_script('custommetabox');

	        wp_register_style( 'font-awesome.min', THEMESTUDIO_CSS.'/font-awesome/css/font-awesome.min.css', false, THEMESTUDIO_THEME_VERSION, 'screen');
	        wp_enqueue_style( 'font-awesome.min' );
	    }
	}
}

if(!function_exists('ts_css')){

	/*
	 * load css
	*/
	function 	ts_css()
	{
		global $ainex;

		if(isset($ainex['theme_color'])){
			$theme_color = $ainex['theme_color'];
		} else {
			$theme_color = 'blue';
		}

		wp_enqueue_style( 'ainex-style', get_stylesheet_uri() );

		$styles = array(
			'reset',
			'style',
			'custom-bg',
			'custom',
			$theme_color,
			'font-awesome.min',
			'responsive-layouts',
			'core',
			'revolution-fullwidth',
			'accordion',
			'tabs',
			'tabs-style2',
			'fadeeffect',
			'pricing-table',
			'flexslider',
			'whmcs-style',
		);

		if(isset($ainex['switch_combine_css']) && $ainex['switch_combine_css'] == '1'){
			wp_enqueue_style( 'themestudio-combined-css', get_template_directory_uri() . '/assets/combine/do.combine.php?styles='.implode(',', $styles));
		}else {
			foreach($styles as $style){
				wp_enqueue_style( $style, THEMESTUDIO_CSS.'/'.$style.'.css');
			}
		}

	    wp_register_style('settings', THEMESTUDIO_JS . '/revolutionslider/rs-plugin/css/settings.css', false, THEMESTUDIO_THEME_VERSION, 'screen' );
	    wp_enqueue_style( 'settings' );

	    wp_register_style('skin', THEMESTUDIO_JS.'/jcarousel/skin.css', false, THEMESTUDIO_THEME_VERSION, 'screen' );
	    wp_enqueue_style( 'skin' );

	    wp_register_style('skin2', THEMESTUDIO_JS.'/jcarousel/skin2.css', false, THEMESTUDIO_THEME_VERSION, 'screen' );
	    wp_enqueue_style( 'skin2' );

	}
	add_action("wp_enqueue_scripts",'ts_css');

}


if(!function_exists('ts_get_custom_style')){

	function ts_get_custom_style()
	{

	    global $ainex;

	    $return ='';

	    if(isset($ainex['custom_css_code'])){
	    	$custom_css = $ainex['custom_css_code'];
	    } else {
	    	$custom_css = '';
	    }

	    if(isset($ainex['opt-background-pattern'])) {
		    switch ($ainex['opt-background-pattern']) {
		    	case 'preset':
		    		$return.= ' body{ background: url('.$ainex["opt-background-patternPreset"].') repeat left top;}';
		    	break;

		    	case 'custom':
		    		$return.= '';
		    	break;

		    	default:
		    		$return.= ' body{ background: #FFF; } ';
		    	break;
		    }
		}
	    $return.= $custom_css;

	    if ( is_user_logged_in() ) {
	    	$return.='#header.sticky #trueHeader { top: 30px; }';
	    }

	    $return .= ".header_inner #header.sticky #trueHeader{background-color: ".$ainex['header_background']['background-color'].";
			background-image: -webkit-gradient(linear, left top, left bottom, from(". $ainex['true_header_background']['from']."), to(". $ainex['true_header_background']['to']."));
			background-image: -webkit-linear-gradient(top, ".$ainex['true_header_background']['from'].", ".$ainex['true_header_background']['to'].");
			background-image: -moz-linear-gradient(top, ".$ainex['true_header_background']['from'].", ".$ainex['true_header_background']['to'].");
			background-image: -o-linear-gradient(top, ".$ainex['true_header_background']['from'].", ".$ainex['true_header_background']['to'].");
			background-image: linear-gradient(to bottom, ".$ainex['true_header_background']['from'].", ".$ainex['true_header_background']['to'].");}";

	    wp_add_inline_style( 'ainex-style', $return );
	}
	add_action( 'wp_enqueue_scripts', 'ts_get_custom_style' );

}


if ( !function_exists('fancybox_style') ) {

	function fancybox_style ()
	{
	    wp_register_style( 'jquery.fancybox', THEMESTUDIO_JS.'/portfolio/source/jquery.fancybox.css', false, THEMESTUDIO_THEME_VERSION, 'screen');
	    wp_enqueue_style( 'jquery.fancybox' );

	    wp_register_style( 'isotope', THEMESTUDIO_JS.'/portfolio/isotope.css', false, THEMESTUDIO_THEME_VERSION, 'screen');
	    wp_enqueue_style( 'isotope' );

	    wp_register_script('jquery.fancybox', THEMESTUDIO_JS . '/portfolio/source/jquery.fancybox.js', false, THEMESTUDIO_THEME_VERSION, true);
		wp_enqueue_script( 'jquery.fancybox' );

	    wp_register_script('jquery.fancybox-media', THEMESTUDIO_JS . '/portfolio/source/helpers/jquery.fancybox-media.js', false, THEMESTUDIO_THEME_VERSION, true);
		wp_enqueue_script( 'jquery.fancybox-media' );

	    wp_register_script('jquery.isotope', THEMESTUDIO_JS . '/portfolio/jquery.isotope.js', false, THEMESTUDIO_THEME_VERSION, true);
		wp_enqueue_script( 'jquery.isotope' );
	}
	add_action("wp_enqueue_scripts",'fancybox_style');

}


if(!function_exists('flex_assets')){

	/*
	 * Flex slider
	*/
	function flex_assets()
	{
	    wp_register_style('flexslider', THEMESTUDIO_JS.'/flexslider/flexslider.css', false, THEMESTUDIO_THEME_VERSION, 'screen');
	    wp_enqueue_style('flexslider');

	    wp_register_script('jquery.flexslider', THEMESTUDIO_JS.'/flexslider/jquery.flexslider.js', false, THEMESTUDIO_THEME_VERSION, true);
	    wp_enqueue_script('jquery.flexslider' );
	}

}


if(!function_exists('ts_animation')){

	function ts_animation()
	{
	    wp_register_style( 'animate-css', THEMESTUDIO_JS.'/animate/animate.min.css', false, THEMESTUDIO_THEME_VERSION, 'screen');
	    wp_enqueue_style( 'animate-css' );

	    wp_register_script('animation-wow', THEMESTUDIO_JS.'/animate/wow.min.js', false, THEMESTUDIO_THEME_VERSION, true );
	    wp_enqueue_script( 'animation-wow' );
	}
	add_action("wp_enqueue_scripts",'ts_animation');

}


if ( !function_exists('ts_subscribe_js') ) {

	function ts_subscribe_js() {
		wp_register_script('modernizr-custom', THEMESTUDIO_JS . '/subscribe/modernizr-custom.js', false, THEMESTUDIO_THEME_VERSION, true);
		wp_enqueue_script( 'modernizr-custom' );

		wp_register_script('precise-frontend-jquery', THEMESTUDIO_JS . '/subscribe/precise-frontend-jquery.js', false, THEMESTUDIO_THEME_VERSION, true);
		wp_enqueue_script( 'precise-frontend-jquery' );
	}
	add_action('wp_enqueue_scripts','ts_subscribe_js');

}

if ( !function_exists('ts_testimonial_slider') ) {

	function ts_testimonial_slider()
	{
		wp_register_style('owl.carousel', THEMESTUDIO_JS . '/owl-carousel/owl.carousel.css' , false, THEMESTUDIO_THEME_VERSION, 'screen');
		wp_enqueue_style( 'owl.carousel' );

		wp_register_style('owl.theme', THEMESTUDIO_JS . '/owl-carousel/owl.theme.css' , false, THEMESTUDIO_THEME_VERSION, 'screen');
		wp_enqueue_style( 'owl.theme' );

		wp_register_script('owl.carousel', THEMESTUDIO_JS . '/owl-carousel/owl.carousel.js', false, THEMESTUDIO_THEME_VERSION, true);
		wp_enqueue_script( 'owl.carousel' );
	}

}