/***************************************************************************************
Copyright (C) 2001 ab_ditto
This script is made by and copyrighted to ab_ditto at back.to/ab or ab_ditto@hotmail.com
This may be used freely as long as this msg is intact!
***************************************************************************************
excepted from this copyright is the (seperatly marked) NN6 "scrollbarkiller" by Eddie Traversa
***************************************************************************************/
//*****parameters to set*****
impad=alerta; //the path to your panorama-pic
//if you have troubles with NN & large pics try using a .gif instead of a .jpg
imwid=get_image_width; //the width of your pic
imhei=get_image_height; //the height of your pic
visual_angle = get_visual_angle; // 180º ou 360º
poslef=30; //the left position of the panorama on your page
postop=20; //the top position of the panorama on your page
panwid=250; //the width of the shown area
panhei=200; //the height of the shown area
//if it differs from the image-height, the image gets scaled in length and height
//*****additional parameters*****
buttl='left.gif'; //path to the left-button (if you use your own pics)
buttr='right.gif'; //path to the right-button (if you use your own pics)
buttw=20; //width of one button
butth=20; //height of a button
//speed=50; //timeout between moves; set it lower to increase speed
move=1; // movement at one step in pixel

//*****nothing more to do, have fun :)
tim=0;noscroll=true;
imw=imwid*panhei/imhei;imh=panhei;
if(visual_angle==180){
	imstart=(imw/2*(-1))+(panwid/2);
} else if (visual_angle==360){
	imstart=panwid/2-imw*1.5;	
}
jumpa=panwid/2-imw*2.5;jumpwida=imw-move;
jumpb=panwid/2-imw/2;jumpwidb=imw+move;
conwid=buttw+(5*1);contop=postop+(imh*1)+(10*1);
conlefa=poslef+(panwid/2)-conwid;conlefb=poslef+(panwid/2);

if (impad=='bilheteria2.jpg') imstart = imstart -230;
if (impad=='perfil_esq2.jpg') imstart =-140;

function sr(speed){
	if(!noscroll){
		now=parseFloat(document.getElementById("pano").style.left);
		if(visual_angle==180){
			if (now<=(imw-panwid)*(-1)){
					stop();  // 180º
			} else{now-=move;}
		} else if (visual_angle==360){
			if (now <= jumpa) { // 360º		
				now+=jumpwida; //360º
			} else{now-=move;}
		}
		document.getElementById("pano").style.left=now;
		tim=setTimeout("sr("+speed+")",speed);
	}
}

function sl(speed){
	if(!noscroll){
		now=parseFloat(document.getElementById("pano").style.left);
		if(visual_angle==180){
			if(now>=-5){
				stop();  // 180º
			} else{now+=move;}
		}
		else if (visual_angle==360){
			if (now >= jumpb) { // 360º
				now-=jumpwidb; // 360º
			} else{now+=move;}
		}
	
		document.getElementById("pano").style.left=now;
		tim=setTimeout("sl("+speed+")",speed);
	}
}

pointer_x_aux =0;
function try_it(inside) {
	pointer_x = inside.clientX;
	if(pointer_x>=pointer_x_aux+5 || pointer_x<=pointer_x_aux-5){
		pointer_x_aux = pointer_x;
		pan_pointer_location = pointer_x - poslef;
		if (pan_pointer_location < panwid/2) {
			stop();
			noscroll=false;
			speed = pan_pointer_location/2;
			sl(speed);
		}
		else if (pan_pointer_location > panwid/2) {
			stop();
			noscroll=false;
			speed = (panwid -pan_pointer_location)/2;
			sr(speed);
		}
		else{
			noscroll=true;
			stop();
		}
	}
}

function stop(){clearTimeout(tim); noscroll=true}
//***************************************************************************************
//NN6 "scrollbarkiller" by Eddie Traversa
if (document.getElementById && !document.all){document.write('<div id="kill-scrollbars" style="position:relative">');}
//***************************************************************************************
document.write("<div id='panorama' onmousemove='try_it(event)' onmouseout='stop()' >"); //  <!-- onmousemove='try_it(event)' onmouseout='stop()' -->
if(visual_angle==180){
	document.write("<div id='pano' style='position:absolute; left:"+imstart+"px; top:0px; width:"+imw+"px; height:"+imh+"px; z-index:2; visibility:visible;'>");
	document.write("<table><tr><td nowrap><img src='"+impad+"' width="+imw+"px height="+imh+"px></td></tr></table>");
} else if (visual_angle==360){
	document.write("<div id='pano' style='position:absolute; left:"+imstart+"px; top:0px; width:"+imw*3+"px; height:"+imh+"px; z-index:2; visibility:visible;'>");
	document.write("<table><tr><td nowrap><img src='"+impad+"' width="+imw+"px height="+imh+"px><img src='"+impad+"' width="+imw+"px height="+imh+"px><img src='"+impad+"' width="+imw+"px height="+imh+"px></td></tr></table>");
}
document.write("</div></div>");
//document.write("<div id='left'><a href='javascript://' onmouseover='noscroll=false; sl(20)' onmouseout='stop()'><img src='"+buttl+"' width="+buttw+"px height="+butth+"px border='0';></a></div>");
//document.write("<div id='right'><a href='javascript://' onmouseover='noscroll=false; sr(20)' onmouseout='stop()'><img src='"+buttr+"' width="+buttw+"px height="+butth+"px border='0';></a></div>");

document.write("<div id='left'><a href='javascript://' onmouseover='noscroll=false; sl(15)' onmouseout='stop()'><img src='01.gif' border='0';></a>");
document.write("<a href='javascript://' onmouseover='noscroll=false; sl(20)' onmouseout='stop()'><img src='02.gif' border='0';></a>");
document.write("<a href='javascript://' onmouseover='noscroll=false; sl(40)' onmouseout='stop()'><img src='03.gif' border='0';></a></div>");
document.write("<div id='right'><a href='javascript://' onmouseover='noscroll=false; sr(40)' onmouseout='stop()'><img src='04.gif' border='0';></a>");
document.write("<a href='javascript://' onmouseover='noscroll=false; sr(20)' onmouseout='stop()'><img src='05.gif' border='0';></a>");
document.write("<a href='javascript://' onmouseover='noscroll=false; sr(15)' onmouseout='stop()'><img src='06.gif' border='0';></a></div>");
document.write("<style>");
document.write("body { margin-left:0; margin-right:0; margin-top:0; margin-bottom:0;width:100%;height:100%;overflow:hidden;}");
document.write("#panorama {position:absolute; left:"+poslef+"px; top:"+postop+"px; width:"+panwid+"px; height:"+panhei+"px; z-index:1; clip:rect(0px,"+panwid+"px,"+panhei+"px,0px); overflow:hidden;}");
document.write("#left {position:absolute; left:"+(poslef)+"px; top:"+contop+"px; z-index:1; text-align:right;}");
//document.write("#left {position:absolute; left:"+conlefa+"px; top:"+contop+"px; width:"+conwid+"px; z-index:1; text-align:right;}");
//document.write("#right {position:absolute; left:"+conlefb+"px; top:"+contop+"px; width:"+conwid+"px; z-index:1; text-align:left;}");
document.write("#right {position:absolute; left:"+(conlefb-5)+"px; top:"+contop+"px; z-index:1; text-align:left;}");
document.write("</style>");
