<?php
//  All of the documentation and software included in the PHP Climate
//  Release is copyrighted by Sebastien Windal
//
//  Copyright 2002
//  Sebastien Windal.  All rights reserved.
//
//  Redistribution and use in source and binary forms, with or without
//  modification, are permitted provided that the following conditions are met:
//  1. Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//  2. Redistributions in binary form must reproduce the above copyright
//     notice, this list of conditions and the following disclaimer in the
//     documentation and/or other materials provided with the distribution.
//  3. All advertising materials mentioning features or use of this software
//     must display the following acknowledgement:
//     This product includes software developed by Sebastien Windal and their
//     contributors.
//  4. Neither my name nor the names of its contributors may be used to
//     endorse or promote products derived from this software without
//     specific prior written permission.
//
//  THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
//  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
//  ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
//  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
//  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
//  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
//  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
//  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
//  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
//  SUCH DAMAGE.
//


//Support routines and data for the generation of
//the main page (index.php).

include_once "zip.php";

//Popular comparison array

function print_pop_comp($common_arg) {

$pop_comp = array("San-Francisco_CA""San-Jose_CA",
                  
"Los-Angeles_CA""New-York_NY",
                  
"New-York_NY""Chicago_IL",
                  
"Las-Vegas_NV""Atlantic-City_NJ",
                  
"Boston_MA""Seattle_WA",
                  
"Denver_CO""Salt-Lake-City_UT");

    
$count count($pop_comp); 
    for (
$i 0$i $count$i=$i+2) {
        echo 
"&raquo; <a href=\"compare.php?city1=";
        echo 
$pop_comp[$i];
        echo 
"&amp;city2=";
                echo 
$pop_comp[$i+1];
        echo 
"&amp;$common_arg";
        echo 
"\">" $pop_comp[$i] . " vs. " .  $pop_comp[$i+1];
        echo 
"</a><br>\n";
    }

}


//Prints link to single graphes for major US metropolitan areas (ranked by
//population according to 2000 US census
function print_major_cities($common_arg) {

$major_metro = array("New-York_NY",
                     
"Los-Angeles_CA",
                     
"Chicago_IL",
             
"Washington_DC",
             
"San-Francisco_CA",
             
"Philadelphia_PA",
             
"Boston_MA",
             
"Detroit_MI",
             
"Dallas_TX",
             
"Houston_TX",
             
"Atlanta_GA",
             
"Miami_FL",
             
"Seattle_WA"
        
);

        
$count count($major_metro);
        for (
$i 0$i $count$i++) {
                echo 
"&raquo; <a href=\"citygraph.php?city1=";
                echo 
$major_metro[$i];
                echo 
"&amp;$common_arg";
        echo 
"\">" $major_metro[$i];
                echo 
"</a><br>\n";
        }
}


function 
print_city_option_list() {

    
$cities = array("");
    if (
$handle opendir('data'))
        {
        while (
false != ($file readdir($handle)))
        {
            if (
strncmp($file"."1) && strncmp($file"CVS"3))
            {
                
array_push($cities$file);
            }
        }
        
closedir($handle);
    }
    
sort($cities);
    
$cities[0] = "Select City";
    
$count count($cities);
    for (
$i 0$i $count$i++) {
        echo 
"<option value=\"" ;
        echo 
$cities[$i];
        echo 
"\">";
        for (
$c 0;
             
$c strlen($cities[$i]);
             
$c++)
        {
            if (
$cities[$i][$c] == '_')
                echo 
", ";
            else if (
$cities[$i][$c] == "-")
                echo 
" ";
            else
                echo 
$cities[$i][$c];
        }
        echo 
"\n";
    }
}
?>