﻿
// Constructor
ecReviewClass=function()
{
        // Get day of the year to use of versions for images
        this.date = new Date();
        this.onejan = new Date(this.date.getFullYear(),0,1);
        this.DOY = Math.ceil((this.date - this.onejan) / 86400000);
        
		// Buid award images
        this.container = document.getElementById("ecReviewButton");
        
        this.span = document.createElement("SPAN");
        this.span.style.marginTop = "5px";
        this.span.style.marginRight = "5px";
        this.span.style.marginBottom = "0px";
        this.span.style.marginLeft = "5px";
        this.span.style.display = "block";
        this.span.style.paddingTop = "3px";
        
        this.done=false;
        
        //Check if already run
        this.objs = this.container.getElementsByTagName("IMG");
        for (this.i=0;this.i<this.objs.length;this.i++)
        	if (this.objs[this.i].src)
        		if (this.objs[this.i].src.indexOf("reviewButtonStar") > 0)
        			this.done=true;
        		
        		
        if (!this.done) {
	        this.reviewImage = document.createElement("IMG");
	        this.reviewImage.src = "http://review.equinecompare.co.uk/reviewButtonStar"+ecReviewSite+".png?v=" + this.DOY;
	        this.reviewImage.style.marginRight= "10px";
	        this.reviewImage.title = "Popularity Ranking";
	        this.reviewImage.alt = "";
	        
			this.visitorImage = document.createElement("IMG");
	        this.visitorImage.src = "http://images.equinecompare.co.uk/review/reviewButtonGraph"+ecReviewSite+".png?v=" + this.DOY;
	        this.visitorImage.title = "Unique Visitor Ranking";
	        this.visitorImage.alt= "";
	        
	        this.span.appendChild(this.reviewImage);
	        this.span.appendChild(this.visitorImage);
	        this.container.appendChild(this.span);
        }
}

var ecReviewObj = new ecReviewClass();