var mouseOver = false;
var buttonSubmit = false;
var scheduleLink = "http://www.aefactoryservice.com/ae_consumer/index.html?schedule=true";

$('#ajaxDiv').hover(
	function() { mouseOver = true; }, 
	function() { mouseOver = false; }
);
$('#checkzip').hover(
	function() {buttonSubmit = true; },
	function() {buttonSubmit = false; }
);

$('INPUT.auto-hint, TEXTAREA.auto-hint').focus(function(){
    if($(this).val() == $(this).attr('placeholder')){
        $(this).val('');
        $(this).removeClass('auto-hint');
		$('#ajaxDiv').hide('fast');
    }
});

$('INPUT.auto-hint, TEXTAREA.auto-hint').blur(function() {
	if(mouseOver) { 
		if(buttonSubmit) {
			buttonSubmit = true;
		}
		window.open(scheduleLink,'_top');
		return false;
	}
	if(buttonSubmit) {
		document.checkzipform.submit();
		buttonSubmit = false;
		mouseOver = false;
		return;
	}
	$('#chk_zip').val('');
    if($(this).val() == '' && $(this).attr('placeholder') != ''){
       $(this).val($(this).attr('placeholder'));
       $(this).addClass('auto-hint');
	}
	$('#chk_zip').attr('class','chk_zip');
	$('#ajaxDiv').delay(200).hide('fast');
});
$('INPUT.auto-hint, TEXTAREA.auto-hint').each(function(){
    if($(this).attr('placeholder') == ''){ return; }
    if($(this).val() == ''){ $(this).val($(this).attr('placeholder')); }
    else { $(this).removeClass('auto-hint'); }
});
$('#go_to_scheduler').click(function() {
		window.open(scheduleLink,'_top');
		mouseOver = false;
		return;
	});
