function changeProdColor(divId,subHeadingId,changeType){
	divObj = document.getElementById(divId);
	subDivObj = document.getElementById(subHeadingId);

	if (changeType==1){
		divObj.style.color='#38a8ed';
		if (subDivObj){
			subDivObj.className='proSubLink';
		}
	}else{
		divObj.style.color='#777777';
		if (subDivObj){
			subDivObj.className='proLink';
		}
	}
}

function changeHeadingOver(num,name){
	document.getElementById('prodnum').innerHTML=num;	
	document.getElementById('prodName').innerHTML="&nbsp;&nbsp;"+name+' ';
}

var currentBand=1;
function moveDealToProduct(Pid, spd, setDirectLocation){	
	var NewBand=Math.ceil(Math.abs(Pid/3));
	if(NewBand == currentBand) return(false);
	spd=(spd)?spd:15;
	if(NewBand>currentBand){
		var BandMoves=NewBand-currentBand;
	}else{
		var BandMoves=currentBand-NewBand;
	}
	BandMoves=BandMoves*3;	
	if (setDirectLocation==1) {
		moveProductLocation('prod_0', spd, Pid, TotalBands);
	}else{
		hoverProduct('prod_0', spd, Pid, TotalBands);			
	}
	currentBand=NewBand;
	highlightBand(NewBand);	
	return;	
}

function hoverProduct(bannerId, speed, productId, totalProd) {
	var tmpMargin = 0;
	var curPos = 0;
	var newPos = 0;
	var dealObj = document.getElementById(bannerId);
	cleanWhitespace(dealObj);
	var filmObj = dealObj.firstChild;	
	var windowWidth = filmObj.firstChild.offsetWidth;	
	speed=(speed)?speed:'15';	
	filmObj.id = '_' + bannerId;
	var totalFilmWidth = 0;
	for(i=0; i<filmObj.childNodes.length; i++){
		totalFilmWidth +=  filmObj.childNodes[i].offsetWidth;
	}
	filmObj.style.position = 'absolute';
	filmObj.style.width = totalFilmWidth + 'px';	
	var currentLeftMargin = (filmObj.style.marginLeft) ? parseInt(filmObj.style.marginLeft) : 0;
	var productBand = (parseInt(Math.ceil(productId/3)) - 1);
	productBand = (productBand * 3);
	var estLeftMargin = 0 - (windowWidth * productBand);	
	filmObj.oldProdId = productId;	
	if (estLeftMargin < currentLeftMargin) {
		moveDeal('move_next', 'prod_0', speed, estLeftMargin);
	}else{
		moveDeal('move_prev', 'prod_0', speed, estLeftMargin);
	}	
	return false;
}

function moveDeal(period, bannerId, speed, band){
	var dealObj = document.getElementById(bannerId);
	cleanWhitespace(dealObj);
	var filmObj = dealObj.firstChild;	
	var windowWidth = filmObj.firstChild.offsetWidth;
	var productBand = (!band) ? 3 : band;
	
	filmObj.id = '_' + bannerId;
	if (isNaN(band)) {
		if(filmObj.orgObj && filmObj.orgObj.slideStatus){
			return false;
		}
	}
	var totalFilmWidth = 0;
	for(i=0; i<filmObj.childNodes.length; i++){
		totalFilmWidth +=  filmObj.childNodes[i].offsetWidth;
	}
	filmObj.style.position = 'absolute';
	filmObj.style.width = totalFilmWidth + 'px';	
	var currentLeftMargin = (filmObj.style.marginLeft) ? parseInt(filmObj.style.marginLeft) : 0;
			
	switch(period){
		case 'first':
			var stopPosition = 0;
			if(currentLeftMargin >= 0) return false;
			var moveDirection = 2;
			filmObj.slideCount = 1;
		break;
		
		case 'prev':
			var stopPosition = currentLeftMargin + (windowWidth * productBand);
			if(currentLeftMargin >= 0) {
				return false;				
			}
			var moveDirection = 2;
		break;
			
		case 'next':
			var stopPosition = currentLeftMargin - (windowWidth * productBand);	
			if(Math.abs(stopPosition) >= totalFilmWidth) {
				return false;				
			}
			var moveDirection = 4;
		break;
		
		case 'move_prev':
			var stopPosition = productBand;
			var moveDirection = 2;
		break;
		
		case 'move_next':
			var stopPosition = productBand;
			var moveDirection = 4;
		break;
		
		case 'last':
			var stopPosition = 0 - totalFilmWidth + windowWidth;			
			if(currentLeftMargin <= stopPosition) return false;
			var moveDirection = 4;
			filmObj.slideCount = filmObj.childNodes.length - 2;
		break;		
	}
	var slideObj = new slider();
	slideObj.sliderId = filmObj.id;
	slideObj.moveDirection = moveDirection;	
	slideObj.stopPosition = stopPosition;
	slideObj.ready = true;	
	filmObj.orgObj = slideObj;
	slideObj.slideBy = speed;	
	slideObj.slideMarginLeft = currentLeftMargin;
	slideObj.gotoFunction = 'check';
	slideObj.slide();	
}

function highlightBand(band){	
	
	var c3=band*3;
	var c2=c3-1;
	var c1=c3-2;
	document.getElementById('numlist_'+CircledProd[0]).setAttribute("class", "prodNumList");	
	document.getElementById('numlist_'+CircledProd[0]).setAttribute("className", "prodNumList");
	document.getElementById('numlist_'+CircledProd[1]).setAttribute("class", "prodNumList");
	document.getElementById('numlist_'+CircledProd[1]).setAttribute("className", "prodNumList");
	document.getElementById('numlist_'+CircledProd[2]).setAttribute("class", "prodNumList ");	
	document.getElementById('numlist_'+CircledProd[2]).setAttribute("className", "prodNumList ");
	
	var circle1=document.getElementById('numlist_'+c1);	
	var circle2=document.getElementById('numlist_'+c2);	
	var circle3=document.getElementById('numlist_'+c3);	
		
	if(circle1){
		circle1.setAttribute("class", "prodNumList darkcircle");	
		circle1.setAttribute("className", "prodNumList darkcircle");  
		CircledProd[0]=c1;
	}else{
		CircledProd[0]=1;		
	}
	
	if(circle2){	
	 	circle2.setAttribute("class", "prodNumList mediumcircle");	
		circle2.setAttribute("className", "prodNumList mediumcircle"); 
		CircledProd[1]=c2;
	}else{		
		CircledProd[1]=1;
	}
	
	if(circle3){
		circle3.setAttribute("class", "prodNumList lightcircle");	
		circle3.setAttribute("className", "prodNumList lightcircle");  
		CircledProd[2]=c3;  
	}else{		
		CircledProd[2]=1;	
	}
}
function check(slideObj){
	var fildDiv = document.getElementById(slideObj.sliderId);
	var imgObjs = fildDiv.getElementsByTagName('img');
}
function MoveToNextProduct(Dir){	
	if(Dir=='left'){		
		if(currentBand==1){
			return false;	
		}		
		var NewBand=currentBand-1;					
		moveDeal('prev', 'prod_0', 20);
		currentBand=NewBand;					
	}else{		
		if(currentBand==TotalBands){			
			return false;
		} 		
		var NewBand=currentBand+1;					
		moveDeal('next', 'prod_0', 20);
		currentBand=NewBand;				
	}
	highlightBand(NewBand);			
}
function moveProductLocation(bannerId, speed, productId, totalProd) {
	var tmpMargin = 0;
	var curPos = 0;
	var newPos = 0;
	var dealObj = document.getElementById(bannerId);
	cleanWhitespace(dealObj);
	var filmObj = dealObj.firstChild;	
	var windowWidth = filmObj.firstChild.offsetWidth;
	
	speed=(speed)?speed:'20';
	
	filmObj.id = '_' + bannerId;

	var totalFilmWidth = 0;
	for(i=0; i<filmObj.childNodes.length; i++){
		totalFilmWidth +=  filmObj.childNodes[i].offsetWidth;
	}
	filmObj.style.position = 'absolute';
	filmObj.style.width = totalFilmWidth + 'px';
	
	var currentLeftMargin = (filmObj.style.marginLeft) ? parseInt(filmObj.style.marginLeft) : 0;
	var productBand = (parseInt(Math.ceil(productId/3)) - 1);
	productBand = (productBand * 3);

	var estLeftMargin = 0 - (windowWidth * productBand);
	filmObj.style.marginLeft = estLeftMargin + 'px';

	return false;
}
function viewProductDet(prodCnt,detURL){
	var prdCnt = document.getElementById('prodCount'+prodCnt);
	
	prdCnt.value=parseInt(prdCnt.value)+1;
	
	if(prdCnt.value=="2"){
		location.href=detURL;
	}else{
		moveDealToProduct(prodCnt,'');
	}
}