 var speed=8;
function scroll_check(maskId, scrollableContainerId, top_scroll, bottom_scroll){
	var divid =document.getElementById(scrollableContainerId);
	var difference = document.getElementById(maskId).offsetHeight - divid.offsetHeight;
	var imgidbottom = document.getElementById(bottom_scroll);
	var imgidtop = document.getElementById(top_scroll);
	divid.style.top = 0;
	if(divid.offsetHeight <= document.getElementById(maskId).offsetHeight)
	{
	  imgidtop.src="../Common/images/scroll_btn_top_disable.gif";
		imgidbottom.src="../Common/images/scroll_btn_bottom_disable.gif";
		imgidtop.style.cursor='default';
		imgidbottom.style.cursor='default';
	}
	else
	{
	  imgidtop.src="../Common/images/scroll_btn_top_disable.gif";
    imgidbottom.src="../Common/images/scroll_btn_bottom.gif";
		imgidbottom.style.cursor="pointer"; 
	}
}
	
function moveup(scrollableContainerId, maskId, bottom_scroll, top_scroll){
 if (window.moveupvar) clearTimeout(moveupvar);	
  var divid =document.getElementById(scrollableContainerId);
	var difference = document.getElementById(maskId).offsetHeight - divid.offsetHeight;
	var imgidbottom = document.getElementById(bottom_scroll);
	var imgidtop = document.getElementById(top_scroll);

	if(difference >= divid.offsetTop) 
	{
		imgidbottom.src="../Common/images/scroll_btn_bottom_disable.gif";
	  imgidbottom.style.cursor="default";
		
	}
	
  if(difference <= divid.offsetTop && difference < 0) 
	{ 
	  imgidtop.src="../Common/images/scroll_btn_top.gif";
		imgidbottom.style.cursor="pointer"; 
		divid.style.top = divid.offsetTop - speed + "px";
    moveupvar = setTimeout(function() {moveup(scrollableContainerId, maskId, bottom_scroll, top_scroll);},20);
	}
	

}

function movedown(scrollableContainerId, top_scroll, bottom_scroll){
 if (window.movedownvar) clearTimeout(movedownvar);	
  var divid = document.getElementById(scrollableContainerId);
	var imgidtop = document.getElementById(top_scroll);
	var imgidbottom = document.getElementById(bottom_scroll);	
	if(divid.offsetTop < 0)
	{
   imgidtop.src="../Common/images/scroll_btn_top.gif"; 
	 imgidtop.style.cursor="pointer";
	}
	else
	{
	 imgidtop.src="../Common/images/scroll_btn_top_disable.gif"; 
	 imgidtop.style.cursor="default";
	}
 if(divid.offsetTop < 0)
 {
  imgidbottom.src="../Common/images/scroll_btn_bottom.gif";			
  divid.style.top = divid.offsetTop + speed + "px";
  movedownvar = setTimeout(function() {movedown(scrollableContainerId, top_scroll, bottom_scroll);},20); 
 }
}
 
function stopscroll(){
  if (window.moveupvar) clearTimeout(moveupvar)
  if (window.movedownvar) clearTimeout(movedownvar)
}
function closePopup(popupId){
  var divid = document.getElementById(popupId);
	var fade = document.getElementById("fade");
	fade.style.display = "none";	
	divid.style.display = "none";	
}

function pageWidth() {
	return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
} 

function makeExternalPopup(popupId){
  var divid = document.getElementById(popupId);
	var fade = document.getElementById("fade");
	fade.style.height = document.getElementById("outer_container").offsetHeight + "px";	
	fade.style.display = "block";	
	divid.style.display = "block";	
	divid.style.left = (pageWidth()-divid.offsetWidth)/2 + "px";
}

function movedownHome(scrollableContainerId, top_scroll, bottom_scroll){
 if (window.movedownvar) clearTimeout(movedownvar);	
  var divid = document.getElementById(scrollableContainerId);
	var imgidtop = document.getElementById(top_scroll);
	var imgidbottom = document.getElementById(bottom_scroll);	
	if(divid.offsetTop < 0)
	{
   imgidtop.src="./Common/images/scroll_btn_top.gif"; 
	 imgidtop.style.cursor="pointer";
	}
	else
	{
	 imgidtop.src="./Common/images/scroll_btn_top_disable.gif"; 
	 imgidtop.style.cursor="default";
	}
 if(divid.offsetTop < 0)
 {
  imgidbottom.src="./Common/images/scroll_btn_bottom.gif";			
  divid.style.top = divid.offsetTop + speed + "px";
  movedownvar = setTimeout(function() {movedownHome(scrollableContainerId, top_scroll, bottom_scroll);},20); 
 }
}

function moveupHome(scrollableContainerId, maskId, bottom_scroll, top_scroll){
 if (window.moveupvar) clearTimeout(moveupvar);	
  var divid =document.getElementById(scrollableContainerId);
	var difference = document.getElementById(maskId).offsetHeight - divid.offsetHeight;
	var imgidbottom = document.getElementById(bottom_scroll);
	var imgidtop = document.getElementById(top_scroll);

	if(difference >= divid.offsetTop) 
	{
		imgidbottom.src="./Common/images/scroll_btn_bottom_disable.gif";
	  imgidbottom.style.cursor="default";
		
	}
	
  if(difference <= divid.offsetTop && difference < 0) 
	{ 
	  imgidtop.src="./Common/images/scroll_btn_top.gif";
		imgidbottom.style.cursor="pointer"; 
		divid.style.top = divid.offsetTop - speed + "px";
    moveupvar = setTimeout(function() {moveupHome(scrollableContainerId, maskId, bottom_scroll, top_scroll);},20);
	}
	

}


function scroll_checkHome(maskId, scrollableContainerId, top_scroll, bottom_scroll){
	var divid =document.getElementById(scrollableContainerId);
	var difference = document.getElementById(maskId).offsetHeight - divid.offsetHeight;
	var imgidbottom = document.getElementById(bottom_scroll);
	var imgidtop = document.getElementById(top_scroll);
	divid.style.top = 0;
	if(divid.offsetHeight <= document.getElementById(maskId).offsetHeight)
	{
	  imgidtop.src="./Common/images/scroll_btn_top_disable.gif";
		imgidbottom.src="../Common/images/scroll_btn_bottom_disable.gif";
		imgidtop.style.cursor='default';
		imgidbottom.style.cursor='default';
	}
	else
	{
	  imgidtop.src="./Common/images/scroll_btn_top_disable.gif";
    imgidbottom.src="./Common/images/scroll_btn_bottom.gif";
		imgidbottom.style.cursor="pointer"; 
	}
}