var trueroots_site_us = "www.trueroots.us";
var trueroots_site_ca = "www.trueroots.ca";
var trueroots_site_uk = "www.trueroots.co.uk";
var trueroots_site_hk = "www.trueroots.hk";
var trueroots_site_sg = "www.trueroots.sg";
var trueroots_site_de = "www.trueroots.eu";
var trueroots_site_fr = "www.trueroots.eu";


$(document).ready(function() {
    
		$("#site_selector").change(function() {
				var index1 = $("#site_selector")[0].selectedIndex;
				goto_site(document.getElementById('site_selector').options[index1].value);
		});
		
		
		$('#cancel_session').click(function() {
			if (confirm('Are you sure you want to cancel your order?')) {
				window.location = '/home';
			}
			return false;
		});
	}
);

function goto_site(id) {
	var sites = new Array();
	sites['US'] = trueroots_site_us;
	sites['CA'] = trueroots_site_ca;
	sites['UK'] = trueroots_site_uk;
	sites['HK'] = trueroots_site_hk;
	sites['SG'] = trueroots_site_sg;
	sites['EU'] = trueroots_site_de;
	sites['EU'] = trueroots_site_fr;

	window.location = window.location.protocol + "//" + sites[id] + window.location.pathname;
}


function input_hover(id, bg_regular, bg_hover) {
	var button = $('#' + id);
	button.mouseover(function() {
		button.css('background-image', 'url(' + bg_hover + ')');
	});
	button.mouseout(function() {
		button.css('background-image', 'url(' + bg_regular + ')');
	});
}




function open_printad(url) {
	window.open(url, "printad", "toolbar=no, status=no, scrollbars=yes, resizable=yes, width=540, height=550");
}



/*
This prototype implements the array function indexOf for
browsers that dont support it (IE of course)

This prototype is provided by the Mozilla foundation and
is distributed under the MIT license.
http://www.ibiblio.org/pub/Linux/LICENSES/mit.license
*/

if (!Array.prototype.indexOf)
{
  Array.prototype.indexOf = function(elt /*, from*/)
  {
    var len = this.length;

    var from = Number(arguments[1]) || 0;
    from = (from < 0)
         ? Math.ceil(from)
         : Math.floor(from);
    if (from < 0)
      from += len;

    for (; from < len; from++)
    {
      if (from in this &&
          this[from] === elt)
        return from;
    }
    return -1;
  };
}