function wp_lightbox_url_content_in_overlay_display($page_url, $width, $height, $source)
{
    global $wp_lightbox_config;
    if (empty($width) || empty($height)) {
        $width = $wp_lightbox_config->getValue('wp_lightbox_width');
        $height = $wp_lightbox_config->getValue('wp_lightbox_height');
    }
    $unique_overlay_id = wp_lightbox_generate_unique_id();
    $wp_lightbox_output = <<<EOT

\t<div class="lightbox_ultimate_anchor lightbox_ultimate_image_anchor">

\t<a href="{$page_url}" class="wp_lightbox_url_content_trigger" rel="#{$unique_overlay_id}"><img src="{$source}" alt="" /></a>

\t<div id="{$unique_overlay_id}" class="lightbox_ultimate_fp_overlay" style="width:{$width}px;">

\t<div class="contentWrap" style="height:{$height}px;overflow-y:auto;"></div>  

\t</div>

\t</div>  

EOT;
    return $wp_lightbox_output;
}
function wp_lightbox_embed_code_html5($link, $poster_url = "", $width, $height)
{
    global $wp_lightbox_config;
    $wp_lightbox_html5_autoplay = $wp_lightbox_config->getValue('wp_lightbox_html5_autoplay');
    $autoplay = "";
    if (!empty($wp_lightbox_html5_autoplay)) {
        $autoplay = 'autoplay="autoplay"';
    }
    $unique_player_id = wp_lightbox_generate_unique_id();
    $wp_lightbox_output = <<<EOT

\t<video id="{$unique_player_id}" width="{$width}" height="{$height}" {$poster_url} controls="control" {$autoplay} preload="none"> 

\t\t<source src="{$link}" type="video/mp4" /> 

\t</video>

EOT;
    return $wp_lightbox_output;
}
function get_html5_video_embed_code($link, $poster, $width, $height, $anchor, $anchor_type)
{
    global $wp_lightbox_config;
    $unique_video_overlay_id = wp_lightbox_generate_unique_id();
    $unique_player_id = wp_lightbox_generate_unique_id();
    $poster_url = '';
    if (!empty($poster)) {
        $poster_url = <<<EOT

\t\tposter="{$poster}"

EOT;
    }
    if (empty($width) || empty($height)) {
        $width = $wp_lightbox_config->getValue('wp_lightbox_width');
        $height = $wp_lightbox_config->getValue('wp_lightbox_height');
    }
    if ($anchor_type == "text") {
        $wp_lightbox_output = <<<EOT

\t\t<div class="lightbox_ultimate_anchor lightbox_ultimate_text_anchor">

\t\t<a href="#{$unique_player_id}" class="wp_lightbox_html5_trigger" rel="#{$unique_video_overlay_id}">{$anchor}</a>

\t  \t<div id="{$unique_video_overlay_id}" class="lightbox_ultimate_fp_overlay" style="width:{$width}px;">

\t\t\t<video id="{$unique_player_id}" width="{$width}" height="{$height}" {$poster_url} controls="control" preload="none"> 

\t\t\t\t<source src="{$link}" type="video/mp4" />  

\t\t\t</video>

\t  </div> 

\t  </div> 

EOT;
    } else {
        $wp_lightbox_output = <<<EOT

\t\t<div class="lightbox_ultimate_anchor lightbox_ultimate_image_anchor">

\t\t<a href="#{$unique_player_id}" class="wp_lightbox_html5_trigger" rel="#{$unique_video_overlay_id}"><img src="{$anchor}" alt="" /></a>

\t  \t<div id="{$unique_video_overlay_id}" class="lightbox_ultimate_fp_overlay" style="width:{$width}px;">

\t\t\t<video id="{$unique_player_id}" width="{$width}" height="{$height}" {$poster_url} controls="control" preload="none"> 

\t\t\t\t<source src="{$link}" type="video/mp4" />  

\t\t\t</video>

\t  </div> 

\t  </div> 

EOT;
    }
    return $wp_lightbox_output;
}
function wp_lightbox_flowplayer_protected_s3_video_display($name, $bucket, $width, $height, $source)
{
    global $wp_lightbox_config;
    //Do some error checking on the name and bucket parameters
    if (preg_match("/http/", $name)) {
        return '<div class="wp_lightbox_error_message">Looks like you have entered a URL in the "name" field for your Protected S3 Video shortcode. You should only use the name of the video file in this field (Not the full URL of the file).</div>';
    }
    if (preg_match("/http/", $bucket)) {
        return '<div class="wp_lightbox_error_message">Looks like you have entered a URL in the "bucket" field for your Protected S3 Video shortcode. You should only use the name of the bucket in this field (Not the full URL).</div>';
    }
    $access_key = $wp_lightbox_config->getValue('wp_lightbox_amazon_s3_access_key');
    $secret_key = $wp_lightbox_config->getValue('wp_lightbox_amazon_s3_secret_key');
    $link_duration = $wp_lightbox_config->getValue('wp_lightbox_amazon_s3_link_duration');
    if (empty($access_key) || empty($secret_key)) {
        return '<div class="wp_lightbox_error_message">You must fill in a value in both the "AWS Access Key ID" and the "AWS Secret Access Key" fields in the settings menu!</div>';
    }
    if (empty($link_duration) && $link_duration != '0') {
        $link_duration = '300';
    }
    if (empty($width) || empty($height)) {
        $width = $wp_lightbox_config->getValue('wp_lightbox_width');
        $height = $wp_lightbox_config->getValue('wp_lightbox_height');
    }
    $objS3 = new wp_lightbox_ultimate_amazon_s3("{$access_key}", "{$secret_key}");
    $file = $objS3->getAuthenticatedURL($bucket, $name, $link_duration);
    $file = urlencode($file);
    $unique_video_overlay_id = wp_lightbox_generate_unique_id();
    $wp_lightbox_output = <<<EOT

\t<div class="lightbox_ultimate_anchor lightbox_ultimate_image_anchor">

\t<a href="#" class="wp_lightbox_fp_trigger" rel="#{$unique_video_overlay_id}"><img src="{$source}" alt="" /></a>

\t<div id="{$unique_video_overlay_id}" class="lightbox_ultimate_fp_overlay" style="width:{$width}px;">\t

\t<a class="player" href="{$file}" style="display:block;width:{$width}px;height:{$height}px;"></a>

\t</div>

\t</div>

EOT;
    return $wp_lightbox_output;
}