﻿// commented lines are for when full urls are used for the image source

// preload '_on' images with class of 'hover'
$(window).bind('load', function() {
	var preload = new Array();
	$(".hover").each(function() {
		s = $(this).attr("src").replace(/\.(.+)$/i, "_on.$1");
		//s = $(this).attr("src").replace(/.gif$/ig,"_on.gif");
		preload.push(s)
	});
    var img = document.createElement('img');
    $(img).bind('load', function() {
        if(preload[0]) {
            this.src = preload.shift();
        }
    }).trigger('load');
});
// apply mouseovers
$(document).ready(function() {
    $(".hover").each(function() {
        if ($(this).attr("src").match(/_on\.(.+)$/i)) {
		//if ($(this).attr("src").match(/_on.gif$/ig)) {
            $(this).removeClass("hover");
        }
    });
    $(".hover").hover(function() {
        s = $(this).attr("src").replace(/\.(.+)$/i, "_on.$1");
		//s = $(this).attr("src").replace(/.gif$/ig,"_on.gif");
        $(this).attr("src", s);
    }, function() {
        s = $(this).attr("src").replace(/_on\.(.+)$/i, ".$1");
		//s = $(this).attr("src").replace(/_on.gif$/ig,".gif");
        $(this).attr("src", s);
    });
});

 
$(document).ready(function() { 
	$('ul.sf-menu').superfish(); 
	$(".page-header img").pngfix({
				sizingMethod: "scale"
			});
	$("input[@type=text], input[@type=password], input[@type=checkbox], input[@type=radio], select, textarea").focus(function(){
		$(this).parent().addClass("fieldFocus");
		});
	$("input[@type=text], input[@type=password], input[@type=checkbox], input[@type=radio], select, textarea").blur(function(){
		$(this).parent().removeClass("fieldFocus");
		});
	$("#referral img").tooltip({
	bodyHandler: function() {
		return $($(this).attr("rel")).html();
	},
	showURL: false,
	fade: 500
	});
});