var prevValue=0;
var nextValue=0;
//sets previous value
function setPrevValue(_value){
	prevValue =_value;
}
//sets next value
function setNextValue(_value){
	nextValue =_value;
}
//invoke previos logic
function previous(isdiv){
	var totalImage = $("totalImage").value;
	
	if (prevValue==0)
		return;
		

	if ((prevValue-4)<=0)
		prevValue=0;
	else
		prevValue=prevValue-4;

	nextValue= nextValue-4;			
	
	for (var i=0;i<totalImage;i++){
		if (!$('thumb_'+i))
			continue;
		if (i>=prevValue && i<nextValue)
			jQuery('#thumb_'+i).show();
		else	
			$('thumb_'+i).style.display='none';
	}
	
	if (prevValue==0) {
		if(isdiv){
			$('proPrevButton').innerHTML ='<font color="white">iiiii</font>';
			$('propNextButton').innerHTML ='<a href="javascript:next(true);"><img border="0" src="css/images/next_image.png" width="17" height="14"></img></a>';
		}
		else{
			$('proPrevButton').style.display='none';
			$('propNextButton').style.display='block';
		}
		return;
	} else {
		if(isdiv){
			$('propNextButton').innerHTML ='<a href="javascript:next(true);"><img border="0" src="css/images/next_image.png" width="17" height="14"></img></a>';
		}
		else{
			$('propNextButton').style.display='block';
		}
	}
}
//invokes next logic
function next(isdiv){
	var totalImage = $("totalImage").value;
	if (nextValue == 0){
		nextValue=4;
	}
	
	if (nextValue>=totalImage)
		return;
		
		
	prevValue=prevValue+4;
	nextValue= nextValue+4;		
	
	for (var i=0;i<totalImage;i++){
		if (!$('thumb_'+i))
			continue;
		if (i>=prevValue && i<nextValue)
			jQuery('#thumb_'+i).show();
		else	
			$('thumb_'+i).style.display='none';
	}
	
	if (nextValue>=totalImage) {
		if(isdiv){
			$('propNextButton').innerHTML ='<font color="white">iiiii</font>';
			$('proPrevButton').innerHTML ='<a href="javascript:previous(true);"><img border="0" src="css/images/previous_image.png" width="17" height="14"></img></a>';
		}
		else{
			$('propNextButton').style.display='none';
			$('proPrevButton').style.display='block';
		}
		return;
	} else {
		if(isdiv){
			$('proPrevButton').innerHTML ='<a href="javascript:previous(true);"><img border="0" src="css/images/previous_image.png" width="17" height="14"></img></a>';
		}
		else{
			$('proPrevButton').style.display='block';
		}
	}
}
