var i; //image number;
var path="images/"; //the path of the images
var image_names=new Array(); //array of names of the images that need to be loaded;
var images=new Array(); // image array
var text_names=new Array();
var texts=new Array();
var timeout=3000;
var timeout2=1000;
var opacity;
var opacity2;
var step=0;
//declaring the images
i=4;
image_names[0]="01.jpg";
image_names[1]="02.jpg";
image_names[2]="03.jpg";
image_names[3]="04.jpg";

text_names[0]="01_text.jpg";
text_names[1]="02_text.jpg";
text_names[2]="03_text.jpg";
text_names[3]="04_text.jpg";

opacity=100;
opacity2=0;
//end

function preload_images(nr,image_array){
	var i;
	
	for (i = 0; i < nr; i++){
			images[i]=new Image(960,300);
			images[i].src=path+image_names[i];
	}
	
}

function preload_texts(nr,text_array){
	var i;
	
	for (i = 0; i < nr; i++){
			texts[i]=new Image();
			texts[i].src=path+text_names[i];
	}
	
}

function change_image(){
	step++;
	if(step==1){
			document.getElementById("button_1").src='images/picture_arrow_light.jpg';
			document.getElementById("button_2").src='images/picture_arrow_ldark.jpg';
			document.getElementById("header_picture_one").src=images[2].src;
			document.getElementById("header_text_one").src=texts[2].src;
			setTimeout("fade_in()",timeout);
	}
	if(step==2){
		document.getElementById("button_2").src='images/picture_arrow_light.jpg';
			document.getElementById("button_3").src='images/picture_arrow_ldark.jpg';
			document.getElementById("header_picture_two").src=images[3].src;
			document.getElementById("header_text_two").src=texts[3].src;
			setTimeout("fade_out()",timeout);
	}
	if(step==3){
		document.getElementById("button_3").src='images/picture_arrow_light.jpg';
			document.getElementById("button_4").src='images/picture_arrow_ldark.jpg';
			document.getElementById("header_picture_one").src=images[0].src;
			document.getElementById("header_text_one").src=texts[0].src;
			setTimeout("fade_in()",timeout);
	}
	if(step==4){
			document.getElementById("button_4").src='images/picture_arrow_light.jpg';
			document.getElementById("button_1").src='images/picture_arrow_ldark.jpg';
			document.getElementById("header_picture_two").src=images[1].src;
			document.getElementById("header_text_two").src=texts[1].src;
			step=0;
			setTimeout("fade_out()",timeout);
	}
}

function fade_out(){
	opacity=opacity-1;
	opacity2=opacity2+1;
	document.getElementById("header_picture_one").style.opacity=opacity/100;
	document.getElementById("header_picture_one").style.filter="alpha(opacity="+opacity+")";
	document.getElementById("header_picture_two").style.opacity=opacity2/100;
	document.getElementById("header_picture_two").style.filter="alpha(opacity="+opacity2+")";
	document.getElementById("header_text_one").style.opacity=opacity/100;
	document.getElementById("header_text_one").style.filter="alpha(opacity="+opacity+")";
	document.getElementById("header_text_two").style.opacity=opacity2/100;
	document.getElementById("header_text_two").style.filter="alpha(opacity="+opacity2+")";
	if(opacity2==100){
		setTimeout("change_image()",timeout2);
			return;
	}
	setTimeout("fade_out()",25);	
}

function fade_in(){
	opacity=opacity+1;
	opacity2=opacity2-1;
	document.getElementById("header_picture_one").style.opacity=opacity/100;
	document.getElementById("header_picture_one").style.filter="alpha(opacity="+opacity+")";
	document.getElementById("header_picture_two").style.opacity=opacity2/100;
	document.getElementById("header_picture_two").style.filter="alpha(opacity="+opacity2+")";
	document.getElementById("header_text_one").style.opacity=opacity/100;
	document.getElementById("header_text_one").style.filter="alpha(opacity="+opacity+")";
	document.getElementById("header_text_two").style.opacity=opacity2/100;
	document.getElementById("header_text_two").style.filter="alpha(opacity="+opacity2+")";
	if(opacity==100){
		setTimeout("change_image()",timeout2);
			return;
	}
	setTimeout("fade_in()",25);
}







