function Tabs() {
	this.tabs = [];
	this.panels = [];
	this.current = 0;
}
Tabs.prototype = {
	addTab: function addTab(tab) {
		this.tabs.push(tab);
		var len = this.tabs.length-1;
		var self = this;
		$(tab.button).click(function(event){
			event.preventDefault();
			$(self.tabs[self.current].button.parentNode).toggleClass('active');
			$(self.tabs[len].button.parentNode).toggleClass('active');
			self.current = len;
			self.show(len);
		});
	},
	show: function show(idx) {
		this.tabs.forEach(function(tab){
			tab.hide();
		});
		this.tabs[idx].show();
	}
}
function Tab(button, panel) {
	this.button = button;
	this.panel = panel;
}
Tab.prototype = {
	show: function show(idx) {
		this.panel.css('display','');
	},
	hide: function hide() {
		this.panel.css('display','none');
	}
}

$(document).ready(function(){
	$('input').focus(function(){
		var self = $(this);
		if(self.attr('value') == self.attr('placeholder')) {
			var value = '';
			if(typeof self.data('orig_value') != undefined){
				value = self.data('orig_value');
			}
			$(this).attr('value', value);
			$(this).removeClass('hasPlaceHolder');
		}
	});
	$('input').each(function(){
		var self = $(this);
		if(typeof self.attr('placeholder') != 'undefined') {
			self.data('orig_value', self.attr('value'));
			if(self.attr('value') == '') {
				self.attr('value', self.attr('placeholder'));
				self.addClass('hasPlaceHolder');
			}
		}
	});

	$('#emailSignUpDiv_btn').click(function(event){
		event.preventDefault();
		$('#email_signup').submit();
	});
});


//IE does not have a forEach method for arrays........

if (!Array.prototype.forEach)
{
	Array.prototype.forEach = function(fun /*, thisp*/)
	{
		var len = this.length;
		if (typeof fun != "function")
			throw new TypeError();

		var thisp = arguments[1];
		for (var i = 0; i < len; i++)
		{
		if (i in this)
			fun.call(thisp, this[i], i, this);
		}
	};
}


