var flash={
	currentnarrow:0,
	currentwide:0,
	narrowopacity:100,
	wideopacity:0,
	narrow:['narrow_pic','narrow_pic','narrow_pic','narrow_pic'],
	wide:['head_1a','head_2a','head_3a','head_4a','head_5a'],
	
	changeimg_wide:function(){
		this.currentwide++;
		if(this.currentwide==this.wide.length){
			this.currentwide=0;
		}
		document.getElementById('wideimage').src='./img/'+this.wide[this.currentwide]+'.jpg';
		this.fadein_wide();
	},
	fadein_wide:function(){
		this.wideopacity<100?this.wideopacity+=5:this.wideopacity=100;
		with(document.getElementById('wideimage').style){
			filter='alpha(opacity='+this.wideopacity+')';
			MozOpacity=this.wideopacity/100;
			opacity=this.wideopacity/100;
			KhtmlOpacity=this.wideopacity/100;
		}
		if(this.wideopacity<100){
			setTimeout("flash.fadein_wide()","50");
		}else{
			var nextimage=this.currentwide+1;
			if(nextimage==this.wide.length){
				nextimage=0;
			}
			document.getElementById('wideimage_cell').style.background='url(./img/'+this.wide[nextimage]+'.jpg)';
			setTimeout("flash.fadeout_wide()","2000");
		}
	},
	fadeout_wide:function(){
		this.wideopacity>0?this.wideopacity-=5:this.wideopacity=0;
		with(document.getElementById('wideimage').style){
			filter='alpha(opacity='+this.wideopacity+')';
			MozOpacity=this.wideopacity/100;
			opacity=this.wideopacity/100;
			KhtmlOpacity=this.wideopacity/100;
		}
		if(this.wideopacity>0){
			setTimeout("flash.fadeout_wide()","50");
		}else{
			this.changeimg_wide();
		}
	},
	
	changeimg_narrow:function(){
		this.currentnarrow++;
		if(this.currentnarrow==this.narrow.length){
			this.currentnarrow=0;
		}
		document.getElementById('narrowimage').src='./img/'+this.narrow[this.currentnarrow]+'.jpg';
		this.fadein_narrow();
	},
	fadein_narrow:function(){
		this.narrowopacity<100?this.narrowopacity+=5:this.narrowopacity=100;
		with(document.getElementById('narrowimage').style){
			filter='alpha(opacity='+this.narrowopacity+')';
			MozOpacity=this.narrowopacity/100;
			opacity=this.narrowopacity/100;
			KhtmlOpacity=this.narrowopacity/100;
		}
		if(this.narrowopacity<100){
			setTimeout("flash.fadein_narrow()","50");
		}else{
			var nextimage=this.currentnarrow+1;
			if(nextimage==this.narrow.length){
				nextimage=0;
			}
			document.getElementById('narrowimage_cell').style.background='url(./img/'+this.narrow[nextimage]+'.jpg)';
			setTimeout("flash.fadeout_narrow()","2100");
		}
	},
	fadeout_narrow:function(){
		this.narrowopacity>0?this.narrowopacity-=5:this.narrowopacity=0;
		with(document.getElementById('narrowimage').style){
			filter='alpha(opacity='+this.narrowopacity+')';
			MozOpacity=this.narrowopacity/100;
			opacity=this.narrowopacity/100;
			KhtmlOpacity=this.narrowopacity/100;
		}
		if(this.narrowopacity>0){
			setTimeout("flash.fadeout_narrow()","50");
		}else{
			this.changeimg_narrow();
		}
	},
	start:function(){
		document.getElementById('wideimage').src='./img/'+this.wide[0]+'.jpg';
		document.getElementById('narrowimage').src='./img/'+this.narrow[0]+'.jpg';
		this.fadein_wide();
		setTimeout("flash.fadeout_narrow()","700");
	}
	
}

function resize(container,image) {
	var curWidth = $(image).width();
	var curHeight = $(image).height();
	
	var newWidth = $(container).width();
	var newHeight = $(container).height();
	
	var ratio = Math.max(newWidth/curWidth,newHeight/curHeight);
	
	newWidth = curWidth * ratio;
	newHeight = curHeight * ratio;
	
	if ((newWidth/curWidth) < (newHeight/curHeight)) {
		$(image).css("width",newWidth+"px");
		$(image).css("height","auto");
	} else {
		$(image).css("width","auto");
		$(image).css("height",newHeight+"px");
	}
}

