/*
Added by mohan on 20-02-09
Change request made by: Mandeep
==================================================================
Code Starts
*/
var left=0,right=0;
						
function scrol_photo(iLR)
{	//alert(iLR);
	if(iLR!=0)
	{
		if(right==26)
		{
			return 0;
		}
		right=right+1;
		left=left-1;
	}
	else
	{
		if(left==0)
		{
			return 0;
		}
		left=left+1;
		right=right-1;
	}	
}
/*
scrol_photo function ends here
=====================================================================
code ends
*/

function photoGallery(dir) 
{	//alert(dir);
	var temp = scrol_photo(dir);
	if(temp == 0)
	{
		return false;	
	}
	if(photoGallery != 0) 
	{

		//move left
		if(dir != 0) 
		{
			if(photoGalleryCounter == 0) { $('cal-img-mover2').style.left = photoGalleryWidth }
			//reset the photo containers and the counter 
			if(photoGalleryCounter == (photoGalleryTotal-(photoGalleryTotal*2))) 
			{ 
				$('cal-img-mover1').style.left = '-10px'; 
				$('cal-img-mover2').style.left = photoGalleryWidth;
				photoGalleryCounter = 0
			}	
				photoGalleryCounter = photoGalleryCounter -1;
				Effect.MoveBy( 'cal-img-mover1', 0, -326, 
				{ beforeStart: function() { disablepGalleryBtns(0); }, 
					afterFinish: function() { disablepGalleryBtns(1); }, duration:1} ); 

				Effect.MoveBy( 'cal-img-mover2', 0, -326, {duration:1} );

		} 
		else { 
		
		//move right
		if(photoGalleryCounter == 0) { $('cal-img-mover2').style.left = photoGalleryWidthRight; }
		//reset the photo containers and the counter 
		if(photoGalleryCounter == photoGalleryTotal) { 
			$('cal-img-mover1').style.left = '0px'; 
			$('cal-img-mover2').style.left = photoGalleryWidthRight;
			photoGalleryCounter = 0}
				photoGalleryCounter = photoGalleryCounter +1;
				Effect.MoveBy( 'cal-img-mover1', 0, 326, { 
				beforeStart: function() { disablepGalleryBtns(0); }, afterFinish: function() { disablepGalleryBtns(1); }, duration:1} ); 
				Effect.MoveBy( 'cal-img-mover2', 0, 326, {duration:1} ); 
		}
	}
}	

//this function deactivates button while photo gallery is moving
function disablepGalleryBtns(active) {	
	if(active == 0) { 
		$('col2-calimg-container').style.width = '590px';
		$('col2-calimg-container').style.clip = 'rect(auto auto auto 5px)';
		$('cal-pGalleryBtn-right').onclick =  null;
		$('cal-pGalleryBtn-left').onclick =  null }
	if(active == 1) { 
		$('col2-calimg-container').style.width = '590px';
		$('col2-calimg-container').style.clip = 'rect(auto auto auto auto)';
		$('cal-pGalleryBtn-right').onclick =  photoGallery;
		$('cal-pGalleryBtn-left').onclick =  new Function("photoGallery("+0+")");
		}
}

