var dateObj     = new Date();
var coverArray  = new Array("WesternCape", "Gauteng", "KwaZuluNatal")
var nameArray   = new Array("WESTERN CAPE", "GAUTENG", "KWAZULU-NATAL")
var magURLArray = new Array("javascript:popReader('http://cptmag.thepropertymag.co.za')", "javascript:popReader('http://gtnmag.thepropertymag.co.za')", "javascript:popReader('http://kznmag.thepropertymag.co.za')")
var monthsArray = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var monthStr    = monthsArray[dateObj.getMonth()]
var yearStr     = String(dateObj.getFullYear())
var thisCover   = 0
// ==============================================
var coverURL = "/images/452774491/Covers/"+ yearStr +"/"+ monthStr +"/"+ coverArray[thisCover] +".jpg"
window.onload = preloadcovers
var rotator
function preloadcovers(){
    var cover1 = new Image();
        cover1.src = "/images/452774491/Covers/"+ yearStr +"/"+ monthStr +"/"+ coverArray[0] +".jpg"
    var cover2 = new Image();
        cover2.src = "/images/452774491/Covers/"+ yearStr +"/"+ monthStr +"/"+ coverArray[1] +".jpg"
    var cover3 = new Image();
        cover3.src = "/images/452774491/Covers/"+ yearStr +"/"+ monthStr +"/"+ coverArray[2] +".jpg"
        rotator = window.setInterval("rightCover()", 5000);
}
function applyTransition(oImg){
   try{
        oImg.filters(0).Apply();
        oImg.style.visibility = "visible";
        oImg.filters(0).Play();
   }catch(e){
        oImg.style.visibility = "visible";
   }
}
function rightCover(){
    thisCover = (thisCover<coverArray.length-1)? thisCover+1 : 0
    var coverURL = "/images/452774491/Covers/"+ yearStr +"/"+ monthStr +"/"+ coverArray[thisCover] +".jpg"
    document.all.CoverPic.src = coverURL;
    document.all.coverName.innerText = nameArray[thisCover];
    document.all.coverURL.href = magURLArray[thisCover];
    document.all.CoverPic.style.visibility = "hidden"
    applyTransition(CoverPic);
}
function setRegionCover(coverInt){
    if(thisCover != coverInt){
        window.clearInterval(rotator);
        thisCover = coverInt
        var coverURL = "/images/452774491/Covers/"+ yearStr +"/"+ monthStr +"/"+ coverArray[thisCover] +".jpg"
        document.all.CoverPic.src = coverURL;
        document.all.coverName.innerText = nameArray[thisCover];
        document.all.coverURL.href = magURLArray[thisCover];
        document.all.CoverPic.style.visibility = "hidden"
        applyTransition(CoverPic);
    }
}
function popReader(url){
    var readerWinObj = window.open(url, "reader", "width=1000, height=650");
    readerWinObj.focus();
    //return false;
}

document.write('<TABLE cellSpacing=0 cellPadding=0 border=0>');
document.write('<TR><TD><A id=coverURL href="'+ magURLArray[thisCover] +'">');
document.write('<IMG id=CoverPic src="'+ coverURL +'" border=0 STYLE="filter:progid:DXImageTransform.Microsoft.Fade">');
document.write('</A></TD></TR>');
document.write('<TR><TD align=center class=whiteTextOnGrey style="padding:2px">');
document.write('<SPAN id=coverName>'+ nameArray[thisCover] +'</SPAN>');
document.write('</TD></TR>');
document.write('</TABLE>');