var carouselChangevar = 1;
var carouselM;
var carouselImgall = 0;

function carouselPick(content){
	carouselChangevar = content;
	i = 1;
	
	while(i <= carouselImgall){
		$("#flashDesc"+ i).css("display", "none");
		$("#flashImg"+ i).css("display", "none");
		$("#flashBt"+ i).removeClass('selected');
		
		i++;
	}
	
	$("#flashDesc"+ carouselChangevar).fadeIn("slow");
	$("#flashImg"+ carouselChangevar).fadeIn("slow");
	$("#flashBt"+ carouselChangevar).addClass('selected');
	
	carouselChangevar++;
	
	if(carouselChangevar > carouselImgall){ carouselChangevar = 1; }
}

function carouselChange(){
	carouselPick(carouselChangevar);
	
	carouselM = setTimeout("carouselChange();",5000);
}

function carouselLoadme(total){
	carouselImgall = total;
	i = 1;
	
	while(i <= carouselImgall){
		initClicks(i);
		
		i++;
	}
	
	carouselChange();
}

function initClicks(m){
	$('#flashBt'+ m).click(function() {
		var mm = m;
		
		carouselPick(mm);
	});
}

function checkForm(){
	var err = 0;
	
	if($("#contactName").val() == "") err++;
	if($("#contactEmail").val() == "") err++;
	if($("#contactSubject").val() == "") err++;
	if($("#contactMessage").val() == "") err++;
	
	if(err > 0){
		alert("Please fill in the required fields. Thank you!");
		
		return false;
	}else{
		return true;
	}
}

