// JavaScript Document

function changephoto(num){
	myphoto=new Image()
	myphoto.src="images/photo_"+num+".jpg";
//	myphoto.onload = MM_showHideLayers('blue','','hide');
//	alert("the width of images/photo_"+num+".jpg is : "+myphoto.width+" pixels");
	}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
function divwidth(num){
	MM_showHideLayers('blue','','show');   //make blue appear !!!!!!!!!!
	changephoto(num);
	newwidth = get_photo_width(photo_width,"photo_width",num);
	descrip = get_photo_descrip(photo_descrip,"photo_descrip",num);
	document.getElementById('description').innerHTML = descrip;
//	document.getElementById('middle').style.width=(164+myphoto.width+"px");
//	alert("description will be "+descrip);
	oMiddle = new Object();
	oMiddle.callRate = 35;   //instead of 35
	oMiddle.slideTime = 1200;
	oMiddle.isIE = document.all ? true : false;
	oMiddle.themiddle = (document.getElementById('middle'));
///////////////////////////////////////////////////////////////////////////////////
/// THE FOLLOWING IS WHAT WE WANT TO ACHIEVE SMOOTHLY   ///////////////////////////
///////////////////////////////////////////////////////////////////////////////////
//	difference = targetWidth-this.currentwidth;									///
//	decrement = Math.round(difference/oMiddle.divisor);							///
//	document.getElementById('middle').style.width = currentwidth - decrement;	///
///////////////////////////////////////////////////////////////////////////////////	

	interval_ID = window.setInterval("oMiddle.main()",oMiddle.callRate);
	

	oMiddle.main = function(){
		this.currentwidth = parseInt(document.getElementById('middle').style.width);
		this.targetWidth = newwidth;
	//	alert("this.currentwidth is "+this.currentwidth+" and targetWidth (from newwidth) is "+this.targetWidth);
		if(this.currentwidth != this.targetWidth){
			this.slideInit();
			this.slide();
			}
			
		else{
			clearInterval(interval_ID);
			MM_showHideLayers('nester','','show');   //make blue appear !!!!!!!!!!
			document.photo.src=myphoto.src;
			}
		}
	var inc=1
		
	oMiddle.slideInit = function( ){
		this.A 		= this.targetWidth - this.currentwidth;
		this.D 		= this.currentwidth
		this.E		= 0.05*inc;
		inc=inc+1;
		this.F		= Math.PI/2
//		alert("this.E is "+this.E)	
//		alert("this.A (or targetWidth ("+this.targetWidth+") minus currentwidth ("+this.currentwidth+")) is "+this.A+" oh, and the current time is "+this.C)
		}
	
	oMiddle.slide = function(){
		var newWidth 	= this.A * Math.sin( this.F* ( this.E ) ) + this.D;
	//	alert("the newWidth will be "+newWidth+".  And this.currentwidth is "+this.currentwidth);
		
		if((this.A > 0 && newWidth > this.currentwidth)||(this.A < 0 && newWidth < this.currentwidth)){
				document.getElementById('middle').style.width = newWidth;
				}
		else	{
				document.getElementById('middle').style.width = this.targetWidth;
				}
	//		alert("we are analysing the middle width. it is "+document.getElementById('middle').style.width)
		middle_position();			
		}/**/
}
