/*
Added by mohan on 20-02-09
Change request made by: Mandeep
==================================================================
Code Starts
*/
var left=0,right=0;
var max_img=10;

function set_max_img(max_img_count)
{
	/*
	if you are changing content through ajax and want to make image galary dynamic then call this function as follows after readystate of xmlhttp object
						set_max_img(document.getElementById("img_count").innerHTML);
						
						
			here img_count is a div with property display:none 
			innerHTML of this div will change on the call of ajax function
			for further clarification call to mohan
	*/
	max_img=max_img_count;
	left=0;
	right=0;

}

function scrol_photo(iLR)
{

	if(iLR!=0)
	{
		if(right==max_img)
		{
			return false;
		}
		right=right+1;
		left=left-1;
	}
	else
	{
		if(left==0)
		{
			return false;
		}
		left=left+1;
		right=right-1;
	}	

	return true;
}
/*
scrol_photo function ends here
=====================================================================
code ends
*/


/*
Added by Mohan dtd 27-07-09 for good health good life
---------------------------------------------------------------------------------------------------------
*/
function photoGallery_ghgl(dir) 
{	

	if(!scrol_photo(dir))
		return;
	
	if(photoGallery_ghgl != 0) 
	{

		//move left
		if(dir != 0) 
		{
			if(photoGalleryCounter == 0) 
			{ 
				$('global-img-mover2').style.left = photoGalleryWidth 
			}
			//reset the photo containers and the counter 
			if(photoGalleryCounter == (photoGalleryTotal-(photoGalleryTotal*2))) 
			{ 
				$('global-img-mover1').style.left = '-10px'; 
				$('global-img-mover2').style.left = photoGalleryWidth;
				photoGalleryCounter = 0
			}	
				photoGalleryCounter = photoGalleryCounter -1;
				Effect.MoveBy( 'global-img-mover1', 0, -168, 
				{ beforeStart: function() { disablepGalleryBtns_ghgl(0); }, 
					afterFinish: function() { disablepGalleryBtns_ghgl(1); }, duration:1} ); 

				Effect.MoveBy( 'global-img-mover2', 0, -168, {duration:1} );

		} 
		else { 
		
		//move right
		if(photoGalleryCounter == 0) { $('global-img-mover2').style.left = photoGalleryWidthRight; }
		//reset the photo containers and the counter 
		if(photoGalleryCounter == photoGalleryTotal) { 
			$('global-img-mover1').style.left = '0px'; 
			$('global-img-mover2').style.left = photoGalleryWidthRight;
			photoGalleryCounter = 0}
				photoGalleryCounter = photoGalleryCounter +1;
				Effect.MoveBy( 'global-img-mover1', 0, 168, { 
				beforeStart: function() { disablepGalleryBtns_ghgl(0); }, afterFinish: function() { disablepGalleryBtns_ghgl(1); }, duration:1} ); 
				Effect.MoveBy( 'global-img-mover2', 0, 168, {duration:1} ); 
		}
		
		imgDispGHGL(Math.abs(photoGalleryCounter));
	}
}



function disablepGalleryBtns_ghgl(active) {	
	if(active == 0) { 
		//$('col2-img-container').style.width = '625px';
		//$('col2-img-container').style.clip = 'rect(auto auto auto 5px)';
		$('global-pGalleryBtn-right').onclick =  null;
		$('global-pGalleryBtn-left').onclick =  null }
	if(active == 1) { 
		//$('col2-img-container').style.width = '625px';
		//$('col2-img-container').style.clip = 'rect(auto auto auto auto)';
		$('global-pGalleryBtn-right').onclick =  photoGallery_ghgl;
		$('global-pGalleryBtn-left').onclick =  new Function("photoGallery_ghgl("+0+")");
		}
}


/* 
End  27-07-09 for good health good life
---------------------------------------------------------------------------------------------------------
*/

/*
Added by Mohan dtd 28-07-09 for good health good life
---------------------------------------------------------------------------------------------------------
*/
function photoGallery_ghgl2(dir) 
{	
	if(!scrol_photo(dir))
		return;
	
	if(photoGallery_ghgl2 != 0) 
	{
		//move left
		if(dir != 0) 
		{
			if(photoGalleryCounter == 0) { $('global-img-mover2').style.left = photoGalleryWidth }
			//reset the photo containers and the counter 
			if(photoGalleryCounter == (photoGalleryTotal-(photoGalleryTotal*2))) 
			{ 
				$('global-img-mover1').style.left = '-10px'; 
				$('global-img-mover2').style.left = photoGalleryWidth;
				photoGalleryCounter = 0
			}	
				photoGalleryCounter = photoGalleryCounter -1;
				Effect.MoveBy( 'global-img-mover1', 0, -164, 
				{ beforeStart: function() { disablepGalleryBtns_ghgl2(0); }, 
					afterFinish: function() { disablepGalleryBtns_ghgl2(1); }, duration:1} ); 

				Effect.MoveBy( 'global-img-mover2', 0, -164, {duration:1} );

		} 
		else 
		{ 
		
		//move right
			if(photoGalleryCounter == 0)
			{
				$('global-img-mover2').style.left = photoGalleryWidthRight;
			}
			//reset the photo containers and the counter 
			if(photoGalleryCounter == photoGalleryTotal)
			{ 
				$('global-img-mover1').style.left = '0px'; 
				$('global-img-mover2').style.left = photoGalleryWidthRight;
				photoGalleryCounter = 0;
			}
			photoGalleryCounter = photoGalleryCounter +1;
			
			Effect.MoveBy( 'global-img-mover1', 0, 164, { 
				beforeStart: function() { disablepGalleryBtns_ghgl2(0); }, afterFinish: function() { disablepGalleryBtns_ghgl2(1); }, duration:1} ); 
				Effect.MoveBy( 'global-img-mover2', 0, 164, {duration:1} ); 
			
		}
		imgDisp(Math.abs(photoGalleryCounter)+1);
		
	}
}



function disablepGalleryBtns_ghgl2(active) {	
	if(active == 0) { 
		//$('col2-img-container').style.width = '625px';
		//$('col2-img-container').style.clip = 'rect(auto auto auto 5px)';
		$('global-pGalleryBtn-right').onclick =  null;
		$('global-pGalleryBtn-left').onclick =  null }
	if(active == 1) { 
		//$('col2-img-container').style.width = '625px';
		//$('col2-img-container').style.clip = 'rect(auto auto auto auto)';
		$('global-pGalleryBtn-right').onclick =  photoGallery_ghgl2;
		$('global-pGalleryBtn-left').onclick =  new Function("photoGallery_ghgl2("+0+")");
		}
}


/* 
End  28-07-09 for good health good life
---------------------------------------------------------------------------------------------------------
*/

function photoGallery(dir) 
{	
	if(!scrol_photo(dir))
		return;
	if(photoGallery != 0) 
	{

		//move left
		if(dir != 0) 
		{
			if(photoGalleryCounter == 0) { $('global-img-mover2').style.left = photoGalleryWidth }
			//reset the photo containers and the counter 
			if(photoGalleryCounter == (photoGalleryTotal-(photoGalleryTotal*2))) 
			{ 
				$('global-img-mover1').style.left = '-10px'; 
				$('global-img-mover2').style.left = photoGalleryWidth;
				photoGalleryCounter = 0
			}	
				photoGalleryCounter = photoGalleryCounter -1;
				Effect.MoveBy( 'global-img-mover1', 0, -126, 
				{ beforeStart: function() { disablepGalleryBtns(0); }, 
					afterFinish: function() { disablepGalleryBtns(1); }, duration:1} ); 

				Effect.MoveBy( 'global-img-mover2', 0, -126, {duration:1} );

		} 
		else { 
		
		//move right
		if(photoGalleryCounter == 0) { $('global-img-mover2').style.left = photoGalleryWidthRight; }
		//reset the photo containers and the counter 
		if(photoGalleryCounter == photoGalleryTotal) { 
			$('global-img-mover1').style.left = '0px'; 
			$('global-img-mover2').style.left = photoGalleryWidthRight;
			photoGalleryCounter = 0}
				photoGalleryCounter = photoGalleryCounter +1;
				Effect.MoveBy( 'global-img-mover1', 0, 126, { 
				beforeStart: function() { disablepGalleryBtns(0); }, afterFinish: function() { disablepGalleryBtns(1); }, duration:1} ); 
				Effect.MoveBy( 'global-img-mover2', 0, 126, {duration:1} ); 
		}
	}
}	

//this function deactivates button while photo gallery is moving
function disablepGalleryBtns(active) {	
	if(active == 0) { 
		//$('col2-img-container').style.width = '625px';
		//$('col2-img-container').style.clip = 'rect(auto auto auto 5px)';
		$('global-pGalleryBtn-right').onclick =  null;
		$('global-pGalleryBtn-left').onclick =  null }
	if(active == 1) { 
		//$('col2-img-container').style.width = '625px';
		//$('col2-img-container').style.clip = 'rect(auto auto auto auto)';
		$('global-pGalleryBtn-right').onclick =  photoGallery;
		$('global-pGalleryBtn-left').onclick =  new Function("photoGallery("+0+")");
		}
}
/* ---------------------------------------------------------------------------------------------------------------- */
/* ----------------------             For health Center                 ------------------------------------------ */
function photoGallery_hc(dir) 
{	
	if(!scrol_photo(dir))
		return;
	if(photoGallery_hc != 0) 
	{

		//move left
		if(dir != 0) 
		{
			if(photoGalleryCounter == 0) { $('global-img-mover2').style.left = photoGalleryWidth }
			//reset the photo containers and the counter 
			if(photoGalleryCounter == (photoGalleryTotal-(photoGalleryTotal*2))) 
			{ 
				$('global-img-mover1').style.left = '-10px'; 
				$('global-img-mover2').style.left = photoGalleryWidth;
				photoGalleryCounter = 0
			}	
				photoGalleryCounter = photoGalleryCounter -1;
				Effect.MoveBy( 'global-img-mover1', 0, -145, 
				{ beforeStart: function() { disablepGalleryBtns_hc(0); }, 
					afterFinish: function() { disablepGalleryBtns_hc(1); }, duration:1} ); 

				Effect.MoveBy( 'global-img-mover2', 0, -145, {duration:1} );

		} 
		else { 
		
		//move right
		if(photoGalleryCounter == 0) { $('global-img-mover2').style.left = photoGalleryWidthRight; }
		//reset the photo containers and the counter 
		if(photoGalleryCounter == photoGalleryTotal) { 
			$('global-img-mover1').style.left = '0px'; 
			$('global-img-mover2').style.left = photoGalleryWidthRight;
			photoGalleryCounter = 0}
				photoGalleryCounter = photoGalleryCounter +1;
				Effect.MoveBy( 'global-img-mover1', 0, 145, { 
				beforeStart: function() { disablepGalleryBtns_hc(0); }, afterFinish: function() { disablepGalleryBtns_hc(1); }, duration:1} ); 
				Effect.MoveBy( 'global-img-mover2', 0, 145, {duration:1} ); 
		}
	}
}	

//this function deactivates button while photo gallery is moving
function disablepGalleryBtns_hc(active) {	
	if(active == 0) { 
		//$('col2-img-container').style.width = '625px';
		//$('col2-img-container').style.clip = 'rect(auto auto auto 5px)';
		$('global-pGalleryBtn-right').onclick =  null;
		$('global-pGalleryBtn-left').onclick =  null }
	if(active == 1) { 
		//$('col2-img-container').style.width = '625px';
		//$('col2-img-container').style.clip = 'rect(auto auto auto auto)';
		$('global-pGalleryBtn-right').onclick =  photoGallery_hc;
		$('global-pGalleryBtn-left').onclick =  new Function("photoGallery_hc("+0+")");
		}
}
/* -------------------------------------------------------------------------------------------------------------------------- */
