<?php


function lioit_enqueue_css() {
	
	global $data; //THEMEOPTIONS

	wp_enqueue_style('anaheim', 'http://fonts.googleapis.com/css?family=Anaheim', 'style');
	wp_enqueue_style('orienta', 'http://fonts.googleapis.com/css?family=Orienta', 'style');
	wp_enqueue_style('montserrat', 'http://fonts.googleapis.com/css?family=Montserrat+Alternates', 'style');
	wp_enqueue_style('pt-sans', 'http://fonts.googleapis.com/css?family=PT+Sans', 'style');
	
	//RESPONSIVE
	if($data['responsive'] != '0') {
		wp_enqueue_style('responsive', get_template_directory_uri() . '/responsive.css', 'style');
	}
	//disable_top_bar
	
}

add_action('wp_enqueue_scripts', 'lioit_enqueue_css');


function lioit_register_js() {
	if (!is_admin()) {
		
		wp_deregister_script('jquery'); 
		wp_register_script('jquery', ("https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"), false, '1.7.1'); 
		wp_enqueue_script('jquery');	
		
		wp_deregister_script('jquery-ui'); 
			wp_register_script('jquery-ui', ("https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"), false, '1.8.16'); 
		wp_enqueue_script('jquery-ui');
		wp_register_script('jquery_cookie', Lioit_JS . '/cookie.js', 'jquery');
		wp_register_script('cycle_slider', Lioit_JS . '/jquery.cycle.all.min.js', 'jquery');
		wp_register_script('flexslider', Lioit_JS . '/jquery.flexslider-min.js', 'jquery');
		wp_register_script('flexsliderrtl', Lioit_JS . '/jquery.flexslider-rtl.js', 'jquery');
		wp_register_script('jqueryTools', Lioit_JS . '/jquery.tools.min.js', 'jquery');
		wp_register_script('isotope', Lioit_JS . '/jquery.isotope.min.js', 'jquery');
		wp_register_script('effects', Lioit_JS . '/effects.js', 'jquery');
		wp_register_script('Tweets', Lioit_JS . '/jquery.tweet.js', 'jquery');
		wp_register_script('prettyPhoto', Lioit_JS . '/jquery.prettyPhoto.js', 'jquery');
		wp_register_script('Tipsy', Lioit_JS . '/jquery.tipsy.js', 'jquery');
		
		wp_register_script('hoverdir', Lioit_JS . '/jquery.hoverdir.js', 'jquery');
		wp_register_script('elastislide', Lioit_JS . '/jquery.elastislide.js', 'jquery');
		wp_register_script('jquerytweet', Lioit_JS . '/jquery.tweet.js', 'jquery');
		wp_enqueue_script('notification', Lioit_JS . '/notification.js', 'jquery', '', TRUE);
		wp_register_script('liscroll', Lioit_JS . '/jquery.li-scroller.1.0.js', 'jquery');
		wp_register_script('liscrollr', Lioit_JS . '/jquery.li-scroller_r.1.0.js', 'jquery');
		wp_register_script('custom', Lioit_JS . '/custom.js', 'jquery', '1.0', TRUE);
		
		
		wp_enqueue_script('jquery_cookie');
		wp_enqueue_script('cycle_slider');
		
		if(is_rtl()) {
		wp_enqueue_script('flexsliderrtl');
		} else {
		wp_enqueue_script('flexslider');
		}
		wp_enqueue_script('jqueryTools');
		wp_enqueue_script('isotope');
		wp_enqueue_script('effects');
		wp_enqueue_script('Tweets');
		wp_enqueue_script('prettyPhoto');
		wp_enqueue_script('Tipsy');
		
		wp_enqueue_script('hoverdir');
		wp_enqueue_script('jquerytweet');
		wp_enqueue_script('notification');
		wp_enqueue_script('custom');
	
		if(is_rtl()) {
		wp_enqueue_script('liscrollr');
		} else {
		wp_enqueue_script('liscroll');
		}
		
		
		
	}
}
add_action('init', 'lioit_register_js');

/*-----------------------------------------------------------------------------------*/
# lioit Thumb SRC
/*-----------------------------------------------------------------------------------*/
function catch_that_image(){
		global $post;
		$image = '';
		$size = '';
		//get the post thumbnail
		$image_id = get_post_thumbnail_id($post->ID);
		$image = wp_get_attachment_image_src($image_id, $size);
		$image = $image[0];
		if ($image) return $image;
		//If there is still no image, get the first image from the post
		return lioit_get_first_image();
		}
		      function lioit_get_first_image() 
               {
                 global $post, $posts;
                 $first_img = '';
                 ob_start();
                 ob_end_clean();
                 $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
                 if(isset($matches[1][0]))
                 {
                         $first_img = $matches[1][0];
                 }                      
                 else
                 {
                        $first_img = Lioit_IMG.'/preview.png';
                      
                 }
               
                 return $first_img;
            
		}

function my_password_form() {
    global $post;
    $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
    $o = '<div class="postPassowdBox"><form class="protected-post-form" action="' . get_option( 'siteurl' ) . '/wp-pass.php" method="post">
    ' . __( "<span>To view this protected post, enter the password below: </span>","lioit" ) . '
    <label for="' . $label . '">' . __( "Password:" ) . ' </label><input class="postPassowd" name="post_password" id="' . $label . '" type="password" size="20" /><input class="postPassowdgo" type="submit" name="Submit" value="' . esc_attr__( "Submit","lioit" ) . '" />
    </form></div>
    ';
    return $o;
}
add_filter( 'the_password_form', 'my_password_form' );
?>