The best way to do this is to check the port on the back end and write the URL based on the port. Using Javascript is not reliable across all browsers.
Here is an example using one of the links you have on your site...
Code:
<a href="http://www.ausscrapcentral.com.au/aschot50/in.php?id=27">
{if $smarty.server.SERVER_PORT == 443}
[img]https://www.ausscrapcentral.com.au/aschot50/button.php?id=27[/img]
{else}
[img]http://www.ausscrapcentral.com.au/aschot50/button.php?id=27[/img]
{/if}
</a>