/* main page video box (domestic & intl)
===================================================================== */
var CurPage = 0;
var PrvPage = 2;
var Lock = false;
var intPage=1;
function Blur( lnk ) {
	try {
		lnk.blur();
	} catch(e) {};
}
/*
 * Next() and Prev()
 * are called from previous and next buttons
 */
function Next(lnk,pause) {
	Blur( lnk );
			stop = false;
		 StopStartRotate(pause)
	
	if(!Lock) {
		SlideLeft();
	}
}

function Prev(lnk,pause) {
	Blur( lnk );
			stop = false;
		StopStartRotate(pause)
	
	if(!Lock) {
		SlideRight();
	}
}

/*
 * Page( intPage )
 * called from clicking on gray dot icon
 */

function Page(intt,lnk,pause) {
	
	Blur( lnk );
	if (pause != null)
	{	stop = false;
		StopStartRotate(pause)
	}
	if((CurPage != intt)&&(!Lock)) {
		
		
		if(CurPage < intt) {
						
			if((intt - CurPage) > 1) {
				PrvPage = intPage;
				intPage = intt;
				SlideDoubleLeft();
				
			}
			else {

				intPage = intt;
				SlideLeft();
			}

			
		}
		else {
			
			if((CurPage - intt) > 1) {
	
				intPage = intt;
				SlideLeft();
			}
			else {
				
				
				SlideRight();
			}
			
		}
		
	}
	
}



function MouseOver( id ) {
	for(i=0;i<3;i++) {
	$(id).src = '/bluelinks-for-employers/images/index/toggle/New Folder/toggle-btn-'+i+'-over.png';
	}
}

function Locker( intDur ) {
	var LockerTime = intDur * 100;
	Lock = true;
	setTimeout(function() { Lock = false; },LockerTime);
}


function SlideLeft() {
	Locker(3);
	new Effect.MoveBy( 'mainGraphic'+CurPage, 0, -970 , {duration: 0.5} );
	new Effect.MoveBy( 'mainGraphic'+intPage, 0, -970 , {duration: 0.5} );
	var PrvPageObj = document.getElementById('mainGraphic'+PrvPage);
	PrvPageObj.style.left = '970px';
	//new Effect.MoveBy( 'mainGraphic2', 0, -970 , {duration: 0.5} );
	intPage = PrvPage;
	PrvPage = CurPage;
	if (CurPage == 2)
	{
		CurPage = 0;
	}else{
		CurPage++;
	}
	//alert('1int:'+intPage+'   prv:'+PrvPage+'    cur:'+CurPage);
	MoveDot();
	UpdateBtns();
}

function SlideDoubleLeft() {
	
	//alert('int:'+intPage+'   prv:'+PrvPage+'    cur:'+CurPage);
	var PrvPageObj = document.getElementById('mainGraphic'+PrvPage);
	PrvPageObj.style.left = '-970px';
	var intPageObj = document.getElementById('mainGraphic'+intPage);
	intPageObj.style.left = '970px';
	var curPageObj = document.getElementById('mainGraphic'+CurPage);
	curPageObj.style.left = '970px';
	//new Effect.MoveBy( 'mainGraphic'+CurPage, 0, -970 , {duration: 0.5} );
	new Effect.MoveBy( 'mainGraphic'+intPage, 0, -970 , {duration: 0.5} );
	//var curPageObj = document.getElementById('mainGraphic'+CurPage);
	//curPageObj.style.left = '970px';
	swap = CurPage;
	CurPage = intPage;
	intPage = swap;
	
	
	MoveDot();
	UpdateBtns();
	
}

function SlideRight() {
	Locker(3);

	new Effect.MoveBy( 'mainGraphic'+CurPage, 0, 970 , {duration: 0.5} );
	new Effect.MoveBy( 'mainGraphic'+PrvPage, 0, 970 , {duration: 0.5} );
	var intPageObj = document.getElementById('mainGraphic'+intPage);
	intPageObj.style.left = '-970px';
	//new Effect.MoveBy( 'mainGraphic2', 0, -970 , {duration: 0.5} );
	PrvPage = intPage;
	intPage = CurPage;
	if (CurPage == 0)
	{
		CurPage = 2;
	}else{
		CurPage--;
	}
	
	MoveDot();
	UpdateBtns();
}

function SlideDoubleRight() {
	Locker(6);
	new Effect.MoveBy( 'mainGraphic0', 0, 1940 , {duration: 0.5} );
	new Effect.MoveBy( 'mainGraphic1', 0, 1940 , {duration: 0.5} );
	new Effect.MoveBy( 'mainGraphic2', 0, 1940 , {duration: 0.5} );
	CurPage--;
	CurPage--;
	MoveDot();
	UpdateBtns();
}

// image change functions
function MoveDot() {
	for(i=0;i<3;i++) {
		$('Btn'+i).src = '/bluelinks-for-employers/images/index/toggle/New Folder/toggle-btn-'+i+'.png';
		
	}
	$('Btn'+CurPage).src = '/bluelinks-for-employers/images/index/toggle/New Folder/toggle-btn-'+CurPage+'-over.png';
	$('Btn'+CurPage).onmouseover = function() {}
	$('Btn'+CurPage).onmouseout = function() {}
}
function UpdateBtns() {
	if(CurPage > 0) {
		$('BtnL').style.cursor ='auto';
		$('BtnL').src = '/bluelinks-for-employers/images/index/toggle/rewind.png';
		$('BtnL').onmouseover = function() { this.src='/bluelinks-for-employers/images/index/toggle/rewind.png'; }
		$('BtnL').onmouseout = function() { this.src='/bluelinks-for-employers/images/index/toggle/rewind.png'; }
	}
	else {
		$('BtnL').style.cursor ='default';
		$('BtnL').src = '/bluelinks-for-employers/images/index/toggle/rewind.png';
		$('BtnL').onmouseover = function() {}
		$('BtnL').onmouseout = function() {}
	}

	if(CurPage < 2) {
		$('BtnR').style.cursor ='auto';
		$('BtnR').src = '/bluelinks-for-employers/images/index/toggle/forward.png';
		$('BtnR').onmouseover = function() {this.src = '/bluelinks-for-employers/images/index/toggle/forward.png';}
		$('BtnR').onmouseout = function() {this.src = '/bluelinks-for-employers/images/index/toggle/forward.png';}
	}
	else {
		$('BtnR').style.cursor ='default';
		$('BtnR').src = '/bluelinks-for-employers/images/index/toggle/forward.png';
		$('BtnR').onmouseover = function() {}
		$('BtnR').onmouseout = function() {}
	}
}
/* end main page video box
===================================================================== */


var secs
var timerID = null
var timerRunning = false
var delay = 1000
var imgId = 1
var stop = false 

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 8
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
		
        var aId = 'toggleBtn-a-id-'+imgId;
		var aObj = document.getElementById(aId);
		Pager(imgId,aObj);
		imgId = imgId + 1;
		if(imgId == 3){
			imgId = 0;
			}
			if (stop == false)
			{
				InitializeTimer()
			}
			
    }
    else
    {
        //self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}

function Pager(intt,lnk,pause) {
	intPage = intt;
	Blur( lnk );
	if (pause != null)
	{	stop = false;
		StopStartRotate(pause)
	}
	if((CurPage != intPage)&&(!Lock)) {
		SlideLeft();
	}
	
}

function StopStartRotate(id) {
	var Obj = document.getElementById(id);
	if (stop == false)
	{
		stop = true;
		Obj.src = '/bluelinks-for-employers/images/index/toggle/play.png';
		secs = 999;
	}else {
		stop = false;
		Obj.src = '/bluelinks-for-employers/images/index/toggle/pause.png';
		secs = 0;
		imgId=intPage;
		StartTheTimer()
	}
}