How can i add a link to every image in this script?

Hi need some help.

How can i add a link to every image in this script?

This is a banner script that updates the images itself on certain time and day. (found on this forum).
I would like to at a link to each image. Is that possible ?

<script LANGUAGE="JavaScript">
<!--
today = new Date(); if(today.getMinutes() < 10) {pad = "0"} else pad = "";
if((today.getHours() >= 7) && (today.getHours() < 13)) {document.write("<IMG width='100%' height='100%' SRC='https://dl.dropboxusercontent.com/u/6888551/banners/page-1/banner-2/page1-banner2-image1.gif'>")}

if((today.getHours() >= 13) && (today.getHours() < 19)) {document.write("<IMG width='100%' height='100%' SRC='https://dl.dropboxusercontent.com/u/6888551/banners/page-1/banner-2/page1-banner2-image2.gif'>")}

if((today.getHours() >= 19) && (today.getHours() > 1)) {document.write("<IMG width='100%' height='100%' SRC='https://dl.dropboxusercontent.com/u/6888551/banners/page-1/banner-2/page1-banner2-image3.gif'>")}

if((today.getHours() >= 0) && (today.getHours() < 7)) {document.write("<IMG width='100%' height='100%' SRC='https://dl.dropboxusercontent.com/u/6888551/banners/page-1/banner-2/page1-banner2-image4.gif'>")}
// -->
</script>

Appreciate any help.

You really should not use document.write on a page that is loaded or loading.

Would be best to use DOM to insert images after the page is loaded. In which case it would just be a matter of surrounding each IMG tag with an anchor (<a></a>) tag.

HTH

As WolfShade says, document.write is bad practise.

Instead try something like this:

.myBanner{
    width: 100%;
    height: 100%
}
var today = new Date(),
    pad = (today.getMinutes() < 10)? "0" : "",
    bannerContainer = document.getElementById("bannerContainer"),
    banner = new Image(),
    baseSrc = "https://dl.dropboxusercontent.com/u/6888551/banners/page-1/banner-2/page1-banner2-image",
    a = document.createElement('a'),
    src;

if((today.getHours() >= 7) && (today.getHours() < 13)) {
    src = baseSrc + "1.gif";
} else if((today.getHours() >= 13) && (today.getHours() < 19)) {
    src = baseSrc + "2.gif";   
} else if((today.getHours() >= 19) && (today.getHours() > 1)) {
    src = baseSrc + "3.gif";
} else {
    src = baseSrc + "4.gif";
}

a.href = "http://example.com",
a.appendChild(banner);
banner.className = "myBanner";
banner.src = src;
bannerContainer.appendChild(a);