// JavaScript Document
$(function(){
		   
		var imgscontainer=$("div.scrollbox");
		var imgpanels=$("div.imgpanel");
		var leftbn=$(".scrollbns.leftbn");
		var rightbn=$(".scrollbns.rightbn");
		var totalimgs=$("div.scrollbox").children().size();
		var panelWidth=$("div.imgpanel").css("width");
		var moveingDistance=172;
		var curpanel=0;
		var moveNum=0;
		
		imgscontainer.css("width",(imgpanels[0].offsetWidth+5)*imgpanels.length+2);
		$("div.scroll").css("overflow","hidden")
		
		
		function changeDirection(direction,curpanel){
			
			
			
			if(curpanel<0){
			 moveNum=-curpanel;
			
			}else moveNum=curpanel;
			if(direction==true){
			if(moveNum>(totalimgs-3)) return false;
			}
					
           
			var moveleftvalue=curpanel*moveingDistance;
			imgscontainer
				.stop()
				.animate({
					"left": moveleftvalue
				}, function() {
					$("#roomslider").data("Moving", false);
				});			
			
			
		}
		
		//set the imgscontainer's width
		rightbn.click(function(){
							       
							        if(moveNum>=(totalimgs-3)) return false;
									curpanel--;
								
									changeDirection(true,curpanel)		
											})
		leftbn.click(function(){
									if(moveNum==0) return false;
									curpanel++;		
									changeDirection(false,curpanel)		
											})
		
		   })