$(document).ready(function() {
    $(".printTrigger").printHelper();
    
	$(".newsletterSignup").fancybox({
			'type': 'iframe',
			width: 300,
			height: 336
	});
	
	$(".login").fancybox({
	    'type'		: 'iframe',
	    padding		: 0,
	    width		: 400
	});
	
	//search field
	$('label.searchLabel').click(function(){$('input.search').focus();});
	$('input.search').focusin(function(){$('label.searchLabel').fadeOut('fast');});
	$('input.search').focusout(function(){
		var searchText = $('input.search').val()
		if(searchText == "") {
			$('label.searchLabel').text('Site Search...');
			$('label.searchLabel').fadeIn('fast');
		}
	});
	
	//Dropdown Menu
	$('ul.primary li').hoverIntent(
		function() {
			if ($.browser.msie)
				$(this).find("div.secondary").show();
			else
				$(this).find("div.secondary").show().stop().animate({"opacity": 1}, 100);
		},
		function() {
			if ($.browser.msie){
				$(this).find("div.secondary").hide();
			}else{
				$(this).find("div.secondary").stop().animate({"opacity": 0}, "fast",
					function(){
						$(this).hide();
					}
				);
			}
		}
	);
	
	$('ul.primary li').click(function(){
		$(this).find('div.secondary').hide();
	});
	
	$('div.arrow').show();
	
	$('li.hasDropdown').css("margin-right","25px");
	//End Dropdown Menu

	//convert richtext popup full size images to fancybox images
	$(".sectionss img").each(function(){
		if(!$(this).parent().is("a"))
			$(this).wrap("<a class='single_image' href='" + $(this).attr("src") + "'></a>");
	});
	//end convert richtext popup full size images to fancybox images
	
	//convert richtext popup thumb images to fancybox images
	$(".sectionss a").each(function(){
		var href = $(this).attr("href");
		if(href != undefined){
			var index = href.indexOf("viewImage");
			if(index > -1){
				href = href.replace("javascript:viewImage('", "");
				href = href.replace("')","");
				$(this).attr("href", href);
				$(this).addClass("single_image"); 
			}
		}
	});
	$("#getDirections").formfocus({
        focus : true,
        blur : true,
        keyup : true,
        label : false
    });
	$("a.single_image").fancybox();
	//end convert richtext popup images to fancybox images
});
