<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2005 Coppermine Dev Team
  v1.1 originaly written by Gregory DEMAR

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  ********************************************
  Coppermine version: 1.4.3
  $Revision: 1.0 $
  $Author: tranzndance $
  $Date: 2006/01/30 $
  $Demo: http://TakeThu.com/?theme=valentines
**********************************************/

// ------------------------------------------------------------------------- //
// This theme has had redundant CORE items removed                           //
// ------------------------------------------------------------------------- //
define('THEME_HAS_RATING_GRAPHICS', 1);
define('THEME_HAS_NO_SUB_MENU_BUTTONS',1);
define('THEME_IS_XHTML10_TRANSITIONAL',1);  // Remove this if you edit this template until
                                            // you have validated it. See docs/theme.htm.
define('THEME_HAS_NAVBAR_GRAPHICS', 1);
// HTML template for sys_menu
$template_sys_menu = <<<EOT
         {BUTTONS}
EOT;

// HTML template for template sys_menu spacer
$template_sys_menu_spacer ="::";

// HTML template for template sub_menu
// special note: I left the java 'hide' off of the first and third buttons to help avoid trouble keeping sys_menu open. :Donnoman

$template_sub_menu = <<<EOT
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
    <td width="50%"></td>
    <td><img src="themes/valentines/images/menu_button_bg_left.gif" border="0" alt="" /><br /></td>
    <td style="background-image:url(themes/valentines/images/menu_button_bg_middle.gif);" valign="top">
            <a href="index.php"><img src="themes/valentines/images/home.gif" border="0" alt="" /><br /></a>
    </td>
    <td><img src="themes/valentines/images/menu_button_bg_right.gif" border="0" alt="" /><br /></td>
    <td><img src="themes/valentines/images/menu_button_bg_left.gif" border="0" alt="" /><br /></td>
    <td style="background-image:url(themes/valentines/images/menu_button_bg_middle.gif);" valign="top">
            <a href="{ALB_LIST_TGT}" title="{ALB_LIST_TITLE}">{ALB_LIST_LNK}</a>
    </td>
    <td><img src="themes/valentines/images/menu_button_bg_right.gif" border="0" alt="" /><br /></td>
    <td><img src="themes/valentines/images/menu_button_bg_left.gif" border="0" alt="" /><br /></td>
    <td style="background-image:url(themes/valentines/images/menu_button_bg_middle.gif);" valign="top">
            <a href="{LASTUP_TGT}" title="{LASTUP_LNK}">{LASTUP_LNK}</a>
    </td>
    <td><img src="themes/valentines/images/menu_button_bg_right.gif" border="0" alt="" /><br /></td>
    <td><img src="themes/valentines/images/menu_button_bg_left.gif" border="0" alt="" /><br /></td>
    <td style="background-image:url(themes/valentines/images/menu_button_bg_middle.gif);" valign="top">
            <a href="{LASTCOM_TGT}" title="{LASTCOM_LNK}">{LASTCOM_LNK}</a>
    </td>
    <td><img src="themes/valentines/images/menu_button_bg_right.gif" border="0" alt="" /><br /></td>
    <td><img src="themes/valentines/images/menu_button_bg_left.gif" border="0" alt="" /><br /></td>
    <td style="background-image:url(themes/valentines/images/menu_button_bg_middle.gif);" valign="top">
            <a href="{TOPN_TGT}" title="{TOPN_LNK}">{TOPN_LNK}</a>
    </td>
    <td><img src="themes/valentines/images/menu_button_bg_right.gif" border="0" alt="" /><br /></td>
    <td><img src="themes/valentines/images/menu_button_bg_left.gif" border="0" alt="" /><br /></td>
    <td style="background-image:url(themes/valentines/images/menu_button_bg_middle.gif);" valign="top">
            <a href="{TOPRATED_TGT}" title="{TOPRATED_LNK}">{TOPRATED_LNK}</a>
    </td>
    <td><img src="themes/valentines/images/menu_button_bg_right.gif" border="0" alt="" /><br /></td>
    <td><img src="themes/valentines/images/menu_button_bg_left.gif" border="0" alt="" /><br /></td>
    <td style="background-image:url(themes/valentines/images/menu_button_bg_middle.gif);" valign="top">
            <a href="{FAV_TGT}" title="{FAV_LNK}">{FAV_LNK}</a>
    </td>
    <td><img src="themes/valentines/images/menu_button_bg_right.gif" border="0" alt="" /><br /></td>
    <td><img src="themes/valentines/images/menu_button_bg_left.gif" border="0" alt="" /><br /></td>
    <td style="background-image:url(themes/valentines/images/menu_button_bg_middle.gif);" valign="top">
            <a href="{SEARCH_TGT}" title="{SEARCH_LNK}">{SEARCH_LNK}</a>
    </td>
    <td><img src="themes/valentines/images/menu_button_bg_right.gif" border="0" alt="" /><br /></td>
<!-- BEGIN custom_link -->
	<td><img src="themes/valentines/images/menu_button_bg_left.gif" border="0" alt="" /><br /></td>
    <td style="background-image:url(themes/valentines/images/menu_button_bg_middle.gif);" valign="top">
            <a href="{CUSTOM_LNK_TGT}" title="{CUSTOM_LNK_TITLE}">{CUSTOM_LNK_LNK}</a>
    </td>
    <td><img src="themes/valentines/images/menu_button_bg_right.gif" border="0" alt="" /><br /></td>
<!-- END custom_link -->
    <td width="50%"></td>
  </tr>
</table>

EOT;


// HTML template for title row of the thumbnail view (album title + sort options)
$template_thumb_view_title_row = <<<EOT

                        <table width="100%" cellpadding="0" cellspacing="0">
                        <tr>
                                <td width="100%" class="statlink">{ALBUM_NAME}</td>
                                <td class="sortorder_options" style="font-size: 100%;">{TITLE}</td>
                                <td class="sortorder_options" style="font-size: 100%;"><span class="statlink"><a href="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=ta" title="{SORT_TA}">&nbsp;+&nbsp;</a></span></td>
                                <td class="sortorder_options" style="font-size: 100%;"><span class="statlink"><a href="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=td" title="{SORT_TD}">&nbsp;-&nbsp;</a></span></td>
                                <td>&nbsp;&nbsp;</td>
                                <td class="sortorder_options" style="font-size: 100%;">{NAME}</td>
                                <td class="sortorder_options" style="font-size: 100%;"><span class="statlink"><a href="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=na" title="{SORT_NA}">&nbsp;+&nbsp;</a></span></td>
                                <td class="sortorder_options" style="font-size: 100%;"><span class="statlink"><a href="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=nd" title="{SORT_ND}">&nbsp;-&nbsp;</a></span></td>
                                <td>&nbsp;&nbsp;</td>
                                <td class="sortorder_options" style="font-size: 100%;">{DATE}</td>
                                <td class="sortorder_options" style="font-size: 100%;"><span class="statlink"><a href="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=da" title="{SORT_DA}">&nbsp;+&nbsp;</a></span></td>
                                <td class="sortorder_options" style="font-size: 100%;"><span class="statlink"><a href="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=dd" title="{SORT_DD}">&nbsp;-&nbsp;</a></span></td>
                                <td>&nbsp;&nbsp;</td>
                                <td class="sortorder_options" style="font-size: 100%;">{POSITION}</td>
                                <td class="sortorder_options" style="font-size: 100%;"><span class="statlink"><a href="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=pa" title="{SORT_PA}">&nbsp;+&nbsp;</a></span></td>
                                <td class="sortorder_options" style="font-size: 100%;"><span class="statlink"><a href="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=pd" title="{SORT_PD}">&nbsp;-&nbsp;</a></span></td>
                        </tr>
                        </table>

EOT;

// HTML template for the image navigation bar
$template_img_navbar = <<<EOT

        <tr>
                <td align="center" valign="middle" class="navmenu" width="48px">
                        <a href="{THUMB_TGT}" class="navmenu_pic" title="{THUMB_TITLE}"><img src="{LOCATION}images/thumbnails.gif" align="middle" border="0px" alt="{THUMB_TITLE}" /></a>
                </td>
                <td align="center" valign="middle" class="navmenu" width="48px">
                        <a href="javascript:;" class="navmenu_pic" onclick="blocking('picinfo','yes', 'block'); return false;" title="{PIC_INFO_TITLE}"><img src="{LOCATION}images/info.gif" border="0px" align="middle" alt="{PIC_INFO_TITLE}" /></a>
                </td>
                <td align="center" valign="middle" class="navmenu" width="48px">
                        <a href="{SLIDESHOW_TGT}" class="navmenu_pic" title="{SLIDESHOW_TITLE}"><img src="{LOCATION}images/slideshow.gif" border="0px" align="middle" alt="{SLIDESHOW_TITLE}" /></a>
                </td>
<!-- BEGIN report_file_button -->
                <td align="center" valign="middle" class="navmenu" width="48px">
                        <a href="{REPORT_TGT}" class="navmenu_pic" title="{REPORT_TITLE}"><img src="{LOCATION}images/report.gif" border="0" align="middle" alt="{REPORT_TITLE}" /></a>
                </td>
<!-- END report_file_button -->
<!-- BEGIN ecard_button -->
                <td align="center" valign="middle" class="navmenu" width="48px">
                        <a href="{ECARD_TGT}" class="navmenu_pic" title="{ECARD_TITLE}"><img src="{LOCATION}images/ecard.gif"  border="0px" align="middle" alt="{ECARD_TITLE}" /></a>
                </td>
<!-- END ecard_button -->
                <a name="top_display_media"></a><td align="center" valign="middle" class="navmenu" width="100%">{PIC_POS}</td>
<!-- BEGIN rew_button -->
                <td align="center" valign="middle" class="navmenu" width="48px">
                        <a href="{REW_TGT}" class="navmenu_pic" title="{REW_TITLE}"><img src="{LOCATION}images/rewind.gif"  border="0px" align="middle" alt="{REW_TITLE}" /></a>
                </td>
<!-- END rew_button -->
                <td align="center" valign="middle" class="navmenu" width="48px">
                        <a href="{PREV_TGT}" class="navmenu_pic" title="{PREV_TITLE}"><img src="{LOCATION}images/prev.gif"  border="0px" align="middle" alt="{PREV_TITLE}" /></a>
                </td>
                <td align="center" valign="middle" class="navmenu" width="48px">
                        <a href="{NEXT_TGT}" class="navmenu_pic" title="{NEXT_TITLE}"><img src="{LOCATION}images/next.gif"  border="0px" align="middle" alt="{NEXT_TITLE}" /></a>
                </td>
<!-- BEGIN ff_button -->
                <td align="center" valign="middle" class="navmenu" width="48px">
                      <a href="{FF_TGT}" class="navmenu_pic" title="{FF_TITLE}"><img src="{LOCATION}images/fastforward.gif"  border="0px" alt="{FF_TITLE}"/></a>
                </td>
<!-- END ff_button -->
        </tr>

EOT;

function theme_html_img_nav_menu()
{
    global $CONFIG, $CURRENT_PIC_DATA, $meta_nav, $THEME_DIR ; //$PHP_SELF,
    global $album, $cat, $pos, $pic_count, $lang_img_nav_bar, $lang_text_dir, $template_img_navbar;

    $cat_link = is_numeric($album) ? '' : '&amp;cat=' . $cat;

    $human_pos = $pos + 1;
    $page = ceil(($pos + 1) / ($CONFIG['thumbrows'] * $CONFIG['thumbcols']));
    $pid = $CURRENT_PIC_DATA['pid'];
		$max_items = $CONFIG['max_film_strip_items'];

		$end = $pic_count - 1;
		$end_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$end#top_display_media";
		$end_title = $lang_img_nav_bar['go_album_end'];
		$meta_nav .= "<link rel=\"end\" href=\"$end_tgt\" title=\"$end_title\" />
		";
    if ($pos == 0) {
				$start_tgt = "javascript:;";
				$start_title = "";
				$meta_nav .= "<link rel=\"start\" href=\"$start_tgt\" title=\"$start_title\" />
				";
		}
    if ($pos > 0) {
				$start = 0;
				$start_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$start#top_display_media";
				$start_title = $lang_img_nav_bar['go_album_start'];
        $prev = $pos - 1;
        $prev_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$prev#top_display_media";
        $prev_title = $lang_img_nav_bar['prev_title'];
				$meta_nav .= "<link rel=\"prev\" href=\"$prev_tgt\" title=\"$prev_title\" />
				";
				$meta_nav .= "<link rel=\"start\" href=\"$start_tgt\" title=\"$start_title\" />
				";

			if ($pos >= $CONFIG['max_film_strip_items']) {
					$rewind = $pos - $max_items;
					$rew_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$rewind#top_display_media";
					$rew_title = sprintf($lang_img_nav_bar['go_back_x_items'], $max_items);
			} else {
				$rew_tgt = $start_tgt;
				$rew_title = $start_title;
			}

    } else {
        $prev_tgt = "javascript:;";
        $prev_title = "";
				$rew_tgt = "javascript:;";
				$rew_title = "";
    }
    if ($pos < ($pic_count -1)) {
        $next = $pos + 1;
        $next_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$next#top_display_media";
        $next_title = $lang_img_nav_bar['next_title'];
				$meta_nav .= "<link rel=\"next\" href=\"$next_tgt\" title=\"$next_title\"/>
				";

				if ($pos <= ($pic_count -1) - ceil(($max_items/2))) {
					$fastforward = $pos + $max_items;
					if ($fastforward >= $pic_count) {
						$ff_tgt = $end_tgt;
						$ff_title = $end_title;
					} else {
						$ff_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$fastforward#top_display_media";
						$ff_title = sprintf($lang_img_nav_bar['go_forward_x_items'], $max_items);
					}
				} else {
						$ff_tgt = "javascript:;";
						$ff_title = "";
				}
    } else {
        $next_tgt = "javascript:;";
        $next_title = "";
				$ff_tgt = "javascript:;";
				$ff_title = "";
    }

    if (USER_CAN_SEND_ECARDS) {
        $ecard_tgt = "ecard.php?album=$album$cat_link&amp;pid=$pid&amp;pos=$pos";
        $ecard_title = $lang_img_nav_bar['ecard_title'];
    } else {
        template_extract_block($template_img_navbar, 'ecard_button'); // added to remove button if cannot send ecard
        /*$ecard_tgt = "javascript:alert('" . addslashes($lang_img_nav_bar['ecard_disabled_msg']) . "');";
        $ecard_title = $lang_img_nav_bar['ecard_disabled'];*/
    }

    // BEGIN YouTube Addition

    // Displays a picture
	function theme_html_picture()
	{
	    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $USER;
	    global $album, $comment_date_fmt, $template_display_media;
	    global $lang_display_image_php, $lang_picinfo;

	    $pid = $CURRENT_PIC_DATA['pid'];
	    $pic_title = '';

	    if (!isset($USER['liv']) || !is_array($USER['liv'])) {
	        $USER['liv'] = array();
	    }
	    // Add 1 to hit counter
	    if (!USER_IS_ADMIN && !in_array($pid, $USER['liv']) && isset($_COOKIE[$CONFIG['cookie_name'] . '_data'])) {
	        add_hit($pid);
	        if (count($USER['liv']) > 4) array_shift($USER['liv']);
	        array_push($USER['liv'], $pid);
	    }

	    if($CONFIG['thumb_use']=='ht' && $CURRENT_PIC_DATA['pheight'] > $CONFIG['picture_width'] ){ // The wierd comparision is because only picture_width is stored
	      $condition = true;
	    }elseif($CONFIG['thumb_use']=='wd' && $CURRENT_PIC_DATA['pwidth'] > $CONFIG['picture_width']){
	      $condition = true;
	    }elseif($CONFIG['thumb_use']=='any' && max($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']) > $CONFIG['picture_width']){
	      $condition = true;
	    }else{
	     $condition = false;
	    }

	    if ($CURRENT_PIC_DATA['title'] != '') {
	        $pic_title .= $CURRENT_PIC_DATA['title'] . "\n";
	    }
	    if ($CURRENT_PIC_DATA['caption'] != '') {
	        $pic_title .= $CURRENT_PIC_DATA['caption'] . "\n";
	    }
	    if ($CURRENT_PIC_DATA['keywords'] != '') {
	        $pic_title .= $lang_picinfo['Keywords'] . ": " . $CURRENT_PIC_DATA['keywords'];
	    }

	    if (!$CURRENT_PIC_DATA['title'] && !$CURRENT_PIC_DATA['caption']) {
	        template_extract_block($template_display_media, 'img_desc');
	    } else {
	        if (!$CURRENT_PIC_DATA['title']) {
	            template_extract_block($template_display_media, 'title');
	        }
	        if (!$CURRENT_PIC_DATA['caption']) {
	            template_extract_block($template_display_media, 'caption');
	        }
	    }

	    $CURRENT_PIC_DATA['menu'] = html_picture_menu(); //((USER_ADMIN_MODE && $CURRENT_ALBUM_DATA['category'] == FIRST_USER_CAT + USER_ID) || ($CONFIG['users_can_edit_pics'] && $CURRENT_PIC_DATA['owner_id'] == USER_ID && USER_ID != 0) || GALLERY_ADMIN_MODE) ? html_picture_menu($pid) : '';

	    if ($CONFIG['make_intermediate'] && $condition ) {
	        $picture_url = get_pic_url($CURRENT_PIC_DATA, 'normal');
	    } else {
	        $picture_url = get_pic_url($CURRENT_PIC_DATA, 'fullsize');
	    }

	    $image_size = compute_img_size($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight'], $CONFIG['picture_width']);

	    $pic_title = '';
	    $mime_content = cpg_get_type($CURRENT_PIC_DATA['filename']);


	    if ($mime_content['content']=='movie' || $mime_content['content']=='audio') {

	        if ($CURRENT_PIC_DATA['pwidth']==0 || $CURRENT_PIC_DATA['pheight']==0) {
	            $CURRENT_PIC_DATA['pwidth']  = 320; // Default width

	            // Set default height; if file is a movie
	            if ($mime_content['content']=='movie') {
	                $CURRENT_PIC_DATA['pheight'] = 240; // Default height
	            }
	        }

	        $ctrl_offset['mov']=15;
	        $ctrl_offset['wmv']=45;
	        $ctrl_offset['swf']=0;
	        $ctrl_offset['rm']=0;
	        $ctrl_offset_default=45;
	        $ctrl_height = (isset($ctrl_offset[$mime_content['extension']]))?($ctrl_offset[$mime_content['extension']]):$ctrl_offset_default;
	        $image_size['whole']='width="'.$CURRENT_PIC_DATA['pwidth'].'" height="'.($CURRENT_PIC_DATA['pheight']+$ctrl_height).'"';
	    }

	    if ($mime_content['content']=='image') {
	        if (preg_match('/^youtube_(.*)\.jpg$/', $CURRENT_PIC_DATA['filename'], $ytmatches)){

			    		$vid = $ytmatches[1];
			      		$pic_html = '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/'. $vid . '"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/'. $vid . '" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object><br />';

			    	} elseif (isset($image_size['reduced'])) {

	            $winsizeX = $CURRENT_PIC_DATA['pwidth']+5;  //the +'s are the mysterious FF and IE paddings
	            $winsizeY = $CURRENT_PIC_DATA['pheight']+3; //the +'s are the mysterious FF and IE paddings
	            $pic_html = "<a href=\"javascript:;\" onclick=\"MM_openBrWindow('displayimage.php?pid=$pid&amp;fullsize=1','" . uniqid(rand()) . "','scrollbars=yes,toolbar=no,status=no,resizable=yes,width=$winsizeX,height=$winsizeY')\">";
	            $pic_title = $lang_display_image_php['view_fs'] . "\n==============\n" . $pic_title;
	            $pic_html .= "<img src=\"" . $picture_url . "\" class=\"image\" border=\"0\" alt=\"{$lang_display_image_php['view_fs']}\" /><br />";
	            $pic_html .= "</a>\n";
	        } else {
	            $pic_html = "<img src=\"" . $picture_url . "\" {$image_size['geom']} class=\"image\" border=\"0\" alt=\"\" /><br />\n";
	        }
	    } elseif ($mime_content['content']=='document') {
	        $pic_thumb_url = get_pic_url($CURRENT_PIC_DATA,'thumb');
	        $pic_html = "<a href=\"{$picture_url}\" target=\"_blank\" class=\"document_link\"><img src=\"".$pic_thumb_url."\" border=\"0\" class=\"image\" /></a>\n<br />";
	    } else {
	        $autostart = ($CONFIG['media_autostart']) ? ('true'):('false');

	        $players['WMP'] = array('id' => 'MediaPlayer',
	                                'clsid' => 'classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" ',
	                                'codebase' => 'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ',
	                                'mime' => 'type="application/x-mplayer2" ',
	                               );
	        $players['RMP'] = array('id' => 'RealPlayer',
	                                'clsid' => 'classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" ',
	                                'codebase' => '',
	                                'mime' => 'type="audio/x-pn-realaudio-plugin" '
	                               );
	        $players['QT']  = array('id' => 'QuickTime',
	                                'clsid' => 'classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" ',
	                                'codebase' => 'codebase="http://www.apple.com/qtactivex/qtplugin.cab" ',
	                                'mime' => 'type="video/x-quicktime" '
	                               );
	        $players['SWF'] = array('id' => 'SWFlash',
	                                'clsid' => ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ',
	                                'codebase' => 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ',
	                                'mime' => 'type="application/x-shockwave-flash" '
	                               );
	        $players['UNK'] = array('id' => 'DefaultPlayer',
	                                'clsid' => '',
	                                'codebase' => '',
	                                'mime' => ''
	                               );

	        if (isset($_COOKIE[$CONFIG['cookie_name'].'_'.$mime_content['extension'].'player'])) {
	            $user_player = $_COOKIE[$CONFIG['cookie_name'].'_'.$mime_content['extension'].'player'];
	        } else {
	            $user_player = $mime_content['player'];
	        }

	                // There isn't a player selected or user wants client-side control
	        if (!$user_player) {
	            $user_player = 'UNK';
	        }

	        $player = $players[$user_player];

	        $pic_html  = '<object id="'.$player['id'].'" '.$player['clsid'].$player['codebase'].$player['mime'].$image_size['whole'].'>';
	        $pic_html .= "<param name=\"autostart\" value=\"$autostart\" /><param name=\"src\" value=\"". $picture_url . "\" />";
	        $pic_html .= '<embed '.$image_size['whole'].' src="'. $picture_url . '" autostart="'.$autostart.'" '.$player['mime'].'></embed>';
	        $pic_html .= "</object><br />\n";
	    }

	    $CURRENT_PIC_DATA['html'] = $pic_html;
	    $CURRENT_PIC_DATA['header'] = '';
	    $CURRENT_PIC_DATA['footer'] = '';

	    $CURRENT_PIC_DATA = CPGPluginAPI::filter('file_data',$CURRENT_PIC_DATA);

	    $params = array('{CELL_HEIGHT}' => '100',
	        '{IMAGE}' => $CURRENT_PIC_DATA['header'].$CURRENT_PIC_DATA['html'].$CURRENT_PIC_DATA['footer'],
	        '{ADMIN_MENU}' => $CURRENT_PIC_DATA['menu'],
	        '{TITLE}' => bb_decode($CURRENT_PIC_DATA['title']),
	        '{CAPTION}' => bb_decode($CURRENT_PIC_DATA['caption']),
	        );

	    return template_eval($template_display_media, $params);
	}

	function theme_html_img_nav_menu()
	{
	    global $CONFIG, $CURRENT_PIC_DATA, $meta_nav, $THEME_DIR ; //$PHP_SELF,
	    global $album, $cat, $pos, $pic_count, $lang_img_nav_bar, $lang_text_dir, $template_img_navbar;

	    $cat_link = is_numeric($album) ? '' : '&amp;cat=' . $cat;
	        $uid_link = is_numeric($_GET['uid']) ? '&amp;uid=' . $_GET['uid'] : '';

	    $human_pos = $pos + 1;
	    $page = ceil(($pos + 1) / ($CONFIG['thumbrows'] * $CONFIG['thumbcols']));
	    $pid = $CURRENT_PIC_DATA['pid'];

	    $start = 0;
	        $start_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$start";
	        $start_title = $lang_img_nav_bar['go_album_start'];
	        $meta_nav .= "<link rel=\"start\" href=\"$start_tgt\" title=\"$start_title\" />
	        ";
	        $end = $pic_count - 1;
	        $end_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$end";
	        $end_title = $lang_img_nav_bar['go_album_end'];
	        $meta_nav .= "<link rel=\"last\" href=\"$end_tgt\" title=\"$end_title\" />
	        ";

	    if ($pos > 0) {
	        $prev = $pos - 1;
	        $prev_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$prev$uid_link";
	        $prev_title = $lang_img_nav_bar['prev_title'];
	                                $meta_nav .= "<link rel=\"prev\" href=\"$prev_tgt\" title=\"$prev_title\" />
	                                ";
	    } else {
	        $prev_tgt = "javascript:;";
	        $prev_title = "";
	    }

	    if ($pos < ($pic_count -1)) {
	        $next = $pos + 1;
	        $next_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$next$uid_link";
	        $next_title = $lang_img_nav_bar['next_title'];
	                                $meta_nav .= "<link rel=\"next\" href=\"$next_tgt\" title=\"$next_title\"/>
	                                ";
	    } else {
	        $next_tgt = "javascript:;";
	        $next_title = "";
	    }

	    if (USER_CAN_SEND_ECARDS) {
	        $ecard_tgt = "ecard.php?album=$album$cat_link&amp;pid=$pid&amp;pos=$pos";
	        $ecard_title = $lang_img_nav_bar['ecard_title'];
	    } else {
	        template_extract_block($template_img_navbar, 'ecard_button'); // added to remove button if cannot send ecard
	        /*$ecard_tgt = "javascript:alert('" . addslashes($lang_img_nav_bar['ecard_disabled_msg']) . "');";
	        $ecard_title = $lang_img_nav_bar['ecard_disabled'];*/
	    }

	                //report to moderator buttons
	    if (($CONFIG['report_post']==1) && (USER_CAN_SEND_ECARDS)) {
	        $report_tgt = "report_file.php?album=$album$cat_link&amp;pid=$pid&amp;pos=$pos";
	    } else { // remove button if report toggle is off
	        template_extract_block($template_img_navbar, 'report_file_button');

	    }

	                    $thumb_tgt = "thumbnails.php?album=$album$cat_link&amp;page=$page$uid_link";
	        $meta_nav .= "<link rel=\"up\" href=\"$thumb_tgt\" title=\"".$lang_img_nav_bar['thumb_title']."\"/>
	        ";

	    $slideshow_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link$uid_link&amp;pid=$pid&amp;slideshow=".$CONFIG['slideshow_interval'];

	    $pic_pos = sprintf($lang_img_nav_bar['pic_pos'], $human_pos, $pic_count);

	    if (defined('THEME_HAS_NAVBAR_GRAPHICS')) {
	            $location= $THEME_DIR;
	        } else {
	            $location= '';
	        }

	    $params = array('{THUMB_TGT}' => $thumb_tgt,
	        '{THUMB_TITLE}' => $lang_img_nav_bar['thumb_title'],
	        '{PIC_INFO_TITLE}' => $lang_img_nav_bar['pic_info_title'],
	        '{SLIDESHOW_TGT}' => $slideshow_tgt,
	        '{SLIDESHOW_TITLE}' => $lang_img_nav_bar['slideshow_title'],
	        '{PIC_POS}' => $pic_pos,
	        '{ECARD_TGT}' => $ecard_tgt,
	        '{ECARD_TITLE}' => $ecard_title,
	        '{PREV_TGT}' => $prev_tgt,
	        '{PREV_TITLE}' => $prev_title,
	        '{NEXT_TGT}' => $next_tgt,
	        '{NEXT_TITLE}' => $next_title,
	        '{PREV_IMAGE}' => ($lang_text_dir=='ltr') ? 'prev' : 'next',
	        '{NEXT_IMAGE}' => ($lang_text_dir=='ltr') ? 'next' : 'prev',
	        '{REPORT_TGT}' => $report_tgt,
	        '{REPORT_TITLE}' => $lang_img_nav_bar['report_title'],
	        '{LOCATION}' => $location,
	        );

	    return template_eval($template_img_navbar, $params);
	}

	function theme_html_rating_box()
	{
	    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR;
	    global $template_image_rating, $lang_rate_pic;

	    if (!(USER_CAN_RATE_PICTURES && $CURRENT_ALBUM_DATA['votes'] == 'YES')) return '';

	    $votes = $CURRENT_PIC_DATA['votes'] ? sprintf($lang_rate_pic['rating'], round($CURRENT_PIC_DATA['pic_rating'] / 2000, 1), $CURRENT_PIC_DATA['votes']) : $lang_rate_pic['no_votes'];
	    $pid = $CURRENT_PIC_DATA['pid'];

	    if (defined('THEME_HAS_RATING_GRAPHICS')) {
	        $location= $THEME_DIR;
	    } else {
	        $location= '';
	    }

	    $params = array('{TITLE}' => $lang_rate_pic['rate_this_pic'],
	        '{VOTES}' => $votes,
	        '{RATE0}' => "ratepic.php?pic=$pid&amp;rate=0",
	        '{RATE1}' => "ratepic.php?pic=$pid&amp;rate=1",
	        '{RATE2}' => "ratepic.php?pic=$pid&amp;rate=2",
	        '{RATE3}' => "ratepic.php?pic=$pid&amp;rate=3",
	        '{RATE4}' => "ratepic.php?pic=$pid&amp;rate=4",
	        '{RATE5}' => "ratepic.php?pic=$pid&amp;rate=5",
	        '{RUBBISH}' => $lang_rate_pic['rubbish'],
	        '{POOR}' => $lang_rate_pic['poor'],
	        '{FAIR}' => $lang_rate_pic['fair'],
	        '{GOOD}' => $lang_rate_pic['good'],
	        '{EXCELLENT}' => $lang_rate_pic['excellent'],
	        '{GREAT}' => $lang_rate_pic['great'],
	        '{WIDTH}' => $CONFIG['picture_table_width'],
	        '{LOCATION}' => $location,        //theme dir or default images directory
	        );

	    return template_eval($template_image_rating, $params);
	}


    // END YouTube Addition

    //report to moderator buttons
    if (($CONFIG['report_post']==1) && (USER_CAN_SEND_ECARDS)) {
        $report_tgt = "report_file.php?album=$album$cat_link&amp;pid=$pid&amp;pos=$pos";
    } else { // remove button if report toggle is off
        template_extract_block($template_img_navbar, 'report_file_button');

    }

        $thumb_tgt = "thumbnails.php?album=$album$cat_link&amp;page=$page";
        $meta_nav .= "<link rel=\"up\" href=\"$thumb_tgt\" title=\"".$lang_img_nav_bar['thumb_title']."\"/>
        ";

    $slideshow_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pid=$pid&amp;slideshow=".$CONFIG['slideshow_interval'];

    $pic_pos = sprintf($lang_img_nav_bar['pic_pos'], $human_pos, $pic_count);

    if (defined('THEME_HAS_NAVBAR_GRAPHICS')) {
            $location= $THEME_DIR;
        } else {
            $location= '';
        }

    $params = array('{THUMB_TGT}' => $thumb_tgt,
        '{THUMB_TITLE}' => $lang_img_nav_bar['thumb_title'],
        '{PIC_INFO_TITLE}' => $lang_img_nav_bar['pic_info_title'],
        '{SLIDESHOW_TGT}' => $slideshow_tgt,
        '{SLIDESHOW_TITLE}' => $lang_img_nav_bar['slideshow_title'],
        '{PIC_POS}' => $pic_pos,
        '{ECARD_TGT}' => $ecard_tgt,
        '{ECARD_TITLE}' => $ecard_title,
        '{START_TGT}' => $start_tgt,
        '{START_TITLE}' => $start_title,
        '{PREV_TGT}' => $prev_tgt,
        '{PREV_TITLE}' => $prev_title,
        '{PREV_IMAGE}' => ($lang_text_dir=='ltr') ? 'prev' : 'next',
        '{REW_TGT}' => $rew_tgt,
        '{REW_TITLE}' => $rew_title,
        '{NEXT_TGT}' => $next_tgt,
        '{NEXT_TITLE}' => $next_title,
        '{NEXT_IMAGE}' => ($lang_text_dir=='ltr') ? 'next' : 'prev',
        '{FF_TGT}' => $ff_tgt,
        '{FF_TITLE}' => $ff_title,
        '{REPORT_TGT}' => $report_tgt,
        '{REPORT_TITLE}' => $lang_img_nav_bar['report_title'],
        '{LOCATION}' => $location,
        '{FF_CSS}' => $ff_css,
        );

    return template_eval($template_img_navbar, $params);
}

// HTML template for the display of comments
$template_image_comments = <<<EOT
<table align="center" width="{WIDTH}" cellspacing="1" cellpadding="0" class="maintableb">

        <tr>
                <td>
                        <table width="100%" cellpadding="0px" cellspacing="0px">
                           <tr>
                                <td class="tableh2_compact" nowrap="nowrap">
                                        <b>{MSG_AUTHOR}</b><a name="comment{MSG_ID}">&nbsp;</a>
<!-- BEGIN ipinfo -->
                                                                                 ({IP})
<!-- END ipinfo -->
</td>


                                <td class="tableh2_compact" align="right" width="100%">
<!-- BEGIN report_comment_button -->
     <a href="report_file.php?pid={PID}&amp;msg_id={MSG_ID}&amp;what=comment" title="{REPORT_COMMENT_TITLE}"><img src="themes/valentines/images/report.gif" width="16px" height="16px" border="0px" align="middle" alt="{REPORT_COMMENT_TITLE}" /></a>
<!-- END report_comment_button -->


<!-- BEGIN buttons -->
                                        <a href="javascript:;" onclick="blocking('cbody{MSG_ID}','', 'block'); blocking('cedit{MSG_ID}','', 'block'); return false;" title="{EDIT_TITLE}"><img src="themes/valentines/images/edit.gif" border="0px" align="middle" alt="" /></a>
                                        <a href="delete.php?msg_id={MSG_ID}&amp;what=comment"  onclick="return confirm('{CONFIRM_DELETE}');"><img src="themes/valentines/images/delete.gif" border="0px" align="middle" /></a>
<!-- END buttons -->
                                </td>
                                <td class="tableh2_compact" align="right" nowrap="nowrap">
                                        <span class="comment_date">[{MSG_DATE}]</span>
                                </td></tr>
                        </table>
                </td>
        </tr>
        <tr>
                <td class="tableb_compact">
                        <div id="cbody{MSG_ID}" style="display:block">
                                {MSG_BODY}
                        </div>
                        <div id="cedit{MSG_ID}" style="display:none">
<!-- BEGIN edit_box_smilies -->
                                <form name="f{MSG_ID}" method="post" action="db_input.php">
                                    <table width="100%" cellpadding="0px" cellspacing="0px">
                                        <tr>
                                            <td valign="top">
                                                <input type="text" name="msg_author" value="{MSG_AUTHOR}" class="textinput" size="25" />
                                                <input type="hidden" name="event" value="comment_update" />
                                                <input type="hidden" name="msg_id" value="{MSG_ID}" />
                                            </td>
                                            <td width="70%">
                                                <textarea cols="40" rows="2" class="textinput" name="msg_body" onselect="storeCaret_f{MSG_ID}(this);" onclick="storeCaret_f{MSG_ID}(this);" onkeyup="storeCaret_f{MSG_ID}(this);" style="width:99%;">{MSG_BODY_RAW}</textarea>
                                            </td>
                                            <td align="right">
                                                <input type="submit" class="comment_button" name="submit" value="{OK}" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="3">
                                                <img src="images/spacer.gif" width="1px" height="2px" />
                                                <br />
                                            </td>
                                        </tr>
                                    </table>
                                </form>
                                {SMILIES}
<!-- END edit_box_smilies -->
<!-- BEGIN edit_box_no_smilies -->
                                <form name="f{MSG_ID}" method="post" action="db_input.php">
                                    <table width="100%" cellpadding="0px" cellspacing="0px">
                                        <tr>
                                            <td valign="top">
                                                <input type="hidden" name="event" value="comment_update" />
                                                <input type="hidden" name="msg_id" value="{MSG_ID}" />
                                                <input type="text" name="msg_author" value="{MSG_AUTHOR}" class="textinput" size="25" />
                                            </td>
                                            <td width="70%">
                                                <textarea cols="40" rows="2" class="textinput" name="msg_body" style="width:99%;">{MSG_BODY_RAW}</textarea>
                                            </td>
                                            <td align="right">
                                                <input type="submit" class="comment_button" name="submit" value="{OK}" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="3">
                                                <img src="images/spacer.gif" width="1px" height="2px" />
                                                <br />
                                            </td>
                                        </tr>
                                    </table>
                                </form>
<!-- END edit_box_no_smilies -->
                        </div>
                </td>
        </tr>
</table>
EOT;

$template_add_your_comment = <<<EOT
	<form method="post" name="post" action="db_input.php">
		<table align="center" width="{WIDTH}" cellspacing="1" cellpadding="0" class="maintable">
			<tr>
					<td width="100%" class="tableh2_compact"><b>{ADD_YOUR_COMMENT}</b></td>
			</tr>
			<tr>
                <td colspan="1">
                        <table width="100%" cellpadding="0" cellspacing="0">

<!-- BEGIN user_name_input -->
							<tr>
								<td class="tableb_compact">
                                        {NAME}
                                </td>
                                <td class="tableb_compact">
                                        <input type="text" class="textinput" name="msg_author" size="10" maxlength="20" value="{USER_NAME}" />
                                </td>
<!-- END user_name_input -->
<!-- BEGIN input_box_smilies -->
                                <td class="tableb_compact">
                                {COMMENT}
								</td>
                                <td width="100%" class="tableb_compact">
                                <input type="text" class="textinput" id="message" name="msg_body" onselect="storeCaret_post(this);" onclick="storeCaret_post(this);" onkeyup="storeCaret_post(this);" maxlength="{MAX_COM_LENGTH}" style="width: 100%;" />
								</td>
<!-- END input_box_smilies -->
<!-- BEGIN input_box_no_smilies -->
                                <td class="tableb_compact">
                                {COMMENT}
								</td>
                                <td width="100%" class="tableb_compact">
                                <input type="text" class="textinput" id="message" name="msg_body"  maxlength="{MAX_COM_LENGTH}" style="width: 100%;" />
                                </td>
<!-- END input_box_no_smilies -->
                                <td class="tableb_compact">
                                <input type="hidden" name="event" value="comment" />
                                <input type="hidden" name="pid" value="{PIC_ID}" />
                                <input type="submit" class="comment_button" name="submit" value="{OK}" />
                                </td>
							</tr>
                        </table>
                </td>
        </tr>
<!-- BEGIN smilies -->
        <tr>
                <td width="100%" class="tableb_compact">
                        {SMILIES}
                </td>
        </tr>
<!-- END smilies -->
		</table>
	</form>
EOT;


// Creates buttons from a template using an array of tokens
// this function is used in this file it needs to be declared before being called.
function assemble_template_buttons($template_buttons,$buttons) {
    $counter=0;
    $output='';

    foreach ($buttons as $button)  {
      if (isset($button[4])) {
         $spacer=$button[4];
      } else {
      $spacer='';
      }

        $params = array(
            '{SPACER}'     => $spacer,
            '{BLOCK_ID}'   => $button[3],
            '{HREF_TGT}'   => $button[2],
            '{HREF_TITLE}' => $button[1],
            '{HREF_LNK}'   => $button[0]
            );
        $output.=template_eval($template_buttons, $params);
    }
    return $output;
}


// Creates an array of tokens to be used with function assemble_template_buttons
// this function is used in this file it needs to be declared before being called.
function addbutton(&$menu,$href_lnk,$href_title,$href_tgt,$block_id,$spacer) {
  $menu[]=array($href_lnk,$href_title,$href_tgt,$block_id,$spacer);
}


// HTML template for template sys_menu spacer
$template_sys_menu_spacer ="::";

if (!defined('THEME_HAS_NO_SYS_MENU_BUTTONS')) {

  // HTML template for template sys_menu spacer
  $template_sys_menu_spacer ="::";

  // HTML template for template sys_menu buttons
  $template_sys_menu_button = <<<EOT
  <!-- BEGIN {BLOCK_ID} -->
        <a href="{HREF_TGT}" title="{HREF_TITLE}">{HREF_LNK}</a> {SPACER}
  <!-- END {BLOCK_ID} -->
EOT;

  // HTML template for template sys_menu buttons
    // {HREF_LNK}{HREF_TITLE}{HREF_TGT}{BLOCK_ID}{SPACER}
    addbutton($sys_menu_buttons,'{HOME_LNK}','{HOME_TITLE}','{HOME_TGT}','home',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{MY_GAL_LNK}','{MY_GAL_TITLE}','{MY_GAL_TGT}','my_gallery',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{MEMBERLIST_LNK}','{MEMBERLIST_TITLE}','{MEMBERLIST_TGT}','allow_memberlist',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{MY_PROF_LNK}','{MY_PROF_TITLE}','{MY_PROF_TGT}','my_profile',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{ADM_MODE_LNK}','{ADM_MODE_TITLE}','{ADM_MODE_TGT}','enter_admin_mode',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{USR_MODE_LNK}','{USR_MODE_TITLE}','{USR_MODE_TGT}','leave_admin_mode',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{UPL_PIC_LNK}','{UPL_PIC_TITLE}','{UPL_PIC_TGT}','upload_pic',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{REGISTER_LNK}','{REGISTER_TITLE}','{REGISTER_TGT}','register',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{FAQ_LNK}','{FAQ_TITLE}','{FAQ_TGT}','faq',$template_sys_menu_spacer);
    addbutton($sys_menu_buttons,'{LOGIN_LNK}','{LOGIN_TITLE}','{LOGIN_TGT}','login','');
    addbutton($sys_menu_buttons,'{LOGOUT_LNK}','{LOGOUT_TITLE}','{LOGOUT_TGT}','logout','');
    // Login and Logout don't have a spacer as only one is shown, and either would be the last option.

  $params = array('{BUTTONS}' => assemble_template_buttons($template_sys_menu_button,$sys_menu_buttons));
  $template_sys_menu = template_eval($template_sys_menu,$params);
}



// Function to start a 'standard' table
function starttable($width = '-1', $title = '', $title_colspan = '1')
{
    global $CONFIG;

    if ($width == '-1') $width = $CONFIG['picture_table_width'];
    if ($width == '100%') $width = $CONFIG['main_table_width'];
    if ($title) {
        echo <<<EOT
<!-- Start standard table title -->
<table align="center" width="$width" cellspacing="0" cellpadding="0" class="maintablea">
        <tr>
                <td>
                        <table width="100%" cellspacing="0" cellpadding="0" class="tableh1a">
                                <tr>
                                        <td class="tableh1a"><img src="themes/valentines/images/tableh1a_bg_left.gif" alt="" /></td>
                                        <td class="tableh1a" style="background-image:url(themes/valentines/images/tableh1a_bg_middle.gif);" width="100%">$title</td>
                                        <td class="tableh1a"><img src="themes/valentines/images/tableh1a_bg_right.gif" alt="" /></td>
                                </tr>
                        </table>
                </td>
        </tr>
</table>
<!-- Start standard table -->
<table align="center" width="$width" cellspacing="0" cellpadding="0">
  <tr>
   <td style="background-image:url(themes/valentines/images/main_table_r1_c1b.gif);" valign="top"><img name="main_table_r1_c1" src="themes/valentines/images/main_table_r1_c1.gif" border="0"  alt="" /></td>
        <td width="100%"><table width="100%" cellspacing="1" cellpadding="0" class="maintableb">

EOT;
    } else {
        echo <<<EOT

<!-- Start standard table -->
<table align="center" width="$width" cellspacing="0" cellpadding="0">
  <tr>
   <td style="background-image:url(themes/valentines/images/main_table_r1_c1b.gif);" valign="top"><img name="main_table_r1_c1" src="themes/valentines/images/main_table_r1_c1.gif" border="0"  alt="" /></td>
        <td width="100%"><table width="100%" cellspacing="1" cellpadding="0" class="maintable">

EOT;
    }
}

function endtable()
{
    echo <<<EOT
        </table>
   </td>
   <td style="background-image:url(themes/valentines/images/main_table_r1_c3b.gif);" valign="top"><img name="main_table_r1_c3" src="themes/valentines/images/main_table_r1_c3.gif" border="0"  alt="" /></td>
  </tr>
  <tr>
   <td><img name="main_table_r2_c1" src="themes/valentines/images/main_table_r2_c1.gif" width="10" height="4" border="0"  alt="" /></td>
   <td style="background-image:url(themes/valentines/images/main_table_r2_c2b.gif);"><img name="main_table_r2_c2" src="themes/valentines/images/main_table_r2_c2.gif" border="0"  alt="" /></td>
   <td><img name="main_table_r2_c3" src="themes/valentines/images/main_table_r2_c3.gif" width="10" height="4" border="0"  alt="" /></td>
  </tr>
</table>
<!-- End standard table -->

EOT;
}

?>
