
function getObj( id ) {
	return document.getElementById( id );
}

var dir = new Array(0,0);// 0 = left, 1 = right
var timerNavI = new Array(0,0);
var index = new Array(0,0);
click=0;

// **** Functional Code - NO NEED to Change
function zxcBAnimator(zxcmde,zxcobj,zxcsrt,zxcfin,zxctime,flg){
 if (typeof(zxcobj)=='string'){ zxcobj=document.getElementById(zxcobj); }
 if (!zxcobj||(!zxcsrt&&!zxcfin)||zxcsrt==zxcfin) return;
 var zxcoop=zxcobj[zxcmde.replace(/[-#]/g,'')+'oop'];
 if (zxcoop){
  clearTimeout(zxcoop.to); 
  if (zxcoop.srtfin[0]==zxcsrt&&zxcoop.srtfin[1]==zxcfin&&zxcmde.match('#')) zxcoop.update([zxcoop.data[0],(zxcoop.srtfin[0]==zxcoop.data[2])?zxcfin:zxcsrt],zxctime,flg);
  else zxcoop.update([zxcsrt,zxcfin],zxctime,flg);
 }
 else zxcobj[zxcmde.replace(/[-#]/g,'')+'oop']=new zxcBAnimatorOOP(zxcmde,zxcobj,zxcsrt,zxcfin,zxctime,flg);
}

function zxcBAnimatorOOP(zxcmde,zxcobj,zxcsrt,zxcfin,zxctime,flg){
 this.srtfin=[zxcsrt,zxcfin];
 this.to=null;
 this.obj=zxcobj;
 this.mde=zxcmde.replace(/[-#]/g,'');
 this.update([zxcsrt,zxcfin],zxctime,flg); 
}

zxcBAnimatorOOP.prototype.update=function(zxcsrtfin,zxctime,flg){
 this.time=zxctime||this.time||2000;
 this.data=[zxcsrtfin[0],zxcsrtfin[0],zxcsrtfin[1]];
 this.srttime=new Date().getTime();
 this.cng(flg);
}

zxcBAnimatorOOP.prototype.cng=function(flg){
 var zxcms=new Date().getTime()-this.srttime;
 //getObj('info').innerHTML = this.data[2]+"|"+this.data[1]+"|"+zxcms+'<'+this.time; 
 
 this.data[0]=(this.data[2]-this.data[1])/this.time*zxcms+this.data[1];
 
 if (this.mde!='left'&&this.mde!='top'&&this.data[0]<0) this.data[0]=0;
 if (this.mde!='opacity') this.obj.style[this.mde]=this.data[0]+'px';
 else  zxcOpacity(this.obj,this.data[0]);
 if (zxcms<this.time) this.to=setTimeout(function(zxcoop){return function(){zxcoop.cng(flg);}}(this),10);
 else {  
 	if (this.mde=='left') {
  		this.data[0]=this.data[2];
  		timerNavI[flg] = 0;    		
  		timerNavI[flg] = 0;    
  		if(dir[flg]==1) {
  			setHide(index[flg]+3,flg); 
  			setHide(index[flg]+4,flg);
  			setHide(index[flg]+5,flg);
  		}
  		if(dir[flg]==1) {
  			setHide(index[flg]+3,flg); 
  			setHide(index[flg]+4,flg);
  			setHide(index[flg]+5,flg);
  		}
  	}
  	if (this.mde!='opacity') this.obj.style[this.mde]=this.data[0]+'px';
  	else {
  		zxcOpacity(this.obj,this.data[0]);
  		if( this.data[0] <= 0 && this.data[2]<=0 ) getObj( 'div_'+hideItem+'_'+hideSubItem ).style.display = '';	
  	}
 }
}

function zxcOpacity(zxcobj,zxcopc){
 if (zxcopc<0||zxcopc>100) return;
 zxcobj.style.filter='alpha(opacity='+zxcopc+')';
 zxcobj.style.opacity=zxcobj.style.MozOpacity=zxcobj.style.KhtmlOpacity=zxcopc/100-.001;
}
// end

function setVisible( id,flg ) {
	currentDiv=getObj( 'div' + flg + '_'+id);
	if( currentDiv != null )
	if( currentDiv.style.display == 'none' ) currentDiv.style.display = 'block';	
}

function setHide(id, flg) {
    currentDiv = getObj('div' + flg + '_' + id);
    if (currentDiv != null) {
        if (currentDiv.style.display != 'none') currentDiv.style.display = 'none';
    }
}

function goPrev(dirIMG,flg) {   
	dir[flg] = 1;
	if( index[flg] >= 1 && !timerNavI[flg]) {
		timerNavI[flg] = 1;		
		start = -(index[flg]*157)+48;
		end   =  ((3-index[flg])*157)+48;
		index[flg] = index[flg] -3;						
		zxcBAnimator('left#','sourceDiv' + flg,start,end,200,flg);				
		getObj('imgNext'+flg).src = dirIMG + 'next.gif';	
		if( index[flg] == 0 ) {
			getObj('imgPrev'+flg).src = dirIMG + 'previuos_dis.gif';		
			getObj('btnLeftDiv'+flg).className = 'btnLeft colorE';
			//getObj( 'carBotLeft' ).className = 'pBotLeftCar';
		}
	}	
}

function goNext(dirIMG,flg) {
	dir[flg] = 0;	
	if(( index[flg] + 2 ) < imgPlaces[flg] && !timerNavI[flg]) {
		timerNavI[flg] = 1;		
		setVisible( index[flg] + 3,flg );
		setVisible( index[flg] + 4,flg );
		setVisible(index[flg] + 5,flg);		
		start = -(index[flg]*157)+48;
		end   =  (-(index[flg]+3)*157)+48;		
		index[flg] = index[flg] +3;			
		zxcBAnimator('left#','sourceDiv' + flg,start,end,200,flg);
		getObj('imgPrev'+flg).src = dirIMG + 'previuos.gif';		
		if( index[flg] + 2 >= imgPlaces[flg] ) {
			getObj('imgNext'+flg).src = dirIMG + 'next_dis.gif';		
			getObj('btnRightDiv'+flg).className = 'btnRight colorE';
			//getObj( 'carBotRight' ).className = 'pBotRightCar';
		}
	}
}

function onMove( id, flg ) { 
	if( index[flg] >= 1 && !timerNavI[flg] ) {
		if( id == 'btnLeftDiv'+flg ) getObj( id ).className = 'btnLeft colorS';
		//if( id == 'btnLeftDiv' ) getObj( 'carBotLeft' ).className = 'pBotLeftCarSel';
	}
	
	if(( index[flg] + 2 ) < imgPlaces[flg] && !timerNavI[flg] ) {
		if( id == 'btnRightDiv'+flg ) getObj( id ).className = 'btnRight colorS';
		//if( id == 'btnRightDiv' ) getObj( 'carBotRight' ).className = 'pBotRightCarSel';
	}
}

function onOut( id ) { 
	if( id == 'btnLeftDiv'+flg ) getObj( id ).className = 'btnLeft colorE';
//	if( id == 'btnLeftDiv' ) getObj( 'carBotLeft' ).className = 'pBotLeftCar';
//	
	if( id == 'btnRightDiv'+flg ) getObj( id ).className = 'btnRight colorE';
//	if( id == 'btnRightDiv' ) getObj( 'carBotRight' ).className = 'pBotRightCar';
	
}

function itemMove( id ) {	
	getObj( 'divItem_'+id ).className = 'selectItem';		
}

function itemOut( id ) {
	getObj( 'divItem_'+id ).className = '';
}

function initButtons(dirIMG, flg) {   
	if( index[flg] + 2 >= imgPlaces[flg] ) {
		getObj('imgNext'+flg).src = dirIMG + 'next_dis.gif';		
		getObj('btnRightDiv'+flg).className = 'btnRight colorE';
		//getObj( 'carBotRight' ).className = 'pBotRightCar';
	}
}