/*
 * jQuery plugin 
 * adds class that works as :hover,:active,:focus,:target
 * to specific elements
 */
jQuery.fn.sfHover = function() {
	jQuery(this).hover(function() {
		jQuery(this).addClass("sfHover");
	},function() {
		jQuery(this).removeClass("sfHover");
	})
	return this
}
jQuery.fn.sfFocus = function() {
	jQuery(this).each(function(i) {
		jQuery(this).bind("focus", function() {
			jQuery(this).addClass('sfFocus');
		});
		jQuery(this).bind("blur", function() {
			jQuery(this).removeClass('sfFocus');
		});
	});
	return this;
}
jQuery.fn.sfActive = function() {
	jQuery(this).each(function(i) {
		jQuery(this).mousedown (function() {
			jQuery(this).addClass('sfActive');
		})
		jQuery(this).mouseup (function() {
			$(this).removeClass('sfActive');
		})
	});
	return this;
}
jQuery.fn.sfTarget = function() {
	jQuery(this).each(function(i) {
		jQuery(this).click(function() {
			jQuery(".sfTarget").removeClass('sfTarget');
			elem = jQuery(this).attr("href");
			if(elem) {
				jQuery(elem).addClass('sfTarget');
			}
			return this
		})
	});
	return this;
}


$(document).ready(function() {

	$('input[type="text"]').sfFocus();
	$('input[type="password"]').sfFocus();
	$('textarea').sfFocus();
	$('#menu ul.navi li').sfHover();

	//ul li:first-child
	$("ul").each(function(){$( $(this).children()[0]).addClass('fchild');});
	//dl dt:first-child
	$('dl').each(function(){$( $(this).children()[0]).addClass('noBorder');});
	//dl dd:first-child
	$('dl').each(function(){$( $(this).children()[1]).addClass('noBorder');});


	//add even/odd class to table
	$("table tr:even").addClass("evenHighlight");
	$("table tr:odd").addClass("oddHighlight");

	//activate label for ie w/img
	if(jQuery.browser.msie){
		$('label img').click(function(){
			var target = $(this).parents('label');
			var jumpEle = target.attr('for');
			$('#'+jumpEle).focus();
		});
	//activate label for Safari
	}else if(jQuery.browser.safari){
		$('label').click(function(){
			var target = $(this);
			var jumpEle = target.attr('for');
			$('#'+jumpEle).focus();
		}).hover(function(){
			$(this).css('cursor','pointer');
		},function(){
			$(this).css('cursor','default');
		});
	}

});



