﻿$J(function() {
	// Preload images
	$J("img.jq_hover").each(function() {		
		$J("<img>").attr("src", $J(this).attr("src").replace(/^(.*)(\.\w+)$/, "$1_a$2"));
	});

	$J("img.jq_hover").hover(
		function()
		{
		    if($J(this).attr("src").toLowerCase().indexOf("pixel.gif")!=-1)
		    {
		        $J(this)[0].style.filter = $J(this)[0].style.filter.replace("_a.png", ".png");
		        $J(this)[0].style.filter = $J(this)[0].style.filter.replace(".png", "_a.png");
		    }
		    else
		    {
		        $J(this).attr("src", $J(this).attr("src").replace(/^(.*)_a(\.\w+)$/, "$1$2"));
			$J(this).attr("src", $J(this).attr("src").replace(/^(.*)(\.\w+)$/, "$1_a$2"));
			}
		},
		function()
		{
		    if($J(this).attr("src").toLowerCase().indexOf("pixel.gif")!=-1)
		        $J(this)[0].style.filter = $J(this)[0].style.filter.replace("_a.png", ".png");
		    else
			$J(this).attr("src", $J(this).attr("src").replace(/^(.*)_a(\.\w+)$/, "$1$2"));
			
		}
	);

	$J("img.jq_hover_fade")
		.wrap("<span style=\"position: relative;\"></span>")
		.after("<img border=0 style=\"position: absolute; top: 0; left: 0;\"/>")
		.next()
			.css("opacity", 0)
			.attr("src", function() {
				return $J(this).prev().attr("src").replace(/^(.*)(\.\w+)$/, "$1_a$2");
			})
			.hover(
				function() {
					$J(this).animate({ opacity: 1 }, 400);
				},
				function() {
					$J(this).animate({ opacity: 0 }, 400);
				}
			);
	
	$J("img.jq_png_hover").hover(
		function()
		{	
		    if(this.style.filter)
		    {   
		        var str = this.style.filter; 
                var patt = new RegExp("http://.*\.png", "i");

                var result = patt.exec(str);
                
                if(result)
                {                    
			        $J(this).attr("src", String(result).replace(/^(.*)(.png)$/i, "$1_a$2"));			        
			    }
			}
			else
			{
			    $J(this).attr("src", $J(this).attr("src").replace(/^(.*)(\.\w+)$/, "$1_a$2"));
			}
		},
		function()
		{
		    if(this.style.filter)
		    {   
		        var str = this.style.filter; 
                var patt = new RegExp("http://.*\.png", "i");

                var result = patt.exec(str);
                                
                if(result)
                {                    
			        $J(this).attr("src", String(result));			        
			    }
			}
			else
			{
			    $J(this).attr("src", $J(this).attr("src").replace(/^(.*)_a(\.\w+)$/, "$1$2"));
			}
		}
	);

//	$J("hr.sep_wide").after("<div align=center><img src=\"/images/sep_wide.png\" vspace=7 width=475 height=13 /></div>").remove();
//	$J("hr.sep_short").after("<div align=center><img src=\"/images/sep_short.png\" vspace=7 width=235 height=13 /></div>").remove();
});