function comingsoon(htmlContentResource) {

	/* Add default values to params object */
	params = new Object();
	params.ajax = htmlContentResource;
	params.modal = false;
	params.overlay = 50;
	params.onLoad = function(obj) {
		
		/* Handle focus on email input field */
		var emailInputEl = $('input[type="text"]', obj.w);
		var emailButtonEl = $('input[type="submit"]', obj.w);
		
		emailInputEl.addClass("blur");
		emailInputEl.focus(function() {
			$(this).removeClass("blur").addClass("focus");
		    if (this.value == this.defaultValue){ 
		    	this.value = '';
			}
			if(this.value != this.defaultValue){
				this.select();
			}
		});
		emailInputEl.blur(function() {
		    if ($.trim(this.value) == ''){
		    	this.value = (this.defaultValue ? this.defaultValue : '');
		    	$(this).removeClass("focus").addClass("blur");
			}
		});
		/* Disable autofocus */
		setTimeout(function(){emailInputEl.blur(); }, 1);
		
		/* Ajax form submission */
		$(obj.w).find("form").ajaxForm({
    		type: "post",
    		dataType: "json",
    		iframe: false,
            beforeSubmit:	function() {
				
				return validateForm(emailInputEl);
			},
            success:		function(data) {
            	if(data.success) {
            		$(obj.w).find("#error").hide();
	            	$(obj.w).find("#success").show();
	            	emailInputEl.val("").removeClass("focus").addClass("blur").focus().blur();
	            	
	            	emailInputEl.attr('disabled', 'disabled');
	            	emailButtonEl.attr('disabled', 'disabled');
	            	
            	} else {
            		$(obj.w).find("#success").hide();
            		$(obj.w).find("#error").show();
            	}
            },
            error: function() {
            	$(obj.w).find("#success").hide();
            	$(obj.w).find("#error").show();
            }
		});

	};
	
	/* create and show modal */
	var modalEl = $("<div></div>");
	modalEl.addClass("jqmWindow").appendTo($(document.body)).jqm(params).jqmShow();

}
/* Email format validation */
function validateForm(el) {
	if(validateEmail(el.val())) {
		el.removeClass("error");
		return true;
	}
	el.addClass("error");
    return false;
}
function validateEmail(email) {
	var pattern = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9+-]+(\.[a-z0-9+-]+)*(\.[a-z]{2,3})$/gi;
	return (email.search(pattern) == -1)?false:true;
}

$(document).ready(function() {
	var lang = (document.documentElement.lang || document.getElementsByTagName("html")[0].getAttribute("lang")).substr(0, 2).toLowerCase();
	comingsoon("html/comingsoon."+lang+".html");
});
