var pos;
//var nIcons;
var aIcons;
var oButtonLeft;
var oButtonRight;
var bInit = false;

function scrollItLeft() {
	//alert('scrollLeft!');
	if (!bInit) {
		initScroll();
	}
	if (pos > 0) {
		tmpPos = pos - 4;
		if(tmpPos<0) {
			tmpPos=0;
		}
		i=tmpPos;
		for (; i<tmpPos+4 && i<aIcons.length; i++) {
			aIcons[i].style.display='block';
		}
		for (; i<tmpPos+12 && i<aIcons.length; i++) {
			aIcons[i].style.display='none';
		}
		pos=tmpPos;
		//Set_Cookie('pos', pos);
		if (pos==0) {
			oButtonLeft.setAttribute('src', 'images/leftArr_End.gif');
			oButtonLeft.style.cursor='default';
		}
		oButtonRight.setAttribute('src', 'images/rightArr.gif');
		oButtonRight.style.cursor='pointer';
			boxRed(tmpPos)
	}
		
}

function scrollRight() {
	if (!bInit) {
		initScroll();
	}
	//alert ('Pos: ' + pos + ' length: ' + aIcons.length);
	if ( (pos+4) < aIcons.length) {
		tmpPos = pos + 4;
		if( tmpPos > aIcons.length-4 ) {
			tmpPos=aIcons.length-4;
		}
		rightPos = tmpPos+3;
		i = rightPos;
		
		//alert ("tmpPos: " + tmpPos + "rightPos: " + rightPos);
		for (; i>tmpPos-1 && i>=0; i--) {
			aIcons[i].style.display='block';
		}
		for (; i>tmpPos-7 && i>=0; i--) {
			aIcons[i].style.display='none';
		}
		pos=tmpPos;
		//Set_Cookie('pos', pos);
		if (pos+4==aIcons.length) {
			oButtonRight.setAttribute('src', 'images/rightArr_End.gif');
			oButtonRight.style.cursor='default';
		}
		oButtonLeft.setAttribute('src', 'images/leftArr.gif');
		oButtonLeft.style.cursor='pointer';
		boxRed(tmpPos)
	}	
}

function initScroll() {
	pos = -1;
	oList = document.getElementById('divIconList');
	aIcons = new Array();
	n = 0;
	for(i=0; i<oList.childNodes.length; i++) {
		if (oList.childNodes[i].nodeType==1) { //Is an element
			//alert('n: ' + n);
			//alert(oList.childNodes[i].className);
			if(pos==-1 && oList.childNodes[i].className.search('.*DisNone.*')<0) {
				pos=n;
			}
			//alert('pos: ' + pos);
			aIcons[n]=oList.childNodes[i];
			n++;
		}
	}
	if (pos==-1) {
		pos=0;
	}
	//alert(pos);
	oButtonLeft = document.getElementById('imgButtonLeft');
	oButtonRight = document.getElementById('imgButtonRight');
	bInit = true;
}

function boxRed(pos){ 
//alert(pos)
//document.getElementById("pet").innerHTML='Pos: ' + pos //+ ' length: ' + aIcons.length + "tmpPos: " + tmpPos + "rightPos: " + rightPos
if (pos==0) document.getElementById('boxRed').src="images/browse/1.gif"
if (pos==1) document.getElementById('boxRed').src="images/browse/2.gif"
if (pos==2) document.getElementById('boxRed').src="images/browse/3.gif"
if (pos==3) document.getElementById('boxRed').src="images/browse/4.gif"
if (pos==4) document.getElementById('boxRed').src="images/browse/5.gif"
if (pos==5) document.getElementById('boxRed').src="images/browse/6.gif"
if (pos==6) document.getElementById('boxRed').src="images/browse/7.gif"
}


/*
var pos2;
//var nIcons;
var aIcons2;
var oButtonLeft2;
var oButtonRight2;
var bInit2 = false;

function scrollItLeft2() {
	//alert('scrollLeft!');
	if (!bInit2) {
		initScroll2();
	}
	if (pos2 > 0) {
		tmpPos = pos2 - 4;
		if(tmpPos<0) {
			tmpPos=0;
		}
		i=tmpPos;
		for (; i<tmpPos+4 && i<aIcons2.length; i++) {
			aIcons2[i].style.display='block';
		}
		for (; i<tmpPos+12 && i<aIcons2.length; i++) {
			aIcons2[i].style.display='none';
		}
		pos2=tmpPos;
		if (pos2==0) {
			oButtonLeft2.setAttribute('src', 'images/leftArr_End.gif');
			oButtonLeft2.style.cursor='default';
		}
		oButtonRight2.setAttribute('src', 'images/rightArr.gif');
		oButtonRight2.style.cursor='pointer';
	}
		
}

function scrollRight2() {
	if (!bInit2) {
		initScroll2();
	}
	//alert ('Pos: ' + pos + ' length: ' + aIcons.length);
	if ( (pos2+6) < aIcons2.length) {
		tmpPos = pos2 + 4;
		if( tmpPos > aIcons2.length-4 ) {
			tmpPos=aIcons2.length-4;
		}
		rightPos2 = tmpPos+3;
		i = rightPos2;
		//alert ("tmpPos: " + tmpPos + "rightPos: " + rightPos);
		for (; i>tmpPos-1 && i>=0; i--) {
			aIcons2[i].style.display='block';
		}
		for (; i>tmpPos-7 && i>=0; i--) {
			aIcons2[i].style.display='none';
		}
		pos2=tmpPos;
		if (pos2+6==aIcons2.length) {
			oButtonRight2.setAttribute('src', 'images/rightArr_End.gif');
			oButtonRight2.style.cursor='default';
		}
		oButtonLeft2.setAttribute('src', 'images/leftArr.gif');
		oButtonLeft2.style.cursor='pointer';
	}	
}

function initScroll2() {
	pos2 = -1;
	oList2 = document.getElementById('divIconList2');
	aIcons2 = new Array();
	n = 0;
	for(i=0; i<oList2.childNodes.length; i++) {
		if (oList2.childNodes[i].nodeType==1) { //Is an element
			//alert('n: ' + n);
			//alert(oList.childNodes[i].className);
			if(pos2==-1 && oList2.childNodes[i].className.search('.*DisNone.*')<0) {
				pos2=n;
			}
			//alert('pos: ' + pos);
			aIcons2[n]=oList2.childNodes[i];
			n++;
		}
	}
	if (pos2==-1) {
		pos2=0;
	}
	//alert(pos);
	oButtonLeft2 = document.getElementById('imgButtonLeft2');
	oButtonRight2 = document.getElementById('imgButtonRight2');
	bInit2 = true;
}
*/