<?php
$title = "Ocean colour products";
ini_set('include_path', './' . PATH_SEPARATOR . '../' . PATH_SEPARATOR . ini_get('include_path'));


// Check to see if we have a link
if (isset($_REQUEST["link"])) {
	include_once("include/config.php");
	include_once("include/normpath.php");
	//$BASEDIR = getBaseDir(getcwd(), constant('CONTEXT')); // context must be correct
	//$BASEURL = 'http://'.$_SERVER["HTTP_HOST"];
	$BASEURL = constant('BASEURL');

	$link = normalise_path($_REQUEST["link"]);
	if (substr($link,0,4) === 'http' ) die('link error');
	else if (substr($link,0,2) === '..' ) die('link error');
	if (!file_exists($link)) {
		header( 'Location: '.$BASEURL.'/404.php' );
		die('404');
	}

	// Try to figure out the permlink parameters and pass them through
	$dom = new DOMDocument;
	$dom->loadHTMLFile( $link );
	$xpath = new DOMXPath($dom);

	// Pull out the interesting bits
	$prev = $xpath->query('//a[text()="[PREV]"]')->item(0)->getAttribute('href');
	$next = $xpath->query('//a[text()="[NEXT]"]')->item(0)->getAttribute('href');
	$img = $dom->getElementsByTagName('img')->item(0)->getAttribute('src');

	$url = $BASEURL.'/oceancolour.php';
	$url .= '?permlink=true';
	$url .= '&relativeFolderPath='.dirname($link);
	$url .= '&regionalMap=1';
	$url .= '&imageUrl='.htmlspecialchars($BASEURL.'/'.dirname($link).'/'.$img);
	$url .= '&previous='.$prev;
	$url .= '&current='.basename($link);
	$url .= '&next='.$next;
	$url .= '&imgNameDate=todo';
	$url .= '&popup=false';
	$url .= '&baseFolderUrl='.htmlspecialchars($BASEURL.'/'.dirname($link));
	$url .= '&datePickerUrl='.dirname($link);
	$url .= '&debug=True';
	$url .= '&error=';
	//header('Location: http://www.google.com.au');
	header('Location: '.$url);
	exit;
}
else {
	$link='none';
}



include_once("include/header.php");
$docroot = $_SERVER["DOCUMENT_ROOT"];
?>
    <div class="row">
        <div class="col-md-4">
            <!--<h3 class="highlightedHeader" >Prepared maps and animations</h3>-->

            <map name="imapchl">
				<area shape="rect" coords="63   -2  107   31" href="TimorP_chl/latest.html" alt="TimorP_chl" title="Timor Passage-Darwin">
				<area shape="rect" coords="46  27  81  59" href="Broome_chl/latest.html" alt="Broome_chl" title="Broome">
				<area shape="rect" coords="-35 -15   9  19" href="XmasI_chl/latest.html" alt="XmasI_chl" title="Christmas Is.">
				<area shape="rect" coords="17  48  48  75" href="NWS_chl/latest.html" alt="NWS_chl" title="NW shelf">
				<area shape="rect" coords="9  58  39  92" href="Ningaloo_chl/latest.html" alt="Ningaloo_chl" title="Ningaloo">
				<area shape="rect" coords="28  112   36  119" href="Rottnest_chl/latest.html" alt="Rottnest_chl" title="Rottnest Is">
				<area shape="rect" coords="17  107   36  121" href="DonPer_chl/latest.html" alt="DonPer_chl" title="Dongara-Perth">
				<area shape="rect" coords="5   88   39  130" href="Perth_chl/latest.html" alt="Perth_chl" title="Shark Bay-Perth">
				<area shape="rect" coords="5   88   39  130" href="Perth_chl/latest.html" alt="Perth_chl" title="Perth">
				<area shape="rect" coords="9  107   43  145" href="CLeeu_chl/latest.html" alt="CLeeu_chl" title="Cape Leeuwin">
				<area shape="rect" coords="113  127  145  152" href="SAgulfs_chl/latest.html" alt="SAgulfs_chl" title="SA gulfs">
				<area shape="rect" coords="88  113  128  140" href="EGAB_chl/latest.html" alt="EGAB_chl" title="Eastern GAB">
				<area shape="rect" coords="70  113  124  146" href="RechEyre_chl/latest.html" alt="RechEyre_chl" title="Esperance-Eyre Pen.">
				<area shape="rect" coords="117  121  169  173" href="Adelaide_chl/latest.html" alt="Adelaide_chl" title="Adelaide-Melbourne">
				<area shape="rect" coords="194  104  204  113" href="Coffs_chl/latest.html" alt="Coffs_chl" title="Coffs Harbour">
				<area shape="rect" coords="180  116  206  145" href="SNSW_chl/latest.html" alt="SNSW_chl" title="Southern NSW">
				<area shape="rect" coords="191   80  209  104" href="Brisbane2_chl/latest.html" alt="Brisbane2_chl" title="Brisbane">
				<area shape="rect" coords="185   92  215  128" href="Bris-Syd_chl/latest.html" alt="Bris-Syd" title="Brisbane-Sydney">
				<area shape="rect" coords="178   58  213   87" href="SGBR_chl/latest.html" alt="SGBR_chl" title="Southern GBR">
				<area shape="rect" coords="161   31  196   64" href="CGBR_chl/latest.html" alt="CGBR_chl" title="Central GBR">
				<area shape="rect" coords="104    0  152   48" href="GoC_chl/latest.html" alt="GoC_chl" title="Gulf of Carpentaria">
				<area shape="rect" coords="143    2  189   34" href="NGBR_chl/latest.html" alt="NGBR_chl" title="Northern GBR">
				<area shape="rect" coords="187   73  222  121" href="Brisbane_chl/latest.html" alt="Brisbane_chl" title="Brisbane-Newcastle">
				<area shape="rect" coords="182  105  230  135" href="LordHoweS_chl/latest.html" alt="LordHoweS_chl" title="LordHowe Is.-Sydney">
				<area shape="rect" coords="159  155  196  182" href="TasE_chl/latest.html" alt="TasE" title="Tas-east">
				<area shape="rect" coords="169  121  204  173" href="Syd-Hob_chl/latest.html" alt="Syd-Hob_chl" title="Sydney-Hobart">
				<area shape="rect" coords="143  155  191  189" href="Tas_chl/latest.html" alt="Tas_chl" title="Tasmania">
				<area shape="rect" coords="26  121   74  147" href="AlbEsp_chl/latest.html" alt="AlbEsp_chl" title="Albany-Esperance">
				<area shape="rect" coords="2  164   87  186" href="MODIScomp/latest.html" alt="MODIScomp" title="Australia-NZ">
				<area shape="rect" coords="46  18  83  48" href="Kimberley_chl/latest.html" alt="Kimberley_chl" title="Kimberley">
				<area shape="default" href="MODIScomp/latest.html" alt="MODIScomp" title="Australia-NZ">
            </map>
            <div>
                <h2>Ocean Colour</h2>
				<img class="highlight" src="misc/imapchl.gif" usemap="#imapchl">
            </div>

        </div>
        <div class="col-md-8">
            <div id="proxiedPagesContainer">
                <div class="voffset4"></div>
                <!--<h4>Click on the map to see the graphs</h4>-->
                <h4>Select your region</h4>
            </div>
        </div>
    </div>
<?php
include_once("include/footer.php");
?>
