function openPopup(url, name, w, h)
{
	if (document.all)
	{
		var winX = (screen.availWidth - w)*.5;
		var winY = (screen.availHeight - h)*.5;
		popupWin = window.open(url, name, "status=no,scrollbars=yes,menubar=no,toolbar=no,width=" + w + ",height=" + h + ",left=" + winX + ",top=" + winY);
	}
	else
	{
		var winX = window.screenX + ((window.outerWidth - w) / 2);
		var winY = window.screenY + ((window.outerHeight - h) / 2);
		popupWin = window.open(url, name, "status=0,scrollbars=1,menubar=0,toolbar=0,width=" + w + ",height=" + h + ",screenX=" + winX + ",screenY=" + winY);
	}
}
/** 
	The following javascript now handles the side menu effects 
**/
$(document).ready(function(){

	$('.subnav-list').hide();

	$('li.nav-item').mouseout(function(){
		var expand = $(this).hasClass("nav-expand");
		
		$(this).children("ul.subnav-list").hide();

	});
	
	$('li.nav-item').mouseover(function(){
	
		$(this).children("ul.subnav-list").show();
	
	});
	
	$('#locator-text').blur(function(){
		
		var NumberToTest = 15;
		if (!(/^-?\d+$/).test($(this).attr("value")))
			$(this).attr("value", "Enter zip code");
	
	});
	
	$('#locator-text').focus(function(){	
		if (!(/^-?\d+$/).test($(this).attr("value")))
			$(this).attr("value", "");
	});
	
	
	//$('#logo').click(function(){	
	//	location.href = "/"
	//});
	
	//$('#header h1').click(function(){	
	//	location.href = "/"
	//});
	
	$("#locator>.submit").replaceWith('<a class="submit" href="#" onclick="$(this).parent().submit(); return false;">Submit</a>');
	$(".arrow-link").before("<img src=\"/images/backgrounds/small-arrow.jpg\" class=\"arrows\" />");
	
	$("#carecare-optin>.submit").replaceWith('<a class="submit" href="#">Submit</a>');
	$('#carecare-optin>.submit').click(function(){	
		//featureTracker('homepage/optin', 'carcare');
		$('#carecare-optin>p').replaceWith("<p>Thank You! <br /><br />You address has been submitted.<p>");
		$('#carecare-optin>input').hide();
		$('#carecare-optin>a').hide();
	});
	
	if ( $('#slide-images').length > 0){
		$('#slide-images').cycle.defaults = { 
			fx:           		'fade', // one of: fade, shuffle, zoom, scrollLeft, etc 
			timeout:       	12000,  // milliseconds between slide transitions (0 to disable auto advance) 
			continuous:    0,     // true to start next transition immediately after current one completes 
			speed:         	500,  // speed of the transition (any valid fx speed value) 
			before:        	slideButton,  // transition callback (scope set to element to be shown) 
			startingSlide: 	0,     // zero-based index of the first slide to be displayed 
			sync:          		1,     // true if in/out transitions should occur simultaneously 
			autostop:      	1,     // true to end slideshow after X transitions (where X == slide count) 
			cleartype:     	0,     // true if clearType corrections should be applied (for IE) 
			nowrap:        	0,      // true to prevent slideshow from wrapping 
			pause: 			1		// enables pause on hover
		};
		
		var $container = $('#slide-images').cycle('fade');
	}
	
	$(".buttons ul li").each(function(index){
				$(this).bind("mouseenter",function(){
					var val = parseFloat($(this).children().html());
					$container.cycle(val);
					$('.buttons').css("background-position", "0 -" + (40*val) + "px");
				});
	});
	
	
});


var slideIndex; 
slideIndex = 0;

function slideButton(){
	if (slideIndex == 160) slideIndex = 0;
	$('.buttons').css("background-position", "0 -" + slideIndex + "px");
	slideIndex = slideIndex + 40;
}

