//////////////////////////////////////////////////////
//
//	The purpose of this file is to
//	apply a hover class on mouseover
//	on the <li> elements in the nav.
//	This is because IE doesn't put
//	the pseudo class :hover on <li> elements
//
//	This is code that uses the
//	jquery javascript library (http://jquery.com/)
//
//////////////////////////////////////////////////////
$(document).ready(function(){
   $('#rotImage').each(function(){
 this.src = 'cmsimages/landingpg_img0' + (Math.floor(Math.random()*3) + 1) + '.jpg';
 });
 });
$(window).load(function() {
	if (document.all&&document.getElementById) {
		// this is needed for the IE 6 pseudo hover class bug
		$(".navtop li").hover(function () {
			$(this).addClass("hover");
		},function () {
			$(this).removeClass("hover");
		});
	} else {
		// this is need for safari when nav covers flash
		$(".navtop li ul").hover(function () {
			$(this).addClass("redraw");
		},function () {
			$(this).removeClass("redraw");
		});
	}
	
	if (document.all&&document.getElementById) {
		// this is needed for the IE 6 pseudo hover class bug
		$(".navsub li").hover(function () {
			$(this).addClass("hover");
		},function () {
			$(this).removeClass("hover");
		});
	} else {
		// this is need for safari when nav covers flash
		$(".navsub li ul").hover(function () {
			$(this).addClass("redraw");
		},function () {
			$(this).removeClass("redraw");
		});
	}
	
	//FAQ Q & A toggle
	$('.QA .Q').toggle(function(){
		$(this).addClass("open");
		$($(this).siblings(".A")[0]).addClass("open");
	},
	function(){
		$(this).removeClass("open");
		$($(this).siblings(".A")[0]).removeClass("open");
	});
	
	//Overview Box
	$('.overview_box').each(function(){
		
		var curr = 0;
		var max = 0;
		var boxContent = $(this).children('.box_content')[0];
		var contentArray = $(boxContent).children('div');
		max = contentArray.length - 1;
		
		$(contentArray[0]).show();
		
		var boxTop = $(this).children('.box_top')[0];
		
		var navigation = $(boxTop).children('.navigation')[0];
		var prev = $(navigation).children('.prev')[0];
		var next = $(navigation).children('.next')[0];
		
		$(prev).click(function(){
			
			$(contentArray[curr]).hide();
			if(curr == 0)	
				curr = max;
			else
				curr = curr - 1;
			
			$(contentArray[curr]).show();
			return false;
		});
		
		$(next).click(function(){
			
			$(contentArray[curr]).hide();
			curr = (curr + 1) % (max + 1);
			$(contentArray[curr]).show();
			return false;
		});
	});
});
