﻿
var fadeinCurrentSlide = 2;

function fadeinInit(id){

	var fadein1 = new Image(600,225); 
	fadein1 .src="http://boxerservice.com.au/images/fadeins/1.jpg"; 


	var fadein2 = new Image(600,225); 
	fadein1 .src="http://boxerservice.com.au/images/fadeins/2.jpg"; 



	var fadein3 = new Image(600,225); 
	fadein1 .src="http://boxerservice.com.au/images/fadeins/3.jpg"; 



	var fadein4 = new Image(600,225); 
	fadein1 .src="http://boxerservice.com.au/images/fadeins/4.jpg"; 



	var fadein5 = new Image(600,225); 
	fadein1 .src="http://boxerservice.com.au/images/fadeins/5.jpg"; 


    setInterval("fadein('"+id+"')",4000);

}

function fadein(id){

    var numSlides = 5;
   
    var src = "images/fadeins/"+window.fadeinCurrentSlide+".jpg";
    var obj = document.getElementById(id); 
    var style = document.getElementById(id).style; 
        
    obj.setAttribute("src",src);

    opacity(id,0,100,1000);
        
    window.fadeinCurrentSlide = window.fadeinCurrentSlide==numSlides? 1 : window.fadeinCurrentSlide + 1; 
}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 
