 jQuery(document).ready(function() {

	//set to false in the even that we don't use autologout and we're in /account/ or /product/
	var analog_timeout = true;
	var times_check_logged = 0;

	var loc = location.href
	jQuery(document).everyTime(5000, function(i) {
		if((loc.indexOf("/account/") != -1) || (loc.indexOf("/product/") != -1)) {
			checkLogout();
		}
	});
	
	function checkLogout()
	{
		times_check_logged += 1;
		if(times_check_logged >= Constants.SESSION_EXPIRE_LIMIT/5 && analog_timeout)
		{
			if ($(".login").length > 0)
			{
				$(".login").click(function() { location.href = this.href; });
				$(".login").click();
			}
			else if (Constants.D_PARTNER_POST_LOGOUT_URL != undefined && Constants.D_PARTNER_POST_LOGOUT_URL != '')
				location.href = Constants.D_PARTNER_POST_LOGOUT_URL;
		}
	}
	
	//override jquery.post to reset times_checked_out
	oldPost = jQuery.post;
	jQuery.post = function(url, data, callback, type)
		{
			times_check_logged = 0;
			oldPost(url, data, callback, type)
		}
	
	
});
