<?php



// [dropcap foo="foo-value"]

function dropcap_func($atts, $content) {




	//extract short code attr

	extract(shortcode_atts(array(

		'style' => ''

	), $atts));

	

	//get first char

	$first_char = substr($content, 0, 1);

	$text_len = strlen($content);

	$rest_text = substr($content, 1, $text_len);



	$return_html = '<span class="dropcap '.$style.'">'.$first_char.'</span>';

	$return_html.= do_shortcode($rest_text);

	$return_html.= '<br class="clear"/><br/>';

	

	return $return_html;

}

add_shortcode('dropcap', 'dropcap_func');





// [quote foo="foo-value"]

function quote_func($atts, $content) {

	//extract short code attr
	extract(shortcode_atts(array(

		'align' => '',
		'width' => '',

	), $atts));


	$return_html = '<blockquote class="'.$align.'" style="width:'.$width.';">'.do_shortcode($content).'</blockquote>';

	return $return_html;

}

add_shortcode('quote', 'quote_func');



function testimonial_func($atts, $content) {

	//extract short code attr
	extract(shortcode_atts(array(

		'align' => '',
		'width' => '100%',
		'author' => '',

	), $atts));

	$return_html = '<div style="float:'.$align.';width:'.$width.';">';
	$return_html.= '<div class="testimonial_wrapper">'.do_shortcode($content).'</div>';
	$return_html.= '<div class="testimonial_arrow"></div>';
	$return_html.= '<div class="testimonial_name"><strong>'.$author.'</strong></div>';
	$return_html.= '</div>';

	return $return_html;

}

add_shortcode('testimonial', 'testimonial_func');



function pre_func($atts, $content) {


	$return_html = '<pre>'.strip_tags($content).'</pre>';

	

	return $return_html;

}

add_shortcode('pre', 'pre_func');





// [button foo="foo-value"]

function button_func($atts, $content) {




	//extract short code attr

	extract(shortcode_atts(array(

		'href' => '',

		'align' => '',

		'bg_color' => '',

		'text_color' => '',

		'size' => 'small',

		'style' => '',

		'color' => '',

		'target' => '_self',

	), $atts));

	

	if(!empty($color))

	{

		switch(strtolower($color))

		{

			case 'black':

				$bg_color = '#000000';

				$text_color = '#ffffff';

			break;

			case 'grey':

				$bg_color = '#7F8C8D';

				$text_color = '#ffffff';

			break;

			case 'white':

				$bg_color = '#f5f5f5';

				$text_color = '#444444';

			break;

			case 'blue':

				$bg_color = '#3498DB';

				$text_color = '#ffffff';

			break;

			case 'yellow':

				$bg_color = '#F1C40F';

				$text_color = '#ffffff';

			break;

			case 'red':

				$bg_color = '#E74C3C';

				$text_color = '#ffffff';

			break;

			case 'orange':

				$bg_color = '#F39C12';

				$text_color = '#ffffff';

			break;

			case 'green':

				$bg_color = '#2ECC71';

				$text_color = '#ffffff';

			break;

			case 'pink':

				$bg_color = '#ed6280';

				$text_color = '#ffffff';

			break;

			case 'purple':

				$bg_color = '#9B59B6';

				$text_color = '#ffffff';

			break;

		}

	}

	
	if(!empty($bg_color))
	{
		$border_color = $bg_color;
	}
	else
	{
		$border_color = 'transparent';
	}
	
	
	if(!empty($bg_color))
	{
		$return_html = '<a class="button '.$size.' '.$align.'" style="background-color:'.$bg_color.' !important;border:1px solid '.$border_color.' !important;color:'.$text_color.' !important;'.$style.'"';
	}
	else
	{
		$return_html = '<a class="button '.$size.' '.$align.'"';
	}
	

	if(!empty($href))

	{

		$return_html.= ' onclick="window.open(\''.$href.'\', \''.$target.'\')"';

	}

	

	$return_html.= '>'.$content.'</a>';

	

	return $return_html;

}

add_shortcode('button', 'button_func');





function lightbox_func($atts, $content) {

	extract(shortcode_atts(array(
		'title' => '',
		'href' => '',
		'type' => 'image',
		'youtube_id' => '',
		'vimeo_id' => '',
		'dailymotion_id' => '',
		'style' => '',
	), $atts));

	$class = 'lightbox';

	if($type != 'image')
	{
		$class.= '_'.$type;
	}

	if($type == 'youtube')
	{
		$href = '#video_'.$youtube_id;
	}

	if($type == 'vimeo')
	{
		$href = '#video_'.$vimeo_id;
	}

	$data_iframe = '';

	if($type=='iframe')
	{
		$data_iframe = 'data-fancybox-type="iframe"';
	}
	
	$return_html = '';
	$return_html.= '<a href="'.$href.'" class="'.$class.'" style="'.$style.'" '.$data_iframe.'>'.do_shortcode($content).'</a>';


	if(!empty($youtube_id))
	{
		$return_html.= '<div style="display:none;"><div id="video_'.$youtube_id.'" style="width:900px;height:488px"><iframe width="900" height="488" src="http://www.youtube.com/embed/'.$youtube_id.'?theme=dark&amp;rel=0&amp;wmode=opaque" frameborder="0"></iframe></div></div>';
	}

	if(!empty($vimeo_id))
	{
		$return_html.= '<div style="display:none;"><div id="video_'.$vimeo_id.'" style="width:900px;height:506px"><iframe src="http://player.vimeo.com/video/'.$vimeo_id.'?title=0&amp;byline=0&amp;portrait=0" width="900" height="506" frameborder="0"></iframe></div></div>';
	}

	return $return_html;

}

add_shortcode('lightbox', 'lightbox_func');



function styled_box_func($atts, $content) {




	//extract short code attr

	extract(shortcode_atts(array(

		'title' => '',

		'width' => '95%',

		'style' => '',

		'color' => '',

	), $atts));

	

	switch(strtolower($color))

		{

			case 'black':

				$bg_color = '#000000';

				$text_color = '#ffffff';

			break;

			default:

			case 'gray':

				$bg_color = '#666666';

				$text_color = '#ffffff';

			break;

			case 'white':

				$bg_color = '#f5f5f5';

				$text_color = '#444444';

			break;

			case 'blue':

				$bg_color = '#004a80';

				$text_color = '#ffffff';

			break;

			case 'yellow':

				$bg_color = '#f9b601';

				$text_color = '#ffffff';

			break;

			case 'red':

				$bg_color = '#9e0b0f';

				$text_color = '#ffffff';

			break;

			case 'orange':

				$bg_color = '#fe7201';

				$text_color = '#ffffff';

			break;

			case 'green':

				$bg_color = '#7aad34';

				$text_color = '#ffffff';

			break;

			case 'pink':

				$bg_color = '#d2027d';

				$text_color = '#ffffff';

			break;

			case 'purple':

				$bg_color = '#582280';

				$text_color = '#ffffff';

			break;

		}

	

	$bg_color_light = '#'.hex_lighter(substr($bg_color, 1), 20);

	$border_color = '#'.hex_lighter(substr($bg_color, 1), 10);

	

	$return_html = '<div class="styled_box_title" style="border:1px solid '.$border_color.';background: '.$bg_color.' '.$style.'">'.$title.'</div>';
	$return_html.= '<div class="styled_box_content" style="border:1px solid '.$border_color.';border-top:0;">'.html_entity_decode(do_shortcode($content)).'</div>';

	

	return $return_html;

}

add_shortcode('styled_box', 'styled_box_func');





function frame_left_func($atts, $content) {




	//extract short code attr

	extract(shortcode_atts(array(

		'src' => '',

		'href' => '',

	), $atts));

	

	$return_html = '<div class="frame_left">';

	

	if(!empty($href))

	{

		$return_html.= '<a href="'.$href.'" class="img_frame">';

	}

	

	$return_html.= '<img src="'.$src.'" alt=""/>';

	

	if(!empty($href))

	{

		$return_html.= '</a>';

	}

	

	if(!empty($content))

	{

		$return_html.= '<span class="caption">'.$content.'</span>';

	}

	

	$return_html.= '</div>';

	

	return $return_html;

}

add_shortcode('frame_left', 'frame_left_func');





function frame_right_func($atts, $content) {




	//extract short code attr

	extract(shortcode_atts(array(

		'src' => '',

		'href' => '',

	), $atts));

	

	$return_html = '<div class="frame_right">';

	

	if(!empty($href))

	{

		$return_html.= '<a href="'.$href.'" class="img_frame">';

	}

	

	$return_html.= '<img src="'.$src.'" alt=""/>';

	

	if(!empty($href))

	{

		$return_html.= '</a>';

	}

	

	if(!empty($content))

	{

		$return_html.= '<span class="caption">'.$content.'</span>';

	}

	

	$return_html.= '</div>';

	

	return $return_html;

}

add_shortcode('frame_right', 'frame_right_func');





function frame_center_func($atts, $content) {




	//extract short code attr

	extract(shortcode_atts(array(

		'src' => '',

		'href' => '',

	), $atts));

	

	$return_html = '<div class="frame_center">';

	

	if(!empty($href))

	{

		$return_html.= '<a href="'.$href.'" class="img_frame">';

	}

	

	$return_html.= '<img src="'.$src.'" alt=""/>';

	

	if(!empty($href))

	{

		$return_html.= '</a>';

	}

	

	if(!empty($content))

	{

		$return_html.= '<span class="caption">'.$content.'</span>';

	}

	

	$return_html.= '</div>';

	

	return $return_html;

}

add_shortcode('frame_center', 'frame_center_func');





function list_func($atts, $content) {




	//extract short code attr

	extract(shortcode_atts(array(

		'type' => '',

	), $atts));

	

	$return_html = '

		<style>

			.pp_list.'.$type.' ul li {

				display: block;

				background: url("'.get_bloginfo( 'stylesheet_directory' ).'/images/icon/'.$type.'_16x16.png") no-repeat top left;

			}

		</style>

	';

	

	$return_html.= '<div class="pp_list '.$type.'">'.strip_tags($content,'<ul><li><a>').'</div>';

	

	return $return_html;

}

add_shortcode('list', 'list_func');





function highlight_func($atts, $content) {




	//extract short code attr

	extract(shortcode_atts(array(

		'type' => 'yellow',

	), $atts));

	
	$return_html = '';
	$return_html.= '<span class="highlight_'.$type.'">'.strip_tags($content).'</span>';

	

	return $return_html;

}

add_shortcode('highlight', 'highlight_func');





function tagline_func($atts, $content) {
	
	$return_html = '';
	$return_html.= '<div class="tagline"><h2>'.strip_shortcodes(strip_tags($content)).'</h2>';
	$return_html.= '</div>';
	

	return $return_html;

}

add_shortcode('tagline', 'tagline_func');





function one_half_func($atts, $content) {




	//extract short code attr

	extract(shortcode_atts(array(

		'class' => '',

	), $atts));

	

	$return_html = '<div class="one_half '.$class.'">'.do_shortcode($content).'</div>';

	

	return $return_html;

}

add_shortcode('one_half', 'one_half_func');





function one_half_last_func($atts, $content) {




	//extract short code attr

	extract(shortcode_atts(array(

		'class' => '',

	), $atts));

	

	$return_html = '<div class="one_half last '.$class.'">'.do_shortcode($content).'</div><br class="clear"/>';

	

	return $return_html;

}

add_shortcode('one_half_last', 'one_half_last_func');


function one_third_func($atts, $content) {


	

	$return_html = '<div class="one_third">'.do_shortcode($content).'</div>';

	

	return $return_html;

}

add_shortcode('one_third', 'one_third_func');





function one_third_last_func($atts, $content) {


	

	$return_html = '<div class="one_third last">'.do_shortcode($content).'</div><br class="clear"/>';

	

	return $return_html;

}

add_shortcode('one_third_last', 'one_third_last_func');





function two_third_func($atts, $content) {


	

	$return_html = '<div class="two_third">'.do_shortcode($content).'</div>';

	

	return $return_html;

}

add_shortcode('two_third', 'two_third_func');





function two_third_last_func($atts, $content) {


	

	$return_html = '<div class="two_third last">'.do_shortcode($content).'</div><br class="clear"/>';

	

	return $return_html;

}

add_shortcode('two_third_last', 'two_third_last_func');





function one_fourth_func($atts, $content) {


	

	$return_html = '<div class="one_fourth">'.do_shortcode($content).'</div>';

	

	return $return_html;

}

add_shortcode('one_fourth', 'one_fourth_func');





function one_fourth_last_func($atts, $content) {


	

	$return_html = '<div class="one_fourth last">'.do_shortcode($content).'</div><br class="clear"/>';

	

	return $return_html;

}

add_shortcode('one_fourth_last', 'one_fourth_last_func');





function one_fifth_func($atts, $content) {


	

	$return_html = '<div class="one_fifth">'.do_shortcode($content).'</div>';

	

	return $return_html;

}

add_shortcode('one_fifth', 'one_fifth_func');





function one_fifth_last_func($atts, $content) {


	

	$return_html = '<div class="one_fifth last">'.do_shortcode($content).'</div><br class="clear"/>';

	

	return $return_html;

}

add_shortcode('one_fifth_last', 'one_fifth_last_func');





function one_sixth_func($atts, $content) {


	

	$return_html = '<div class="one_sixth">'.do_shortcode($content).'</div>';

	

	return $return_html;

}

add_shortcode('one_sixth', 'one_sixth_func');





function one_sixth_last_func($atts, $content) {


	

	$return_html = '<div class="one_sixth last">'.do_shortcode($content).'</div><br class="clear"/>';

	

	return $return_html;

}

add_shortcode('one_sixth_last', 'one_sixth_last_func');





function accordion_func($atts, $content) {
	//extract short code attr
	extract(shortcode_atts(array(
		'title' => '',
		'close' => 0,
	), $atts));

	$close_class = '';

	if(!empty($close))
	{
		$close_class = 'pp_accordion_close';
	}
	else
	{
		$close_class = 'pp_accordion';
	}

	//Add jquery ui script dynamically
	wp_enqueue_script("jquery-ui-core");
	wp_enqueue_script("jquery-ui-accordion");
	wp_enqueue_script('custom-accordion', get_stylesheet_directory_uri()."/js/custom-accordion.js", false, THEMEVERSION, true);

	$return_html = '<div class="'.$close_class.'"><h3><a href="#">'.$title.'</a></h3>';
	$return_html.= '<div><p>';
	$return_html.= do_shortcode($content);
	$return_html.= '</p></div></div>';

	return $return_html;
}

add_shortcode('accordion', 'accordion_func');


function pp_pre_func($atts, $content) {
	//extract short code attr
	extract(shortcode_atts(array(
		'title' => '',
		'close' => 1,
	), $atts));

	$return_html = '';
	$return_html.= '<pre>';
	$return_html.= $content;
	$return_html.= '</pre>';

	return $return_html;
}

add_shortcode('pp_pre', 'pp_pre_func');


function tabs_func($atts, $content) {
	//extract short code attr
	extract(shortcode_atts(array(
		'tab1' => '',
		'tab2' => '',
		'tab3' => '',
		'tab4' => '',
		'tab5' => '',
		'tab6' => '',
		'tab7' => '',
		'tab8' => '',
		'tab9' => '',
		'tab10' => '',
	), $atts));
	
	$tab_arr = array(
		$tab1,
		$tab2,
		$tab3,
		$tab4,
		$tab5,
		$tab6,
		$tab7,
		$tab8,
		$tab9,
		$tab10,
	);

	//Add jquery ui script dynamically
	wp_enqueue_script("jquery-ui-core");
	wp_enqueue_script("jquery-ui-tabs");
	wp_enqueue_script('custom-tab', get_stylesheet_directory_uri()."/js/custom-tab.js", false, THEMEVERSION, true);

	$return_html = '<div class="tabs"><ul>';

	foreach($tab_arr as $key=>$tab)
	{
		//display title1
		if(!empty($tab))
		{
			$return_html.= '<li><a href="#tabs-'.($key+1).'">'.$tab.'</a></li>';
		}
	}

	$return_html.= '</ul>';
	$return_html.= do_shortcode($content);
	$return_html.= '</div>';

	return $return_html;
}

add_shortcode('tabs', 'tabs_func');





function tab_func($atts, $content) {




	//extract short code attr

	extract(shortcode_atts(array(

		'id' => '',

	), $atts));

	
	$return_html = '';
	$return_html.= '<div id="tabs-'.$id.'" class="tab_wrapper"><br class="clear"/>'.pp_apply_content($content).'</div>';

	

	return $return_html;

}

add_shortcode('tab', 'tab_func');



function pricing_func($atts, $content) {


	

	//extract short code attr

	extract(shortcode_atts(array(

		'size' => '',

		'title' => '',

		'column' => 3,

		'last' => 0,

	), $atts));

	

	$width_class = 'three';

	switch($column)

	{

		case 3:

			$width_class = 'three';

		break;

		case 4:

			$width_class = 'four';

		break;

	}

	

	$return_html = '<div class="pricing_box '.$size.' '.$width_class.'">';

	

	if(!empty($title))

	{

		$return_html.= '<div class="header">';

		$return_html.= '<span>'.$title.'</span>';

		$return_html.= '</div>';

	}

	

	$return_html.= do_shortcode($content);

	$return_html.= '</div>';

	

	if(!empty($last))

	{

		$return_html.= '<br class="clear"/>';

	}

	

	return $return_html;

}

add_shortcode('pricing', 'pricing_func');



function map_func($atts) {

	//extract short code attr
	extract(shortcode_atts(array(
		'width' => 400,
		'height' => 300,
		'lat' => 0,
		'long' => 0,
		'zoom' => 12,
		'type' => '',
		'popup' => '',
		'address' => '',
	), $atts));

	$custom_id = time().rand();
	$return_html = '<div class="map_shortcode_wrapper" id="map'.$custom_id.'" style="width:'.$width.'px;height:'.$height.'px"></div>';
	
	$ext_attr = array(
		'id' => 'map'.$custom_id,
		'lat' => $lat,
		'long' => $long,
		'zoom' => $zoom,
		'type' => $type,
		'popup' => $popup,
		'address' => $address,
	);
	
	$ext_attr_serialize = serialize($ext_attr);
	
	wp_enqueue_script("script-contact-map".$custom_id, get_stylesheet_directory_uri()."/templates/script-shortcode-map.php?data=".$ext_attr_serialize, false, THEMEVERSION, true);

	return $return_html;

}

add_shortcode('map', 'map_func');





function youtube_func($atts) {




	//extract short code attr

	extract(shortcode_atts(array(

		'width' => 640,

		'height' => 385,

		'video_id' => '',

	), $atts));

	

	$custom_id = time().rand();

	

	$return_html = '<iframe title="YouTube video player" width="'.$width.'" height="'.$height.'" src="http://www.youtube.com/embed/'.$video_id.'?theme=dark&rel=0&wmode=transparent" frameborder="0" allowfullscreen></iframe>';

	

	return $return_html;

}

add_shortcode('youtube', 'youtube_func');





function vimeo_func($atts, $content) {



	//extract short code attr

	extract(shortcode_atts(array(

		'width' => 640,

		'height' => 385,

		'video_id' => '',

	), $atts));

	

	$custom_id = time().rand();

	

	$return_html = '<iframe src="http://player.vimeo.com/video/'.$video_id.'?title=0&amp;byline=0&amp;portrait=0" width="'.$width.'" height="'.$height.'" frameborder="0"></iframe>';

	
	return $return_html;

}

add_shortcode('vimeo', 'vimeo_func');





function video_func($atts) {
	//extract short code attr
	extract(shortcode_atts(array(
		'width' => 640,
		'height' => 385,
		'img_src' => '',
		'video_src' => '',
	), $atts));

	$custom_id = time().rand();
	
	$ext_self_video_attr = array(
		'id' => 'self_hosted_vid_'.$custom_id,
		'file' => $video_src,
		'image' => $img_src,
		'width' => $width,
		'height' => $height,
	);
					
	$ext_self_video_attr_serialize = serialize($ext_self_video_attr);
					
	wp_enqueue_script("script-shortcode-selfhosted-video".$custom_id, get_stylesheet_directory_uri()."/templates/script-shortcode-selfhosted-video.php?data=".$ext_self_video_attr_serialize, false, THEMEVERSION, true);

	$return_html = '<div id="video_self_'.$custom_id.'" style="width:'.$width.'px;height:'.$height.'px">';
	$return_html.= '<div id="self_hosted_vid_'.$custom_id.'">JW Player goes here</div>';
	$return_html.= '</div>';

	return $return_html;
}

add_shortcode('video', 'video_func');


function portfolio1_func($atts, $content) {

	//extract short code attr
	extract(shortcode_atts(array(
		'title' => 'Recent Portfolios',
		'items' => 8,
		'set_id' => '',
		'portfolio_url' => '',
		'pause_time' => 5,
	), $atts));

	$custom_id = time().rand();
	$pause_time = $pause_time * 1000;
	$content = trim($content);
	
	$ext_attr = array(
		'id' => 'home_portfolio_'.$custom_id,
		'items' => $items,
		'set_id' => $set_id,
		'portfolio_url' => $portfolio_url,
		'pause_time' => $pause_time,
	);
	
	$ext_attr_serialize = serialize($ext_attr);
	
	wp_enqueue_script("script-shortcode-portfolio".$custom_id, get_stylesheet_directory_uri()."/templates/script-shortcode-portfolio.php?data=".$ext_attr_serialize, false, THEMEVERSION, true);

	$return_html = '<div class="portfolio1_wrapper"><div class="one_fourth"><h4 class="cufon">'.$title.'</h4><p>'.$content.'</p>';

	if(!empty($portfolio_url))
	{
		$return_html.= '<br/><a class="classic" href="'.$portfolio_url.'">'.__( 'View more events', THEMEDOMAIN ).'</a>';
	}
	
	$return_html.= '</div>';

	//Get portfolios items
	$args = array(
	    'numberposts' => $items,
	    'order' => 'ASC',
	    'orderby' => 'menu_order',
	    'post_type' => array('portfolios'),
	);

	if(!empty($set_id))
	{
		$args['portfoliosets'] = $set_id;
	}

	$recent_portfolios_arr = get_posts($args);

	if(!empty($recent_portfolios_arr))
	{
		$return_html.= '<div id="home_portfolio_'.$custom_id.'" class="home_portfolio three_fourth">';
		$return_html.= '<ul class="slides">';

		foreach($recent_portfolios_arr as $key => $recent_portfolio)
		{
			if(($key+1)%3 == 0)
			{
				$column_class = 'one_third last';
			}
			else
			{
				$column_class = 'one_third';
			}

			if(empty($key) OR $key%3 == 0)
			{
				$return_html.= '<li>';
			}

			$portfolio_type = get_post_meta($recent_portfolio->ID, 'portfolio_type', true);
			$portfolio_video_id = get_post_meta($recent_portfolio->ID, 'portfolio_video_id', true);
			$portfolio_link_url = get_post_meta($recent_portfolio->ID, 'portfolio_link_url', true);										

			if(empty($portfolio_link_url))
			{
			    $permalink_url = get_permalink($recent_portfolio->ID);
			}
			else
			{
			    $permalink_url = $portfolio_link_url;
			}

			$image_url = '';						

			if(has_post_thumbnail($recent_portfolio->ID, 'portfolio4'))
			{
			    $image_id = get_post_thumbnail_id($recent_portfolio->ID);
			    $image_url = wp_get_attachment_image_src($image_id, 'portfolio4', true);
			    $large_image_url = wp_get_attachment_image_src($image_id, 'original', true);
			}

			$return_html.= '<div class="'.$column_class.'">';

			switch($portfolio_type)
			{
				case 'External Link':
				default:
					$return_html.= '<div class="portfolio200_shadow">';
					$return_html.= '<a href="'.$permalink_url.'"><img src="'.$image_url[0].'" alt="" class="portfolio_img"/><div class="portfolio200_overlay"><div class="overlay_icon_circle"><img src="'.get_stylesheet_directory_uri().'/images/icon_link.png" alt="" class=""/></div></div></a>';
					$return_html.= '</div>';
				break;
				// end external link

				case 'Portfolio Content':
				default:
					$return_html.= '<div class="portfolio200_shadow">';
					$return_html.= '<a href="'.get_permalink($recent_portfolio->ID).'"><img src="'.$image_url[0].'" alt="" class="portfolio_img"/><div class="portfolio200_overlay"><div class="overlay_icon_circle"><img src="'.get_stylesheet_directory_uri().'/images/icon_link.png" alt="" class=""/></div></div></a>';
					$return_html.= '</div>';
				break;
				// end portfolio content

				case 'Image':
					$return_html.= '<div class="portfolio200_shadow">';
					$return_html.= '<a href="'.$large_image_url[0].'" class="img_frame"><img src="'.$image_url[0].'" alt="" class="portfolio_img"/><div class="portfolio200_overlay"><div class="overlay_icon_circle"><img src="'.get_stylesheet_directory_uri().'/images/icon_image.png" alt="" class=""/></div></div></a>';
					$return_html.= '</div>';
				break;
				// end image

				case 'Youtube Video':
					$return_html.= '<div class="portfolio200_shadow">';
					$return_html.= '<a href="#video_'.$portfolio_video_id.'" class="lightbox_youtube"><img src="'.$image_url[0].'" alt="" class="portfolio_img"/><div class="portfolio200_overlay"><div class="overlay_icon_circle"><img src="'.get_stylesheet_directory_uri().'/images/icon_video.png" alt="" class=""/></div></div></a>';
					$return_html.= '</div>';
					$return_html.= '<div style="display:none;">
								    <div id="video_'.$portfolio_video_id.'" style="width:900px;height:488px"><iframe width="900" height="488" src="http://www.youtube.com/embed/'.$portfolio_video_id.'?theme=dark&amp;rel=0&amp;wmode=opaque" frameborder="0"></iframe></div>	
								</div>';
				break;
				// end youtube video

				case 'Vimeo Video':
					$return_html.= '<div class="portfolio200_shadow">';
					$return_html.= '<a href="#video_'.$portfolio_video_id.'" class="lightbox_vimeo"><img src="'.$image_url[0].'" alt="" class="portfolio_img"/><div class="portfolio200_overlay"><div class="overlay_icon_circle"><img src="'.get_stylesheet_directory_uri().'/images/icon_video.png" alt="" class=""/></div></div></a>';
					$return_html.= '</div>';
					$return_html.= '<div style="display:none;">
								    <div id="video_'.$portfolio_video_id.'" style="width:900px;height:506px"><iframe src="http://player.vimeo.com/video/'.$portfolio_video_id.'?title=0&amp;byline=0&amp;portrait=0" width="900" height="506" frameborder="0"></iframe></div>	
								</div>';
				break;
				// end vimeo video

				case 'Self-Hosted Video':
			    	//Get video URL
			    	$portfolio_mp4_url = get_post_meta($recent_portfolio->ID, 'portfolio_mp4_url', true);
					$preview_image = wp_get_attachment_image_src($image_id, 'large', true);

					$return_html.= '<div class="portfolio200_shadow">';
					$return_html.= '<a href="#video_self_'.$key.'" class="lightbox_vimeo"><img src="'.$image_url[0].'" alt="" class="portfolio_img"/><div class="portfolio200_overlay"><div class="overlay_icon_circle"><img src="'.get_stylesheet_directory_uri().'/images/icon_video.png" alt="" class=""/></div></div></a>';
					$return_html.= '</div>';

					$ext_self_video_attr = array(
						'id' => 'self_hosted_vid_'.$key,
						'file' => $portfolio_mp4_url,
						'image' => $preview_image[0],
						'width' => '900',
						'height' => '488',
					);
					
					$ext_self_video_attr_serialize = serialize($ext_self_video_attr);
					
					wp_enqueue_script("script-shortcode-selfhosted-video".$custom_id, get_stylesheet_directory_uri()."/templates/script-shortcode-selfhosted-video.php?data=".$ext_self_video_attr_serialize, false, THEMEVERSION, true);
					
					$return_html.= '<div style="display:none;"><div id="video_self_'.$key.'" style="width:900px;height:488px"><div id="self_hosted_vid_'.$key.'">JW Player goes here</div></div>	</div>';
				break;
				// end self-hosted video
			}
			$return_html.= '<div class="portfolio_desc portfolio_desc_200"><h6 class="portfolio_header">'.$recent_portfolio->post_title.'</h6>'.$recent_portfolio->post_excerpt.'</div>';
			$return_html.= '</div>';

			if($key>0 && ($key+1)%3 == 0)
			{
				$return_html.= '</li>';
			}
		}

		$return_html.= '</ul></div>';
	}
	else
	{
		$return_html.= 'Empty portfolio item. Please make sure you have created it or check the short code.';
	}

	$return_html.= '</div>';

	return $return_html;

}

add_shortcode('portfolio1', 'portfolio1_func');



function portfolio2_func($atts, $content) {
	//extract short code attr
	extract(shortcode_atts(array(
		'title' => 'Recent Portfolios',
		'items' => 8,
		'set_id' => '',
		'pause_time' => 10,
	), $atts));

	$custom_id = time().rand();
	$pause_time = $pause_time * 1000;
	$content = trim($content);
	
	$ext_attr = array(
		'id' => 'home_portfolio_'.$custom_id,
		'items' => $items,
		'set_id' => $set_id,
		'pause_time' => $pause_time,
	);
	
	$ext_attr_serialize = serialize($ext_attr);
	
	wp_enqueue_script("script-shortcode-portfolio".$custom_id, get_stylesheet_directory_uri()."/templates/script-shortcode-portfolio.php?data=".$ext_attr_serialize, false, THEMEVERSION, true);

	$args = array(
	    'numberposts' => $items,
	    'order' => 'ASC',
	    'orderby' => 'menu_order',
	    'post_type' => array('portfolios'),
	);

	if(!empty($set_id))
	{
		$args['portfoliosets'] = $set_id;
	}
	
	$recent_portfolios_arr = get_posts($args);

	if(!empty($recent_portfolios_arr))
	{
		$return_html = '<div id="home_portfolio_'.$custom_id.'" class="portfolio2_wrapper">';
		$return_html.= '<ul class="slides">';

		foreach($recent_portfolios_arr as $key => $recent_portfolio)
		{
			if(($key+1)%4 == 0)
			{
				$column_class = 'one_fourth last';
			}
			else
			{
				$column_class = 'one_fourth';
			}

			$portfolio_type = get_post_meta($recent_portfolio->ID, 'portfolio_type', true);
			$portfolio_video_id = get_post_meta($recent_portfolio->ID, 'portfolio_video_id', true);
			$portfolio_link_url = get_post_meta($recent_portfolio->ID, 'portfolio_link_url', true);											

			if(empty($portfolio_link_url))
			{
			    $permalink_url = get_permalink($recent_portfolio->ID);
			}
			else
			{
			    $permalink_url = $portfolio_link_url;
			}

			$image_url = '';						

			if(has_post_thumbnail($recent_portfolio->ID, 'portfolio4'))
			{
			    $image_id = get_post_thumbnail_id($recent_portfolio->ID);
			    $image_url = wp_get_attachment_image_src($image_id, 'portfolio4', true);
			    $full_image_url = wp_get_attachment_image_src($image_id, 'full', true);
			}

			if(empty($key) OR $key%4 == 0)
			{
				$return_html.= '<li>';
			}

			$return_html.= '<div class="'.$column_class.' css_shadow">';

			switch($portfolio_type)
			{
				case 'External Link':
				default:
					$return_html.= '<div class="portfolio200_shadow">';
					$return_html.= '<a href="'.$permalink_url.'"><img src="'.$image_url[0].'" alt="" class="portfolio_img"/><div class="portfolio200_overlay"><div class="overlay_icon_circle"><img src="'.get_stylesheet_directory_uri().'/images/icon_link.png" alt="" class=""/></div></div></a>';
					$return_html.= '</div>';
				break;
				// end external link

				case 'Portfolio Content':
				default:
					$return_html.= '<div class="portfolio200_shadow">';
					$return_html.= '<a href="'.get_permalink($recent_portfolio->ID).'"><img src="'.$image_url[0].'" alt="" class="portfolio_img"/><div class="portfolio200_overlay"><div class="overlay_icon_circle"><img src="'.get_stylesheet_directory_uri().'/images/icon_link.png" alt="" class=""/></div></div></a>';
					$return_html.= '</div>';
				break;
				// end portfolio content

				case 'Image':
					$return_html.= '<div class="portfolio200_shadow">';
					$return_html.= '<a href="'.$full_image_url[0].'" class="img_frame"><img src="'.$image_url[0].'" alt="" class="portfolio_img"/><div class="portfolio200_overlay"><div class="overlay_icon_circle"><img src="'.get_stylesheet_directory_uri().'/images/icon_image.png" alt="" class=""/></div></div></a>';
					$return_html.= '</div>';
				break;
				// end image

				case 'Youtube Video':
					$return_html.= '<div class="portfolio200_shadow">';
					$return_html.= '<a href="#video_'.$portfolio_video_id.'" class="lightbox_youtube"><img src="'.$image_url[0].'" alt="" class="portfolio_img"/><div class="portfolio200_overlay"><div class="overlay_icon_circle"><img src="'.get_stylesheet_directory_uri().'/images/icon_video.png" alt="" class=""/></div></div></a>';
					$return_html.= '</div>';

					$return_html.= '<div style="display:none;">
								    <div id="video_'.$portfolio_video_id.'" style="width:900px;height:488px"><iframe width="900" height="488" src="http://www.youtube.com/embed/'.$portfolio_video_id.'?theme=dark&amp;rel=0&amp;wmode=opaque"></iframe></div>	
								</div>';
				break;
				// end youtube video

				case 'Vimeo Video':
					$return_html.= '<div class="portfolio200_shadow">';
					$return_html.= '<a href="#video_'.$portfolio_video_id.'" class="lightbox_vimeo"><img src="'.$image_url[0].'" alt="" class="portfolio_img"/><div class="portfolio200_overlay"><div class="overlay_icon_circle"><img src="'.get_stylesheet_directory_uri().'/images/icon_video.png" alt="" class=""/></div></div></a>';
					$return_html.= '</div>';
					
					$return_html.= '<div style="display:none;">
								    <div id="video_'.$portfolio_video_id.'" style="width:900px;height:506px"><iframe src="http://player.vimeo.com/video/'.$portfolio_video_id.'?title=0&amp;byline=0&amp;portrait=0" width="900" height="506"></iframe></div>	
								</div>';
				break;
				// end vimeo video

				case 'Self-Hosted Video':
			    	//Get video URL
			    	$portfolio_mp4_url = get_post_meta($recent_portfolio->ID, 'portfolio_mp4_url', true);
					$preview_image = wp_get_attachment_image_src($image_id, 'large', true);

					$return_html.= '<div class="portfolio200_shadow">';
					$return_html.= '<a href="#video_self_'.$key.'" class="lightbox_vimeo"><img src="'.$image_url[0].'" alt="" class="portfolio_img"/><div class="portfolio200_overlay"><div class="overlay_icon_circle"><img src="'.get_stylesheet_directory_uri().'/images/icon_video.png" alt="" class=""/></div></div></a>';
					$return_html.= '</div>';

					$ext_self_video_attr = array(
						'id' => 'self_hosted_vid_'.$key,
						'file' => $portfolio_mp4_url,
						'image' => $preview_image[0],
						'width' => '900',
						'height' => '488',
					);
					
					$ext_self_video_attr_serialize = serialize($ext_self_video_attr);
					
					wp_enqueue_script("script-shortcode-selfhosted-video".$custom_id, get_stylesheet_directory_uri()."/templates/script-shortcode-selfhosted-video.php?data=".$ext_self_video_attr_serialize, false, THEMEVERSION, true);
					$return_html.= '<div style="display:none;"><div id="video_self_'.$key.'" style="width:900px;height:488px"><div id="self_hosted_vid_'.$key.'">JW Player goes here</div></div>	</div>';

				break;
				// end self-hosted video
			}	

			$return_html.= '<div class="portfolio_desc portfolio_desc_200"><h6 class="portfolio_header">'.$recent_portfolio->post_title.'</h6>'.$recent_portfolio->post_excerpt.'</div>';
			$return_html.= '</div>';

			if($key>0 && ($key+1)%4 == 0)
			{
				$return_html.= '</li>';
			}
		}

		$return_html.= '</ul></div>';
	}
	else
	{
		$return_html.= 'Empty portfolio item. Please make sure you have created it or check the short code.<br class="clear"/>';
	}
	
	return $return_html;

}

add_shortcode('portfolio2', 'portfolio2_func');





function img_reflect_left_func($atts, $content) {




	//extract short code attr

	extract(shortcode_atts(array(

		'src' => '',

	), $atts));

	

	$return_html = '<div class="alignleft">';

	$return_html.= '<img src="'.$src.'" alt="" class="reflection"/>';

	$return_html.= '</div>';

	

	return $return_html;

}

add_shortcode('img_reflect_left', 'img_reflect_left_func');





function img_reflect_right_func($atts, $content) {




	//extract short code attr

	extract(shortcode_atts(array(

		'src' => '',

	), $atts));

	

	$return_html = '<div class="alignright">';

	$return_html.= '<img src="'.$src.'" alt="" class="reflection"/>';

	$return_html.= '</div>';

	

	return $return_html;

}

add_shortcode('img_reflect_right', 'img_reflect_right_func');





function img_reflect_center_func($atts, $content) {




	//extract short code attr

	extract(shortcode_atts(array(

		'src' => '',

		'href' => '',

	), $atts));

	

	$return_html = '<div class="aligncenter">';

	$return_html.= '<img src="'.$src.'" alt="" class="reflection"/>';

	$return_html.= '</div>';

	

	return $return_html;

}

add_shortcode('img_reflect_center', 'img_reflect_center_func');



function divider_func($atts, $content) {




	//extract short code attr

	extract(shortcode_atts(array(

		'width' => '',

	), $atts));

	
	$return_html = '';
	$return_html.= '<br class="clear"/><hr/><br/>';

	

	return $return_html;

}

add_shortcode('divider', 'divider_func');


function new_line_func($atts, $content) {

	

	$return_html.= '<br class="clear"/>';

	

	return $return_html;

}

add_shortcode('new_line', 'new_line_func');



function service1_func($atts, $content) {

	remove_filter('the_content', 'pp_formatter', 99);



	//extract short code attr

	extract(shortcode_atts(array(

		'items' => 4,

		'new_line' => 1,
		
		'service_cat' => '',

	), $atts));

	

	//Get service items

	$args = array(

	    'numberposts' => $items,

	    'order' => 'ASC',

	    'orderby' => 'menu_order',

	    'post_type' => array('services'),

	);

	if(!empty($service_cat))
	{
		$args['service_cats'] = $service_cat;
	}

	$services_arr = get_posts($args);
	$return_html = '';
	

	if(!empty($services_arr))

	{
		$return_html.= '<div class="service_wrapper">';
		
		foreach($services_arr as $key => $service)

		{

			$image_url = '';						

			if(has_post_thumbnail($service->ID, 'full'))

			{

			    $image_id = get_post_thumbnail_id($service->ID);

			    $image_url = wp_get_attachment_image_src($image_id, 'full', true);

			}

		

			if(($key+1)%4 == 0)

			{

				$column_class = 'one_fourth last ppb_serivce_wrapper';

			}

			else

			{

				$column_class = 'one_fourth ppb_serivce_wrapper';

			}

			

			$return_html.= '<div class="'.$column_class.'">';
			$return_html.= '<div class="service_icon">';
			$return_html.= '<img src="'.$image_url[0].'" alt=""/>';
			$return_html.= '</div>';
			$return_html.= '<h5 class="service_header">'.$service->post_title.'</h5><br/>';
			$return_html.= '<p>'.$service->post_content.'</p>';
			$return_html.= '</div>';

		}

	}

	else

	{

		$return_html.= 'Empty service item. Please make sure you have created it or check the short code.';

	}

	$return_html.= '</div>';

	if(!empty($new_line))

	{

		$return_html.= '<br class="clear"/>';

	}

	

	return $return_html;

}

add_shortcode('service1', 'service1_func');



function service2_func($atts, $content) {

	remove_filter('the_content', 'pp_formatter', 99);



	//extract short code attr

	extract(shortcode_atts(array(

		'items' => 3,

		'new_line' => 1,
		
		'service_cats' => '',

	), $atts));

	

	//Get service items

	$args = array(

	    'numberposts' => $items,

	    'order' => 'ASC',

	    'orderby' => 'menu_order',

	    'post_type' => array('services'),

	);

	if(!empty($service_cat))
	{
		$args['service_cats'] = $service_cat;
	}	

	$services_arr = get_posts($args);
	$return_html = '';
	

	if(!empty($services_arr))
	{
		$return_html.= '<div class="service_wrapper">';

		foreach($services_arr as $key => $service)

		{

			$image_url = '';						

			if(has_post_thumbnail($service->ID, 'full'))

			{

			    $image_id = get_post_thumbnail_id($service->ID);

			    $image_url = wp_get_attachment_image_src($image_id, 'full', true);

			}

		

			if(($key+1)%3 == 0)

			{

				$column_class = 'one_third last ppb_serivce_wrapper';

			}

			else

			{

				$column_class = 'one_third ppb_serivce_wrapper';

			}

			

			$return_html.= '<div class="'.$column_class.'">';
			$return_html.= '<div class="service_icon">';
			$return_html.= '<img src="'.$image_url[0].'" alt=""/>';
			$return_html.= '</div>';
			$return_html.= '<h5 class="service_header">'.$service->post_title.'</h5><br/>';
			$return_html.= '<p>'.$service->post_content.'</p>';
			

			if(($key+1)%3!=0)
			{
				$return_html.= '</div>';
			}
			else
			{
				$return_html.= '</div><br class="clear"/>';
			}
		}
	}

	else

	{
		$return_html.= 'Empty service item. Please make sure you have created it or check the short code.';
	}
	
	$return_html.= '</div>';

	if(!empty($new_line))
	{
		$return_html.= '<br class="clear"/>';
	}

	return $return_html;

}

add_shortcode('service2', 'service2_func');



function pp_gallery_func($atts, $content) {

	//extract short code attr

	extract(shortcode_atts(array(

		'gallery_id' => '',

		'width' => 205,

		'height' => 205,

	), $atts));

	

	//Get service items

	$args = array( 

        'post_type' => 'attachment', 

        'numberposts' => -1, 

        'post_status' => null, 

        'post_parent' => $gallery_id,

        'order' => 'ASC',

        'orderby' => 'menu_order',

    );

	

	$images_arr = get_posts($args);
	$return_html = '';
	

	if(!empty($images_arr))
	{
		$return_html.= '<div class="pp_gallery">';
		foreach($images_arr as $key => $image)
		{
			$thumb = $image->ID;
			$img_url = wp_get_attachment_url( $thumb,'full'); //get img URL
			$image_resized = aq_resize( $img_url, $width, $height, true ); //resize & crop img
			
			$return_html.= '<div style="float:left;margin-right:20px;margin-bottom:20px">';
			$return_html.= '<a rel="gallery" href="'.$image->guid.'">';
			$return_html.= '<img src="'.$image_resized.'" alt="" class="post_img"/>';
			$return_html.= '</a>';
			$return_html.= '</div>';
		}
		$return_html.= '</div>';
	}
	else
	{
		$return_html.= 'Empty gallery item. Please make sure you have upload image to it or check the short code.';
	}

	$return_html.= '<br class="clear"/>';

	return $return_html;

}

add_shortcode('pp_gallery', 'pp_gallery_func');


function audio_func($atts, $content) {


	//extract short code attr
	extract(shortcode_atts(array(
		'src' => '',
		'width' => '100',
		'height' => '30',
	), $atts));

	$return_html = '<audio src="'.$src.'" width="'.$width.'"></audio>';

	return $return_html;
}

add_shortcode('audio', 'audio_func');


function tooltip_func($atts, $content) {

	//extract short code attr
	extract(shortcode_atts(array(
		'text' => '',
	), $atts));

	$return_html = '<a href="#" title="'.$text.'" class="tooltip"><strong>'.$content.'</strong></a>';

	return $return_html;
}

add_shortcode('tooltip', 'tooltip_func');


function googlefont_func($atts, $content) {

	//extract short code attr
	extract(shortcode_atts(array(
		'font' => '',
		'fontsize' => '',
	), $atts));

	$return_html = '';

	if(!empty($font))
	{
		$encoded_font = urlencode($font);
		wp_enqueue_style($encoded_font, "http://fonts.googleapis.com/css?family=".$encoded_font, false, "", "all");
		
		$return_html = '<div class="googlefont" style="font-family:'.$font.';font-size:'.$fontsize.'px">'.$content.'</div>';
	}

	return $return_html;
}

add_shortcode('googlefont', 'googlefont_func');


// Actual processing of the shortcode happens here
function pp_last_run_shortcode( $content ) {
    global $shortcode_tags;
 
    // Backup current registered shortcodes and clear them all out
    $orig_shortcode_tags = $shortcode_tags;
    remove_all_shortcodes();
 
    add_shortcode( 'one_half', 'one_half_func' );
    add_shortcode( 'one_half_last', 'one_half_last_func' );
    add_shortcode( 'one_third', 'one_third_func' );
    add_shortcode( 'one_third_last', 'one_third_last_func' );
    add_shortcode( 'two_third', 'two_third_func' );
    add_shortcode( 'two_third_last', 'two_third_last_func' );
    add_shortcode( 'one_fourth', 'one_fourth_func' );
    add_shortcode( 'one_fourth_last', 'one_fourth_last_func' );
    add_shortcode( 'one_fifth', 'one_fifth_func' );
    add_shortcode( 'one_fifth_last', 'one_fifth_last_func' );
    add_shortcode( 'lightbox', 'lightbox_func' );
    add_shortcode( 'frame_left', 'frame_left_func' );
    add_shortcode( 'frame_right', 'frame_right_func' );
    add_shortcode( 'frame_left', 'frame_left_func' );
    add_shortcode( 'frame_center', 'frame_center_func' );
    add_shortcode( 'img_reflect_left', 'img_reflect_left_func' );
    add_shortcode( 'img_reflect_right', 'img_reflect_right_func' );
    add_shortcode( 'img_reflect_center', 'img_reflect_center_func' );
    add_shortcode( 'pricing', 'pricing_func' );
    add_shortcode( 'styled_box', 'styled_box_func' );
    add_shortcode( 'gallery', 'gallery_func' );
    add_shortcode( 'tabs', 'tabs_func' );
    add_shortcode( 'tab', 'tab_func' );
    add_shortcode( 'accordion', 'accordion_func' );
    add_shortcode( 'pp_pre', 'pp_pre_func' );
    add_shortcode( 'testimonial', 'testimonial_func' );
    
    add_shortcode( 'ppb_text', 'ppb_text_func' );
    add_shortcode( 'ppb_divider', 'ppb_divider_func' );
 
    // Do the shortcode (only the one above is registered)
    $content = do_shortcode( $content );
 
    // Put the original shortcodes back
    $shortcode_tags = $orig_shortcode_tags;
 
    return $content;
}
 
add_filter( 'the_content', 'pp_last_run_shortcode', 7 );

?>