opacity_value = 1;
fade_speed = 50;
var switch_box_image = "";

function switch_pic(pic){
	clearTimeout(t);
	switch_box_image = document.getElementById('switch_box_image');
	swapfile=pic;
	if (opacity_value > 0.9){fadeout();}
}

function auto_switch_pic(pic){
	switch_box_image = document.getElementById('switch_box_image');
	swapfile=pic;
	fadeout();
}


function autoswitch(a){
	if (document.getElementById('switch_box_image') != null){
		auto_switch_pic(a)
		a++;
		if (a>3){a=1;}
		t=setTimeout("autoswitch("+a+")",8000);
	}
}





function fadeout(){
		opacity_value = opacity_value - 0.1;
        switch_box_image.style.opacity = opacity_value;
		switch_box_image.style.filter = 'alpha(opacity = ' + (opacity_value*100) + ')';
		if (opacity_value < 0.1){
			switch_box_image.innerHTML='<img src="uploads/images/switch_images/'+swapfile+'.jpg" alt="" height="299" width="637">';
			fadein()
			return;
			}
		f=setTimeout("fadeout()",fade_speed);
  	}
	
function fadein(){
		opacity_value = opacity_value + 0.1;
        switch_box_image.style.opacity = opacity_value;
		switch_box_image.style.filter = 'alpha(opacity = ' + (opacity_value*100) + ')';
		if (opacity_value > 0.9){return;}
		f=setTimeout("fadein()",fade_speed);
  	}
