function store_cookie(name, value)
{
  var expires = '';
  if ( value == '' ) {
    expires = '; expires=Fri, 02-Jan-1970 00:00:00 GMT';
  }
  document.cookie = name + '=' + escape(value) +
                    '; path=/' +
		    expires;
}

function store_selections()
{
  if ( parent.frames[2].document.applets.length > 0 ) {
    var java_app = parent.frames[2].document.applets[0];
    var sel = java_app.get_selection(4);
    store_cookie("SEATADVISOR_SELECTION", sel);
  }
}

function set_map_type(type)
{
  if ( parent.frames[2].document.applets.length > 0 && parent.frames[2].loaded ) {
    var map_type = parseInt(type);

    var java_app = parent.frames[2].document.applets[0];
    java_app.set_map_type(map_type);

    var tt_suffix = "";
    var tickets = 0;

    if ( parent.frames[2].document.forms.length > 1 &&
         parent.frames[2].document.forms[1].event_select.selectedIndex > 0 ) {
      //tt_suffix = "_tt";
      tickets = 1;
    }

    if ( parent.frames[2].seat_map == "true" ) {
      if ( map_type == 1 ) {
        if ( parent.frames[1].document.map_key ) {
          parent.frames[1].document.map_key.src   = "/images/map/key_quality_seat" + tt_suffix + ".gif";
          parent.frames[1].document.links[1].href = "/common/seat_view_key_frame.shtml";
	}
      } else if ( map_type == 3 ) {
        if ( parent.frames[1].document.map_key ) {
          parent.frames[1].document.map_key.src   = "/images/map/key_comfort_seat" + tt_suffix + ".gif";
          parent.frames[1].document.links[1].href = "/common/seat_comfort_key_frame.shtml";
	}
      } else if ( map_type == 4 ) {
        if ( parent.frames[1].document.map_key ) {
	  if ( tickets ) {
            parent.frames[1].document.map_key.src = "/images/map/key_price_seat" + tt_suffix + ".gif";
	  } else {
            parent.frames[1].document.map_key.src = "/images/map/key_price_na" + tt_suffix + ".gif";
	  }
          parent.frames[1].document.links[1].href = "/common/map_key_detail.shtml";
	}
      }
    } else {
      if ( map_type == 1 ) {
        if ( parent.frames[1].document.map_key ) {
          parent.frames[1].document.map_key.src   = "/images/map/key_quality_section" + tt_suffix + ".gif";
          parent.frames[1].document.links[1].href = "/common/section_view_key_frame.shtml";
	}
      } else if ( map_type == 3 ) {
        if ( parent.frames[1].document.map_key ) {
          parent.frames[1].document.map_key.src   = "/images/map/key_comfort_section" + tt_suffix + ".gif";
          parent.frames[1].document.links[1].href = "/common/section_comfort_key_frame.shtml";
	}
      } else if ( map_type == 4 ) {
        if ( parent.frames[1].document.map_key ) {
          parent.frames[1].document.map_key.src   = "/images/map/key_price_na" + tt_suffix + ".gif";
          //parent.frames[1].document.map_key.src = "/images/map/key_price_seat" + tt_suffix + ".gif";
          parent.frames[1].document.links[1].href = "/common/map_key_detail.shtml";
	}
      }
    }
  }
  return false;
}

//
// Retrieve current map type setting in the map applet.
//
function get_map_type()
{
  var map_type = 1;	// default
  if ( parent.frames[2].document.applets.length > 0 && parent.frames[2].loaded )
  {
    var java_app = parent.frames[2].document.applets[0];
    map_type = java_app.get_map_type();
  }
  return map_type;
}

//
// Function to sync the sidebar radio button trio
// selection with what the seatmap currently has
// as it's internal map-type setting.  Called
// both by the sidebar and main_frame onload()
// since we can't predict which will load first.
//
function set_radio_select()
{
  // Make sure all the required document elements are
  // in place.
  if ( parent.frames[0].document.forms[0] &&
       parent.frames[0].document.forms[0].map_type ) {
    var map_type = get_map_type();
    var idx = 0;        // "view" map
    if ( map_type == 3 ) {
      idx = 1;          // "comfort" map
    } else if ( map_type == 4 ) {
      idx = 2;          // "price" map
    }
    parent.frames[0].document.forms[0].map_type[idx].checked = true;
  }
}

function future_date(year, month, day, hour, minute, ampm) {
  month--;
  hour = hour - 0;
  if ( ampm == "pm" && hour < 12 ) {
    hour += 12;
  } else if ( ampm == "am" && hour == 12 ) {
    hour = 0;
  }
  var event_date = new Date(year, month, day, hour, minute);
  var today = new Date();
  if ( event_date.getTime() <= today.getTime() ) {
    return 0;
  }
  return 1;
}

function new_window(url) {
  new_win = window.open(url, 'new_win', 'width=580,height=480,status=1,resizable=1,scrollbars=1');
}

function new_window_var(url,w,h,name) {
  new_win = window.open(url, name, 'width=' + w + ',height=' + h + ',status=1,resizable=1,scrollbars=1');
  if (parseInt(navigator.appVersion) >= 4 ) {
    new_win.focus();
  }
}

var unm = "express";
var dmn = "seatadvisor.com";

function make_comm_link(color)
{
   make_comm_link_w_text(color, unm + "@" + dmn)
}

function make_comm_link_w_text(color, link_text)
{
   document.write("<a href=\"mailto");
   document.write(":" + unm);
   document.write("@");
   document.write(dmn + "\" style=\"color: " + color + "\">" + link_text);
   document.write("<\/a>");
}

// make MAILTO
// dga- 2006-09-08
//
// somewhat more general functions than above to make a MAILTO
//
// Usage example:
//
// <head>
// ...
// <script language = "JavaScript" src="/jscript/util.js"></script>
// </head>
// ...
// <script language="JavaScript" type="text/javascript">
// javascript:makemt('brentm', 'seatadvisor.com', 'blue', 'Brent Miller');
// </script>
// 
function makemt(prefix, suffix, color, link_text)
{
   document.write("<a href=\"mailto");
   document.write(":" + prefix);
   document.write("@");
   document.write(suffix + "\" style=\"color: " + color + "\">" + link_text);
   document.write("<\/a>");
}

// make mail address as hidden input
//
// Usage example:
//
// <script language="JavaScript" type="text/javascript">
// javascript:makema_hidden_input('recipient', 'foobar', 'foo.com');
// </script>
// ==|
// <input type=hidden name="recipient" value="foobar@foo.com">
// 
// Example user:
// www/contact_us/system_request.shtml
//
function makema_hidden_input(field_name, prefix, suffix)
{
   document.write("<input type=hidden name='" + field_name + "' ");
   document.write("value='" + prefix + "@" + suffix + "'>");
}

/**
 * Similar to the above, but doesn't construct the addresses.
 * This allows it to work with multiple addresses.
 *
 * <input type=hidden name="recipient" value="foobar@foo.com, barfoo@foo.com">
 */
function makema_hidden_inputs(field_name, addresses)
{
   document.write("<input type=hidden name='" + field_name + "' ");
   document.write("value='" + addresses + "'>");
}

// dga- 2006-09-08
// The following functions and data is used hide MAILTOs in HTML source.
// This code is from: http://www.jracademy.com/~jtucek/email/download.php
// I have modified some function names below to further mask use of this functionality
//
// This script is (c) copyright 2006 Jim Tucek under the
// GNU General Public License (http://www.gnu.org/licenses/gpl.html)
// For more information, visit www.jracademy.com/~jtucek/email/
// Leave the above comments alone!

var decryption_cache = new Array();

function decrypt_string(crypted_string,n,decryption_key,just_email_address) {
        var cache_index = "'"+crypted_string+","+just_email_address+"'";

        if(decryption_cache[cache_index])                                       // If this string has already been decrypted, just
                return decryption_cache[cache_index];                           // return the cached version.

        if(addresses[crypted_string])                                           // Is crypted_string an index into the addresses array
                var crypted_string = addresses[crypted_string];                 // or an actual string of numbers?

        if(!crypted_string.length)                                              // Make sure the string is actually a string
                return "Error, not a valid index.";

        if(n == 0 || decryption_key == 0) {                                     // If the decryption key and n are not passed to the
                var numbers = crypted_string.split(' ');                        // function, assume they are stored as the first two
                n = numbers[0]; decryption_key = numbers[1];                    // numbers in crypted string.
                numbers[0] = ""; numbers[1] = "";                               // Remove them from the crypted string and continue
                crypted_string = numbers.join(" ").substr(2);
        }

        var decrypted_string = '';
        var crypted_characters = crypted_string.split(' ');

        for(var i in crypted_characters) {
                var current_character = crypted_characters[i];
                var decrypted_character = exponentialModulo(current_character,n,decryption_key);
                if(just_email_address && i < 7)                         // Skip 'mailto:' part
                        continue;
                if(just_email_address && decrypted_character == 63)     // Stop at '?subject=....'
                        break;
                decrypted_string += String.fromCharCode(decrypted_character);
        }

        decryption_cache[cache_index] = decrypted_string;                       // Cache this string for any future calls

        return decrypted_string;
}

//ep_mt - Email Protector MAILTO
//renamed from decrypt_and_email
//
// Example usage:
//
// <head>
// <script language = "JavaScript" src="/jscript/util.js"></script>
// ...
// </head>
// <a href="javascript:ep_mt(2)">E-Mail</a>

function ep_mt(crypted_string,n,decryption_key) {
        //dga- make email address - in original code this function is named
        if(!n || !decryption_key) { n = 0; decryption_key = 0; }
        if(!crypted_string) crypted_string = 0;

        var decrypted_string = decrypt_string(crypted_string,n,decryption_key,false);
        parent.location = decrypted_string;
}

//ep_ma - Email Protector mail address
//dga- renamed from decrypt_and_echo(crypted_string,n,decryption_key)
function ep_ma(crypted_string,n,decryption_key) {
        if(!n || !decryption_key) { n = 0; decryption_key = 0; }
        if(!crypted_string) crypted_string = 0;

        var decrypted_string = decrypt_string(crypted_string,n,decryption_key,true);
        document.write(decrypted_string);
        return true;
}


// Finds base^exponent % y for large values of (base^exponent)
function exponentialModulo(base,exponent,y) {
        if (y % 2 == 0) {
                answer = 1;
                for(var i = 1; i <= y/2; i++) {
                        temp = (base*base) % exponent;
                        answer = (temp*answer) % exponent;
                }
        } else {
                answer = base;
                for(var i = 1; i <= y/2; i++) {
                        temp = (base*base) % exponent;
                        answer = (temp*answer) % exponent;
                }
        }
        return answer;
}

if(!addresses) var addresses = new Array();

// ref this array via: <a href="javascript:xxxmt(N)">, N=0,1,2,...

// 0 - info one  at SA com  Subject: Seat Advisor Information Request
addresses.push("9853 6419 4286 6197 4824 8381 4122 7917 7905 4824 845 6937 7917 164 2209 9266 5966 3513 5589 6197 4122 6197 4847 7434 4824 3513 7917 3594 8659 4705 7917 4286 3722 3513 5427 5157 8656 5589 4705 4122 362 313 5589 6197 4122 8594 4847 7434 4824 3513 7917 3594 3209 4750 845 6937 7917 3594 4286 6197 4122 4824 7917 845 3209 9453 5589 4359 5427 5589 3513 4122");

// 1 - info at TL com  Subject: TL Information Request
addresses.push("9853 6419 4286 6197 4824 8381 4122 7917 7905 4824 845 6937 7917 5966 4122 4824 4705 3271 5589 4122 8381 7917 3594 4847 8659 4705 7917 4286 3722 3513 5427 5157 8656 5589 4705 4122 362 1524 4824 4705 3271 5589 4122 8381 7917 3594 4847 3209 4750 845 6937 7917 3594 4286 6197 4122 4824 7917 845 3209 9453 5589 4359 5427 5589 3513 4122");

// 2 - info at SA com au  Subject: Seat Advisor Australia Information Request
addresses.push("9853 6419 4286 6197 4824 8381 4122 7917 7905 4824 845 6937 7917 5966 3513 5589 6197 4122 6197 4847 7434 4824 3513 7917 3594 8659 4705 7917 4286 8659 6197 5427 3722 3513 5427 5157 8656 5589 4705 4122 362 313 5589 6197 4122 8594 4847 7434 4824 3513 7917 3594 3209 8594 5427 3513 4122 3594 6197 8381 4824 6197 3209 4750 845 6937 7917 3594 4286 6197 4122 4824 7917 845 3209 9453 5589 4359 5427 5589 3513 4122");

// 3 - info at ticketsdirect ca  Subject: TL South Africa Information Request
addresses.push("9853 6419 4286 6197 4824 8381 4122 7917 7905 4824 845 6937 7917 5966 4122 4824 4705 3271 5589 4122 3513 4847 4824 3594 5589 4705 4122 8659 4705 7917 8659 2896 6197 3722 3513 5427 5157 8656 5589 4705 4122 362 1524 4824 4705 3271 5589 4122 5444 7917 3594 4847 3209 313 7917 5427 4122 1622 3209 8594 6937 3594 4824 4705 6197 3209 4750 845 6937 7917 3594 4286 6197 4122 4824 7917 845 3209 9453 5589 4359 5427 5589 3513 4122");

//4 - sales_team at SA com  Subject: Seat Advisor Sales
addresses.push("9853 6419 4286 6197 4824 8381 4122 7917 7905 3513 6197 8381 5589 3513 164 4122 5589 6197 4286 5966 3513 5589 6197 4122 6197 4847 7434 4824 3513 7917 3594 8659 4705 7917 4286 3722 3513 5427 5157 8656 5589 4705 4122 362 313 5589 6197 4122 8594 4847 7434 4824 3513 7917 3594 3209 313 6197 8381 5589 3513");

//5 - express one at SA com  Subject: Seat Advisor Public Relations
addresses.push("9853 6419 4286 6197 4824 8381 4122 7917 7905 5589 3725 5802 3594 5589 3513 3513 164 2209 9266 5966 3513 5589 6197 4122 6197 4847 7434 4824 3513 7917 3594 8659 4705 7917 4286 3722 3513 5427 5157 8656 5589 4705 4122 362 313 5589 6197 4122 8594 4847 7434 4824 3513 7917 3594 3209 9497 5427 5157 8381 4824 4705 3209 9453 5589 8381 6197 4122 4824 7917 845 3513");

//6 - express one at SA com  Subject: Seat Advisor Investor Relations
addresses.push("9853 6419 4286 6197 4824 8381 4122 7917 7905 5589 3725 5802 3594 5589 3513 3513 164 2209 9266 5966 3513 5589 6197 4122 6197 4847 7434 4824 3513 7917 3594 8659 4705 7917 4286 3722 3513 5427 5157 8656 5589 4705 4122 362 313 5589 6197 4122 8594 4847 7434 4824 3513 7917 3594 3209 4750 845 7434 5589 3513 4122 7917 3594 3209 9453 5589 8381 6197 4122 4824 7917 845 3513");

//7 - express one at SA com  Subject: Seat Advisor Business Development
addresses.push("9853 6419 4286 6197 4824 8381 4122 7917 7905 5589 3725 5802 3594 5589 3513 3513 164 2209 9266 5966 3513 5589 6197 4122 6197 4847 7434 4824 3513 7917 3594 8659 4705 7917 4286 3722 3513 5427 5157 8656 5589 4705 4122 362 313 5589 6197 4122 8594 4847 7434 4824 3513 7917 3594 3209 1759 5427 3513 4824 845 5589 3513 3513 3209 8989 5589 7434 5589 8381 7917 5802 4286 5589 845 4122");

//8 - investment at SA com  Subject: Seat Advisor Investor Relations
addresses.push("9853 6419 4286 6197 4824 8381 4122 7917 7905 4824 845 7434 5589 3513 4122 4286 5589 845 4122 5966 3513 5589 6197 4122 6197 4847 7434 4824 3513 7917 3594 8659 4705 7917 4286 3722 3513 5427 5157 8656 5589 4705 4122 362 313 5589 6197 4122 8594 4847 7434 4824 3513 7917 3594 3209 4750 845 7434 5589 3513 4122 7917 3594 3209 9453 5589 8381 6197 4122 4824 7917 845 3513");
