<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs 
    title="Kayak.com Best Fares"
    title_url="http://www.kayak.com/flights?origin=__UP_origin__&amp;destination=__UP_destination__&amp;depart_date=__UP_departureMonth__/1/2007&amp;return_date=__UP_departureMonth__/7/2007&amp;ai=googlegadget"
    category="lifestyle"
    description="Track best airfares based on recent Kayak.com search results. Chart is updated daily. Click edit to specify your origin airport, destination airport and departure month. A list of airport codes can be found here: http://www.kayak.com/airports/"
    screenshot="http://www.kayak.com/labsdata/googlegadget/KayakBestFares-screenshot.png"
    thumbnail="http://www.kayak.com/labsdata/googlegadget/KayakBestFares-thumbnail.gif"
    render_inline="optional"
    width="560"
    height="220"
    scaling="false"
    author="Kayak.com"
    author_email="affiliate-support@kayak.com"
    author_affiliation="Kayak.com"
    author_location="Concord, MA"
/>

<UserPref name="origin" datatype="string" default_value="BOS"
display_name="Origin Airport"/>
<UserPref name="destination" datatype="string" default_value="SFO"
display_name="Destination Airport"/>
<UserPref name="departureMonth" datatype="enum" default_value="01"
display_name="Departure Month">
 <EnumValue value="01" display_value="January"/>
 <EnumValue value="02" display_value="February"/>
 <EnumValue value="03" display_value="March"/>
 <EnumValue value="04" display_value="April"/>
 <EnumValue value="05" display_value="May"/>
 <EnumValue value="06" display_value="June"/>
 <EnumValue value="07" display_value="July"/>
 <EnumValue value="08" display_value="August"/>
 <EnumValue value="09" display_value="September"/>
 <EnumValue value="10" display_value="October"/>
 <EnumValue value="11" display_value="November"/>
 <EnumValue value="12" display_value="December"/>
</UserPref>
<UserPref name="size" datatype="enum" default_value="w=360&amp;h=200" display_name="Size">
 <EnumValue value="w=360&amp;h=200" display_value="Small"/>
 <EnumValue value="w=460&amp;h=220" display_value="Medium"/>
 <EnumValue value="w=560&amp;h=220" display_value="Large"/>
</UserPref>


<Content type="html"><![CDATA[
        <script type="text/javascript">

            var prefs = new _IG_Prefs();
            var origin = prefs.getString("origin");
            var destination = prefs.getString("destination");
            var img_size = prefs.getString("size");

            // get the month in the prefs, but strip the leading zeros
            var pref_month = prefs.getString("departureMonth").replace(/^[0]+/g,"");

            function constructLinks(){
                // See link examples after the script
                var authority = "http://www.kayak.com";
                var ai = "ai=googlegadget";

                // dates used in links
                var href_date_depart = pref_month + "/1/";
                var href_date_return = pref_month + "/7/";
                var img_src_date = "";

                // get the current month and compare it to the one in prefs and output the correct year
                var today = new Date();
                var month = today.getMonth() + 1;
                var year;

                if (month > pref_month) year = today.getYear() + 1901;
                else year = today.getYear() + 1900;

                // construct the dates
                href_date_depart += year;
                href_date_return += year;
                img_src_date += year + "-" + pref_month + "-" + "01";  

                // final links
                var href = authority + "/flights?origin=" + origin + "&destination=" + destination + "&depart_date=" + href_date_depart + "&return_date=" + href_date_return + "&" + ai;
                var img_src = authority + "/s/chart/?chart=monthlyfare&" + img_size + "&orig=" + origin + "&dest=" + destination + "&depart=" + img_src_date + "&" + ai;

                // Build HTML string to display message
                var html = "";

                html += "<a target=\"_blank\" href=\"" + href + "\">";
                html += "<img border=\"0\" alt=\"Best Fare Trend Chart\" src=\"" + img_src + "\" title=\"Click for more details\"></a>";

                _gel("content_div").innerHTML = html;
            }

            _IG_RegisterOnloadHandler(constructLinks);

        </script>

        <div id="content_div"></div>

<!-- Link examples (initial gadget)
<a "target="_blank"
href="http://www.kayak.com/flights?origin=__UP_origin__&amp;destination=__UP_destination__&amp;depart_date=__UP_departureMonth__/1/2010&amp;return_date=__UP_departureMonth__/7/2007&amp;ai=googlegadget">


<img border="0" alt="Best Fare Trend Chart"
src="http://www.kayak.com/s/chart/?chart=monthlyfare&__UP_size__&orig=__UP_origin__&dest=__UP_destination__&depart=2010-__UP_departureMonth__-01&ai=googlegadget" 
      title="Click for more details"></a>
-->

]]>
</Content>
</Module>
