<?php
/*************************  
  Copyright (c) 2004-2011 TinyWebGallery
  written by Michael Dempfle
 
  This program is free software; you can redistribute it and/or modify 
  it under the terms of the TinyWebGallery license (based on 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. 
  See license.txt for details.
 
  TWG version: 1.8.5
 
  $Date: 2009-06-17 22:57:10 +0200 (Mi, 17 Jun 2009) $
  $Revision: 73 $
**********************************************/

defined('_VALID_TWG') or die('Direct Access to this location is not allowed.');

if (!$php_include) {
    header('P3P: CP="ADMa PSAa PSDa IVAa CONi OUR IND ONL COM NAV INT DEM CNT STA PRE DSP OTI COR"');
	$ie_height_iframe_fix = $msie && $iframe_include && ($twg_standalone == "");
	if ($ie_height_iframe_fix) {
	  // I actually tried all doctypes - IE sucks with all in an iframe!  // "http://www.w3.org/TR/html4/strict.dtd"
      echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
      $use_round_corners = false;
    } else {
	  echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';	
	}
	echo '
<html>
';
}

?>
<!--
Powered by TinyWebGallery 1.8.5
Please go to http://www.tinywebgallery.com for the latest version.

Please don't remove this header if you use TWG or a modified version of it!

Copyright (c) 2004-2011 TinyWebGallery written by Michael Dempfle

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.
-->
<?php

if (!$php_include) {
	echo '
<head>
';
}

?>
<?php
if (!$php_include) {

if ($top10_type) {
 $browser_title_prefix .= " - " . $top10_type;
}

if ($image && !$input_invalid) {
  // this is the basic one - it is later improved when the title is read - but for robots a goot title has to exist
  echo '<title>'.$browser_title_prefix . ' - '.removeTitleChars(removeExtension($image)).'</title>';
} else if ($twg_album && !$input_invalid) {
  echo '<title>'.$browser_title_prefix.' - '.removeTitleChars($twg_album).'</title>';
} else {
  echo '<title>'.$browser_title_prefix.'</title>';
}
echo '
<meta name="author" content="Michael Dempfle" >
<meta name="DC.Identifier" content="http://www.tinywebgallery.com" >
<!-- Use IE7 mode -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
<meta http-equiv="X-UA-Compatible" content="IE=8">';

$image_meta = htmlspecialchars (utf8_decode($image),ENT_QUOTES);
$album_meta = htmlspecialchars (utf8_decode($twg_album),ENT_QUOTES);

if (!$input_invalid) {
    if ($metatags == "" && !$twg_album) { // if no metatags are provided and we have no image we use default
      $meta = trim($image_meta .','.$album_meta, " ,");
      echo'<meta name="keywords" content="'.$meta.',TinyWebGallery, twg, photo album, gallery, image gallery, galerie" >';
    } else {
      $meta = trim($image_meta .','.$album_meta.','. $metatags, " ,");
      echo '<meta name="keywords" content="' . $meta .'" >';
    }
}
if ($metadescription == '' && !$image && !$twg_album) { // if no metatags are provided we use default
  if ($default_language != 'de') {
    echo '<meta name="description" lang="en" content="TinyWebGallery is a free php/xml based photo album / gallery that is very easy to install, extremely user friendly and has many unique features.">';
  } else {
    echo '<meta name="description" lang="de" content="TinyWebGallery ist eine freie php/xml Galerie, die einfach zu installieren, extrem benutzerfreundlich ist und viele Features hat, die man sonst vergeblich sucht.">';
  }
} else if ($metadescription == '' && $image && $twg_album) {
  if ($default_language != 'de') {
    echo '<meta name="description" lang="en" content="This image is in the folder ' . $album_meta . ' and has the name '.$image_meta.'" >';
  } else {
    echo '<meta name="description" lang="de" content="Dieses Bild ist im Ordner ' . $album_meta . ' und hat den Namen '.$image_meta.'" >';
  }
} else if ($metadescription == '' && !$image) {
   if ($default_language != 'de') {
    echo '<meta name="description" lang="en" content="This is the thumbnail page of  the folder ' . $album_meta . '." >';
  } else {
    echo '<meta name="description" lang="de" content="Dies ist die Übersichtsseite des Ordners ' . $album_meta . '." >';
  }
} else { // There is a meta description set
  $meta = trim($image_meta .','.$album_meta, " ,");
  echo '
  <meta name="description" content="' . $metadescription .  " - " . $meta .'" >';
}
	echo '
<meta name="robots" content="index,follow,all">
';
}
if (isset($charset)) {
	echo '<META http-equiv="Content-Type" content="text/html; charset=' . $charset . '">';
}

if ($support_piclens && !$image) {
  $plfile = ($privatelogin == "FALSE") ? $cachedir . "/all_pl.rss"  : $cachedir . "/all_pl_".md5($privatelogin).".rss";  
  if (file_exists($plfile)) {
    echo '
    <link rel="alternate" href="'.$plfile.'" type="application/rss+xml" title="" id="gallery" />';
  }
}

?>
<script type="text/javascript">
// check if we are using Netscape < 4.x
var wrongBrowser = false;
if (parseInt(navigator.appVersion.substring(0,1)) <= 4) {
		if (navigator.appName == "Netscape")
			wrongBrowser = true;
}
if (wrongBrowser) {
   document.write('<meta http-equiv="refresh" content="0; URL=html/wrongbrowser.html">');
}
</script>
<script type="text/javaScript" src="<?php echo $install_dir ?>./js/jquery-1.6.1.min.js"></script>
<script type="text/javaScript">
     var $j = jQuery.noConflict();
</script>

<?php if ($video_player=="QT") { ?>
<script type="text/javaScript" src="<?php echo $install_dir ?>./js/AC_QuickTime.js"></script>
<?php } ?>
<!-- 
This loads an external script from the twg server! I try to remove ads like shown on funpic. 
Because they change the code very often I only have to update this file and you don't have a problem
with ad's. if you don't like/need this simply remove the next 3 lines!  
-->
<?php if (get_server_name() != "localhost" && (stristr(get_server_name(), 'funpic') !== FALSE) && $enable_external_adremove) { ?>
  <script type="text/javascript" src="http://www.tinywebgallery.com/js/remove_ad.js" ></script>
<?php } ?>
<?php
echo '<style type="text/css">';
echo '				#div1{height:' . $menu_pic_size_y . 'px;width:' . $menu_pic_size_x . 'px;text-align: center; }';
echo '</style>';

?>
<link rel="stylesheet" type="text/css" href="<?php echo $install_dir ?>style.css" >
<link rel="stylesheet" type="text/css" href="<?php echo $install_dir ?>language/language_flags.css" >
<?php
if ($msie) {
	echo '<link rel="stylesheet" type="text/css" href="' . $install_dir . 'style_ie.css" >';
}
if ($wii) {
	echo '<link rel="stylesheet" type="text/css" href="' . $install_dir . 'style_wii.css" >';
}

if (file_exists($install_dir . 'buttons/iconsets/' . $icon_set . '/style.css')) {
	echo '<link rel="stylesheet" type="text/css" href="' . $install_dir . 'buttons/iconsets/' . $icon_set . '/style.css" >';
}

?>
<link rel="shortcut icon" href="<?php echo $install_dir ?>favicon.ico" type="image/ico" >
<link rel="icon" href="<?php echo $install_dir ?>favicon.ico"  >
<?php
if ($activate_lightbox_topx || $activate_lightbox_thumb || ($activate_lightbox_image && $enable_download)) {

  if ($use_lytebox) {
    echo '<link rel="stylesheet" href="' . $install_dir . 'lightbox/lytebox.css" type="text/css" media="screen"> ';
  } else {
	echo '<link rel="stylesheet" href="' . $install_dir . 'lightbox/css/lightbox.css" type="text/css"> ';
	if ($msie) {
		echo '<link rel="stylesheet" href="' . $install_dir . 'lightbox/css/lightbox_ie.css" type="text/css">';
	}
 }
}
?>
<script type="text/javaScript" src="<?php echo $install_dir ?>./js/twg_image.js"></script>
<?php

if (checkFullscreen()) {
	echo "<script type='text/javascript'>isFullscreen();</script>";
}
// this stylesheet adds the border to the image gallery
if ($myborder == 'TRUE' && !$default_is_fullscreen) {
	echo "<link rel='stylesheet' type='text/css' href='" . $install_dir . "framestyle.css' >";
}
// this stylesheet if for language dependant stylesheet for different font sizes!
/*
$cssname = $install_dir . "language/language_" . $default_language . "_style.css";
if (file_exists($cssname)) {
  echo '<link rel="stylesheet" type="text/css" href="' . $cssname . '" >';
}
*/

if (file_exists($install_dir . "skins/" . $skin . ".css")) {
	echo "<link rel='stylesheet' type='text/css' href='" . $install_dir . "skins/" . $skin . ".css' >";
}

// additional stylesheet if no border is displayed!
if ($show_border !='TRUE' && file_exists($install_dir . "skins/" . $skin . "_noborder.css")) {
   echo "<link rel='stylesheet' type='text/css' href='" . $install_dir . "skins/" . $skin . "_noborder.css' >";
   $use_round_corners = false;
}

if ($use_round_corners && file_exists($install_dir . "skins/" . $skin . "_round.css")) {
   echo "<link rel='stylesheet' type='text/css' href='" . $install_dir . "skins/" . $skin . "_round.css' >";
}


if (file_exists($install_dir . "my_style.css")) {
	echo "<link rel='stylesheet' type='text/css' href='" . $install_dir . "my_style.css' >";
}
if ($msie && file_exists($install_dir . "my_style_ie.css")) {
	echo "<link rel='stylesheet' type='text/css' href='" . $install_dir . "my_style_ie.css' >";
}

if (!$php_include) {
	if ($ie_height_iframe_fix) {
		echo '<style>
		td.twg_info {
			height: 89%;
		}
		</style>';
	}
}

if (!$default_is_fullscreen) {
	$custstylesheet = $basedir . "/" . $twg_album . "/style.css";
	if (file_exists($custstylesheet)) { // individual css
		$custstylesheet = $basedir . "/" . twg_urlencode($twg_album) . "/style.css";
		echo "<link rel='stylesheet' type='text/css' href='" . $custstylesheet . "' >";
	} else {
		$custstylesheet = $cachedir . "/" . twg_urlencode(str_replace("/", "_", $twg_album)) . "_style.css"; // we link directly to the background - because of special characters like (+ü$§!%&-;) this type of encoding is used here
		if (file_exists($custstylesheet)) { // individual css
			echo "<link rel='stylesheet' type='text/css' href='" . $custstylesheet . "' >";
		}
	}
} else {
  if (file_exists($install_dir . "fullscreen.css")) {
	echo "<link rel='stylesheet' type='text/css' href='" . $install_dir . "fullscreen.css' >";
  }
}

if (!$show_counter || !$enable_counter_details) {
	echo '<style type="text/css">td.bottomtablesideleft { cursor: auto; } </style>';
}

if ($image != false && ($default_big_navigation != "HTML") && ($twg_smallnav == 'FALSE') && !$twg_slideshow) { // we are in the image view abd twg_show th dhtml navi
	if ($msie) {
		echo '<link rel="stylesheet" type="text/css" href="' . $install_dir . 'js/gallerystyle_ie.css">';
	} else {
		echo '<link rel="stylesheet" type="text/css" href="' . $install_dir . 'js/gallerystyle.css">';
	}
	echo '
<script type="text/javascript" src="' . $install_dir . 'js/twg_motiongallery.js">
/***********************************************
* CMotion Image Gallery- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/
</script>
';
}

if ($test_connection && $test_client_connection) {
	if ($test_connection_background) {
		include dirname(__FILE__) . "/../js/twg_speed.js.php";
	}
}

if ($activate_lightbox_topx || $activate_lightbox_thumb || ($activate_lightbox_image && $enable_download)) {
     if ($use_lytebox) {
        	echo '<script type="text/javascript" src="' . $install_dir . 'lightbox/lytebox.js"></script>';
     } else {
       echo '<script type="text/javascript" src="' . $install_dir . 'lightbox/js/prototype.js"></script>';
     // 	echo '<script type="text/javascript" src="' . $install_dir . 'lightbox/js/scriptaculous.js?load=effects"></script>';
       echo '<script type="text/javascript" src="' . $install_dir . 'lightbox/js/effects.js"></script>';
       echo '<script type="text/javascript" src="' . $install_dir . 'lightbox/js/lightbox.js"></script>';
       }
}

// height is defined earlier because in twg.js this height is needed	
if ($show_comments_in_layer) {
	$lang_height_comment += $height_of_comment_layer;
}

echo '<link rel="prefetch" href="http://www.tinywebgallery.com/index2.php">';

// we add a canonical URL
if ($image && $twg_album) {
  // we check if we have more than 2 parameters!
  if (count($_GET) > 2) {
    $fullurl = getScriptName() . '?twg_album='.$album_enc.'&amp;twg_show='.$image;
    echo '<link rel="canonical" href="'.$fullurl.'">';
  }
} else if (!$image && $twg_album) {
    // thumbnail page - we check if we have more than 1 parameters!
  if (count($_GET) > 1) {
    $fullurl = getScriptName() . '?twg_album='.$album_enc;
    echo '<link rel="canonical" href="'.$fullurl.'">';
  }
} else if (isset($GET['twg_lang'])) {
    // language selector is only available on the 1st page.
    $fullurl = getScriptName();
    echo '<link rel="canonical" href="'.$fullurl.'">';
}

if (file_exists($install_dir . 'head_addon.php')) {
   include ($install_dir . 'head_addon.php');
}

if (!$php_include) {
	echo '
</head>
';
} else {
  $show_background_images = false;
}
// we flush the header that css and js can be loaded already.
flush();

?>