function changeInputs() {
    var els = document.getElementsByTagName('input');
    var elsLen = els.length;
    var i = 0;
    for (i = 0; i < elsLen; i++) {
        if (els[i].getAttribute("type")) {
            if (els[i].getAttribute("type") == "text")
                els[i].className = (els[i].className) ? els[i].className + " text" : "text";
            else if (els[i].getAttribute("type") == "password")
                els[i].className = (els[i].className) ? els[i].className + " password" : "password";
            else
                els[i].className = (els[i].className) ? els[i].className + " button" : "button";
        }
    }
}
jQuery.preloadImages = function() {
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}
$(document).ready(function() {
	$("#toggle").click(function() {
		if($("#page.inverted").length>0) {
			$("#page").removeClass("inverted");
			$(this).html("Click to toggle dark text on white");
		} else {
			$("#page").addClass("inverted");
			$(this).html("Click to toggle light text on black");
		}
		$(this).blur();
		return false;
	});
	$("#hide-ad").click(function() {$("#link-unit, p:has(#hide-ad)").hide(); return false;});
	$(".show-code a").click(function() {
		var node;
                if($(this).parents(".show-code").eq(0).find("code").length > 0) {
                    node = $(this).parents(".show-code").eq(0).find("code");
                }
                else {
                    node = $(this).parents(".show-code").eq(0).find("pre");
                }
                node.show("slow");
		$(this).parents(".dashed").hide();
		$(this).hide();//in case there is no ".dashed"
		return false;
	})
        $(".odesk-main").attr("href", "http://www.odesk.com/").click(function() {
            window.location = "http://www.odesk.com/referrals/track/amohler";
            return false;
        });
        $(".odesk-profile").attr("href", "http://www.odesk.com/users/~~6ac6d602866e51de").click(function() {
            window.location = "http://www.odesk.com/referrals/track/amohler?redir=http%3A%2F%2Fwww.odesk.com%2Fusers%2F%7E%7E34f81ea196bfb7e8";
            return false;
        });
});

$(document).ready(function() {
	if($(".download-js").length > 0) {
		$(".download-js a").click(function() {
			var href = this.href;
			$.post("../ping.php", {uri: href}, function() {
				window.location = href;
			});
			return false;
		});
	}
});
