
p=1;
x=0;


DeltaX=325
DeltaY=326
ScrollPos=0
ImgOpTime=1000
ImgOpDelta=20
ImgOpCount=ImgOpTime/ImgOpDelta;
ti=document.getElementById('SameImage');
ti2=document.getElementById('SameImage2');
tv=document.getElementById('image_viewer');
ymax=document.documentElement.offsetHeight-DeltaY
xmax=document.documentElement.offsetWidth-DeltaX
tv.style.height=ymax
tv.style.width=xmax
viewframewidth=xmax-98	;


ImgArray = new Array()
function initImage(){


	for(i=1;i<21;i++){
		ImgArray[i] = new Array(800,525)
		ImgArray[i][2] = 'images/presentation/images_'+(i)+'.jpg'
		ImgArray[i][3] = 'images/presentation/small/images_'+i+'.jpg'
	}


	document.getElementById('viewframeid').style.width=viewframewidth

	ImgCor=ImgArray[1][0]/ImgArray[1][1]
	PageCor=xmax/ymax

	if(ImgCor>PageCor){
		ymax=xmax/ImgCor
	}else{
		xmax=ymax*ImgCor
	}

	xs=xmax/ImgOpCount
	ys=ymax/ImgOpCount
	setSize()
}


function imageList(x){
	p=p+x;
	if(p<1)p=1;
	if(p>20)p=20
	changeImgage(p)
	if(viewframe.clickImage)viewframe.clickImage(p)

}
ImageIndex=0

function changeImgage(i){
	//$("#SameImage").animate({opacity: "0"}, 300)

	if(ImageIndex!=0)$("#SameImage2").animate({opacity: "1"}, 300)

	$("#imgleft").animate({opacity: "0.3"}, 300)
	$("#imgright").animate({opacity: "0.3"}, 300)

	//$("#SameImage2").animate({opacity: "0"}, 500)
	setTimeout('ti.src="'+ImgArray[i][2]+'"',300);
	//ti.src=ImgArray[i][2]
    ImageIndex=i;
}
function open3Image(){
	if(ImageIndex!=0){
		$("#SameImage").animate({opacity: "1"}, 500)
	}else{
		$("#SameImage").animate({opacity: "1"}, 0)
	}
	$("#SameImage2").animate({opacity: "0"}, 500)
	//ti.src=ImgArray[i][2]
	setTimeout('ti2.src="'+ti.src+'"',600);
	//open2Image()

}
function open2Image(){
	$("#imgleft").animate({opacity: "1"}, 300)
	$("#imgright").animate({opacity: "1"}, 300)
	//$("#SameImage").animate({opacity: "1"}, 600)

	i=ImageIndex
	p=i;
	s=(2040-viewframewidth+200)*(i-1)/19-100
    count=0
	x=ScrollPos
	ScrollTime=500
	ScrollDelta=40
	ScrollCount=ScrollTime/ScrollDelta;

	delta=(s-ScrollPos)/ScrollCount
	while (Math.abs(s-x)>Math.abs(delta) && count<1000){
		x=x+delta
		setTimeout("viewframe.scroll("+x+",0)",ScrollDelta*count)
		count++
	}
    ScrollPos=s

}

function setSize(){
	ti.style.width=xmax
 	ti.style.height=ymax
	ti2.style.width=xmax
 	ti2.style.height=ymax
 	tv.style.width=xmax

}

function functionLoad(){
 document.getElementById('viewframeid').src='html/htmlview.html'
 initImage(0)
 $("#SameImage").animate({opacity: "0"}, 0)
 $("#SameImage2").animate({opacity: "0"},0)
 //openImage(1)

}