// JavaScript Document
$(document).ready(function() {
	// give 0 border to images in links
	$("a img").attr("border","0");
	$("a[href='#']").click(function() {
		return false;
	});
	
	$("a[href^='http://']").click(function() {
		$(this).attr("target","blank");
	});
	
	// give wuma icons middle valign
	$("ul.menu li a img").attr("align","absmiddle");
	$("ul.menu li a img").css("padding-bottom",5);
	
	// drop down men
	$("ul.menu li.products").hover(function() {
		$(this).children("ul").css("display","block");
	},
	function() {
		$(this).children("ul").css("display","none");
	});
	
	$("ul.menu li.gallery").hover(function() {
		$(this).children("ul").css("display","block");
	},
	function() {
		$(this).children("ul").css("display","none");
	});
	
	// apply supersleight to png's
	//$("img[src^='.png']").supersleight();
	
	// give classes to first and last LI elements of the dropdown
	$("ul.dropdown li:first-child").wrapInner("<div></div>");
	$("ul.dropdown li:last-child").addClass("last");
	$("ul.dropdown li:first-child").addClass("first");
	
	if (window.location.href.indexOf("puppy.php") != -1) {
		$("body").addClass("puppy");	
	}
	
	if ($.client.browser == "Explorer" && $.browser.version == "6.0") {
		
		$("*").each( function()
		{
			if( $(this).css("background-image").indexOf( ".png" ) != -1 )
			{
				$(this).supersleight({apply_positioning:true});
			}
		});
		$("ul.menu > li img[src$='.png']").supersleight({apply_positioning:'true'});
		
		// replace WUMA icon in order for it to show
		$("ul.menu li.products > ul.dropdown li img").replaceWith("<span class=\"wumatext\">WUMA</span>");
	}
	
	$("table#gallery a").fancybox({'overlayOpacity' : 0.5});
	//$("#gallery a").animateToSelector({selectors: ["#gallery a:hover"], properties: ['border-width','border-style','border-color'], events: ['mouseover','mouseout'], duration: 1000});	

	$("legend a").click(
		function() {
			if ($(this).parent().parent("fieldset").css("height") == "auto") {
				$(this).parent().parent("fieldset").css({height: "0"});
				if ($.client.browser == "Firefox") {
					$(this).parent().parent("fieldset").css({padding: "0"});
				}
				if ($.client.browser == "Explorer" && $.browser.version == "6.0") {
					$(this).parent("legend").css({marginTop: "10"});
				}
				$(this).siblings("img").attr("src","images/arrow.gif");
			} else {
				$(this).parent().parent("fieldset").css({height: "auto"});
				$(this).siblings("img").attr("src","images/arrow_down.gif");
				$(this).parent().parent("fieldset").siblings("fieldset").each(function() {
					$(this).children().children("img").attr("src","images/arrow.gif");
			   		$(this).css({height:"0"});
					if ($.client.browser == "Firefox") {
						$(this).css({padding:"0"});
					}
					if ($.client.browser == "Explorer" && $.browser.version == "6.0") {
					$(this).children("legend").css({marginTop: "-10"});
				}
			  	});
			}
		});
	
	
	
	$("#apDiv34 fieldset:first-child").css({height: "auto"});
	$("#apDiv34 fieldset:first-child legend img").attr("src","images/arrow_down.gif");
	
});