// Showme
var stopflag = 0;
var oldmenu = '';
var dnav = '';

function showme(ID){
	stopnoshow('');
	if (oldmenu != ''){
		document.getElementById(oldmenu).style.display='none';
		//$(oldmenu+'_nav').removeClassName('hov');
	}
	
	document.getElementById(ID).style.display='block';
	
	// oldmenu = ID;
}


function startnoshow(ID){
	stopflag = 1;
	oldmenu = ID;
	setTimeout("noshow()",'500');
}

function noshow(){
	if (stopflag == 1){
		if (oldmenu != ''){
			document.getElementById(oldmenu).style.display='none';
			//document.getElementById(oldmenu+'_nav').removeClassName('hov');
		}
		oldmenu = '';
		stopflag = 0;
		if (dnav != ''){
			showme(dnav);
		}
	}
}

function stopnoshow(){
	stopflag = 0;
}



$(document).ready(function() {

	$('.fancybox').fancybox({ padding:'6px' });

	$('#feature_slideshow').cycle({
		fx: 		"fade", 
		timeout:    3000,
 		next: 		".feature_next", 
		prev: 		".feature_prev"
	});
	
	$('#home_slideshow').cycle({
		fx: 		"fade", 
		timeout:    5000,
 		next: 		".feature_next", 
		prev: 		".feature_prev"
	});
	
	$('#area_slideshow').cycle({
		fx: 		"fade", 
		timeout:    5000,
 		next: 		".feature_next", 
		prev: 		".feature_prev"
	});


	// --------------------------------------------------------------------------------------------
	// Form Elements
	// --------------------------------------------------------------------------------------------
	// Turn on labels if field is empty on page load
	$('.input-contain input').each(function() {
		if($(this).val().length == 0) {
			$(this).parent('div').children('label').css('color','#99906b');
		}
	});

	// Textareas + Inputs
	// On focus, dim label
	$('.input-contain input').bind('focusin', function() {
		if($(this).val().length == 0) {
			$(this).parent('div').children('label').css('color', '#cbbf8f');
		}
	});
	// On focusout check to see if empty
	// If empty restore label
	$('.input-contain input').bind('focusout', function() {
		if($(this).val().length == 0) {
			$(this).parent('div').children('label').css('color', '#99906b');
		}
	});
	// On keypress, check to see if empty
	// If not empty clear the label
	$('.input-contain input').bind('keyup', function() {
		if($(this).val().length > 0) {
			$(this).parent('div').children('label').css('color', '#FFF6D4');
		} else {
			$(this).parent('div').children('label').css('color', '#cbbf8f');
		}
	});
	
	// $('#enews-signup form').submit(function() {
	// 	var email_address = $('.input-contain #email').val();
	// 	$.ajax({
	// 		url: $('#enews-signup form').attr('action'),
	// 		type: 'POST',
	// 		data: { email: email_address },
	// 		dataType: 'json',
	// 		success: function(data) {
	// 			console.log(data);
	// 		}
	// 	});
	// 	return false;
	// });


	// $('input[type=checkbox]').prettyCheckboxes();	

});


