var PV_Obj = new Array() ;
function CreatePanoramaView(InDiv,InImgUrl,InWidth,InHeight,InLoop,W,H) {
	var Index = PV_Obj.length ;
	var Obj_Name = "PV_Obj["+Index+"]" ;
	PV_Obj[Index] = new PanoramaView(Obj_Name,InDiv) ;
	PV_Obj[Index].SetPicture(InImgUrl);
	PV_Obj[Index].SetWidth(InWidth) ;
	PV_Obj[Index].SetHeight(InHeight) ;
	PV_Obj[Index].SetLoop(InLoop) ;
	if (W && H) {
		PV_Obj[Index].SetPictureSize(W,H) ;
	}
	PV_Obj[Index].LoadPicture();
}

function PanoramaView(Class,Obj) {
	var ObjectDiv	= Obj ;
	var ClassName	= Class ;
	var Picture		= '' ;
	var Width		= 400 ;
	var Height		= 200 ;
	var Loop		= false ;
	var Img			= new Image() ;
	var ImgWidth	= 0 ;
	var ImgHeight	= 0 ;
	var MaxZoom		= 300 ;
	var MinZoom		= 50 ;
	var ZoomInt		= 20 ;
	var ZoomDelta	= (window.stop)?5:2 ;
	var ZoomWidth	= 0 ;
	var ZoomHeight	= 0 ;
	var ZoomSpeed	= 10 ;
	var ImgZoom		= 100 ;
	var PrevImgZoom	= 100 ;
	var NextImgZoom	= 100 ;
	var DeltaX		= 0 ;
	var DeltaY		= 0 ;
	var DeltaMulti  = 1 ;
	var Speed		= 10 ;
	var DeltaChange = 10 ;
	var NewDivTop	= 0 ;
	var NewDivLeft	= 0 ;
	var CFlagAim	= '' ;
	var PFlagAim	= '-' ; 
	var Player		= true ;
	var About		= false ;
	var DisplayAbout= true ;
	var AboutText	= 'Panorama Viewer Ver 1.0\nBy Johky\nApril 2007' ;
	var ImgUserSetHeight ;
	var ImgUserSetWidth ;
	var MyServer = "http://www.street-directory.com.au" ;
	var DisplayCopyright = true ;
	//MyServer = "http://192.168.0.101" ;

	var Anim,AnimZoom,AnimLoader,DragX,DragY ;
	var DragApprove	= false ;
	var ZoomSmallestStatus = false ;
	var ZoomFitStatus = false ;
	var CheckZoomStatus = false ;

	var LoaderDotPos   = 0 ;
	
	this.LoadingBar = LoadingBar ;
	function LoadingBar() {
		var LoaderColor = "#FFFFFF" ;
		var LoaderBackColor = "#FF0000" ;
		var LoaderLength = 8 ; 
		var LoaderText = "Please wait...<br>Loading Picture" ;
		LoaderDotPos++;
		for (var i = 1; i<=LoaderLength; i++)
		{
			var Color = (i<=LoaderDotPos)?LoaderColor:LoaderBackColor;
			LoaderText += "<font color=\""+Color+"\">.</font>" ;
		}
		if (LoaderDotPos>LoaderLength) {
			LoaderDotPos = 0 ;
		}

		if (!document.getElementById(ObjectDiv+'_LoaderDiv'))
		{
			if (document.getElementById(ObjectDiv))
			{
				var DivText = document.createElement('div');
				DivText.id = ObjectDiv + "_LoaderDiv" ;
				NoBodySelectStart(DivText);
				var Clip = document.getElementById(ObjectDiv);
				Clip.appendChild(DivText);
			}
		}

		if (document.getElementById(ObjectDiv+'_LoaderDiv'))
		{
			var DivText = document.getElementById(ObjectDiv+'_LoaderDiv') ;
			DivText.style.backgroundColor = LoaderBackColor ;
			DivText.style.color = LoaderColor ;
			DivText.align = 'center' ;
			DivText.style.textAlign = 'center' ;
			DivText.style.verticalAlign = 'middle' ;
			DivText.style.fontFamily = 'arial' ;
			DivText.style.fontSize = '12px' ;
			DivText.style.position = 'absolute' ;
			DivText.innerHTML = LoaderText ;
			DivText.style.width = '150px' ;
			DivText.style.height = '32px' ;
			DivText.style.left = (Math.round(Width/2) - Math.round(parseInt(DivText.style.width,10)/2)) +'px' ;
			DivText.style.top = (Math.round(Height/2) - Math.round(parseInt(DivText.style.height,10)/2)) +'px' ;
		}

	}

	this.SetPictureError = SetPictureError ;
	function SetPictureError() {
		LoadingProgressStop();

		var LoaderColor = "#FFFFFF" ;
		var LoaderBackColor = "#FF0000" ;
		if (!document.getElementById(ObjectDiv+'_LoaderDiv'))
		{
			var DivText = document.createElement('div');
			DivText.id = ObjectDiv + "_LoaderDiv" ;
			var Clip = document.getElementById(ObjectDiv);
			Clip.appendChild(DivText);
		}

		var DivText = document.getElementById(ObjectDiv+'_LoaderDiv') ;
		DivText.style.backgroundColor = LoaderBackColor ;
		DivText.style.color = LoaderColor ;
		DivText.align = 'center' ;
		DivText.style.textAlign = 'center' ;
		DivText.style.verticalAlign = 'middle' ;
		DivText.style.fontFamily = 'arial' ;
		DivText.style.fontSize = '12px' ;
		DivText.style.position = 'absolute' ;
		DivText.innerHTML = "Loading Error<br>Please Reload (F5) &amp; Try Again..." ;
		DivText.style.width = '200px' ;
		DivText.style.height = '32px' ;
		DivText.style.left = (Math.round(Width/2) - Math.round(parseInt(DivText.style.width,10)/2)) +'px' ;
		DivText.style.top = (Math.round(Height/2) - Math.round(parseInt(DivText.style.height,10)/2)) +'px' ;
		DivText.style.visibility = 'visible' ;
		DivText.style.display = '' ;
	}

	this.LoadingProgress = LoadingProgress ;
	function LoadingProgress() {
		LoadingBar();
		AnimLoader = setInterval(ClassName+".LoadingBar();", 500) ; 
	}

	this.LoadingProgressStop = LoadingProgressStop ;
	function LoadingProgressStop() {
		clearInterval(AnimLoader);
		var DivText = document.getElementById(ObjectDiv+'_LoaderDiv') ;
		DivText.innerHTML = "" ;
		DivText.style.visibility = 'hidden' ;
		DivText.style.display = 'none' ;
	}

	this.SetDisplayAbout = SetDisplayAbout ;
	function SetDisplayAbout(P) {
		DisplayAbout = (P)?true:false ;
	}

	this.GetDisplayAbout = GetDisplayAbout ;
	function GetDisplayAbout() {
		return DisplayAbout ;
	}
	
	this.SetDisplayCopyright = SetDisplayCopyright ;
	function SetDisplayCopyright(P) {
		DisplayCopyright = (P)?true:false ;
	}

	this.GetDisplayCopyright = GetDisplayCopyright ;
	function GetDisplayCopyright() {
		return DisplayCopyright ;
	}

	this.SetPictureSize = SetPictureSize ;
	function SetPictureSize(W,H) {
		ImgUserSetWidth = W ;
		ImgUserSetHeight = H ;
	}

	this.SetPlayer = SetPlayer ;
	function SetPlayer(P) {
		Player = (P)?true:false ;
	}

	this.GetPlayer = GetPlayer ;
	function GetPlayer() {
		return Player ;
	}

	this.SetPicture = SetPicture ;
	function SetPicture(P) {
		Picture = (P)?P:'' ;
	}

	this.GetPicture = GetPicture ;
	function GetPicture() {
		return Picture ;
	}

	this.SetWidth = SetWidth ;
	function SetWidth(W) {
		Width = (W)?W:400 ;
	}

	this.GetWidth = GetWidth ;
	function GetWidth() {
		return Width ;
	}
	
	this.SetHeight = SetHeight ;
	function SetHeight(H) {
		Height = (H)?H:200 ;
	}

	this.GetHeight = GetHeight ;
	function GetHeight() {
		return Height ;
	}

	this.SetLoop = SetLoop ;
	function SetLoop(L) {
		Loop = (L)?true:false ;
	}

	this.GetLoop = GetLoop ;
	function GetLoop() {
		return Loop ;
	}

	this.LoadPicture = LoadPicture ;
	function LoadPicture() {
		Img = new Image() ;
		Img.src = Picture ;
		Img.onload = SetPictureAttribute ;
		Img.onerror = SetPictureError ;
		SetClip();
		LoadingProgress();
		if (Img.complete)
		{
			ImgHeight = (ImgUserSetHeight)?ImgUserSetHeight:Img.height ;
			ImgWidth = (ImgUserSetWidth)?ImgUserSetWidth:Img.width ;
			ZoomHeight = ImgHeight ;
			ZoomWidth = ImgWidth ;
			DrawCopyright();
			DrawPlayer();
			LoadingProgressStop();
			DrawPicture();
			if (ZoomSmallestStatus)
			{
				ZoomToSmallest();
			}
			if (ZoomFitStatus)
			{
				ZoomToFit();
			}
		}
	}

	this.NoBodySelectStart = NoBodySelectStart ;
	function NoBodySelectStart(Obj) {
		Obj.onselectstart = function () { return false; }
		Obj.ondragstart = function () { return false; }
		if (window.stop)
		{
			Obj.style.MozUserSelect="none" ;
		}
		Obj.oncontextmenu = function () {
			if (DisplayAbout && About == false)
			{
				alert(AboutText); 
				About = true ;
				setTimeout(ClassName+".SetAbout();",1000);
			}
			return false;
		}
	}
	
	this.SetAbout = SetAbout ;
	function SetAbout() {
		About = false ;
	}

	this.SetPictureAttribute = SetPictureAttribute ;
	function SetPictureAttribute() {
		DrawCopyright();
		DrawPlayer();
		LoadingProgressStop();
		ImgHeight = (ImgUserSetHeight)?ImgUserSetHeight:Img.height ;
		ImgWidth = (ImgUserSetWidth)?ImgUserSetWidth:Img.width ;
		ZoomWidth = Math.round(ImgWidth * (ImgZoom/100)) ;
		ZoomHeight = Math.round(ImgHeight * (ImgZoom/100)) ;
		DrawPicture();
		if (ZoomSmallestStatus)
		{
			ZoomToSmallest();
		}
		if (ZoomFitStatus)
		{
			ZoomToFit();
		}
	}

	this.DrawCopyright = DrawCopyright ;
	function DrawCopyright() {
		var Parent = document.getElementById(ObjectDiv);
		var Logo = document.createElement("img");
		Logo.id = ObjectDiv + "_Logo" ;
		Logo.src = MyServer+'/data/australia/logo.gif' ;
		Logo.border = 0 ;
		Logo.style.position = 'absolute' ;
		Logo.style.top = 0+'px' ;
		Logo.style.left = 0+'px' ;
		Logo.style.width = 30+'px';
		Logo.style.height = 30+'px';
		NoBodySelectStart(Logo);
		Parent.appendChild(Logo);

		if (DisplayCopyright) 
		{
			var MyW = 253 ;
			var MyH = 17 ;
			var MyL = -2 ;
			var MyT = (Height-MyH+((window.stop)?2:0)) ;

			var CRI = document.createElement("img");
			CRI.id = ObjectDiv + "_CopyrightBarImage" ;
			CRI.src = MyServer+'/Panorama/icons/copyright.png' ;
			CRI.border = 0 ;
			CRI.style.position = 'absolute' ;
			CRI.style.top = (MyT)+'px' ;
			CRI.style.left = (MyL)+'px' ;
			NoBodySelectStart(CRI);

			if (!window.stop)
			{
				var CR = document.createElement("div");
				CR.id = ObjectDiv + "_CopyrightBar" ;
				CR.style.position = 'absolute' ;
				CR.style.top = (MyT)+'px' ;
				CR.style.left = (MyL)+'px' ;
				CR.style.width = MyW+'px';
				CR.style.height = MyH+'px';
				CR.style.verticalAlign = 'middle';
				CR.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+MyServer+"/Panorama/icons/copyright.png', sizingMethod='scale')" ;
				NoBodySelectStart(CR);
				CR.appendChild(CRI);
				Parent.appendChild(CR);
			} else {
				Parent.appendChild(CRI);
			}
		} else {

		}
	}

	this.DrawPlayer = DrawPlayer ;
	function DrawPlayer() {
		if (Player)
		{
			var MyL = (Width-50) ;
			var MyT = (Height-65) ;

			var NewPlayer = document.createElement('img');
			NewPlayer.id = ObjectDiv + "_Player" ;
			NewPlayer.src = MyServer+'/Panorama/icons/player.png' ;
			NewPlayer.border = 0 ;
			NewPlayer.style.position = 'absolute' ;
			NewPlayer.style.top = (MyT)+'px' ;
			NewPlayer.style.left = (MyL)+'px' ;
			NoBodySelectStart(NewPlayer);
			
			var Parent = document.getElementById(ObjectDiv);
			if (!window.stop)
			{
				var NewDiv = document.createElement('div');
				NewDiv.id = ObjectDiv + "_PlayerDiv" ;
				NewDiv.style.position = 'absolute' ;
				NewDiv.style.width = '50px' ;
				NewDiv.style.height = '65px' ;
				NewDiv.style.top = (MyT)+'px' ;
				NewDiv.style.left = (MyL)+'px' ;
				NewDiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+MyServer+"/Panorama/icons/player.png', sizingMethod='scale')" ;
				NoBodySelectStart(NewDiv);
				NewDiv.appendChild(NewPlayer);
				Parent.appendChild(NewDiv);
			} else {
				Parent.appendChild(NewPlayer);
			}

			var DataMap = new Array();
			DataMap[0] = "0\t0\t15\t15\t"+ClassName+".ZoomOut()\tZoom Out" ;
			DataMap[1] = "15\t0\t20\t15\t"+ClassName+".ZoomDefault()\tZoom To Default Size" ;
			DataMap[2] = "35\t0\t15\t15\t"+ClassName+".ZoomIn()\tZoom In" ;
			DataMap[3] = "0\t15\t15\t15\t"+ClassName+".SetMoveBottomRight()\tMove To Top Left" ;
			DataMap[4] = "15\t15\t20\t15\t"+ClassName+".SetMoveBottom()\tMove To Top" ;
			DataMap[5] = "35\t15\t15\t15\t"+ClassName+".SetMoveBottomLeft()\tMove To Top Right" ;
			DataMap[6] = "0\t30\t15\t20\t"+ClassName+".SetMoveRight()\tMove To Left" ;
			DataMap[7] = "15\t30\t20\t20\t"+ClassName+".StopMove()\tStop Moving" ;
			DataMap[8] = "35\t30\t15\t20\t"+ClassName+".SetMoveLeft()\tMove To Right" ;
			DataMap[9] = "0\t50\t15\t15\t"+ClassName+".SetMoveTopRight()\tMove To Bottom Left" ;
			DataMap[10] = "15\t50\t20\t20\t"+ClassName+".SetMoveTop()\tMove To Bottom" ;
			DataMap[11] = "35\t50\t15\t15\t"+ClassName+".SetMoveTopLeft()\tMove To Bottom Right" ;

			for (var i in DataMap) {
				var Arr = DataMap[i].split("\t");

				var MyAct = document.createElement('img');
				MyAct.src = MyServer + '/Panorama/icons/blank.gif' ;
				MyAct.border = 0 ;
				MyAct.style.position = 'absolute' ;
				MyAct.style.top = Math.round(MyT*1+Arr[1]*1)+'px' ;
				MyAct.style.left = Math.round(MyL*1+Arr[0]*1)+'px' ;
				MyAct.style.width = Math.round(Arr[2])+'px' ;
				MyAct.style.height = Math.round(Arr[3])+'px' ;
				MyAct.style.cursor = (window.stop)?'pointer':'hand' ;
				MyAct.alt = Arr[5] ;
				MyAct.title = Arr[5] ;
				NoBodySelectStart(MyAct);
				MyAct.Action = Arr[4] ;
				MyAct.onclick = function() {
					eval(this.Action);
				}
				Parent.appendChild(MyAct);
			}


		}
	}

	this.SetClip = SetClip ;
	function SetClip() {
		var Parent = document.getElementById(ObjectDiv);
		Parent.innerHTML = "" ;
		Parent.style.position = 'relative' ;
		Parent.style.width = Width + "px"  ;
		Parent.style.height = Height + "px" ;
		Parent.style.overflow = 'hidden' ;
		Parent.style.border = '1px solid black' ;
		NoBodySelectStart(Parent);

		var NewDiv = document.createElement('div');
		NewDiv.id = ObjectDiv + "_Portion" ;
		NewDiv.style.position = 'absolute' ;
		NewDivTop = 0 ;
		NewDivLeft = 0 ;
		MoveClipSet();
		NewDiv.style.top = (NewDivTop)+'px' ;
		NewDiv.style.left = (NewDivLeft)+'px' ;
		NoBodySelectStart(NewDiv);
		NewDiv.onmousedown = StartDrag;
		NewDiv.onmousemove = DragMove;
		NewDiv.onmouseup = StopDrag;

		Parent.appendChild(NewDiv);
	
	}

	this.StartDrag = StartDrag ;
	function StartDrag(e) {
		if (document.getElementById&&!document.all) {
			if (e.which == 2 || e.which == 3) return ;
		} else {
			if (event.button == 2 || event.button == 3) return false ; 
		}
		var ev = (document.getElementById&&!document.all)?e:event;
		DragX  = ev.clientX ;
		DragY  = ev.clientY ;
		DragApprove = true ;
		document.getElementById(ObjectDiv+ "_Portion").style.cursor = 'move' ;
		return false ;
	}
	
	this.StopDrag = StopDrag ;
	function StopDrag(e) {
		if (document.getElementById&&!document.all) {
			if (e.which == 2 || e.which == 3) return ;
		} else {
			if (event.button == 2 || event.button == 3) return false ; 
		}
		DragApprove = false ;
		document.getElementById(ObjectDiv+ "_Portion").style.cursor = 'default' ;
		return false ;
	}

	this.DragMove = DragMove ;
	function DragMove(e) {
		if (document.getElementById&&!document.all) {
			if (e.which == 2 || e.which == 3) return ;
		} else {
			if (event.button == 2 || event.button == 3) return false ; 
		}
		if (DragApprove)
		{
			var ev = (document.getElementById&&!document.all)?e:event;
			var dX = ev.clientX - DragX ;
			var dY = ev.clientY - DragY ;
			DragPicture(dX,dY);
			DragX  = ev.clientX ;
			DragY  = ev.clientY ;
		}
		return false ;
	}

	this.DragPicture = DragPicture ;
	function DragPicture(dX,dY) {
		MovePictureCheck();
		var NewDiv = document.getElementById(ObjectDiv+ "_Portion");
		NewDivLeft = NewDivLeft + dX ;
		NewDivTop = NewDivTop + dY ;
		NewDivTop = NewDivTop + dY ;
		NewDivLeft = NewDivLeft + dX ;
		MoveClipSet();
		NewDiv.style.top = (NewDivTop)+'px' ;
		NewDiv.style.left = (NewDivLeft)+'px' ;
	}


	this.ZoomImage = ZoomImage ;
	function ZoomImage() {
		ZoomWidth = Math.round(ImgWidth * (ImgZoom/100)) ;
		ZoomHeight = Math.round(ImgHeight * (ImgZoom/100)) ;
		SetZoom();
		var PrevZoomWidth = Math.round(ImgWidth * (PrevImgZoom/100)) ;
		var PrevZoomHeight = Math.round(ImgHeight * (PrevImgZoom/100)) ;
		var Scale = (ZoomWidth-PrevZoomWidth) / ZoomWidth ;
		var NDL = NewDivLeft - Math.round(Width/2) ;
		var NDT = NewDivTop - Math.round(Height/2) ;
		NDL += Math.round(NDL*Scale) + Math.round(Width/2);
		NDT += Math.round(NDT*Scale) + Math.round(Height/2);
		NewDivLeft = NDL ;
		NewDivTop = NDT ;
		MovePicture();
		PrevImgZoom = ImgZoom ;
	}

	this.ZoomSmallest = ZoomSmallest ;
	function ZoomSmallest() {
		ZoomSmallestStatus = true ;
	}

	this.ZoomToSmallest = ZoomToSmallest ;
	function ZoomToSmallest() {
		ImgZoom = MinZoom ;
		NextImgZoom = ImgZoom ;
		PrevImgZoom = ImgZoom ;
		ZoomImage();
		ZoomSmallestStatus = false ;
	}
	
	this.ZoomFit = ZoomFit ;
	function ZoomFit() {
		if (ImgUserSetHeight)
		{
			ZoomFitStatus = true ;
		}
	}

	this.ZoomToFit = ZoomToFit ;
	function ZoomToFit() {
		if (ImgUserSetHeight)
		{
			ImgZoom = Math.ceil(100 * Height/ImgUserSetHeight) ;
			NextImgZoom = ImgZoom ;
			PrevImgZoom = ImgZoom ;
			ZoomImage();
		}
		ZoomFitStatus = false ;
	}

	this.ZoomDefault = ZoomDefault ;
	function ZoomDefault(A) {
		if (A) {
			ImgZoom = 100 ;
			NextImgZoom = 100 ;
			PrevImgZoom = 100 ;
			ZoomImage();
		} else {
			NextImgZoom = 100 ;
			CheckZoom();
			AnimZoom = setInterval(ClassName+".AnimateZoom();", ZoomSpeed); 
		}
	}

	this.ZoomIn = ZoomIn ;
	function ZoomIn() {
		NextImgZoom = (ImgZoom*1+ZoomInt*1>MaxZoom)?MaxZoom:ImgZoom*1+ZoomInt*1 ;
		if (NextImgZoom%ZoomInt!=0)
		{
			NextImgZoom = NextImgZoom + ZoomInt - (NextImgZoom % ZoomInt);
		}
		CheckZoom();
		AnimZoom = setInterval(ClassName+".AnimateZoom();", ZoomSpeed); 
	}

	this.ZoomOut = ZoomOut ;
	function ZoomOut() {
		NextImgZoom = (ImgZoom*1-ZoomInt*1<MinZoom)?MinZoom:ImgZoom*1-ZoomInt*1 ;
		if (NextImgZoom%ZoomInt!=0)
		{
			NextImgZoom = NextImgZoom - (NextImgZoom % ZoomInt);
		}
		if (NextImgZoom < Math.ceil(100 * Height/ImgHeight)) {
			NextImgZoom = Math.ceil(100 * Height/ImgHeight) ;
		}
		CheckZoom();
		AnimZoom = setInterval(ClassName+".AnimateZoom();", ZoomSpeed); 
	}

	this.CheckZoom = CheckZoom ;
	function CheckZoom() {
		CheckZoomStatus = false ;
		if (NextImgZoom > ImgZoom)
		{
			CheckZoomStatus = true ;
		}
	}

	this.AnimateZoom = AnimateZoom ;
	function AnimateZoom() {
		var D = (ImgZoom>NextImgZoom)?-1:1;
		if ((CheckZoomStatus == true && ImgZoom >= NextImgZoom) || (CheckZoomStatus == false && ImgZoom <= NextImgZoom))
		{
			D = 0 ;
			clearInterval(AnimZoom);
			ImgZoom = NextImgZoom ;
			PrevImgZoom = ImgZoom ;
			ZoomImage();
		} else {
			ImgZoom = ImgZoom+(D*ZoomDelta) ;
			ZoomImage();
		}
	}

	this.SetZoom = SetZoom ;
	function SetZoom() {
		if (document.getElementById(ObjectDiv + "_Picture_Mid"))
		{
			var NewImg = document.getElementById(ObjectDiv + "_Picture_Mid") ;
			NewImg.width = ZoomWidth ;
			NewImg.height = ZoomHeight ;
			NewImg.style.top = '0px' ;
			NewImg.style.left = '0px' ;
		}
		if (document.getElementById(ObjectDiv + "_Picture_Left"))
		{
			var NewImgLeft = document.getElementById(ObjectDiv + "_Picture_Left") ;
			NewImgLeft.width = ZoomWidth ;
			NewImgLeft.height = ZoomHeight ;
			NewImgLeft.style.top = '0px' ;
			NewImgLeft.style.left = (NewImgLeft.width)+'px' ;
		}
		if (document.getElementById(ObjectDiv + "_Picture_Right"))
		{
			var NewImgRight = document.getElementById(ObjectDiv + "_Picture_Right") ;
			NewImgRight.width = ZoomWidth ;
			NewImgRight.height = ZoomHeight ;
			NewImgRight.style.top = '0px' ;
			NewImgRight.style.left = (-NewImgRight.width)+'px' ;
		}
	}

	this.PictureReset = PictureReset ;
	function PictureReset() {
		ImgZoom = 100 ;
		NewDivLeft = Math.round((-1/2) * ZoomWidth) ;
		NewDivTop = Math.round((-1/2) * ZoomHeight) ;
		var NewDiv = document.getElementById(ObjectDiv+ "_Portion");
		MoveClipSet();
		NewDiv.style.top = (NewDivTop)+'px' ;
		NewDiv.style.left = (NewDivLeft)+'px' ;
	}

	this.DrawPicture = DrawPicture ;
	function DrawPicture() {
		var NewDiv = document.getElementById(ObjectDiv+ "_Portion");
		NewDiv.innerHTML = "" ;
		
		var NewImg = document.createElement('img');
		NewImg.id  = ObjectDiv + "_Picture_Mid" ; 
		NewImg.src = Img.src ;
		NewImg.style.position = 'absolute' ;
		NewImg.width = ZoomWidth ;
		NewImg.height = ZoomHeight ;
		NewImg.style.top = '0px' ;
		NewImg.style.left = '0px' ;
		NoBodySelectStart(NewImg);
		NewDiv.appendChild(NewImg);

		if (Loop)
		{
			var NewImgLeft = document.createElement('img');
			NewImgLeft.id  = ObjectDiv + "_Picture_Left" ; 
			NewImgLeft.src = Img.src ;
			NewImgLeft.style.position = 'absolute' ;
			NewImgLeft.width = ZoomWidth ;
			NewImgLeft.height = ZoomHeight ;
			NewImgLeft.style.top = '0px' ;
			NewImgLeft.style.left = (NewImgLeft.width)+'px' ;
			NoBodySelectStart(NewImgLeft);
			NewDiv.appendChild(NewImgLeft);

			var NewImgRight = document.createElement('img');
			NewImgRight.id  = ObjectDiv + "_Picture_Right" ; 
			NewImgRight.src = Img.src ;
			NewImgRight.style.position = 'absolute' ;
			NewImgRight.width = ZoomWidth ;
			NewImgRight.height = ZoomHeight ;
			NewImgRight.style.top = '0px' ;
			NewImgRight.style.left = (-NewImgRight.width)+'px' ;
			NoBodySelectStart(NewImgRight);
			NewDiv.appendChild(NewImgRight);
		}

		//PictureReset();
	}



	this.StopMove = StopMove ;
	function StopMove() {
		DeltaX = 0 ;
		DeltaY = 0 ;
		CFlagAim = '' ;
		PFlagAim = '-' ; 
		DeltaMulti = 1 ;
		clearInterval(Anim);
	}

	this.SetMoveTop = SetMoveTop ;
	function SetMoveTop() {
		DeltaX = 0 ;
		DeltaY = -1 ;
		CFlagAim = 'T' ;
		SetMove();
	}

	this.SetMoveTopLeft = SetMoveTopLeft ;
	function SetMoveTopLeft() {
		DeltaX = -1 ;
		DeltaY = -1 ;
		CFlagAim = 'TL' ;
		SetMove();
	}

	this.SetMoveLeft = SetMoveLeft ;
	function SetMoveLeft() {
		DeltaX = -1 ;
		DeltaY = 0 ;
		CFlagAim = 'L' ;
		SetMove();
	}

	this.SetMoveBottomLeft = SetMoveBottomLeft ;
	function SetMoveBottomLeft() {
		DeltaX = -1 ;
		DeltaY = 1 ;
		CFlagAim = 'BL' ;
		SetMove();
	}

	this.SetMoveBottom = SetMoveBottom ;
	function SetMoveBottom() {
		DeltaX = 0 ;
		DeltaY = 1 ;
		CFlagAim = 'B' ;
		SetMove();
	}

	this.SetMoveBottomRight = SetMoveBottomRight ;
	function SetMoveBottomRight() {
		DeltaX = 1 ;
		DeltaY = 1 ;
		CFlagAim = 'BR' ;
		SetMove();
	}

	this.SetMoveRight = SetMoveRight ;
	function SetMoveRight() {
		DeltaX = 1 ;
		DeltaY = 0 ;
		CFlagAim = 'R' ;
		SetMove();
	}

	this.SetMoveTopRight = SetMoveTopRight ;
	function SetMoveTopRight() {
		DeltaX = 1 ;
		DeltaY = -1 ;
		CFlagAim = 'TR' ;
		SetMove();
	}

	this.SetMove = SetMove ;
	function SetMove() {
		SpeedCondition() ;
		clearInterval(Anim);
		Anim = setInterval(ClassName+".MovePicture();", Speed); 
	}

	this.SpeedCondition = SpeedCondition ;
	function SpeedCondition(Flag) {
		if (CFlagAim == PFlagAim)
		{
			DeltaMulti = (DeltaMulti+1<=20)?DeltaMulti+1:20 ;
		} else {
			DeltaMulti = 1 ;
		}
		PFlagAim = CFlagAim ;
	}

	this.MovePictureCheck = MovePictureCheck ;
	function MovePictureCheck() {
		if (NewDivTop > 0)
		{
			DeltaY = 0 ;
			NewDivTop = 0 ;
		} else if (NewDivTop < -(ZoomHeight-Height))
		{
			DeltaY = 0 ;
			NewDivTop = -(ZoomHeight-Height) ;
		}

		if (Loop == false)
		{
			if (NewDivLeft > 0)
			{
				DeltaX = 0 ;
				NewDivLeft = 0 ;
			} else if (NewDivLeft < -(ZoomWidth-Width))
			{
				DeltaX = 0 ;
				NewDivLeft = -(ZoomWidth-Width) ;
			}
		} else {
			if (NewDivLeft > 0)
			{
				NewDivLeft = NewDivLeft - ZoomWidth  ;
			} else if (NewDivLeft < -(ZoomWidth-Width))
			{
				NewDivLeft = NewDivLeft + ZoomWidth  ;
			}
		}

		if (DeltaX == 0 && DeltaY == 0)
		{
			StopMove() ;
		}
	}

	this.MoveClipSet = MoveClipSet ;
	function MoveClipSet() {
		if (NewDivTop >= 0)
		{
			NewDivTop = 0 ;
		} else if (NewDivTop <= -(ZoomHeight-Height))
		{
			NewDivTop = -(ZoomHeight-Height) ;
		}

		if (Loop == false)
		{
			if (NewDivLeft >= 0)
			{
				NewDivLeft = 0 ;
			} else if (NewDivLeft <= -(ZoomWidth-Width))
			{
				NewDivLeft = -(ZoomWidth-Width) ;
			}
		} else {
			if (NewDivLeft >= 0)
			{
				NewDivLeft = NewDivLeft - ZoomWidth  ;
			} else if (NewDivLeft <= -(ZoomWidth-Width))
			{
				NewDivLeft = NewDivLeft + ZoomWidth  ;
			}
		}
	}
	this.MovePicture = MovePicture ;
	function MovePicture() {
		MovePictureCheck();
		var NewDiv = document.getElementById(ObjectDiv+ "_Portion");
		NewDivLeft = NewDivLeft + (DeltaX*DeltaMulti) ;
		NewDivTop = NewDivTop + (DeltaY*DeltaMulti) ;
		MoveClipSet();
		NewDiv.style.top = (NewDivTop)+'px' ;
		NewDiv.style.left = (NewDivLeft)+'px' ;
	}
	
	this.Debug = Debug ;
	function Debug() {
		if (document.getElementById(ObjectDiv+"Debug"))
		{
			var D = document.getElementById(ObjectDiv+"Debug");
			var X = "" ;
			X += "<br>ImgZoom : " + ImgZoom ;
			X += "<br>NextImgZoom : " + NextImgZoom ;
			X += "<br>ZoomHeight : " + ZoomHeight ;
			X += "<br>ImgHeight : " + ImgHeight ;
			/*
			X += "<br>Anim : " + Anim ;
			X += "<br>Aim : " + CFlagAim ;
			X += "<br>PrevAim : " + PFlagAim ;
			X += "<br>Speed : " + DeltaMulti ;
			X += "<br>Left : " + NewDivLeft ;
			X += "<br>Top : " + NewDivTop ;
			*/

			D.innerHTML = X ;
		}
	}

}