﻿/// <reference path="jquery-1.4.2.min.js" />



$(document).ready(function () {
	slideImage('#fpSlide');
	insertNavImgs();


	$('#txtzip').keydown(function (e) {
		if (e.which == 13) {
			checkZip();
			return false;
		}
		else {
			return true;
		}
	});

	$('.faqQuestion span').hover(function () { $(this).addClass('faqQuestionHover') }, function () { $(this).removeClass('faqQuestionHover') });

});

function checkZip() {
	window.location = "book-online?zip=" + $('#txtzip').val();
}

function insertNavImgs() {
	$('#topnavigation a').each(function () {
		if ($(this).html() == 'Home') { $(this).html('<img src="/images/btn-home.gif" onmouseover="blink(this)" />'); }
		if ($(this).html() == 'About Us') {
			$(this).html('<img src="/images/btn-about-us.gif" onmouseover="blink(this)" />');
			$(this).addClass('menuanchorclass').attr('rel', 'about');
		}
		if ($(this).html() == 'Book Online') {
		    $(this).html('<img src="/images/btn-order-service.gif" onmouseover="blink(this)" />');
			$(this).addClass('menuanchorclass').attr('rel', 'bookonline');
		}
		if ($(this).html() == 'Franchising') {
			$(this).html('<img src="/images/btn-franchising.gif" onmouseover="blink(this)" />');
			$(this).addClass('menuanchorclass').attr('rel', 'franchise');
		}
		if ($(this).html() == 'Services') {
			$(this).html('<img src="/images/btn-services.gif" onmouseover="blink(this)" />');
			$(this).addClass('menuanchorclass').attr('rel', 'services');
		}
		if ($(this).html() == 'How We Price') { $(this).html('<img src="/images/btn-how-we-price.gif" onmouseover="blink(this)" />'); }
		if ($(this).html() == 'FAQ') { $(this).html('<img src="/images/btn-faqs.gif" onmouseover="blink(this)" />'); }
		if ($(this).html() == 'Contact Us') { $(this).html('<img src="/images/btn-contact.gif" onmouseover="blink(this)" />'); }
	});
}

function blink(obj) { $(obj).fadeTo('fast', .5).fadeTo('fast', 1); }

function slideImage(target) {
	setInterval(function () {
		$(target + ' img:visible').fadeOut(
            function () {
            	if ($(this).hasClass('lastImg')) { $(target + ' .firstImg').fadeIn(); }
            	else { $(this).next().fadeIn(); }
            }
        );
	}, 12000);
}



