var language = 'en';
if (document.location.href.match(/\/us\//)) {
	language = "us";
} else if (document.location.href.match(/\/ca\//)) {
	language = "ca";
} else if (document.location.href.match(/\/fr\//)) {
	language = "fr ";
}
	
$(function () {
	
	// KEY FEATURES
	switch (language) {
		case "fr": var close = "fermer"; break;
		default: var close = "Close"; break;
	}
	
	var kf = $('#key-features').hide().prepend('<a href="#" id="close-key-features">[ ' + close + ' ]</a>').length;
	
	if (kf > 0) {
		$('#menu').after('<p><a href="#" class="key-features"><img src="graphics/key_features_but01.gif" alt="' + $('#key-features > h2:first').text() + '" /></a></p>');
		
		// Preload images
		$('#sidebar a.key-features').preload('graphics/key_features_but01_over.gif');
		
		// Swap images
		$('#sidebar a.key-features').hover(function(){
			$('img', this).attr('src', 'graphics/key_features_but01_over.gif');	
		},function(){
			$('img', this).attr('src', 'graphics/key_features_but01.gif');
		});
		$('#sidebar a.quote').hover(function(){
			$('img', this).attr('src', 'graphics/quote_but01_over.gif');	
		},function(){
			$('img', this).attr('src', 'graphics/quote_but01.gif');
		});
		
		// List Popup
		$('#sidebar a.key-features').click(function () {
			var features = $('#key-features');
			if (features.css('display') == 'none') {
				showKeyFeatures(features);
			} else {
				hideKeyFeatures(features);
			}
			return false;
		});
		$('#close-key-features').click(function () {
			hideKeyFeatures($('#key-features'));
		});
	}
	
	$('a.wras-popup').click(function () {
		window.open('wras.php', 'wras', 'width=550,height=450,scrollbars=1');
		return false;
	});
	$('body.wras #footer p.home a').click(function () {
		self.close();
		return false;
	});
	
	//alert($('.header').offset().left + ' x ' + $('.header').offset().top);
	
	// CURVY CORNERS
	var radius = 30;
	$('.corners').corner({
		tl: { radius: radius },
		tr: { radius: radius },
		bl: { radius: radius },
		br: { radius: radius },
		antiAlias: true
    });
	
	// QUOTE FORM
	$('ul.prod-conf-opts li.standard label, ul.prod-conf-opts li.standard input').click(function() {
		switch (language) {
		case "fr": alert('This option comes as standard. It can not be de-selected.'); break;
		default: alert('This option comes as standard. It can not be de-selected.'); break;
	}
	});
});

function hideKeyFeatures(features) {
	features.hide(500);
}

function showKeyFeatures(features) {
	var offset = $('#sidebar a.key-features img').offset();
	features.css({
		position: 'absolute',
		top: offset.top - 50,
		left: 275,
		border: '1px dotted Gray',
		backgroundColor: '#F8F8F8',
		padding: '0 20px',
		width: 440
	}).show(500);
}