         if (window != top) top.location.href = location.href;
		// Creating namespace for javascript events
		var americanFamilyInsurance = {};
		
		var menu_open = false;

		// Method for building clones of navigation to prevent duplicate content
		americanFamilyInsurance.buildNavigation = function()
		{
			
			
			$('ul > li#my-account > a').each(function()
			{
				$(this).wrapInner('<span></span>').clone().children('span').appendTo(this).addClass('clone').hide();
			});
			
			$("ul > li#my-account > a").hover(function() {
				
				//if(!menu_open) $(this).css('background-position', '0px -39px');
				if(!menu_open) $('#my-account a').addClass('my-account-modal-hover');
				
			}, function() {
				
				//if(!menu_open) $(this).css('background-position', '0px 9px');
				if(!menu_open) $('#my-account a').removeClass('my-account-modal-hover');
			});

			$('ul > li#my-account > a').click(function(event)
			{
				event.preventDefault();
				
				
				if($('#my-account-modal').is(':visible')) {
					
					//$(this).css('background-position', '0px 9px');
					//$(this).removeClass('my-account-modal-click');
					$('#my-account a').removeClass('my-account-modal-click');
					menu_open = false;
					
				} else {
					
					//$(this).css('background-position', '0px -78px');
					$(this).removeClass('my-account-modal-hover').addClass('my-account-modal-click');
					menu_open = true;
					
				}
				
				
				$(this).children('.clone').toggle();
				
			});
			
			
		}
		
			// Fix for IE8 alt text not showing
		function altForTitle(){
            // get all images
            var imgs=document.getElementsByTagName("img");
            for(i=0; i<imgs.length; i++){
                        // if img has alt tag and no title, use alt for title
                        if(imgs[i].alt.length>0 && imgs[i].title.length==0){
                                    imgs[i].title=imgs[i].alt;         
                        }
            }
}
if(window.addEventListener){
            window.addEventListener("load", altForTitle); } else if(window.attachEvent){
            window.attachEvent("onload", altForTitle); }


		
		// Method to handle wrapper footer nav
		americanFamilyInsurance.wrapperFooterNav = function()
		{
			// Setting footer nav height on page load
			$("#nav_footer").css('height', 51);

			// Listening to hover over and out events on footer nav
			$("#nav_footer").hover(function()
			{
				// On Hover
				$(this).stop().animate({height:202}, 500);
			},
			function()
			{ 
				// On Out
				$(this).stop().animate({height:51}, 500);
			});
		}

		// Method to handle modal window
		americanFamilyInsurance.modalWindow = function()
		{
			var hovered = 0;
		
			// Set opactiy to 0 on load
			$('#my-account-modal').animate({opacity: 0, height: 0}, 0);
			$('#my-account-modal').hide();

			// Show modal window on click of navigation
			$("#my-account a").click(function(event)
			{
				// Prevent link from adding hash to URL
				event.preventDefault();

				// If modal is hidden
				if(parseInt($('#my-account-modal').css('opacity')) === 0)
				{
					$(this).addClass('active');
					
					
					$('#my-account-modal').show();
					
					
					$('#my-account-modal').stop().animate({opacity: 1, height: 233}, 200);
					
					$('#my-account-modal').mouseenter(function (){
					    hovered = 1;
					});
					
					$('#my-account-modal').mouseleave(function (){
				    	hovered = 0;
				
				        setTimeout(function () {
				        	if(hovered == 0)
							{
								
								$('#my-account a').children('.clone').hide();
								$('#my-account a').removeClass('my-account-modal-click');
					        	$('#my-account-modal').stop().animate({
									opacity: 0, 
									height: 0
								}, 100, function (){
									$(this).hide();
								});
				        	}
				        }, 4000);
				    });
				}
				else
				{
					$('#my-account a').children('.clone').hide();
				
					$('#my-account-modal').stop().animate({
						opacity: 0, 
						height: 0
					}, 100, function (){
						$(this).hide();
					});
				}
			});

			// Hide modal when user clicks close button inside modal
			$(".modal-close").click(function(event)
			{
				// Prevent link from adding hash to URL
				event.preventDefault();
				
				$('#my-account a').children('.clone').toggle();
				
				//$('#my-account a').css('background-position', '0px 9px');
				$('#my-account a').removeClass('my-account-modal-hover').removeClass('my-account-modal-click');
				
				menu_open = false;
				
				$('#my-account-modal').animate({
					opacity: 0, 
					height: 0
				}, 100, function (){
					$(this).hide();
				});
			});
		}

		americanFamilyInsurance.buildCarousel = function() {

		    //-- added
		    var itemArray = new Array();
		    $('#carousel ul').children().each(function(j) {
		        // add 'id' to each li - needed for external navigation
		        $(this).attr("id", j + 1);
		        // dynamic external navigation
		        var x = Math.round((j / 3) + 0.5);
		        itemArray[j] = ".indicators ." + x;
		        if (j % 3 == 0) {
		            $(".indicators").append('<a class="' + x + ' png-fix" href="#">&nbsp;</a> ');
		        }
		    });
		    $(".indicators a:first-child").addClass("active");
		    //--

		    $('#carousel').jCarouselLite({
		        btnNext: '.jcarousel-prev',
		        btnPrev: '.jcarousel-next',
		        scroll: 3,
		        speed: 800,
		        afterEnd: function(a) {
		            var currentIndex = a[0].id;
		            var currentPage = Math.ceil(currentIndex / 3);
		            $(".indicators a").css('background-image', 'url(../../site-assets/images/indicator-off.png)');
		            $(".indicators ." + currentPage).css('background-image', 'url(../../site-assets/images/indicator-on.png)');

		        },
		        btnGo: itemArray
		    });

		    // Carousel indicators at bottom of carousel
		    $(".indicators a").each(function() {
		        $(this).click(function(event) {
		            event.preventDefault();
		            $(".indicators a.active").removeClass("active");
		            $(this).addClass('active');
		        })
		    });
		}

		americanFamilyInsurance.expandingList = function()
		{
			//hide the DD
			$("#bottom-links dd").hide();
			
			//add event for dt click
			$("#bottom-links dt").click(function(e) {
				e.preventDefault();
				$(this).next('dd').slideToggle('fast');
			});
		}
		
		
		
		americanFamilyInsurance.socialBar = function()
		{
			//alert("social bars");
			function setFontSize(fontSize) {
		        if (fontSize == 1.3) {
		            activeFontSize = 'large';
		        } else if (fontSize == 1.2) {
		            activeFontSize = 'medium';
		        } else {
		            activeFontSize = 'small';
		        }
		        $('#toolbar [class^="resize_"]').each(function() {
		            if ($(this).hasClass('resize_' + activeFontSize)) {
		                $('a', this).addClass('active');
		            } else {
		                $('a', this).removeClass('active');
		            }
		        });
		        $('#content .container, #content_sub, #product_list, #my_account #main #notices').css('font-size', fontSize + 'em');
		         $('#breadcrumbs').css('font-size', ((11 / 12) * parseFloat(fontSize)) + 'em');
				$('#content').css('font-size', (parseFloat(fontSize)) + 'em');
				//$('body').css('font-size', ((7.5 / 12) * parseFloat(fontSize)) + 'em');
		    }
		    function toggleShare(open) {
		        if (open) {
		            $('#toolbar').addClass('active');
		            $('#toolbar li.share .container').show();
		        } else {
		            $('#toolbar').removeClass('active');
		            $('#toolbar li.share .container').hide();
		        }
		    }
		    $('a[href^=http]').not('[href*=amfam.com]' || '[href*=amfamlatino.com]').bind("click", function() {});
		    var fontSize = $.cookie('newFontSize');
		    var activeFontSize = 'small';
		    if (fontSize == null) {
		        $.cookie('newFontSize', 1, {
		            path: '/',
		            domain: document.domain
		        });
		    }
		    setFontSize($.cookie('newFontSize'));
		    $('#toolbar [class^="resize_"] a').click(function(e) {
		        e.preventDefault();
		        var listItem = $(this).parents('li[class^="resize_"]');
		        var fontSize = $.cookie('newFontSize');
		        if (listItem.hasClass('resize_small')) {
		            fontSize = 1;
		        }
		        if (listItem.hasClass('resize_medium')) {
		            fontSize = 1.2;
		        }
		        if (listItem.hasClass('resize_large')) {
		            fontSize = 1.3;
		        }
		        $.cookie('newFontSize', fontSize, {
		            path: '/',
		            domain: document.domain
		        });
		        setFontSize($.cookie('newFontSize'));
		    });
		    $('#toolbar .print a').click(function(e) {
		        e.preventDefault();
		        window.print();
		    });
		    $('#toolbar li.share > a').click(function(e) {
		        e.preventDefault();
		        if ($('#toolbar').hasClass('active')) {
		            toggleShare(0);
		        } else {
		            toggleShare(1);
		            setSocialLinks();
		            /**/
		            }
		    });
		    $.extend({
		        URLEncode: function(c) {
		            var o = '';
		            var x = 0;
		            c = c.toString();
		            var r = /(^[a-zA-Z0-9_.]*)/;
		            while (x < c.length) {
		                var m = r.exec(c.substr(x));
		                if (m != null && m.length > 1 && m[1] != '') {
		                    o += m[1];
		                    x += m[1].length;
		                } else {
		                    if (c[x] == ' ')
		                        o += '+';
		                    else {
		                        var d = c.charCodeAt(x);
		                        var h = d.toString(16);
		                        o += '%' + (h.length < 2 ? '0': '') + h.toUpperCase();
		                    }
		                    x++;
		                }
		            }
		            return o;
		        },
		        URLDecode: function(s) {
		            var o = s;
		            var binVal,
		            t;
		            var r = /(%[^%]{2})/;
		            while ((m = r.exec(o)) != null && m.length > 1 && m[1] != '') {
		                b = parseInt(m[1].substr(1), 16);
		                t = String.fromCharCode(b);
		                o = o.replace(m[1], t);
		            }
		            return o;
		        }
		    });

		    function setSocialLinks() {

		        var url = location.href;
		        var title = document.title;

		        $('a.social').attr('target', '_blank');
		        //	$('#toolbar .container li.email > a').attr('href','http://wwwa.amfam.com/send-email-to-friend.asp?link='+url);
		        $('#toolbar .container li.facebook > a').attr('href', 'http://www.facebook.com/share.php?u=' + url + '&title=' + title);
		        $('#toolbar .container li.twitter > a').attr('href', 'http://twitter.com/home?status=' + url);
		        $('#toolbar .container li.digg > a').attr('href', 'http://digg.com/submit?phase=2&url=' + url + '&title=' + title);
		        $('#toolbar .container li.delicious > a').attr('href', 'http://del.icio.us/post?v=4&noui&jump=close&url=' + url + '&title=' + title);
		        $('#toolbar .container li.stumble > a').attr('href', 'http://www.stumbleupon.com/submit?url=' + url + '&title=' + title);
		        $('#toolbar .container li.reddit > a').attr('href', 'http://reddit.com/submit?url=' + url + '&title=' + title);
		        $('#toolbar .container li.technorati > a').attr('href', 'http://technorati.com/faves?add=' + url);
		        $('#toolbar .container li > a').click(function(e) {
		            toggleShare(0);
		        });
		    }

		    //$('#toolbar .email > a').click(function(e){
		    //	var url=location.href;$('#toolbar .email > a').attr('href','http://wwwa.amfam.com/send-email-to-friend.asp?link='+url);
		    //var url=location.href;$('#toolbar .email > a').attr('href','/send-email-to-friend.asp?link='+url);
		    //});
		}


		$(document).ready(function() {
		    americanFamilyInsurance.buildNavigation();
		    americanFamilyInsurance.modalWindow();
		    americanFamilyInsurance.wrapperFooterNav();
		    americanFamilyInsurance.buildCarousel();
		    americanFamilyInsurance.expandingList();
		    americanFamilyInsurance.socialBar();

		    $("#input-quote").focus(function() { $(this).attr({ value: '' }); });
		    $("#input-quote").blur(function() { $(this).attr({ value: 'ZIP code' }); });

		    $("#zipCode").focus(function() { $(this).attr({ value: '' }); });
		    $("#zipCode").blur(function() {
		        if ($(this).val() == '')
		            $(this).attr({ value: 'ZIP code' });
		    });

		    // remove the last li from a landing page which doesn't have a child div
            // (as that's been removed by MotionPoint)
		    $('ul#sub-nav li:not(:has(div))').remove();

		    // add class="full" to the last li element in case of an odd # of li elements		    
		    if ($('ul#sub-nav > li').length % 2 != 0) { // odd # of elements
		        $('ul#sub-nav li').last().addClass('full');    
		    }
            // remove the box if class='full' has been applied.
		    $("ul#sub-nav li.full span.box-top").remove();


		    /*
		    function clearField(field) {
		    myType = field.type;
		    if (myType == 'checkbox' || myType == 'radio' || myType == undefined)
		    try {
		    for (i = 0; i < 20; i++)
		    field[i].checked = false;
		    } catch(e) {}
		    if (myType == 'hidden' || myType == 'password' || myType == 'text' || myType == 'textarea')
		    field.value = "";
		    if (myType == 'select-one' || myType == 'select-multiple')
		    field.selectedIndex = 0;
		    }
		    */
		    $('.jdiframe').fancybox({
		        'frameWidth': 600,
		        'frameHeight': 500
		    });
		    $('.hoursLink').fancybox({
		        'frameWidth': 400,
		        'frameHeight': 170
		    });
		    $('.iframe').fancybox({
		        'frameWidth': 938,
		        'frameHeight': 470
		    });
		    $('#toolbar .email .iframe').fancybox({
		        'frameWidth': 450,
		        'frameHeight': 290
		    });
		    $('#toolbar .share .container .email .iframe').fancybox({
		        'frameWidth': 450,
		        'frameHeight': 290
		    });
		    $('.prodLic').fancybox({
		        'frameWidth': 400,
		        'frameHeight': 270
		    });
		});


		function changeLanguage(langCode) {
		    var key = escape("lang");
		    var value = escape(langCode);
		    var kvp = document.location.search.substr(1).split('&');
		    var i = kvp.length; var x; while (i--) {
		        x = kvp[i].split('=');
		        if (x[0] == key) {
		            x[1] = value;
		            kvp[i] = x.join('=');
		            break;
		        }
		    }
		    if (i < 0) { kvp[kvp.length] = [key, value].join('='); }
		    document.location.search = kvp.join('&');
		}


		// -------------------------------------------------------------------
		// TabNext()
		// Function to auto-tab phone field
		// Arguments:
		//   obj :  The input object (this)
		//   event: Either 'up' or 'down' depending on the keypress event
		//   len  : Max length of field - tab when input reaches this length
		//   next_field: input object to get focus after this one
		// -------------------------------------------------------------------
		var phone_field_length = 0;
		function TabNext(obj, event, len, next_field) {
		    if (event == "down") {
		        phone_field_length = obj.value.length;
		    }
		    else if (event == "up") {
		        if (obj.value.length != phone_field_length) {
		            phone_field_length = obj.value.length;
		            if (phone_field_length == len) {
		                document.getElementById(next_field).focus();
		            }
		        }
		    }
		}
