// JavaScript Document

var imgCt = 1;

function setImgs() {
	$("#homeBanner .bannerImg img").each(function () {
		$(this).addClass('homeImg' + imgCt);
		imgCt++;
	});
	$("#homeBanner .bannerImg img").each(function () {
		if($(this).hasClass('homeImg1') != true) {
			$(this).hide();
		}
		else {
			$(this).show();
		}
	});
	imgRotator();
}

var imgCtNew = 0;

function imgRotator() {
	imgCtNew++;
	totalimgs = $("#homeBanner .bannerImg img").length;
	
	if(imgCtNew > totalimgs) {
		imgCtNew = 1;
	}
	$("img.homeImg" + imgCtNew).fadeIn(1000);
	setTimeout('fadeSlide(imgCtNew);', 3000);
}

function fadeSlide(imgCtNew) {
	$("img.homeImg" + imgCtNew).fadeOut(1000, imgRotator);
}

$(document).ready(function(){
	makeGlobalActive();
	setDropDown();
	if($('#propFeatures').length > 0) {
		var feature1Height = $('.features1').height();
		var feature2Height = $('.features2').height();
		if(feature1Height > feature2Height) {
			$('.features2').css({height: feature1Height});
		}
		else {
			$('.features1').css({height: feature2Height});
		}
	}


	/*$("#navmenu li").mouseover(function () {
		if(this.className != "") {
		currentLI = this.className;
		var parentWidth = $(this).width();
		$(this).children('ul').css({'width': parentWidth});
		$(this).children('ul a').css({'width': parentWidth});
		}
	});*/
});

function makeGlobalActive(){
	var path = window.location.pathname;
	path = path.replace('.php','')
	pathArray = path.split( '/' );
	pathArray = pathArray.reverse();
	if(pathArray.length > 2) {
		thisSection = pathArray[1];
		
		$("#navmenu li a").each(function () {
			navLink = this.href;
			if(navLink.indexOf(thisSection) != '-1') {
				$(this).addClass('active');
			}
		});
	}
	if(pathArray.length > 3) {
		thisSection = pathArray[2];
		
		$("#navmenu li a").each(function () {
			navLink = this.href;
			if(navLink.indexOf(thisSection) != '-1') {
				$(this).addClass('active');
			}
		});
	}
}

function setDropDown() {
	$("#navmenu li ul").each(function () {
		var parentWidth = $(this).parent('li').width();
		//$(this).css({'width': parentWidth});
		$(this).children('li').css({'width': parentWidth + 20});
		$(this).children('a').css({'width': parentWidth});
	});

}

