/***********************************************
***  BUTTON ROLLOVER & PRELOAD  ****************
************************************************/

$(function(){
	// button rollover
	if ($('.imgBtn') != null) {
	$('.imgBtn').hover(function(){
			$(this).attr("src", $(this).attr("src").replace(/^(.*?)(?:-hover)?(\..*?)$/i,'$1-hover$2'));
		},
		function(){
				$(this).attr("src", $(this).attr("src").replace(/^(.*)-hover(\..*?)$/i, '$1$2'));
			});
	}
	// preload image rollovers
	if ($("img.imgBtn, img[src^='images/buttons/btn'], input[src^='images/buttons/btn']") != null) {
	    $("img.imgBtn, img[src^='images/buttons/btn'], input[src^='images/buttons/btn']").each(function(){
			    $("<img>").attr("src", $(this).attr("src").replace(/(btn-.*)(\..*?)/i, '$1-hover$2'));
		    });
	}
});


/***********************************************
***  COMPACT FORM (LABEL OVER INPUT)  **********
************************************************/

$(function(){
	$('form.compact input, form.compact select, form.compact textarea').focus(function(){
			$('label[for=' + $(this).attr('id') + ']').hide();
		});
	$('form.compact input, form.compact select, form.compact textarea').each(function(ele){
			if($(this).val().length > 0)
				$('label[for=' + $(this).attr('id') + ']').css({ display: "none" });
		});
	$('form.compact input, form.compact select, form.compact textarea').blur(function(){
			if($(this).val().length == 0)
				$('label[for=' + $(this).attr('id') + ']').show();
		});
	$('form.compact').removeClass('compact');
});


/***********************************************
***  NAV SLIDING  ******************************
************************************************/

$(function(){
	$('#nav li').hover(function(){
			$(this).stop().animate({
					paddingLeft: 15
				}, 200);
		},
		function(){
				$(this).stop().animate({
						paddingLeft: 0
					}, 200);
			});
});


/***********************************************
***  INFO LINK SLIDING  ************************
************************************************/

$(function(){
	$('.infoTile .infoLink a').hover(function(){
			$(this).stop().animate({
					paddingLeft: 15
				}, 200);
		},
		function(){
				$(this).stop().animate({
						paddingLeft: 0
					}, 200);
			});
});


/***********************************************
***  SITE LOCATOR  *****************************
************************************************/

$(function(){
	// nav functionality
	$("#mapControls .toggleBtn").click(function(){
			if($(this).parent().hasClass('expanded')) {
				hideMapControls($(this));
			}
			else if($(this).parent().hasClass('collapsed')) {
				showMapControls($(this));
			}
		});
	$('#mapSearchBtn').click(function(){$("#locator").submit();});
});


var hideMapControls = function(ele){
	$(ele).parent().removeClass('expanded');
	$(ele).parent().addClass('collapsed');
	$(ele).parent().stop().animate({top: -190}, 200);
	$(ele).html('Show');
}
var showMapControls = function(ele){
	$(ele).parent().addClass('expanded');
	$(ele).parent().removeClass('collapsed');
	$(ele).parent().stop().animate({top: 0}, 200);
	$(ele).html('Hide');
}

/***********************************************
***  TEXT SIZING  ******************************
************************************************/

$(function(){
	$('#pageControls #textSizeUp').click(function(){
			ts('content',1);
		});
	$('#pageControls #textSizeDown').click(function(){
			ts('content',-1);
		});
});


/***********************************************
***  ZEBRA STRIPES  ****************************
************************************************/


$(function(){
	$(".contactInfo tr:nth-child(2n)").addClass("dark");
});


/***********************************************
***  SWF OBJECT  *******************************
************************************************/

$(function(){
	swfobject.embedSWF("banners/CAS-9340-RELIANCE-BONUS.swf", "bannerReplace", "728", "90", "8.0.0", "", {}, {wmode : "transparent"}, {});
});



