function setCurrentTab(new_tab) {
	$(current_tab).addClass('hide');
	$(current_tab + '_header').removeClass('on');
	current_tab = new_tab;
	$(current_tab).removeClass('hide');
	$(current_tab + '_header').addClass('on');
}

Element.implement({
	visible: function() { return this.style.display != 'none'; },
	toggle: function() { this[this.visible() ? 'hide' : 'show'](); return this; },
	hide: function() { this.style.display = 'none'; return this; },
	show: function() { this.style.display = ''; return this; }
});

// mootools < 1.2
Element.extend({
	visible: function() { return this.style.display != 'none'; },
	toggle: function() { this[this.visible() ? 'hide' : 'show'](); return this; },
	hide: function() { this.style.display = 'none'; return this; },
	show: function() { this.style.display = ''; return this; }
});

function swapLabel(label){
	$('int_label').title = $('int_label').innerHTML;
	$('int_label').innerHTML = label.title;
};
function revertLabel() { $('int_label').innerHTML = $('int_label').title; };

function toggleNav(element) {
	parentUL = $(element).getParent().getElement('ul');
	if (parentUL.visible()) {
		parentUL.hide();
		element.removeClass('open');
	} else {
		parentUL.show();
		element.addClass('open');
	}
}
function newDiv(id) { return (new Element('div')).setProperty('id', id); };

function swfElement(id) { 
	var movieId = id + '_swf';
	if (window.ie)
		return window[movieId];
	return document[movieId];
}

// Goes away with mootools 1.2
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

language = readCookie('language');
if (language) {
  var url = window.location;
  url = url.toString();
  if (language == 'fr')
    newURL = url.replace("//oakley.ca","//fr-ca.oakley.ca");
  else
    newURL = url.replace("//fr-ca.oakley.ca","//oakley.ca");
  if (url != newURL)
    window.location = newURL;
}

function updateQuantity() {
	quantity = readCookie('cart_quantity');
	if (quantity) {
	var $j = jQuery;
		$j('#cart_quantity').html(quantity);
		$j('#cart_total').html(readCookie('cart_total'));
    }
}


/*
Commented out by Kodiak Jensen on 3-23-09
domready V1 does not support SSL
In IE6 and IE7 this causes the alert box to be displayed
	"This page contains both secure and nonsecure items.
	Do you want to display the nonsecure items?"

The solution is to change domready to load	
	
window.addEvent('domready', updateQuantity);
*/
window.addEvent('load', updateQuantity);


if (navigator.appVersion.indexOf("Mac") > -1) window.mac = true;
