$(document).ready(function(){

	var stopAnimation=false;


  // home page banner
 var bannerInterval=0;


var curIndex=1;
  var numImages=$("#slideshow .hideImage").length;

$("#slideshow .hideImage").css("visibility","visible");
$("#slideshow .hideImage").hide();
$("#slideshow .hideImage:first").fadeIn(1000);

if(curIndex==2){
	$(".home .menubanner .rcol .testBox:first").removeClass("homeOn3");
	$(".home .menubanner .rcol .testBox:first").addClass("homeOn3");
} else {
$(".home .menubanner .rcol .testBox:first").removeClass("homeOn");
$(".home .menubanner .rcol .testBox:first").addClass("homeOn");
$(".home .menubanner .rcol .testBox:nth-child(2)").addClass("homeOn2");
}

rotateBanner = function(){

	if(curIndex==1){$(".home .menubanner .rcol .testBox:nth-child("+curIndex+")").removeClass("homeOn");$(".home .menubanner .rcol .testBox:nth-child(2)").removeClass("homeOn2");}else{$(".home .menubanner .rcol .testBox:nth-child("+curIndex+")").removeClass("homeOn");}

	if(curIndex==2){$(".home .menubanner .rcol .testBox:nth-child("+curIndex+")").removeClass("homeOn3");$(".home .menubanner .rcol .testBox:nth-child(1)").removeClass("homeOn4");}else{$(".home .menubanner .rcol .testBox:nth-child("+curIndex+")").removeClass("homeOn");}
// $(".home .menubanner .rcol .testBox:nth-child("+curIndex+")").addClass("homeOn");
   
	 curIndex++;
    if (curIndex>4) {curIndex=1;}

		if(curIndex==1){	$(".home .menubanner .rcol .testBox:nth-child("+curIndex+")").addClass("homeOn");$(".home .menubanner .rcol .testBox:nth-child(2)").addClass("homeOn2");
		} 
		else if(curIndex != 2){
		$(".home .menubanner .rcol .testBox:nth-child("+curIndex+")").addClass("homeOn");
		}else{

		}
		
		if(curIndex==2){	$(".home .menubanner .rcol .testBox:nth-child("+curIndex+")").addClass("homeOn3");$(".home .menubanner .rcol .testBox:nth-child(1)").addClass("homeOn4");
		
		} else {
		$(".home .menubanner .rcol .testBox:nth-child("+curIndex+")").addClass("homeOn");
		}
    //$(".home .menubanner .rcol .testBox:nth-child("+curIndex+")").removeClass("homeOn");
		//$(".home .menubanner .rcol .testBox:nth-child("+curIndex+")").addClass("homeOn");
 
    

  $("#slideshow .hideImage:nth-child(2)").fadeIn(1000,function(){
    var firstImg = $("#slideshow .hideImage:first");
    $("#slideshow .hideImage:first").hide();
    $("#slideshow .hideImage:last").after(firstImg);


  });

}


  bannerInterval = setInterval("rotateBanner()",3000);

	function stopIT(){clearInterval(bannerInterval);}


$(".homeLink").hover(
    function(){
			stopAnimation=true;// mouse in
      $('.homeBox').attr('class', 'box homeBox testBox homeOn');
			$('.top').attr('class', 'box top testBox homeOn2');
			$('.middle').attr('class', 'box middle testBox');
			$('.bottom').attr('class', 'box bottom testBox');
			stopIT();
    },
    function(){
			stopAnimation=false;// mouse out
      $('.homeBox').attr('class', 'box testBox homeBox');
			$('.top').attr('class', 'box top testBox');
			$('.middle').attr('class', 'box middle testBox');
			$('.bottom').attr('class', 'box bottom testBox');
			bannerInterval = setInterval("rotateBanner()",3000);

    }
  );

	$(".businessLink").hover(
    function(){
			stopAnimation=true;// mouse in
      $('.top').attr('class', 'box top testBox homeOn3');
			 $('.homeBox').attr('class', 'box homeBox testBox homeOn4');
			 $('.middle').attr('class', 'box middle testBox');
			$('.bottom').attr('class', 'box bottom testBox');
			  stopIT();

    },
    function(){
			stopAnimation=false;// mouse out
      $('.top').attr('class', 'box top testBox');
			$('.homeBox').attr('class', 'box testBox homeBox');
			$('.middle').attr('class', 'box middle testBox');
			$('.bottom').attr('class', 'box bottom testBox');
    bannerInterval = setInterval("rotateBanner()",3000);
 }
  );


		$(".officeBox").hover(
    function(){
			stopAnimation=true;// mouse in
      $('.middle').attr('class', 'box middle homeOn');
			$('.top').attr('class', 'box top testBox');
			$('.homeBox').attr('class', 'box testBox homeBox');
			$('.bottom').attr('class', 'box bottom testBox');
stopIT();
    },
    function(){
			stopAnimation=false;// mouse out
      $('.middle').attr('class', 'box middle testBox');
			$('.top').attr('class', 'box top testBox');
			$('.homeBox').attr('class', 'box testBox homeBox');
			$('.bottom').attr('class', 'box bottom testBox');
     bannerInterval = setInterval("rotateBanner()",3000);
	}
  );



	$(".disasterBox").hover(
    function(){
			stopAnimation=true;// mouse in
      $('.bottom').attr('class', 'box bottom homeOn');
			$('.middle').attr('class', 'box middle testBox');
			$('.top').attr('class', 'box top testBox');
			$('.homeBox').attr('class', 'box testBox homeBox');
			stopIT();

    },
    function(){
			stopAnimation=false;// mouse out
      $('.bottom').attr('class', 'box bottom testBox');
			$('.middle').attr('class', 'box middle testBox');
			$('.top').attr('class', 'box top testBox');
			$('.homeBox').attr('class', 'box testBox homeBox');
			 bannerInterval = setInterval("rotateBanner()",3000);
    }
  );




$(".homeLink").hover(
function(){
	stopAnimation=true;
$("#slideshow .hideImage").css("visibility","hidden");
$("#fixedImage .one").css("visibility","visible");
  $("#fixedImage .one").hide();
  $("#fixedImage .one:first").show();

},
function(){ // mouse in
	stopAnimation=false;
	$("#slideshow .hideImage").css("visibility","visible");
	$("#fixedImage .one").css("display","none");

}

)


$(".businessLink").hover(
function(){
	stopAnimation=true;
$("#slideshow .hideImage").css("visibility","hidden");
$("#fixedImage .two").css("visibility","visible");
  $("#fixedImage .two").hide();
  $("#fixedImage .two:first").show();

},
function(){ // mouse in
	stopAnimation=false;
	$("#slideshow .hideImage").css("visibility","visible");
	$("#fixedImage .two").css("display","none");

}

)



$(".officeBox").hover(
function(){
	stopAnimation=true;
$("#slideshow .hideImage").css("visibility","hidden");
$("#fixedImage .three").css("visibility","visible");
  $("#fixedImage .three").hide();
  $("#fixedImage .three:first").show();

},
function(){ // mouse in
	stopAnimation=false;
	$("#slideshow .hideImage").css("visibility","visible");
	$("#fixedImage .three").css("display","none");

}

)

$(".disasterBox").hover(
function(){
	stopAnimation=true;
$("#slideshow .hideImage").css("visibility","hidden");
$("#fixedImage .four").css("visibility","visible");
  $("#fixedImage .four").hide();
  $("#fixedImage .four:first").show();

},
function(){ // mouse in
	stopAnimation=false;
	$("#slideshow .hideImage").css("visibility","visible");
	$("#fixedImage .four").css("display","none");

}

)

function testimonialRotate(){
  // home page banner
 var testimonialInterval=0;


  $(".hiddenTestimonial").css("visibility","visible");
  $(".hiddenTestimonial").hide();
 
	
 $(".hiddenTestimonial:first").fadeIn(1000);


  rotateTestimonial = function(){
    $(".hiddenTestimonial:nth-child(2)").fadeIn(1000,function(){
      var firstImg = $(".hiddenTestimonial:first");
			 
      $(".hiddenTestimonial:first").hide();
      $(".hiddenTestimonial:last").after(firstImg);
    });$(".hiddenTestimonial:first").fadeOut(500);
  }

 testimonialInterval = setInterval("rotateTestimonial()",8000);
}

testimonialRotate()
});
