var count1 = 0; 
var baseSpeed1 = 0.03; 
var radiusX1 = 200; 
var radiusY1 = 30; 
var centerX1 = 250; 
var centerY1 = 120;
var speed1 = 0.5;
var imageDivs1 = '';
var numberOfElements1 = 0;
var carousel1 = '';
var speedTest1 = '';
var bob1 = 1;
var extra1 = 0;
var chk11=0;
var chk21=0;
var IsStop1="no";

window.addEvent('domready', function(){
	carousel1 = $('carousel1');
	speedTest1 = $('speedTest1');
	imageDivs1 = carousel1.getElementsByTagName("div"); 
	numberOfElements1 = imageDivs1.length; 
	setInterval('startCarousel1()',38);
	carousel1.addEvent('mousemove', onMouseMove.bindWithEvent( carousel1 ));
	carousel1.addEvent('mouseover', onMouseMove.bindWithEvent( carousel1 ));
	carousel1.addEvent('mouseout', onMouseOut.bindWithEvent( carousel1 ));

//	for (index=0;index<numberOfElements1;index++)
//	{
//	    imageDivs1[index].addEvent('mouseover', onMouseOver.bindWithEvent( imageDivs1[index] ),RecOnMouseMove);
//	    imageDivs1[index].addEvent('mouseout', onMouseOut.bindWithEvent( imageDivs1[index] ));
//	}
});

function PauseCarsoule1() 
{
    IsStop1="yes";
}

function ResumeCarsoule1() 
{
    IsStop1="no";
}

function onMouseMove( evt ) {
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
  			winW = window.innerWidth;
  			winH = window.innerHeight;
 		}
 		
 		if (navigator.appName.indexOf("Microsoft")!=-1) {
  			winW = document.body.offsetWidth;
  			winH = document.body.offsetHeight;
 		}
	}

	tempX = evt.client.x;

	if(tempX > ((winW / 2) + 40)){	
		bob1 = 1;
		extra1=0;	
	}else{
	
		if(tempX < ((winW / 2) - 40)){	
			bob1 = 0;
			extra1 = 0;	
			//alert("stop1");
		}else{
			bob1 = 2;
			extra1 = 0;
			//alert("stop2");
		}
	}
	
	
	if(tempX > ((winW / 2) + 200)){	
		extra1 = 2; 	
	}else{
	
		if(tempX < ((winW / 2) - 200)){	
			extra1=2;	
		}
	}
	
	if(tempX > ((winW / 2) + 300)){	
		extra1 = 4; 	
	}else{
	
		if(tempX < ((winW / 2) - 300)){	
			extra1=4;	
		}
	}
}

function onMouseOut( evt ) {
	bob1 = 1;
	speed1 = 0.5;
	extra1=0;	
    
    }

function startCarousel1(){


if (IsStop1 == "no")
{
	for(i=0; i < numberOfElements1; i++){

		angle = i * ( Math.PI * 2 ) / numberOfElements1;
	
		imageDivsStyle = imageDivs1[ i ].style; 
		imageDivsStyle.position='absolute';

		
		posX = ( Math.sin( count1 * ( baseSpeed1 * speed1 ) + angle )* radiusX1 + centerX1 );
		posY = ( Math.cos( count1 * ( baseSpeed1 * speed1 ) + angle )* radiusY1 + centerY1 );
		
		
		imageDivsStyle.left = posX+"px"; 
		imageDivsStyle.top = (posY-80)+"px";
        
		if (((posX>=178 && posX<=345) && posY>=94))
		{
		        var dvName = 'Div' + (i+1);
		        var imgName = 'Img_' + (i+1);
		        if (window.location.href.toLowerCase().indexOf('candidate') == -1)
		        {
		            if(document.getElementById(imgName))
		                document.getElementById(imgName).src="http://www.apply4u.co.uk/images/user-on_d64x64.png";
		        }
		        if(document.getElementById(dvName))
		            document.getElementById(dvName).style.display='inline';
		} 
		else
		{
		        var dvName = 'Div' + (i+1);
		        var imgName = 'Img_' + (i+1);
		        if (window.location.href.toLowerCase().indexOf('candidate') == -1)
		        {   
		            if(document.getElementById(imgName))   
		                document.getElementById(imgName).src="http://www.apply4u.co.uk/images/user-busy_64x64.png";
		        }
		        if(document.getElementById(dvName))
		            document.getElementById(dvName).style.display='none';   
		}
		
		
		imageDivWidth = posY*1.6;
		imageDivZIndex = Math.round(imageDivWidth)+100;
		
		imageDivsStyle.width = imageDivWidth+'px';
		imageDivsStyle.zIndex = imageDivZIndex;
		
		angle += speed1;
	}
	
	if(bob1==0){
		count1++;
		if(extra1>0){
			count1 = count1 + extra1;
		}	
	}else{
		if(bob1==1){
			count1--;
			if(extra1>0){
				count1 = count1-extra1;
			}	
		}	
	}

}
}