var SSL = {

	check: function()
	{
		var location = top.location,
			href = 'http://' + location.host + location.pathname + location.search;
		
		// Redirect to non-ssl if in ssl and page doesn't require ssl
		if ( location.protocol == 'https:' && !$( 'body' ).hasClass( 'ssl' ) )
		{
			$log( "Shouldn't be in SSL, switching..." );
			
			top.location.href = href;
		}
		
		// Redirect to ssl if we are not in ssl and page requires it
		if ( location.protocol != 'https:' && $( 'body' ).hasClass( 'ssl' ) )
		{
			$log( "Switching to SSL mode..." );
			
			href = 'https://' + location.host + location.pathname + location.search;
			
			(function() {
				top.location.href = href;
			}).delay( 500 );
		}
	}

};

window.addEvent( 'domready', SSL.check );
