var IE = /*@cc_on!@*/false;
var r_frame = 1;
var which = 1;
var r_timeout	= 4000; // milliseconds
var f_timer	= null;
var r_timer = null;
var f_out_step = 1 / 500 * 10;
var in_opacity = 0;
var out_opacity = 1;
var rot_page = null;
var r_first = true;

var lag_timer = null;
var rot_lag_timer = null;
var lag_timeout = 250;
var rot_lag_timeout = 250;

var DivRotatorIframe = null;
var tempIframe = null;

if (IE)
{ var f_in_step = 0.10; var f_interval = 50;}
else
{ var f_in_step = 0.02; var f_interval = 10;}	

// SHOW A PAGE
// First Delay
function rot_show(which)
{
rot_canceltimer();
// Kill any existing lag timer	
if (lag_timer){
lag_timer = window.clearTimeout(lag_timer);
lag_timer = null;
}

// Kill any existing rot_lag timer	
if (rot_lag_timer){
rot_lag_timer = window.clearTimeout(rot_lag_timer);
rot_lag_timer = null;
}

// Now show the page after a lag
lag_timer = window.setTimeout(function(){rot_show_delayed(which)}, lag_timeout);
} // End rot_show

function rot_show_delayed(which)
{
r_frame = which;	
if (r_frame < 1) { r_frame = 1 }
if (r_frame > 6) { r_frame = 1 }

rot_alloff();

if (r_frame==1) {
document.images["rbut1"].src = "/images/homepage/rbut1_on.gif";
// Eliminate IE click sound
DivRotatorIframe = document.getElementById ('DIViframe2');
rot_page = document.getElementById('iframe2');
tempIframe = rot_page.cloneNode(true);
tempIframe.src = '/iframe/rbut1.htm';
DivRotatorIframe.replaceChild(tempIframe, rot_page);
//parent.iframe2.location.href='/iframe/rbut1.htm';
cancel_f_timer(0);
fade_in();
}

if (r_frame==2) {
document.images["rbut2"].src = "/images/homepage/rbut2_on.gif";
// Eliminate IE click sound
DivRotatorIframe = document.getElementById ('DIViframe2');
rot_page = document.getElementById('iframe2');
tempIframe = rot_page.cloneNode(true);
tempIframe.src = '/iframe/rbut2.htm';
DivRotatorIframe.replaceChild(tempIframe, rot_page);
//parent.iframe2.location.href='/iframe/rbut2.htm';
cancel_f_timer(0);
fade_in();
}

if (r_frame==3) {
document.images["rbut3"].src = "/images/homepage/rbut3_on.gif";
// Eliminate IE click sound
DivRotatorIframe = document.getElementById ('DIViframe2');
rot_page = document.getElementById('iframe2');
tempIframe = rot_page.cloneNode(true);
tempIframe.src = '/iframe/rbut3.htm';
DivRotatorIframe.replaceChild(tempIframe, rot_page);
//parent.iframe2.location.href='/iframe/rbut3.htm';
cancel_f_timer(0);
fade_in();
}

if (r_frame==4) {
document.images["rbut4"].src = "/images/homepage/rbut4_on.gif";
// Eliminate IE click sound
DivRotatorIframe = document.getElementById ('DIViframe2');
rot_page = document.getElementById('iframe2');
tempIframe = rot_page.cloneNode(true);
tempIframe.src = '/iframe/rbut4.htm';
DivRotatorIframe.replaceChild(tempIframe, rot_page);
//parent.iframe2.location.href='/iframe/rbut4.htm';
cancel_f_timer(0);
fade_in();
}

if (r_frame==5) {
document.images["rbut5"].src = "/images/homepage/rbut5_on.gif";
// Eliminate IE click sound
DivRotatorIframe = document.getElementById ('DIViframe2');
rot_page = document.getElementById('iframe2');
tempIframe = rot_page.cloneNode(true);
tempIframe.src = '/iframe/rbut5.htm';
DivRotatorIframe.replaceChild(tempIframe, rot_page);
//parent.iframe2.location.href='/iframe/rbut5.htm';
cancel_f_timer(0);
fade_in();
}

if (r_frame==6) {
document.images["rbut6"].src = "/images/homepage/rbut6_on.gif";
// Eliminate IE click sound
DivRotatorIframe = document.getElementById ('DIViframe2');
rot_page = document.getElementById('iframe2');
tempIframe = rot_page.cloneNode(true);
tempIframe.src = '/iframe/rbut6.htm';
DivRotatorIframe.replaceChild(tempIframe, rot_page);
//parent.iframe2.location.href='/iframe/rbut6.htm';
cancel_f_timer(0);
fade_in();
}

}

// SET ALL BUTTONS TO "OFF"
function rot_alloff()
{
document.images["rbut1"].src = "/images/homepage/rbut1_off.gif";
document.images["rbut2"].src = "/images/homepage/rbut2_off.gif";
document.images["rbut3"].src = "/images/homepage/rbut3_off.gif";
document.images["rbut4"].src = "/images/homepage/rbut4_off.gif";
document.images["rbut5"].src = "/images/homepage/rbut5_off.gif";
document.images["rbut6"].src = "/images/homepage/rbut6_off.gif";
}	


// FADE IN THE IFRAME
function fade_in()
{
if (in_opacity >= 0.99)
{
in_opacity = 50;
rot_page = document.getElementById('iframe2');

// Needed for IE because the filter attribute leaves text deteriorated, not ClearType
if (IE && rot_page.style.filter)
{
rot_page.style.removeAttribute('filter');
}

cancel_f_timer(1);
return;
} // if in_opacity >= 0.99

in_opacity = in_opacity + f_in_step

rot_page = document.getElementById('iframe2');
rot_page.style.opacity = in_opacity;
rot_page.style.filter = "alpha(opacity=" + 100*in_opacity + ")";

f_timer = window.clearTimeout(f_timer);
f_timer = window.setTimeout(fade_in, f_interval);
}	


// START ROTATION
function rot_start(which)
{
// Kill any existing rotation	
if(r_timer)
	{
		r_timer = window.clearTimeout(r_timer);
		r_timer = null;
	}
// Delay before starting the rotation
rot_lag_timer = window.setTimeout(function(){rot_start_delayed(which)}, rot_lag_timeout);	
} // End rot_start

function rot_start_delayed(which)
{
rot_alloff();

r_frame = which;
if (r_frame > 6) r_frame = 1;

if (r_frame==1) {
document.images["rbut1"].src = "/images/homepage/rbut1_on.gif";
// Eliminate IE click sound
DivRotatorIframe = document.getElementById ('DIViframe2');
rot_page = document.getElementById('iframe2');
tempIframe = rot_page.cloneNode(true);
tempIframe.src = '/iframe/rbut1.htm';
DivRotatorIframe.replaceChild(tempIframe, rot_page);
//parent.iframe2.location.href='/iframe/rbut1.htm';
}

if (r_frame==2) {
document.images["rbut2"].src = "/images/homepage/rbut2_on.gif";
// Eliminate IE click sound
DivRotatorIframe = document.getElementById ('DIViframe2');
rot_page = document.getElementById('iframe2');
tempIframe = rot_page.cloneNode(true);
tempIframe.src = '/iframe/rbut2.htm';
DivRotatorIframe.replaceChild(tempIframe, rot_page);
//parent.iframe2.location.href='/iframe/rbut2.htm';
}

if (r_frame==3) {
document.images["rbut3"].src = "/images/homepage/rbut3_on.gif"
// Eliminate IE click sound
DivRotatorIframe = document.getElementById ('DIViframe2');
rot_page = document.getElementById('iframe2');
tempIframe = rot_page.cloneNode(true);
tempIframe.src = '/iframe/rbut3.htm';
DivRotatorIframe.replaceChild(tempIframe, rot_page);
//parent.iframe2.location.href='/iframe/rbut3.htm';
}

if (r_frame==4) {
document.images["rbut4"].src = "/images/homepage/rbut4_on.gif";
// Eliminate IE click sound
DivRotatorIframe = document.getElementById ('DIViframe2');
rot_page = document.getElementById('iframe2');
tempIframe = rot_page.cloneNode(true);
tempIframe.src = '/iframe/rbut4.htm';
DivRotatorIframe.replaceChild(tempIframe, rot_page);
//parent.iframe2.location.href='/iframe/rbut4.htm';
}

if (r_frame==5) {
document.images["rbut5"].src = "/images/homepage/rbut5_on.gif";
// Eliminate IE click sound
DivRotatorIframe = document.getElementById ('DIViframe2');
rot_page = document.getElementById('iframe2');
tempIframe = rot_page.cloneNode(true);
tempIframe.src = '/iframe/rbut5.htm';
DivRotatorIframe.replaceChild(tempIframe, rot_page);
//parent.iframe2.location.href='/iframe/rbut5.htm';
}

if (r_frame==6) {
document.images["rbut6"].src = "/images/homepage/rbut6_on.gif";
// Eliminate IE click sound
DivRotatorIframe = document.getElementById ('DIViframe2');
rot_page = document.getElementById('iframe2');
tempIframe = rot_page.cloneNode(true);
tempIframe.src = '/iframe/rbut6.htm';
DivRotatorIframe.replaceChild(tempIframe, rot_page);
//parent.iframe2.location.href='/iframe/rbut6.htm';
}

window.clearTimeout(r_timer);
r_timer = window.setTimeout(function(){rot_start_delayed(r_frame+1)}, r_timeout);
in_opacity = 0;
if (!r_first){ fade_in(); }
r_first = false;
} // End rot_start_delayed


// CANCEL ROTATION TIMER
function rot_canceltimer()
{
	
// alert('in rot_canceltimer');


// Kill any existing lag_timer	
if (lag_timer){
window.clearTimeout(lag_timer);
lag_timer = null;
}

// Kill any existing rot_lag_timer	
if (rot_lag_timer){
window.clearTimeout(rot_lag_timer);
rot_lag_timer = null;
}



	if(r_timer)
	{
		r_timer = window.clearTimeout(r_timer);
		r_timer = null;
		
// alert('r_timer = null');
		
	}

	r_first = true;
	cancel_f_timer(1);
}


// CANCEL FADE TIMER
function cancel_f_timer(opacity_value)
{
	if(f_timer)	{	window.clearTimeout(f_timer); f_timer = null; }
		in_opacity = 0;
		out_opacity = 1;
		rot_page = document.getElementById('iframe2');
    rot_page.style.opacity = opacity_value;
    
    // Needed for IE because the filter attribute leaves text deteriorated, not ClearType
    if (IE && rot_page.style.filter)
     {
      rot_page.style.removeAttribute('filter');
     }
    
//   rot_page.style.filter = "alpha(opacity=" + 100*opacity_value + ")";

}
