var cookieName = 'hinde-capital-cookie';
var cookieValue = 'disclaimer-accepted'
var cookieOptions = { path: '/', expires: 30 };

var testCookie = function() {
	return ($.cookie(cookieName) && $.cookie(cookieName) == cookieValue);
}

var setCookie =  function() {
	$.cookie(cookieName, cookieValue, cookieOptions);
}

AcceptDisclaimer = $.klass({
	initialize: function(options) { },
	onclick: function() {
		setCookie();
		tb_remove();
	}
});

ShowDisclaimer = $.klass({
	initialize: function(options) { 
	},
	onclick: function() {
		this.href = this.element.attr('href') || this.element.attr('alt');
//		console.log(testCookie());
		if(testCookie()) {
			setCookie();
			return true;
		} else {
			$('a.accept-disclaimer').attr({ href: this.href });
			this._showDisclaimer();
			return false;
		}
		
	},
	_showDisclaimer: function() {
		var t = this.element[0].title || this.element[0].name || null;
		var g = this.element[0].rel || false;				
		tb_show(t, "#TB_inline?height=560&width=760&inlineId=disclaimer", g);
	}
});
jQuery(function($) {
	$('a.disclaimer-protected').attach(ShowDisclaimer);
	$('a.accept-disclaimer').attach(AcceptDisclaimer);
});

