var mark = new Number();
mark = 2;

var pic1;
var pic2;

function preloader() {

     // counter
     var i = 0;

     // create object
     imageObj = new Image();

     // set image list
     images = new Array();
     images[1]="../images/LPGallery1.jpg"
     images[2]="../images/LPGallery2.jpg"
     images[3]="../images/LPGallery3.jpg"
     images[4]="../images/LPGallery4.jpg"

     // start preloading
     for(i=1; i<=images.length; i++) 
     {
          imageObj.src=images[i];
     }
	 
	 delay();

} 



function delay() {
	setTimeout("initFade()", 5000);
}

function initFade(){
	for (i=0; i<11; i++){
		setTimeout('fadein(' + i + ')', 100*i);
	}	
}
function fadein(value) {
	
	pic1 = document.getElementById("gal1");
	pic2 = document.getElementById("gal2");
	
	pic2.style.opacity = value/10;
	pic2.style.filter = 'alpha(opacity=' + value*10 + ')';
	
	if ((pic2.style.opacity == 1) && (pic1.style.opacity == 1)) {
		picSwitch();
	}
}

function picSwitch() {
	mark++;
	if(mark == 5){
		mark = 1;
	}
	pic1.src = pic2.src;
	pic2.style.opacity = "0";
	pic2.style.filter = 'alpha(opacity=0)';
	pic2.src = images[mark];
	
	delay();
}
