




var alpha = 99;
var current_img_id = 'main_image_0';
var is_fading = 0;
var slideshow = 1;
var cur_img = 0;
var button_container_pos = 0;
var part = 0;
var nxt_img;



function fade_out(new_img_id){

	if(alpha == 10){
	document.getElementById(current_img_id).style.display='none';
	}

	if(alpha > 0){
	alpha--;
	document.getElementById(current_img_id).style.opacity='0.'+alpha;
	document.getElementById(current_img_id).style.filter='alpha(opacity='+alpha+')';
	setTimeout("fade_out('"+new_img_id+"')", 10);
	}else{
	alpha = 99;
	prepare_fading(new_img_id);
	}

}




function prepare_fading(new_img_id){

if(!document.getElementById(new_img_id)){
is_fading = 0;
}else{
document.getElementById(new_img_id).style.zIndex='2';
document.getElementById(current_img_id).style.zIndex='0';
current_img_id = new_img_id;
is_fading = 0;
}

}



function change_image(new_img_id,new_src){
if((new_img_id != current_img_id)&&(is_fading == 0)){
is_fading = 1;

nxt_img = new Image(); 
nxt_img.src=new_src;

document.getElementById(new_img_id).src=new_src;
document.getElementById(new_img_id).style.zIndex='1';
document.getElementById(new_img_id).style.opacity='0.99';
document.getElementById(new_img_id).style.display='block';

$(nxt_img).load(function(){
fade_out(new_img_id);
});


}
}





function slide_show(){
	
	if((slideshow==1)&&(is_fading == 0)){	
	cur_img++;
	
		if(!document.getElementById('gallery_button_'+cur_img)){
			cur_img = 0;
		}
		
		document.getElementById('gallery_button_'+cur_img).onmouseover();
	}
	setTimeout("slide_show()", 10000);
}




function toggle_slide_show(){
	if(slideshow==1){
		slideshow=0;
	}else{
		slideshow=1;
	}
}




function slide_left(){
if(typeof button_container_width != "undefined"){

if(!((part==0)&&((button_container_width-955-button_container_pos)<287))){

if((button_container_pos < button_container_width-955)&&(part<287)){
button_container_pos += 7;
part += 7;
document.getElementById('start_button_container').style.right=button_container_pos+'px';
setTimeout("slide_left()", 5);
}else{
part = 0;
}

}

}
}




function slide_right(){

if((button_container_pos > 0)&&(part<287)){
button_container_pos -= 7;
part += 7;
document.getElementById('start_button_container').style.right=button_container_pos+'px';
setTimeout("slide_right()", 5);
}else{
part = 0;
}

}







document.write('<style type="text/css">div#main_image{height:330px;} .ns_img{display:none;} .s_img{display:block;} div#main_image  img{position:absolute;left:0px;top:0px;} div#main_image img#main_image_0{display:block;}</style>');









