var $ = jQuery.noConflict();
var g_post_id = 0;

// remap jQuery to $
(function($){
})(window.jQuery);


// remap jQuery to $ AND wait till doc loaded
jQuery(document).ready(function($){
});



function Theme() {
	// private properties
	var privateProp = 'private property';
	
	// public properties
	this.post_id = 0;
	this.post_type = '';
	this.baseUrl = '/';
	this.ajaxUrl = 'ajax.php';
	this.ajaxNonce = '';

	// privileged methods
	this.privilegedFunc = function(){ alert('privileged method'); }

	// private methods
	function privateFunc(){ alert('private method'); }
	
	
	
	this.initSubscribeForm = function() {
		var $this = this;
		$('#subscribe-form input[type=text]').focus(function() {
			$('label[for='+this.id+']').hide();
			$(this).select();
		});

		$('#subscribe-form input[type=text]').blur(function() {
			if($(this).val().length == 0)
				$('label[for='+this.id+']').show();
		});

		$('#subscribe-submit-button').click(function(e) { 
			var data = {
				action: 'subscribe',
				nonce: $this.ajaxNonce,
				email: $('#subscribe-form input[name="email"]').val()
			}
			$.post($this.ajaxUrl, data, function(response) {
				var d = response.d;
				if(d.success == true) {
					alert('Bedankt voor je aanmelding!');
					$('#subscribe-form input[name=email]').val('');
					$('#subscribe-form input[name=email]').focus();
					$('#subscribe-form input[name=email]').blur();
				} else {
					alert('Er is helaas een fout opgetreden.\n\nFout: ' + d.message);
				}
			});			
			e.preventDefault();
			return false;
		});
	
		return this;
	}; 	
};

// public prototype properties
Theme.prototype.prototypeProp = 'prototype property';

// static properties
Theme.staticProp = 'static property';

// public methods
Theme.prototype.init = function() {
	this.initSubscribeForm();
}

