﻿var debug = true;
var log = function(str) {
	if (debug && typeof (console) != 'undefined') {
		console.log(str);
	}
}

$(window).load(function() {
	$("#home-rotator ul").cycle({
		fx: 'fade',
		speedIn: 1000,
		speedOut: 1000,
		delay: -2000,
		timeout: 6000
	});

	$("#specials ul").cycle({
		fx: 'fade',
		speed: 300,
		timeout: 0,
		delay: -2000,
		next: '#snext',
		prev: '#sprev'
	});

	$("#changer a").click(function() {
		var myText = $(this).text();

		var homeRotator = $("#home-rotator ul");
		homeRotator.cycle('stop');

		switch (myText) {
			case '2':
				homeRotator.cycle({
					fx: 'blindZ',
					speedIn: 100,
					speedOut: 3000,
					easeIn: 'bounceout',
					delay: -2000,
					timeout: 6000
				});

				break;
			case '3':
				homeRotator.cycle({
					fx: 'fadeZoom',
					speedIn: 1000,
					speedOut: 3000,
					easeIn: 'bounceout',
					delay: -2000,
					timeout: 6000
				});

				break;
			case '4':
				homeRotator.cycle({
					fx: 'wipe',
					speedIn: 1000,
					speedOut: 3000,
					easeIn: 'bounceout',
					delay: -2000,
					timeout: 6000
				});

				break;
			default:
				homeRotator.cycle({
					fx: 'scrollDown',
					speedIn: 1000,
					speedOut: 3000,
					easeIn: 'bounceout',
					delay: -2000,
					timeout: 6000
				});

				break;
		}

		return false;
	});

});

$(document).ready(function() {

	$("#page-login, #search, #newsletter").formLabel();

	// trackEvents on clicks of links.
	$("a").gaAddon({ trackInternal: true });

	// google translate effs up all the menus, need to do this to "fix" them.
	var href = window.location.href;
	if (href.indexOf('/translate_c?') != -1) {
		$("li > span").each(
			function() {
				if ($(this).attr("onmouseout") != 'undefined') {
					$(this).attr("style", "margin:0px;padding:0px;");
				}
			}
		);
		$("span.google-src-text").attr("style", "margin:0px;padding:0px;");
	}

	$("input.phone").mask("(999) 999-9999");
	$("input.zipcode").mask("99999");
	$("input.datepicker").datepicker();

	$("input[id$='btnSummaryNext']").click(function() {
		// if asp.net validation passed
		if (Page_IsValid) {
			$(this).clone().val('working...').insertAfter($(this)).attr("disabled", "true");
			$(this).hide();
		}
	});

	$("input[id$='btnRegInfoSubmit']").click(function() {
		// if asp.net validation passed
		if (Page_IsValid) {
			$(this).clone().val('working...').insertAfter($(this)).attr("disabled", "true");
			$(this).hide();
		}
	});
});
