// namespace
var ha = {
	page: {},
	settings: {},
	strings: {},
	ui: {},
	util: {}
};

function isDigit(c) { return((c>="0")&&(c<="9")) }

/* 
 * Home page 
 */
ha.page.home = {
	init: function(){
		ha.page.home.submit();
		ha.page.home.cache();
	},
	
	submit: function(){
		$('input#price-btn').click(function(e){
			var amount = $("input#amt").val().replace("$","");
			$.ajax({ 
				type: "GET", 
				url: "/guarantee/ajax/validation/currency.json?amt=" + amount,
				dataType: "json",  
				success:function(data){
					ha.page.home.success(amount,data.productId);
				}, 
				error:function(xhr,err,e){
                    $("#quote-form-error").css("display","block");
                }
			});
		});
	},
	
	success: function(amount, productId){
		$("#quote-form-error").css("display","none");
		ha.util.modalbox.show("","/guarantee/checkout.html?amt="+amount+"&productId="+productId,"700:470:no");
	},
	
	isDigit: function(c) { return((c>="0")&&(c<="9")) },
	
	cache: function(){
		regBox = new Image(); 
		regBox.src = "/guarantee/resources/429/images/skin/registration-box.png";
	}
};

$(document).ready(function(){
	if ($("body.checkout-error, body.home").length > 0){
		ha.util.modalbox.init();
	}
	if ($("body.home").length > 0){
		ha.page.home.init();
	}
	if ($("body.registration").length > 0){
		$('.mb-inner #close-btn').click(function(){self.parent.ha.util.modalbox.remove();});
		$("#propid-info span.link").qtip({ content: '<img src="/guarantee/resources/429/images/products/propId-tip.jpg" border="0" />', position: {corner: {target: 'topLeft', tooltip: 'bottomLeft'}}, style: 'propid'});
	}
	if ($("body.confirmation").length > 0){
		ha.page.conf.init();
	}
});


